Bläddra i källkod

Merge branch 'master' of orgmode.org:org-mode

Eric Schulte 15 år sedan
förälder
incheckning
5d9023b384
9 ändrade filer med 312 tillägg och 294 borttagningar
  1. 33 33
      doc/org.texi
  2. 59 32
      lisp/org-agenda.el
  3. 1 1
      lisp/org-clock.el
  4. 1 1
      lisp/org-crypt.el
  5. 3 3
      lisp/org-exp.el
  6. 2 1
      lisp/org-latex.el
  7. 1 2
      lisp/org-list.el
  8. 6 0
      lisp/org-publish.el
  9. 206 221
      lisp/org.el

+ 33 - 33
doc/org.texi

@@ -2350,7 +2350,7 @@ $3 = remote(FOO, @@@@#$2)      @r{copy column 2 from table FOO into}
 @end example
 @end example
 
 
 @noindent For the second example, table FOO must have at least as many rows
 @noindent For the second example, table FOO must have at least as many rows
-as the current table.  Inefficient@footnote{The computation time scales as
+as the current table.  Note that this is inefficient@footnote{The computation time scales as
 O(N^2) because table FOO is parsed for each field to be copied.} for large
 O(N^2) because table FOO is parsed for each field to be copied.} for large
 number of rows.
 number of rows.
 
 
@@ -4701,11 +4701,11 @@ nearest column format definition.
 @section Special properties
 @section Special properties
 @cindex properties, special
 @cindex properties, special
 
 
-Special properties provide an alternative access method to Org-mode
-features, like the TODO state or the priority of an entry, discussed in the
-previous chapters.  This interface exists so that you can include
-these states in a column view (@pxref{Column view}), or to use them in
-queries.  The following property names are special and should not be
+Special properties provide an alternative access method to Org-mode features,
+like the TODO state or the priority of an entry, discussed in the previous
+chapters.  This interface exists so that you can include these states in a
+column view (@pxref{Column view}), or to use them in queries.  The following
+property names are special and (except for @code{:CATEGORY:}) should not be
 used as keys in the properties drawer:
 used as keys in the properties drawer:
 
 
 @cindex property, special, TODO
 @cindex property, special, TODO
@@ -5318,20 +5318,20 @@ various inputs will be interpreted, the items filled in by Org-mode are
 in @b{bold}.
 in @b{bold}.
 
 
 @example
 @example
-3-2-5         --> 2003-02-05
-2/5/3         --> 2003-02-05
-14            --> @b{2006}-@b{06}-14
-12            --> @b{2006}-@b{07}-12
-2/5           --> @b{2007}-02-05
-Fri           --> nearest Friday (default date or later)
-sep 15        --> @b{2006}-09-15
-feb 15        --> @b{2007}-02-15
-sep 12 9      --> 2009-09-12
-12:45         --> @b{2006}-@b{06}-@b{13} 12:45
-22 sept 0:34  --> @b{2006}-09-22 0:34
-w4            --> ISO week for of the current year @b{2006}
-2012 w4 fri   --> Friday of ISO week 4 in 2012
-2012-w04-5    --> Same as above
+3-2-5         @result{} 2003-02-05
+2/5/3         @result{} 2003-02-05
+14            @result{} @b{2006}-@b{06}-14
+12            @result{} @b{2006}-@b{07}-12
+2/5           @result{} @b{2007}-02-05
+Fri           @result{} nearest Friday (default date or later)
+sep 15        @result{} @b{2006}-09-15
+feb 15        @result{} @b{2007}-02-15
+sep 12 9      @result{} 2009-09-12
+12:45         @result{} @b{2006}-@b{06}-@b{13} 12:45
+22 sept 0:34  @result{} @b{2006}-09-22 0:34
+w4            @result{} ISO week for of the current year @b{2006}
+2012 w4 fri   @result{} Friday of ISO week 4 in 2012
+2012-w04-5    @result{} Same as above
 @end example
 @end example
 
 
 Furthermore you can specify a relative date by giving, as the
 Furthermore you can specify a relative date by giving, as the
@@ -5343,13 +5343,13 @@ a single letter, you use the abbreviation of day name, the date will be
 the Nth such day.  e.g.@:
 the Nth such day.  e.g.@:
 
 
 @example
 @example
-+0            --> today
-.             --> today
-+4d           --> four days from today
-+4            --> same as above
-+2w           --> two weeks from today
-++5           --> five days from default date
-+2tue         --> second Tuesday from now.
++0            @result{} today
+.             @result{} today
++4d           @result{} four days from today
++4            @result{} same as above
++2w           @result{} two weeks from today
+++5           @result{} five days from default date
++2tue         @result{} second Tuesday from now.
 @end example
 @end example
 
 
 @vindex parse-time-months
 @vindex parse-time-months
@@ -5363,9 +5363,9 @@ start time and a duration (in HH:MM format). Use `-' or `-@{@}-' as the separato
 in the former case and use '+' as the separator in the latter case. E.g.@:
 in the former case and use '+' as the separator in the latter case. E.g.@:
 
 
 @example
 @example
-11am-1:15pm    --> 11:00-13:15
-11am--1:15pm   --> same as above
-11am+2:15      --> same as above
+11am-1:15pm    @result{} 11:00-13:15
+11am--1:15pm   @result{} same as above
+11am+2:15      @result{} same as above
 @end example
 @end example
 
 
 @cindex calendar, for selecting date
 @cindex calendar, for selecting date
@@ -13463,9 +13463,9 @@ Org will move the following key bindings in Org files, and in the agenda
 buffer (but not during date selection).
 buffer (but not during date selection).
 
 
 @example
 @example
-S-UP      ->  M-p             S-DOWN     ->  M-n
-S-LEFT    ->  M--             S-RIGHT    ->  M-+
-C-S-LEFT  ->  M-S--           C-S-RIGHT  ->  M-S-+
+S-UP      @result{}  M-p             S-DOWN     @result{}  M-n
+S-LEFT    @result{}  M--             S-RIGHT    @result{}  M-+
+C-S-LEFT  @result{}  M-S--           C-S-RIGHT  @result{}  M-S-+
 @end example
 @end example
 
 
 @vindex org-disputed-keys
 @vindex org-disputed-keys

+ 59 - 32
lisp/org-agenda.el

@@ -599,6 +599,14 @@ all      Don't show any entries with a timestamp in the global todo list.
          The idea behind this is that by setting a timestamp, you
          The idea behind this is that by setting a timestamp, you
          have already \"taken care\" of this item.
          have already \"taken care\" of this item.
 
 
+This variable can also have an integer as a value. If positive (N),
+todos with a timestamp N or more days in the future will be ignored. If
+negative (-N), todos with a timestamp N or more days in the past will be
+ignored. If 0, todos with a timestamp either today or in the future will
+be ignored. For example, a value of -1 will exclude todos with a
+timestamp in the past (yesterday or earlier), while a value of 7 will
+exclude todos with a timestamp a week or more in the future.
+
 See also `org-agenda-todo-ignore-with-date'.
 See also `org-agenda-todo-ignore-with-date'.
 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
 to make his option also apply to the tags-todo list."
 to make his option also apply to the tags-todo list."
@@ -608,7 +616,8 @@ to make his option also apply to the tags-todo list."
 	  (const :tag "Ignore future timestamp todos" future)
 	  (const :tag "Ignore future timestamp todos" future)
 	  (const :tag "Ignore past or present timestamp todos" past)
 	  (const :tag "Ignore past or present timestamp todos" past)
 	  (const :tag "Ignore all timestamp todos" all)
 	  (const :tag "Ignore all timestamp todos" all)
-	  (const :tag "Show timestamp todos" nil)))
+	  (const :tag "Show timestamp todos" nil)
+	  (integer :tag "Ignore if N or more days in past(-) or future(+).")))
 
 
 (defcustom org-agenda-todo-ignore-scheduled nil
 (defcustom org-agenda-todo-ignore-scheduled nil
   "Non-nil means, ignore some scheduled TODO items when making TODO list.
   "Non-nil means, ignore some scheduled TODO items when making TODO list.
@@ -627,6 +636,9 @@ all      Don't show any scheduled entries in the global todo list.
 
 
 t        Same as `all', for backward compatibility.
 t        Same as `all', for backward compatibility.
 
 
+This variable can also have an integer as a value. See
+`org-agenda-todo-ignore-timestamp' for more details.
+
 See also `org-agenda-todo-ignore-with-date'.
 See also `org-agenda-todo-ignore-with-date'.
 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
 to make his option also apply to the tags-todo list."
 to make his option also apply to the tags-todo list."
@@ -637,7 +649,8 @@ to make his option also apply to the tags-todo list."
 	  (const :tag "Ignore past- or present-scheduled todos" past)
 	  (const :tag "Ignore past- or present-scheduled todos" past)
 	  (const :tag "Ignore all scheduled todos" all)
 	  (const :tag "Ignore all scheduled todos" all)
 	  (const :tag "Ignore all scheduled todos (compatibility)" t)
 	  (const :tag "Ignore all scheduled todos (compatibility)" t)
-	  (const :tag "Show scheduled todos" nil)))
+	  (const :tag "Show scheduled todos" nil)
+	  (integer :tag "Ignore if N or more days in past(-) or future(+).")))
 
 
 (defcustom org-agenda-todo-ignore-deadlines nil
 (defcustom org-agenda-todo-ignore-deadlines nil
   "Non-nil means ignore some deadlined TODO items when making TODO list.
   "Non-nil means ignore some deadlined TODO items when making TODO list.
@@ -664,6 +677,9 @@ all     Ignore all TODO entries that do have a deadline.
 
 
 t       Same as `near', for backward compatibility.
 t       Same as `near', for backward compatibility.
 
 
+This variable can also have an integer as a value. See
+`org-agenda-todo-ignore-timestamp' for more details.
+
 See also `org-agenda-todo-ignore-with-date'.
 See also `org-agenda-todo-ignore-with-date'.
 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
 See also the variable `org-agenda-tags-todo-honor-ignore-options' if you want
 to make his option also apply to the tags-todo list."
 to make his option also apply to the tags-todo list."
@@ -674,7 +690,8 @@ to make his option also apply to the tags-todo list."
 	  (const :tag "Ignore near deadlines (compatibility)" t)
 	  (const :tag "Ignore near deadlines (compatibility)" t)
 	  (const :tag "Ignore far deadlines" far)
 	  (const :tag "Ignore far deadlines" far)
 	  (const :tag "Ignore all TODOs with a deadlines" all)
 	  (const :tag "Ignore all TODOs with a deadlines" all)
-	  (const :tag "Show all TODOs, even if they have a deadline" nil)))
+	  (const :tag "Show all TODOs, even if they have a deadline" nil)
+	  (integer :tag "Ignore if N or more days in past(-) or future(+).")))
 
 
 (defcustom org-agenda-tags-todo-honor-ignore-options nil
 (defcustom org-agenda-tags-todo-honor-ignore-options nil
   "Non-nil means honor todo-list ...ignore options also in tags-todo search.
   "Non-nil means honor todo-list ...ignore options also in tags-todo search.
@@ -4537,6 +4554,16 @@ the documentation of `org-diary'."
 	  (org-end-of-subtree 'invisible))))
 	  (org-end-of-subtree 'invisible))))
     (nreverse ee)))
     (nreverse ee)))
 
 
+(defun org-agenda-todo-custom-ignore-p (time n)
+  "Check whether timestamp is farther away then n number of days.
+This function is invoked if `org-agenda-todo-ignore-deadlines',
+`org-agenda-todo-ignore-scheduled' or
+`org-agenda-todo-ignore-timestamp' is set to an integer."
+  (let ((days (org-days-to-time time)))
+    (if (>= n 0)
+	(>= days n)
+      (<= days n))))
+
 ;;;###autoload
 ;;;###autoload
 (defun org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item
 (defun org-agenda-check-for-timestamp-as-reason-to-ignore-todo-item
   (&optional end)
   (&optional end)
@@ -4556,6 +4583,9 @@ the documentation of `org-diary'."
 		 (> (org-days-to-time (match-string 1)) 0))
 		 (> (org-days-to-time (match-string 1)) 0))
 		((eq org-agenda-todo-ignore-scheduled 'past)
 		((eq org-agenda-todo-ignore-scheduled 'past)
 		 (<= (org-days-to-time (match-string 1)) 0))
 		 (<= (org-days-to-time (match-string 1)) 0))
+		((numberp org-agenda-todo-ignore-scheduled)
+		 (org-agenda-todo-custom-ignore-p
+		  (match-string 1) org-agenda-todo-ignore-scheduled))
 		(t)))
 		(t)))
 	  (and org-agenda-todo-ignore-deadlines
 	  (and org-agenda-todo-ignore-deadlines
 	       (re-search-forward org-deadline-time-regexp end t)
 	       (re-search-forward org-deadline-time-regexp end t)
@@ -4567,6 +4597,9 @@ the documentation of `org-diary'."
 		 (> (org-days-to-time (match-string 1)) 0))
 		 (> (org-days-to-time (match-string 1)) 0))
 		((eq org-agenda-todo-ignore-deadlines 'past)
 		((eq org-agenda-todo-ignore-deadlines 'past)
 		 (<= (org-days-to-time (match-string 1)) 0))
 		 (<= (org-days-to-time (match-string 1)) 0))
+		((numberp org-agenda-todo-ignore-deadlines)
+		 (org-agenda-todo-custom-ignore-p
+		  (match-string 1) org-agenda-todo-ignore-deadlines))
 		(t (org-deadline-close (match-string 1)))))
 		(t (org-deadline-close (match-string 1)))))
 	  (and org-agenda-todo-ignore-timestamp
 	  (and org-agenda-todo-ignore-timestamp
 	       (let ((buffer (current-buffer))
 	       (let ((buffer (current-buffer))
@@ -4589,6 +4622,9 @@ the documentation of `org-diary'."
 		       (> (org-days-to-time (match-string 1)) 0))
 		       (> (org-days-to-time (match-string 1)) 0))
 		      ((eq org-agenda-todo-ignore-timestamp 'past)
 		      ((eq org-agenda-todo-ignore-timestamp 'past)
 		       (<= (org-days-to-time (match-string 1)) 0))
 		       (<= (org-days-to-time (match-string 1)) 0))
+		      ((numberp org-agenda-todo-ignore-timestamp)
+		       (org-agenda-todo-custom-ignore-p
+			(match-string 1) org-agenda-todo-ignore-timestamp))
 		      (t))))))))))
 		      (t))))))))))
 
 
 (defconst org-agenda-no-heading-message
 (defconst org-agenda-no-heading-message
@@ -4814,15 +4850,15 @@ be skipped."
 		     (setq clocked (match-string 2 rest)))
 		     (setq clocked (match-string 2 rest)))
 	    (setq clocked "-")))
 	    (setq clocked "-")))
 	(save-excursion
 	(save-excursion
-	  (setq extra nil)
-	  (cond
-	   ((not org-agenda-log-mode-add-notes))
-	   (statep
-	    (and (looking-at ".*\n[ \t]*\\([^-\n \t].*?\\)[ \t]*$")
-		 (setq extra (match-string 1))))
-	   (clockp
-	    (and (looking-at ".*\n[ \t]*-[ \t]+\\([^-\n \t].*?\\)[ \t]*$")
-		 (setq extra (match-string 1)))))
+	  (setq extra
+		(cond
+		 ((not org-agenda-log-mode-add-notes) nil)
+		 (statep
+		  (and (looking-at ".*\\\\\n[ \t]*\\([^-\n \t].*?\\)[ \t]*$")
+		       (match-string 1)))
+		 (clockp
+		  (and (looking-at ".*\n[ \t]*-[ \t]+\\([^-\n \t].*?\\)[ \t]*$")
+		       (match-string 1)))))
 	  (if (not (re-search-backward "^\\*+ " nil t))
 	  (if (not (re-search-backward "^\\*+ " nil t))
 	      (setq txt org-agenda-no-heading-message)
 	      (setq txt org-agenda-no-heading-message)
 	    (goto-char (match-beginning 0))
 	    (goto-char (match-beginning 0))
@@ -5200,7 +5236,7 @@ Any match of REMOVE-RE will be removed from TXT."
 			   (if (stringp dotime) dotime "")
 			   (if (stringp dotime) dotime "")
 			   (and org-agenda-search-headline-for-time txt))))
 			   (and org-agenda-search-headline-for-time txt))))
 	   (time-of-day (and dotime (org-get-time-of-day ts)))
 	   (time-of-day (and dotime (org-get-time-of-day ts)))
-	   stamp plain s0 s1 s2 t1 t2 rtn srp l
+	   stamp plain s0 s1 s2 rtn srp l
 	   duration thecategory)
 	   duration thecategory)
       (and (org-mode-p) buffer-file-name
       (and (org-mode-p) buffer-file-name
 	   (add-to-list 'org-agenda-contributing-files buffer-file-name))
 	   (add-to-list 'org-agenda-contributing-files buffer-file-name))
@@ -5227,26 +5263,17 @@ Any match of REMOVE-RE will be removed from TXT."
 	;; Normalize the time(s) to 24 hour
 	;; Normalize the time(s) to 24 hour
 	(if s1 (setq s1 (org-get-time-of-day s1 'string t)))
 	(if s1 (setq s1 (org-get-time-of-day s1 'string t)))
 	(if s2 (setq s2 (org-get-time-of-day s2 'string t)))
 	(if s2 (setq s2 (org-get-time-of-day s2 'string t)))
+
+	;; Try to set s2 if s1 and `org-agenda-default-appointment-duration' are set
+	(when (and s1 (not s2) org-agenda-default-appointment-duration)
+	  (setq s2
+		(org-minutes-to-hh:mm-string
+		 (+ (org-hh:mm-string-to-minutes s1) org-agenda-default-appointment-duration))))
+
 	;; Compute the duration
 	;; Compute the duration
-	(when s1
-	  (setq t1 (+ (* 60 (string-to-number (substring s1 0 2)))
-		      (string-to-number (substring s1 3)))
-		t2 (cond
-		    (s2 (+ (* 60 (string-to-number (substring s2 0 2)))
-			   (string-to-number (substring s2 3))))
-		    (org-agenda-default-appointment-duration
-		     (+ t1 org-agenda-default-appointment-duration))
-		    (t nil)))
-	  (setq duration (if t2 (- t2 t1)))))
-
-      (when (and s1 (not s2) org-agenda-default-appointment-duration
-		 (string-match "\\([0-9]+\\):\\([0-9]+\\)" s1))
-	(let ((m (+ (string-to-number (match-string 2 s1))
-		    (* 60 (string-to-number (match-string 1 s1)))
-		    org-agenda-default-appointment-duration))
-	      h)
-	  (setq h (/ m 60) m (- m (* h 60)))
-	  (setq s2 (format "%02d:%02d" h m))))
+	(when s2
+	  (setq duration (- (org-hh:mm-string-to-minutes s2)
+			    (org-hh:mm-string-to-minutes s1)))))
 
 
       (when (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")
       (when (string-match (org-re "\\([ \t]+\\)\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$")
 			  txt)
 			  txt)

+ 1 - 1
lisp/org-clock.el

@@ -2481,7 +2481,7 @@ The details of what will be saved are regulated by the variable
 	      (goto-char (cdr resume-clock))
 	      (goto-char (cdr resume-clock))
 	      (let ((org-clock-auto-clock-resolution nil))
 	      (let ((org-clock-auto-clock-resolution nil))
 		(org-clock-in)
 		(org-clock-in)
-		(if (org-invisible-p)
+		(if (outline-invisible-p)
 		    (org-show-context))))))))))
 		    (org-show-context))))))))))
 
 
 ;;;###autoload
 ;;;###autoload

+ 1 - 1
lisp/org-crypt.el

@@ -112,7 +112,7 @@ This setting can also be overridden in the CRYPTKEY property."
     (let ((start-heading (point)))
     (let ((start-heading (point)))
       (forward-line)
       (forward-line)
       (when (not (looking-at "-----BEGIN PGP MESSAGE-----"))
       (when (not (looking-at "-----BEGIN PGP MESSAGE-----"))
-        (let ((folded (org-invisible-p))
+        (let ((folded (outline-invisible-p))
               (epg-context (epg-make-context nil t t))
               (epg-context (epg-make-context nil t t))
               (crypt-key (org-crypt-key-for-heading))
               (crypt-key (org-crypt-key-for-heading))
               (beg (point))
               (beg (point))

+ 3 - 3
lisp/org-exp.el

@@ -475,8 +475,8 @@ This option can also be set with the +OPTIONS line, e.g. \"TeX:nil\"."
   "Non-nil means process LaTeX math fragments for HTML display.
   "Non-nil means process LaTeX math fragments for HTML display.
 When set, the exporter will find and process LaTeX environments if the
 When set, the exporter will find and process LaTeX environments if the
 \\begin line is the first non-white thing on a line.  It will also find
 \\begin line is the first non-white thing on a line.  It will also find
-and process  the math delimiters like $a=b$ and \\( a=b \\) for inline math,
-$$a=b$$ and \\[ a=b \\] for display math.
+and process the math delimiters like $a=b$ and \\( a=b \\) for inline math,
+$$a=b$$ and \\=\\[ a=b \\] for display math.
 
 
 This option can also be set with the +OPTIONS line, e.g. \"LaTeX:mathjax\".
 This option can also be set with the +OPTIONS line, e.g. \"LaTeX:mathjax\".
 
 
@@ -2615,7 +2615,7 @@ command."
       (goto-char (point-min))
       (goto-char (point-min))
       (while (re-search-forward org-drawer-regexp nil t)
       (while (re-search-forward org-drawer-regexp nil t)
 	(goto-char (match-beginning 1))
 	(goto-char (match-beginning 1))
-	(or (org-invisible-p) (org-flag-drawer nil))))
+	(or (outline-invisible-p) (org-flag-drawer nil))))
     (with-current-buffer buffer (erase-buffer))
     (with-current-buffer buffer (erase-buffer))
     (save-excursion
     (save-excursion
       (setq s (goto-char (point-min)))
       (setq s (goto-char (point-min)))

+ 2 - 1
lisp/org-latex.el

@@ -704,7 +704,8 @@ when PUB-DIR is set, use this as the publishing directory."
   (org-install-letbind)
   (org-install-letbind)
   (run-hooks 'org-export-latex-after-initial-vars-hook)
   (run-hooks 'org-export-latex-after-initial-vars-hook)
   (let* ((wcf (current-window-configuration))
   (let* ((wcf (current-window-configuration))
-	 (opt-plist org-export-latex-options-plist)
+	 (opt-plist
+	  (org-export-process-option-filters org-export-latex-options-plist))
 	 (region-p (org-region-active-p))
 	 (region-p (org-region-active-p))
 	 (rbeg (and region-p (region-beginning)))
 	 (rbeg (and region-p (region-beginning)))
 	 (rend (and region-p (region-end)))
 	 (rend (and region-p (region-end)))

+ 1 - 2
lisp/org-list.el

@@ -44,7 +44,6 @@
 (defvar org-ts-regexp)
 (defvar org-ts-regexp)
 (defvar org-ts-regexp-both)
 (defvar org-ts-regexp-both)
 
 
-(declare-function org-invisible-p "org" ())
 (declare-function org-on-heading-p "org" (&optional invisible-ok))
 (declare-function org-on-heading-p "org" (&optional invisible-ok))
 (declare-function outline-next-heading "outline" ())
 (declare-function outline-next-heading "outline" ())
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
@@ -1101,7 +1100,7 @@ item is invisible."
   (unless (or (not (org-in-item-p))
   (unless (or (not (org-in-item-p))
 	      (save-excursion
 	      (save-excursion
 		(goto-char (org-get-item-beginning))
 		(goto-char (org-get-item-beginning))
-		(org-invisible-p)))
+		(outline-invisible-p)))
     (if (save-excursion
     (if (save-excursion
 	  (goto-char (org-get-item-beginning))
 	  (goto-char (org-get-item-beginning))
 	  (org-at-item-timer-p))
 	  (org-at-item-timer-p))

+ 6 - 0
lisp/org-publish.el

@@ -434,6 +434,9 @@ matching filenames."
 	 ;; org-publish-compare-directory-files:
 	 ;; org-publish-compare-directory-files:
 	 (sitemap-requested
 	 (sitemap-requested
 	  (plist-get project-plist :auto-sitemap))
 	  (plist-get project-plist :auto-sitemap))
+	 (sitemap-filename
+	  (or (plist-get project-plist :sitemap-filename)
+	      "sitemap.org"))
 	 (sitemap-sort-folders
 	 (sitemap-sort-folders
 	  (if (plist-member project-plist :sitemap-sort-folders)
 	  (if (plist-member project-plist :sitemap-sort-folders)
 	      (plist-get project-plist :sitemap-sort-folders)
 	      (plist-get project-plist :sitemap-sort-folders)
@@ -454,6 +457,9 @@ matching filenames."
       (setq sitemap-sort-folders nil))
       (setq sitemap-sort-folders nil))
 
 
     (setq org-publish-temp-files nil)
     (setq org-publish-temp-files nil)
+    (if sitemap-requested
+	(pushnew (expand-file-name (concat base-dir sitemap-filename))
+		  org-publish-temp-files))
     (org-publish-get-base-files-1 base-dir recurse match
     (org-publish-get-base-files-1 base-dir recurse match
 				  ;; FIXME distinguish exclude regexp
 				  ;; FIXME distinguish exclude regexp
 				  ;; for skip-file and skip-dir?
 				  ;; for skip-file and skip-dir?

+ 206 - 221
lisp/org.el

@@ -6010,7 +6010,7 @@ in special contexts.
       (save-excursion
       (save-excursion
 	(goto-char eos)
 	(goto-char eos)
 	(outline-next-heading)
 	(outline-next-heading)
-	(if (org-invisible-p) (org-flag-heading nil))))
+	(if (outline-invisible-p) (org-flag-heading nil))))
      ((and (or (>= eol eos)
      ((and (or (>= eol eos)
 	       (not (string-match "\\S-" (buffer-substring eol eos))))
 	       (not (string-match "\\S-" (buffer-substring eol eos))))
 	   (or has-children
 	   (or has-children
@@ -6024,7 +6024,7 @@ in special contexts.
       (save-excursion
       (save-excursion
 	(goto-char eos)
 	(goto-char eos)
 	(outline-next-heading)
 	(outline-next-heading)
-	(if (org-invisible-p) (org-flag-heading nil)))
+	(if (outline-invisible-p) (org-flag-heading nil)))
       (setq org-cycle-subtree-status 'children)
       (setq org-cycle-subtree-status 'children)
       (run-hook-with-args 'org-cycle-hook 'children))
       (run-hook-with-args 'org-cycle-hook 'children))
      ((or children-skipped
      ((or children-skipped
@@ -6191,9 +6191,9 @@ This function is the default value of the hook `org-cycle-hook'."
 	  ;; Properly fold already folded siblings
 	  ;; Properly fold already folded siblings
 	  (goto-char (point-min))
 	  (goto-char (point-min))
 	  (while (re-search-forward re nil t)
 	  (while (re-search-forward re nil t)
-	    (if (and (not (org-invisible-p))
+	    (if (and (not (outline-invisible-p))
 		     (save-excursion
 		     (save-excursion
-		       (goto-char (point-at-eol)) (org-invisible-p)))
+		       (goto-char (point-at-eol)) (outline-invisible-p)))
 		(hide-entry))))
 		(hide-entry))))
 	(org-cycle-show-empty-lines 'overview)
 	(org-cycle-show-empty-lines 'overview)
 	(org-cycle-hide-drawers 'overview)))))
 	(org-cycle-hide-drawers 'overview)))))
@@ -6526,7 +6526,7 @@ the headline hierarchy above."
 	(progn
 	(progn
 	  (org-mark-ring-push org-goto-start-pos)
 	  (org-mark-ring-push org-goto-start-pos)
 	  (goto-char selected-point)
 	  (goto-char selected-point)
-	  (if (or (org-invisible-p) (org-invisible-p2))
+	  (if (or (outline-invisible-p) (org-invisible-p2))
 	      (org-show-context 'org-goto)))
 	      (org-show-context 'org-goto)))
       (message "Quit"))))
       (message "Quit"))))
 
 
@@ -6571,7 +6571,7 @@ or nil."
 		  (org-show-siblings t)
 		  (org-show-siblings t)
 		  (org-show-following-heading t))
 		  (org-show-following-heading t))
 	      (goto-char org-goto-start-pos)
 	      (goto-char org-goto-start-pos)
-	      (and (org-invisible-p) (org-show-context)))
+	      (and (outline-invisible-p) (org-show-context)))
 	  (goto-char (point-min)))
 	  (goto-char (point-min)))
 	(let (org-special-ctrl-a/e) (org-beginning-of-line))
 	(let (org-special-ctrl-a/e) (org-beginning-of-line))
 	(message "Select location and press RET")
 	(message "Select location and press RET")
@@ -6786,14 +6786,14 @@ This is important for non-interactive uses of the command."
 	(cond
 	(cond
 	 ((and (org-on-heading-p) (bolp)
 	 ((and (org-on-heading-p) (bolp)
 	       (or (bobp)
 	       (or (bobp)
-		   (save-excursion (backward-char 1) (not (org-invisible-p)))))
+		   (save-excursion (backward-char 1) (not (outline-invisible-p)))))
 	  ;; insert before the current line
 	  ;; insert before the current line
 	  (open-line (if blank 2 1)))
 	  (open-line (if blank 2 1)))
 	 ((and (bolp)
 	 ((and (bolp)
 	       (not org-insert-heading-respect-content)
 	       (not org-insert-heading-respect-content)
 	       (or (bobp)
 	       (or (bobp)
 		   (save-excursion
 		   (save-excursion
-		     (backward-char 1) (not (org-invisible-p)))))
+		     (backward-char 1) (not (outline-invisible-p)))))
 	  ;; insert right here
 	  ;; insert right here
 	  nil)
 	  nil)
 	 (t
 	 (t
@@ -6801,7 +6801,7 @@ This is important for non-interactive uses of the command."
           (save-excursion
           (save-excursion
 	    (setq previous-pos (point-at-bol))
 	    (setq previous-pos (point-at-bol))
             (end-of-line)
             (end-of-line)
-            (setq hide-previous (org-invisible-p)))
+            (setq hide-previous (outline-invisible-p)))
 	  (and org-insert-heading-respect-content (org-show-subtree))
 	  (and org-insert-heading-respect-content (org-show-subtree))
 	  (let ((split
 	  (let ((split
 		 (and (org-get-alist-option org-M-RET-may-split-line 'headline)
 		 (and (org-get-alist-option org-M-RET-may-split-line 'headline)
@@ -7026,12 +7026,10 @@ in the region."
   "Return the level of the current entry, or nil if before the first headline.
   "Return the level of the current entry, or nil if before the first headline.
 The level is the number of stars at the beginning of the headline."
 The level is the number of stars at the beginning of the headline."
   (save-excursion
   (save-excursion
-    (let ((outline-regexp (org-get-limited-outline-regexp)))
-      (condition-case nil
-	  (progn
-	    (org-back-to-heading t)
-	    (funcall outline-level))
-	(error nil)))))
+    (org-with-limited-levels
+     (ignore-errors
+       (org-back-to-heading t)
+       (funcall outline-level)))))
 
 
 (defun org-get-previous-line-level ()
 (defun org-get-previous-line-level ()
   "Return the outline depth of the last headline before the current line.
   "Return the outline depth of the last headline before the current line.
@@ -7257,7 +7255,7 @@ case."
       (setq beg (point)))
       (setq beg (point)))
     (save-match-data
     (save-match-data
       (save-excursion (outline-end-of-heading)
       (save-excursion (outline-end-of-heading)
-		      (setq folded (org-invisible-p)))
+		      (setq folded (outline-invisible-p)))
       (outline-end-of-subtree))
       (outline-end-of-subtree))
     (outline-next-heading)
     (outline-next-heading)
     (setq ne-end (org-back-over-empty-lines))
     (setq ne-end (org-back-over-empty-lines))
@@ -7349,7 +7347,7 @@ useful if the caller implements cut-and-paste as copy-then-paste-then-cut."
     (skip-chars-forward " \t\r\n")
     (skip-chars-forward " \t\r\n")
     (save-match-data
     (save-match-data
       (save-excursion (outline-end-of-heading)
       (save-excursion (outline-end-of-heading)
-		      (setq folded (org-invisible-p)))
+		      (setq folded (outline-invisible-p)))
       (condition-case nil
       (condition-case nil
 	  (org-forward-same-level (1- n) t)
 	  (org-forward-same-level (1- n) t)
 	(error nil))
 	(error nil))
@@ -7397,7 +7395,7 @@ the inserted text when done."
     (error "%s"
     (error "%s"
      (substitute-command-keys
      (substitute-command-keys
       "The kill is not a (set of) tree(s) - please use \\[yank] to yank anyway")))
       "The kill is not a (set of) tree(s) - please use \\[yank] to yank anyway")))
-  (let* ((visp (not (org-invisible-p)))
+  (let* ((visp (not (outline-invisible-p)))
 	 (txt tree)
 	 (txt tree)
 	 (^re (concat "^\\(" outline-regexp "\\)"))
 	 (^re (concat "^\\(" outline-regexp "\\)"))
 	 (re  (concat "\\(" outline-regexp "\\)"))
 	 (re  (concat "\\(" outline-regexp "\\)"))
@@ -7459,7 +7457,7 @@ the inserted text when done."
     (goto-char beg)
     (goto-char beg)
     (skip-chars-forward " \t\n\r")
     (skip-chars-forward " \t\n\r")
     (setq beg (point))
     (setq beg (point))
-    (if (and (org-invisible-p) visp)
+    (if (and (outline-invisible-p) visp)
 	(save-excursion (outline-show-heading)))
 	(save-excursion (outline-show-heading)))
     ;; Shift if necessary
     ;; Shift if necessary
     (unless (= shift 0)
     (unless (= shift 0)
@@ -8283,183 +8281,183 @@ For file links, arg negates `org-context-in-file-links'."
   (interactive "P")
   (interactive "P")
   (org-load-modules-maybe)
   (org-load-modules-maybe)
   (setq org-store-link-plist nil)  ; reset
   (setq org-store-link-plist nil)  ; reset
-  (let ((outline-regexp (org-get-limited-outline-regexp))
-	link cpltxt desc description search txt custom-id agenda-link)
-    (cond
-
-     ((run-hook-with-args-until-success 'org-store-link-functions)
-      (setq link (plist-get org-store-link-plist :link)
-	    desc (or (plist-get org-store-link-plist :description) link)))
-
-     ((equal (buffer-name) "*Org Edit Src Example*")
-      (let (label gc)
-	(while (or (not label)
-		   (save-excursion
-		     (save-restriction
-		       (widen)
-		       (goto-char (point-min))
-		       (re-search-forward
-			(regexp-quote (format org-coderef-label-format label))
-			nil t))))
-	  (when label (message "Label exists already") (sit-for 2))
-	  (setq label (read-string "Code line label: " label)))
-	(end-of-line 1)
-	(setq link (format org-coderef-label-format label))
-	(setq gc (- 79 (length link)))
-	(if (< (current-column) gc) (org-move-to-column gc t) (insert " "))
-	(insert link)
-	(setq link (concat "(" label ")") desc nil)))
-
-     ((equal (org-bound-and-true-p org-agenda-buffer-name) (buffer-name))
-      ;; We are in the agenda, link to referenced location
-      (let ((m (or (get-text-property (point) 'org-hd-marker)
-		   (get-text-property (point) 'org-marker))))
-	(when m
-	  (org-with-point-at m
-	    (setq agenda-link
-		  (if (interactive-p)
-		      (call-interactively 'org-store-link)
-		    (org-store-link nil)))))))
-
-     ((eq major-mode 'calendar-mode)
-      (let ((cd (calendar-cursor-to-date)))
-	(setq link
-	      (format-time-string
-	       (car org-time-stamp-formats)
-	       (apply 'encode-time
-		      (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
-			    nil nil nil))))
-	(org-store-link-props :type "calendar" :date cd)))
-
-     ((eq major-mode 'w3-mode)
-      (setq cpltxt (if (and (buffer-name)
-			    (not (string-match "Untitled" (buffer-name))))
-		       (buffer-name)
-		     (url-view-url t))
-	    link (org-make-link (url-view-url t)))
-      (org-store-link-props :type "w3" :url (url-view-url t)))
-
-     ((eq major-mode 'w3m-mode)
-      (setq cpltxt (or w3m-current-title w3m-current-url)
-	    link (org-make-link w3m-current-url))
-      (org-store-link-props :type "w3m" :url (url-view-url t)))
-
-     ((setq search (run-hook-with-args-until-success
-		    'org-create-file-search-functions))
-      (setq link (concat "file:" (abbreviate-file-name buffer-file-name)
-			 "::" search))
-      (setq cpltxt (or description link)))
-
-     ((eq major-mode 'image-mode)
-      (setq cpltxt (concat "file:"
-			   (abbreviate-file-name buffer-file-name))
-	    link (org-make-link cpltxt))
-      (org-store-link-props :type "image" :file buffer-file-name))
-
-     ((eq major-mode 'dired-mode)
-      ;; link to the file in the current line
-      (let ((file (dired-get-filename nil t)))
- 	(setq file (if file
- 		       (abbreviate-file-name
- 			(expand-file-name (dired-get-filename nil t)))
- 		     ;; otherwise, no file so use current directory.
- 		     default-directory))
- 	(setq cpltxt (concat "file:" file)
- 	      link (org-make-link cpltxt))))
-
-     ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
-      (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID")))
-      (cond
-       ((org-in-regexp "<<\\(.*?\\)>>")
-	(setq cpltxt
-	      (concat "file:"
-		      (abbreviate-file-name
-		       (buffer-file-name (buffer-base-buffer)))
-		      "::" (match-string 1))
-	      link (org-make-link cpltxt)))
-       ((and (featurep 'org-id)
-	     (or (eq org-link-to-org-use-id t)
-		 (and (eq org-link-to-org-use-id 'create-if-interactive)
-		      (interactive-p))
-		 (and (eq org-link-to-org-use-id 'create-if-interactive-and-no-custom-id)
-		      (interactive-p)
-		      (not custom-id))
-		 (and org-link-to-org-use-id
-		      (condition-case nil
-			  (org-entry-get nil "ID")
-			(error nil)))))
-	;; We can make a link using the ID.
-	(setq link (condition-case nil
-		       (prog1 (org-id-store-link)
-			 (setq desc (plist-get org-store-link-plist
-					       :description)))
-		     (error
-		      ;; probably before first headline, link to file only
-		      (concat "file:"
+  (org-with-limited-levels
+   (let (link cpltxt desc description search txt custom-id agenda-link)
+     (cond
+
+      ((run-hook-with-args-until-success 'org-store-link-functions)
+       (setq link (plist-get org-store-link-plist :link)
+	     desc (or (plist-get org-store-link-plist :description) link)))
+
+      ((equal (buffer-name) "*Org Edit Src Example*")
+       (let (label gc)
+	 (while (or (not label)
+		    (save-excursion
+		      (save-restriction
+			(widen)
+			(goto-char (point-min))
+			(re-search-forward
+			 (regexp-quote (format org-coderef-label-format label))
+			 nil t))))
+	   (when label (message "Label exists already") (sit-for 2))
+	   (setq label (read-string "Code line label: " label)))
+	 (end-of-line 1)
+	 (setq link (format org-coderef-label-format label))
+	 (setq gc (- 79 (length link)))
+	 (if (< (current-column) gc) (org-move-to-column gc t) (insert " "))
+	 (insert link)
+	 (setq link (concat "(" label ")") desc nil)))
+
+      ((equal (org-bound-and-true-p org-agenda-buffer-name) (buffer-name))
+       ;; We are in the agenda, link to referenced location
+       (let ((m (or (get-text-property (point) 'org-hd-marker)
+		    (get-text-property (point) 'org-marker))))
+	 (when m
+	   (org-with-point-at m
+	     (setq agenda-link
+		   (if (interactive-p)
+		       (call-interactively 'org-store-link)
+		     (org-store-link nil)))))))
+
+      ((eq major-mode 'calendar-mode)
+       (let ((cd (calendar-cursor-to-date)))
+	 (setq link
+	       (format-time-string
+		(car org-time-stamp-formats)
+		(apply 'encode-time
+		       (list 0 0 0 (nth 1 cd) (nth 0 cd) (nth 2 cd)
+			     nil nil nil))))
+	 (org-store-link-props :type "calendar" :date cd)))
+
+      ((eq major-mode 'w3-mode)
+       (setq cpltxt (if (and (buffer-name)
+			     (not (string-match "Untitled" (buffer-name))))
+			(buffer-name)
+		      (url-view-url t))
+	     link (org-make-link (url-view-url t)))
+       (org-store-link-props :type "w3" :url (url-view-url t)))
+
+      ((eq major-mode 'w3m-mode)
+       (setq cpltxt (or w3m-current-title w3m-current-url)
+	     link (org-make-link w3m-current-url))
+       (org-store-link-props :type "w3m" :url (url-view-url t)))
+
+      ((setq search (run-hook-with-args-until-success
+		     'org-create-file-search-functions))
+       (setq link (concat "file:" (abbreviate-file-name buffer-file-name)
+			  "::" search))
+       (setq cpltxt (or description link)))
+
+      ((eq major-mode 'image-mode)
+       (setq cpltxt (concat "file:"
+			    (abbreviate-file-name buffer-file-name))
+	     link (org-make-link cpltxt))
+       (org-store-link-props :type "image" :file buffer-file-name))
+
+      ((eq major-mode 'dired-mode)
+       ;; link to the file in the current line
+       (let ((file (dired-get-filename nil t)))
+	 (setq file (if file
+			(abbreviate-file-name
+			 (expand-file-name (dired-get-filename nil t)))
+		      ;; otherwise, no file so use current directory.
+		      default-directory))
+	 (setq cpltxt (concat "file:" file)
+	       link (org-make-link cpltxt))))
+
+      ((and (buffer-file-name (buffer-base-buffer)) (org-mode-p))
+       (setq custom-id (ignore-errors (org-entry-get nil "CUSTOM_ID")))
+       (cond
+	((org-in-regexp "<<\\(.*?\\)>>")
+	 (setq cpltxt
+	       (concat "file:"
+		       (abbreviate-file-name
+			(buffer-file-name (buffer-base-buffer)))
+		       "::" (match-string 1))
+	       link (org-make-link cpltxt)))
+	((and (featurep 'org-id)
+	      (or (eq org-link-to-org-use-id t)
+		  (and (eq org-link-to-org-use-id 'create-if-interactive)
+		       (interactive-p))
+		  (and (eq org-link-to-org-use-id 'create-if-interactive-and-no-custom-id)
+		       (interactive-p)
+		       (not custom-id))
+		  (and org-link-to-org-use-id
+		       (condition-case nil
+			   (org-entry-get nil "ID")
+			 (error nil)))))
+	 ;; We can make a link using the ID.
+	 (setq link (condition-case nil
+			(prog1 (org-id-store-link)
+			  (setq desc (plist-get org-store-link-plist
+						:description)))
+		      (error
+		       ;; probably before first headline, link to file only
+		       (concat "file:"
+			       (abbreviate-file-name
+				(buffer-file-name (buffer-base-buffer))))))))
+	(t
+	 ;; Just link to current headline
+	 (setq cpltxt (concat "file:"
 			      (abbreviate-file-name
 			      (abbreviate-file-name
-			       (buffer-file-name (buffer-base-buffer))))))))
-       (t
-	;; Just link to current headline
-	(setq cpltxt (concat "file:"
-			     (abbreviate-file-name
-			      (buffer-file-name (buffer-base-buffer)))))
-	;; Add a context search string
-	(when (org-xor org-context-in-file-links arg)
-	  (setq txt (cond
-		     ((org-on-heading-p) nil)
-		     ((org-region-active-p)
-		      (buffer-substring (region-beginning) (region-end)))
-		     (t nil)))
-	  (when (or (null txt) (string-match "\\S-" txt))
-	    (setq cpltxt
-		  (concat cpltxt "::"
-			  (condition-case nil
-			      (org-make-org-heading-search-string txt)
-			    (error "")))
-		  desc (or (nth 4 (ignore-errors
-				    (org-heading-components))) "NONE"))))
-	(if (string-match "::\\'" cpltxt)
-	    (setq cpltxt (substring cpltxt 0 -2)))
-	(setq link (org-make-link cpltxt)))))
-
-     ((buffer-file-name (buffer-base-buffer))
-      ;; Just link to this file here.
-      (setq cpltxt (concat "file:"
-			   (abbreviate-file-name
-			    (buffer-file-name (buffer-base-buffer)))))
-      ;; Add a context string
-      (when (org-xor org-context-in-file-links arg)
-	(setq txt (if (org-region-active-p)
-		      (buffer-substring (region-beginning) (region-end))
-		    (buffer-substring (point-at-bol) (point-at-eol))))
-	;; Only use search option if there is some text.
-	(when (string-match "\\S-" txt)
-	  (setq cpltxt
-		(concat cpltxt "::" (org-make-org-heading-search-string txt))
-		desc "NONE")))
-      (setq link (org-make-link cpltxt)))
-
-     ((interactive-p)
-      (error "Cannot link to a buffer which is not visiting a file"))
-
-     (t (setq link nil)))
-
-    (if (consp link) (setq cpltxt (car link) link (cdr link)))
-    (setq link (or link cpltxt)
-	  desc (or desc cpltxt))
-    (if (equal desc "NONE") (setq desc nil))
-
-    (if (and (or (interactive-p) executing-kbd-macro) link)
-	(progn
-	  (setq org-stored-links
-		(cons (list link desc) org-stored-links))
-	  (message "Stored: %s" (or desc link))
-	  (when custom-id
-	    (setq link (concat "file:" (abbreviate-file-name (buffer-file-name))
-			       "::#" custom-id))
-	    (setq org-stored-links
-		  (cons (list link desc) org-stored-links))))
-      (or agenda-link (and link (org-make-link-string link desc))))))
+			       (buffer-file-name (buffer-base-buffer)))))
+	 ;; Add a context search string
+	 (when (org-xor org-context-in-file-links arg)
+	   (setq txt (cond
+		      ((org-on-heading-p) nil)
+		      ((org-region-active-p)
+		       (buffer-substring (region-beginning) (region-end)))
+		      (t nil)))
+	   (when (or (null txt) (string-match "\\S-" txt))
+	     (setq cpltxt
+		   (concat cpltxt "::"
+			   (condition-case nil
+			       (org-make-org-heading-search-string txt)
+			     (error "")))
+		   desc (or (nth 4 (ignore-errors
+				     (org-heading-components))) "NONE"))))
+	 (if (string-match "::\\'" cpltxt)
+	     (setq cpltxt (substring cpltxt 0 -2)))
+	 (setq link (org-make-link cpltxt)))))
+
+      ((buffer-file-name (buffer-base-buffer))
+       ;; Just link to this file here.
+       (setq cpltxt (concat "file:"
+			    (abbreviate-file-name
+			     (buffer-file-name (buffer-base-buffer)))))
+       ;; Add a context string
+       (when (org-xor org-context-in-file-links arg)
+	 (setq txt (if (org-region-active-p)
+		       (buffer-substring (region-beginning) (region-end))
+		     (buffer-substring (point-at-bol) (point-at-eol))))
+	 ;; Only use search option if there is some text.
+	 (when (string-match "\\S-" txt)
+	   (setq cpltxt
+		 (concat cpltxt "::" (org-make-org-heading-search-string txt))
+		 desc "NONE")))
+       (setq link (org-make-link cpltxt)))
+
+      ((interactive-p)
+       (error "Cannot link to a buffer which is not visiting a file"))
+
+      (t (setq link nil)))
+
+     (if (consp link) (setq cpltxt (car link) link (cdr link)))
+     (setq link (or link cpltxt)
+	   desc (or desc cpltxt))
+     (if (equal desc "NONE") (setq desc nil))
+
+     (if (and (or (interactive-p) executing-kbd-macro) link)
+	 (progn
+	   (setq org-stored-links
+		 (cons (list link desc) org-stored-links))
+	   (message "Stored: %s" (or desc link))
+	   (when custom-id
+	     (setq link (concat "file:" (abbreviate-file-name (buffer-file-name))
+				"::#" custom-id))
+	     (setq org-stored-links
+		   (cons (list link desc) org-stored-links))))
+       (or agenda-link (and link (org-make-link-string link desc)))))))
 
 
 (defun org-store-link-props (&rest plist)
 (defun org-store-link-props (&rest plist)
   "Store link properties, extract names and addresses."
   "Store link properties, extract names and addresses."
@@ -8976,7 +8974,7 @@ If the link is in hidden text, expose it."
     (if (re-search-forward org-any-link-re nil t)
     (if (re-search-forward org-any-link-re nil t)
 	(progn
 	(progn
 	  (goto-char (match-beginning 0))
 	  (goto-char (match-beginning 0))
-	  (if (org-invisible-p) (org-show-context)))
+	  (if (outline-invisible-p) (org-show-context)))
       (goto-char pos)
       (goto-char pos)
       (setq org-link-search-failed t)
       (setq org-link-search-failed t)
       (error "No further link found"))))
       (error "No further link found"))))
@@ -8996,7 +8994,7 @@ If the link is in hidden text, expose it."
     (if (re-search-backward org-any-link-re nil t)
     (if (re-search-backward org-any-link-re nil t)
 	(progn
 	(progn
 	  (goto-char (match-beginning 0))
 	  (goto-char (match-beginning 0))
-	  (if (org-invisible-p) (org-show-context)))
+	  (if (outline-invisible-p) (org-show-context)))
       (goto-char pos)
       (goto-char pos)
       (setq org-link-search-failed t)
       (setq org-link-search-failed t)
       (error "No further link found"))))
       (error "No further link found"))))
@@ -9642,7 +9640,7 @@ onto the ring."
     (setq m (car p))
     (setq m (car p))
     (switch-to-buffer (marker-buffer m))
     (switch-to-buffer (marker-buffer m))
     (goto-char m)
     (goto-char m)
-    (if (or (org-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto))))
+    (if (or (outline-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto))))
 
 
 (defun org-remove-angle-brackets (s)
 (defun org-remove-angle-brackets (s)
   (if (equal (substring s 0 1) "<") (setq s (substring s 1)))
   (if (equal (substring s 0 1) "<") (setq s (substring s 1)))
@@ -12023,7 +12021,7 @@ How much context is shown depends upon the variables
       ;; Show heading or entry text
       ;; Show heading or entry text
       (if (and heading-p (not entry-p))
       (if (and heading-p (not entry-p))
 	  (org-flag-heading nil)    ; only show the heading
 	  (org-flag-heading nil)    ; only show the heading
-	(and (or entry-p (org-invisible-p) (org-invisible-p2))
+	(and (or entry-p (outline-invisible-p) (org-invisible-p2))
 	     (org-show-hidden-entry)))    ; show entire entry
 	     (org-show-hidden-entry)))    ; show entire entry
       (when following-p
       (when following-p
 	;; Show next sibling, or heading below text
 	;; Show next sibling, or heading below text
@@ -12947,8 +12945,7 @@ possibly with grouping information.  TODO-TABLE is a similar table with
 TODO keywords, should these have keys assigned to them.
 TODO keywords, should these have keys assigned to them.
 If the keys are nil, a-z are automatically assigned.
 If the keys are nil, a-z are automatically assigned.
 Returns the new tags string, or nil to not change the current settings."
 Returns the new tags string, or nil to not change the current settings."
-  (let* ((table (sort table (lambda (a b) (string< (car a) (car b)))))
-	 (fulltable (append table todo-table))
+  (let* ((fulltable (append table todo-table))
 	 (maxlen (apply 'max (mapcar
 	 (maxlen (apply 'max (mapcar
 			      (lambda (x)
 			      (lambda (x)
 				(if (stringp (car x)) (string-width (car x)) 0))
 				(if (stringp (car x)) (string-width (car x)) 0))
@@ -13807,7 +13804,7 @@ formats in the current buffer."
     (setq end (point))
     (setq end (point))
     (goto-char beg)
     (goto-char beg)
     (while (re-search-forward re end t))
     (while (re-search-forward re end t))
-    (setq hiddenp (org-invisible-p))
+    (setq hiddenp (outline-invisible-p))
     (end-of-line 1)
     (end-of-line 1)
     (and (equal (char-after) ?\n) (forward-char 1))
     (and (equal (char-after) ?\n) (forward-char 1))
     (while (looking-at "^[ \t]*\\(:CLOCK:\\|:LOGBOOK:\\|CLOCK:\\|:END:\\)")
     (while (looking-at "^[ \t]*\\(:CLOCK:\\|:LOGBOOK:\\|CLOCK:\\|:END:\\)")
@@ -18658,8 +18655,7 @@ If point is in an inline task, mark that task instead."
     (cond
     (cond
      (inline-task-p (org-inlinetask-goto-beginning))
      (inline-task-p (org-inlinetask-goto-beginning))
      ((org-at-heading-p) (beginning-of-line))
      ((org-at-heading-p) (beginning-of-line))
-     (t (let ((outline-regexp (org-get-limited-outline-regexp)))
-	  (outline-previous-visible-heading 1))))
+     (t (org-with-limited-levels (outline-previous-visible-heading 1))))
     (setq beg (point))
     (setq beg (point))
     ;; Get end of it
     ;; Get end of it
     (if	inline-task-p
     (if	inline-task-p
@@ -19176,13 +19172,6 @@ interactive command with similar behavior."
 
 
 (define-key org-mode-map "\C-y" 'org-yank)
 (define-key org-mode-map "\C-y" 'org-yank)
 
 
-(defun org-invisible-p ()
-  "Check if point is at a character currently not visible."
-  ;; Early versions of noutline don't have `outline-invisible-p'.
-  (if (fboundp 'outline-invisible-p)
-      (outline-invisible-p)
-    (get-char-property (point) 'invisible)))
-
 (defun org-truely-invisible-p ()
 (defun org-truely-invisible-p ()
   "Check if point is at a character currently not visible.
   "Check if point is at a character currently not visible.
 This version does not only check the character property, but also
 This version does not only check the character property, but also
@@ -19190,18 +19179,14 @@ This version does not only check the character property, but also
   ;; Early versions of noutline don't have `outline-invisible-p'.
   ;; Early versions of noutline don't have `outline-invisible-p'.
   (if (org-bound-and-true-p visible-mode)
   (if (org-bound-and-true-p visible-mode)
       nil
       nil
-    (if (fboundp 'outline-invisible-p)
-	(outline-invisible-p)
-      (get-char-property (point) 'invisible))))
+    (outline-invisible-p)))
 
 
 (defun org-invisible-p2 ()
 (defun org-invisible-p2 ()
   "Check if point is at a character currently not visible."
   "Check if point is at a character currently not visible."
   (save-excursion
   (save-excursion
     (if (and (eolp) (not (bobp))) (backward-char 1))
     (if (and (eolp) (not (bobp))) (backward-char 1))
     ;; Early versions of noutline don't have `outline-invisible-p'.
     ;; Early versions of noutline don't have `outline-invisible-p'.
-    (if (fboundp 'outline-invisible-p)
-	(outline-invisible-p)
-      (get-char-property (point) 'invisible))))
+    (outline-invisible-p)))
 
 
 (defun org-back-to-heading (&optional invisible-ok)
 (defun org-back-to-heading (&optional invisible-ok)
   "Call `outline-back-to-heading', but provide a better error message."
   "Call `outline-back-to-heading', but provide a better error message."
@@ -19429,7 +19414,7 @@ it wil also look at invisible ones."
 		  (setq l (- (match-end 0) (match-beginning 0) 1))
 		  (setq l (- (match-end 0) (match-beginning 0) 1))
 		  (= l level)
 		  (= l level)
 		  (not invisible-ok)
 		  (not invisible-ok)
-		  (progn (backward-char 1) (org-invisible-p)))
+		  (progn (backward-char 1) (outline-invisible-p)))
 	(if (< l level) (setq arg 1)))
 	(if (< l level) (setq arg 1)))
       (setq arg (1- arg)))
       (setq arg (1- arg)))
     (beginning-of-line 1)))
     (beginning-of-line 1)))
@@ -19448,7 +19433,7 @@ Stop at the first and last subheadings of a superior heading."
 		  (setq l (- (match-end 0) (match-beginning 0) 1))
 		  (setq l (- (match-end 0) (match-beginning 0) 1))
 		  (= l level)
 		  (= l level)
 		  (not invisible-ok)
 		  (not invisible-ok)
-		  (org-invisible-p))
+		  (outline-invisible-p))
 	(if (< l level) (setq arg 1)))
 	(if (< l level) (setq arg 1)))
       (setq arg (1- arg)))))
       (setq arg (1- arg)))))
 
 
@@ -19669,9 +19654,9 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
 (defun org-bookmark-jump-unhide ()
 (defun org-bookmark-jump-unhide ()
   "Unhide the current position, to show the bookmark location."
   "Unhide the current position, to show the bookmark location."
   (and (org-mode-p)
   (and (org-mode-p)
-       (or (org-invisible-p)
+       (or (outline-invisible-p)
 	   (save-excursion (goto-char (max (point-min) (1- (point))))
 	   (save-excursion (goto-char (max (point-min) (1- (point))))
-			   (org-invisible-p)))
+			   (outline-invisible-p)))
        (org-show-context 'bookmark-jump)))
        (org-show-context 'bookmark-jump)))
 
 
 ;; Make session.el ignore our circular variable
 ;; Make session.el ignore our circular variable