Browse Source

Merge branch 'maint'

Bastien Guerry 12 years ago
parent
commit
f155f5458e
5 changed files with 45 additions and 30 deletions
  1. 3 3
      doc/org.texi
  2. 1 1
      doc/orgguide.texi
  3. 3 2
      lisp/ob.el
  4. 20 18
      lisp/org-agenda.el
  5. 18 6
      lisp/org-src.el

+ 3 - 3
doc/org.texi

@@ -936,7 +936,7 @@ If you plan to use code from the @file{contrib} subdirectory without
 compiling them, do a similar step for this directory:
 compiling them, do a similar step for this directory:
 
 
 @example
 @example
-(add-to-list 'load-path "~/path/to/orgdir/contrib/lisp")
+(add-to-list 'load-path "~/path/to/orgdir/contrib/lisp" t)
 @end example
 @end example
 
 
 If you want to include those files with the build and install, please
 If you want to include those files with the build and install, please
@@ -1090,7 +1090,7 @@ is not necessary.  In that case it is sufficient to start Emacs as @code{emacs
 
 
 ;; add latest org-mode to load path
 ;; add latest org-mode to load path
 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
 (add-to-list 'load-path (expand-file-name "/path/to/org-mode/lisp"))
-(add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp"))
+(add-to-list 'load-path (expand-file-name "/path/to/org-mode/contrib/lisp" t))
 
 
 ;; activate org
 ;; activate org
 (require 'org-install)
 (require 'org-install)
@@ -14555,7 +14555,7 @@ done
 emacs -Q --batch -l $ORGINSTALL \
 emacs -Q --batch -l $ORGINSTALL \
 --eval "(progn
 --eval "(progn
 (add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\"))
 (add-to-list 'load-path (expand-file-name \"~/src/org/lisp/\"))
-(add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\"))
+(add-to-list 'load-path (expand-file-name \"~/src/org/contrib/lisp/\" t))
 (require 'org)(require 'org-exp)(require 'ob)(require 'ob-tangle)
 (require 'org)(require 'org-exp)(require 'ob)(require 'ob-tangle)
 (mapc (lambda (file)
 (mapc (lambda (file)
        (find-file (expand-file-name file \"$DIR\"))
        (find-file (expand-file-name file \"$DIR\"))

+ 1 - 1
doc/orgguide.texi

@@ -287,7 +287,7 @@ yourself.
 
 
 @smalllisp
 @smalllisp
 ;; The following lines are always needed.  Choose your own keys.
 ;; The following lines are always needed.  Choose your own keys.
-(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
+(add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode)) ; not needed since Emacs 22.2
 (add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on
 (add-hook 'org-mode-hook 'turn-on-font-lock) ; not needed when global-font-lock-mode is on
 (global-set-key "\C-cl" 'org-store-link)
 (global-set-key "\C-cl" 'org-store-link)
 (global-set-key "\C-ca" 'org-agenda)
 (global-set-key "\C-ca" 'org-agenda)

+ 3 - 2
lisp/ob.el

@@ -90,6 +90,7 @@
 (declare-function org-strip-protective-commas "org" (beg end))
 (declare-function org-strip-protective-commas "org" (beg end))
 (declare-function org-remove-if "org" (predicate seq))
 (declare-function org-remove-if "org" (predicate seq))
 (declare-function org-completing-read "org" (&rest args))
 (declare-function org-completing-read "org" (&rest args))
+(declare-function org-add-protective-commas "org-src" (beg end))
 
 
 (defgroup org-babel nil
 (defgroup org-babel nil
   "Code block evaluation and management in `org-mode' documents."
   "Code block evaluation and management in `org-mode' documents."
@@ -1940,7 +1941,7 @@ code ---- the results are extracted in the syntax of the source
 	(let ((wrap (lambda (start finish &optional escape)
 	(let ((wrap (lambda (start finish &optional escape)
 		      (goto-char end) (insert (concat finish "\n"))
 		      (goto-char end) (insert (concat finish "\n"))
 		      (goto-char beg) (insert (concat start "\n"))
 		      (goto-char beg) (insert (concat start "\n"))
-		      (if escape (org-babel-do-key-sequence-in-edit-buffer (kbd "TAB")))
+		      (if escape (org-add-protective-commas (point) end))
 		      (goto-char end) (goto-char (point-at-eol))
 		      (goto-char end) (goto-char (point-at-eol))
 		      (setq end (point-marker))))
 		      (setq end (point-marker))))
 	      (proper-list-p (lambda (it) (and (listp it) (null (cdr (last it)))))))
 	      (proper-list-p (lambda (it) (and (listp it) (null (cdr (last it)))))))
@@ -1987,7 +1988,7 @@ code ---- the results are extracted in the syntax of the source
 	   ((member "latex" result-params)
 	   ((member "latex" result-params)
 	    (funcall wrap "#+BEGIN_LaTeX" "#+END_LaTeX"))
 	    (funcall wrap "#+BEGIN_LaTeX" "#+END_LaTeX"))
 	   ((member "org" result-params)
 	   ((member "org" result-params)
-	    (funcall wrap "#+BEGIN_SRC org" "#+END_SRC" t))
+	    (funcall wrap "#+BEGIN_SRC org" "#+END_SRC" 'escape))
 	   ((member "code" result-params)
 	   ((member "code" result-params)
 	    (funcall wrap (format "#+BEGIN_SRC %s%s" (or lang "none") results-switches)
 	    (funcall wrap (format "#+BEGIN_SRC %s%s" (or lang "none") results-switches)
 		     "#+END_SRC"))
 		     "#+END_SRC"))

+ 20 - 18
lisp/org-agenda.el

@@ -7013,7 +7013,8 @@ Negative selection means regexp must not match for selection of an entry."
        " "))
        " "))
     (setq org-agenda-redo-command
     (setq org-agenda-redo-command
 	  (list 'org-search-view
 	  (list 'org-search-view
-		(car (get-text-property (point) 'org-last-args))
+		(car (get-text-property (min (1- (point-max)) (point))
+					'org-last-args))
 		org-agenda-query-string
 		org-agenda-query-string
 		(+ (length org-agenda-query-string)
 		(+ (length org-agenda-query-string)
 		   (if (member char '(?\{ ?\})) 0 1))))
 		   (if (member char '(?\{ ?\})) 0 1))))
@@ -7035,7 +7036,7 @@ Negative selection means regexp must not match for selection of an entry."
 	 (date (org-read-date))
 	 (date (org-read-date))
 	 (org-agenda-sticky-orig org-agenda-sticky)
 	 (org-agenda-sticky-orig org-agenda-sticky)
 	 (org-agenda-buffer-tmp-name (buffer-name))
 	 (org-agenda-buffer-tmp-name (buffer-name))
-	 (args (get-text-property (point) 'org-last-args))
+	 (args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
 	 (0-arg (or current-prefix-arg (car args)))
 	 (0-arg (or current-prefix-arg (car args)))
 	 (2-arg (nth 2 args))
 	 (2-arg (nth 2 args))
 	 (newcmd (list 'org-agenda-list 0-arg date
 	 (newcmd (list 'org-agenda-list 0-arg date
@@ -7055,7 +7056,7 @@ Negative selection means regexp must not match for selection of an entry."
   "Go to today."
   "Go to today."
   (interactive)
   (interactive)
   (org-agenda-check-type t 'timeline 'agenda)
   (org-agenda-check-type t 'timeline 'agenda)
-  (let* ((args (get-text-property (point) 'org-last-args))
+  (let* ((args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
 	 (curspan (nth 2 args))
 	 (curspan (nth 2 args))
 	 (tdpos (text-property-any (point-min) (point-max) 'org-today t)))
 	 (tdpos (text-property-any (point-min) (point-max) 'org-today t)))
     (cond
     (cond
@@ -7074,7 +7075,7 @@ Negative selection means regexp must not match for selection of an entry."
    (or (and cnt (text-property-any (point-min) (point-max) 'org-day-cnt cnt))
    (or (and cnt (text-property-any (point-min) (point-max) 'org-day-cnt cnt))
        (text-property-any (point-min) (point-max) 'org-today t)
        (text-property-any (point-min) (point-max) 'org-today t)
        (text-property-any (point-min) (point-max) 'org-agenda-type 'agenda)
        (text-property-any (point-min) (point-max) 'org-agenda-type 'agenda)
-       (and (get-text-property (point) 'org-serie)
+       (and (get-text-property (min (1- (point-max)) (point)) 'org-serie)
 	    (org-agenda-goto-block-beginning))
 	    (org-agenda-goto-block-beginning))
        (point-min))))
        (point-min))))
 
 
@@ -7102,7 +7103,7 @@ Negative selection means regexp must not match for selection of an entry."
 With prefix ARG, go forward that many times the current span."
 With prefix ARG, go forward that many times the current span."
   (interactive "p")
   (interactive "p")
   (org-agenda-check-type t 'agenda)
   (org-agenda-check-type t 'agenda)
-  (let* ((args (get-text-property (point) 'org-last-args))
+  (let* ((args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
 	 (span (or (nth 2 args) org-agenda-current-span))
 	 (span (or (nth 2 args) org-agenda-current-span))
 	 (sd (or (nth 1 args) (org-get-at-bol 'day) org-starting-day))
 	 (sd (or (nth 1 args) (org-get-at-bol 'day) org-starting-day))
 	 (greg (calendar-gregorian-from-absolute sd))
 	 (greg (calendar-gregorian-from-absolute sd))
@@ -7129,7 +7130,7 @@ With prefix ARG, go forward that many times the current span."
 	   ;; `cmd' may have been set by `org-agenda-run-series' which
 	   ;; `cmd' may have been set by `org-agenda-run-series' which
 	   ;; uses `org-agenda-overriding-cmd' to decide whether
 	   ;; uses `org-agenda-overriding-cmd' to decide whether
 	   ;; overriding is allowed for `cmd'
 	   ;; overriding is allowed for `cmd'
-	   (get-text-property (point) 'org-serie-cmd))
+	   (get-text-property (min (1- (point-max)) (point)) 'org-serie-cmd))
 	  (org-agenda-overriding-arguments
 	  (org-agenda-overriding-arguments
 	   (list (car args) sd span)))
 	   (list (car args) sd span)))
       (org-agenda-redo)
       (org-agenda-redo)
@@ -7213,7 +7214,7 @@ written as 2-digit years."
   "Change the agenda view to SPAN.
   "Change the agenda view to SPAN.
 SPAN may be `day', `week', `month', `year'."
 SPAN may be `day', `week', `month', `year'."
   (org-agenda-check-type t 'agenda)
   (org-agenda-check-type t 'agenda)
-  (let* ((args (get-text-property (point) 'org-last-args))
+  (let* ((args (get-text-property (min (1- (point-max)) (point)) 'org-last-args))
 	 (curspan (nth 2 args)))
 	 (curspan (nth 2 args)))
     (if (and (not n) (equal curspan span))
     (if (and (not n) (equal curspan span))
 	(error "Viewing span is already \"%s\"" span))
 	(error "Viewing span is already \"%s\"" span))
@@ -7222,7 +7223,7 @@ SPAN may be `day', `week', `month', `year'."
 		   org-starting-day))
 		   org-starting-day))
 	   (sd (org-agenda-compute-starting-span sd span n))
 	   (sd (org-agenda-compute-starting-span sd span n))
 	   (org-agenda-overriding-cmd
 	   (org-agenda-overriding-cmd
-	    (get-text-property (point) 'org-serie-cmd))
+	    (get-text-property (min (1- (point-max)) (point)) 'org-serie-cmd))
 	   (org-agenda-overriding-arguments
 	   (org-agenda-overriding-arguments
 	    (list (car args) sd span)))
 	    (list (car args) sd span)))
       (org-agenda-redo)
       (org-agenda-redo)
@@ -8052,7 +8053,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
 		tags thetags
 		tags thetags
 		new
 		new
 		(let ((org-prefix-format-compiled
 		(let ((org-prefix-format-compiled
-		       (or (get-text-property (point) 'format)
+		       (or (get-text-property (min (1- (point-max)) (point)) 'format)
 			   org-prefix-format-compiled))
 			   org-prefix-format-compiled))
 		      (extra (org-get-at-bol 'extra)))
 		      (extra (org-get-at-bol 'extra)))
 		  (with-current-buffer (marker-buffer hdmarker)
 		  (with-current-buffer (marker-buffer hdmarker)
@@ -8079,9 +8080,11 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."
 			 undone-face done-face))))
 			 undone-face done-face))))
 	    (org-agenda-highlight-todo 'line)
 	    (org-agenda-highlight-todo 'line)
 	    (beginning-of-line 1))
 	    (beginning-of-line 1))
-	   (t (error "Line update did not work"))))
-	(beginning-of-line 0)))
-    (org-agenda-finalize)))
+	   (t (error "Line update did not work")))
+	  (save-restriction
+	    (narrow-to-region (point-at-bol) (point-at-eol))
+	    (org-agenda-finalize)))
+	(beginning-of-line 0)))))
 
 
 (defun org-agenda-align-tags (&optional line)
 (defun org-agenda-align-tags (&optional line)
   "Align all tags in agenda items to `org-agenda-tags-column'."
   "Align all tags in agenda items to `org-agenda-tags-column'."
@@ -8728,12 +8731,11 @@ entries in that Org-mode file."
 	  (fset 'calendar-cursor-to-date oldf))))))
 	  (fset 'calendar-cursor-to-date oldf))))))
 
 
 (defun org-agenda-execute-calendar-command (cmd)
 (defun org-agenda-execute-calendar-command (cmd)
-  "Execute a calendar command from the agenda, with the date associated to
-the cursor position."
+  "Execute a calendar command from the agenda with date from cursor."
   (org-agenda-check-type t 'agenda 'timeline)
   (org-agenda-check-type t 'agenda 'timeline)
   (require 'diary-lib)
   (require 'diary-lib)
-  (unless (get-text-property (point) 'day)
-    (error "Don't know which date to use for calendar command"))
+  (unless (get-text-property (min (1- (point-max)) (point)) 'day)
+    (error "Don't know which date to use for the calendar command"))
   (let* ((oldf (symbol-function 'calendar-cursor-to-date))
   (let* ((oldf (symbol-function 'calendar-cursor-to-date))
 	 (point (point))
 	 (point (point))
 	 (date (calendar-gregorian-from-absolute
 	 (date (calendar-gregorian-from-absolute
@@ -8781,7 +8783,7 @@ argument, latitude and longitude will be prompted for."
   "Open the Emacs calendar with the date at the cursor."
   "Open the Emacs calendar with the date at the cursor."
   (interactive)
   (interactive)
   (org-agenda-check-type t 'agenda 'timeline)
   (org-agenda-check-type t 'agenda 'timeline)
-  (let* ((day (or (get-text-property (point) 'day)
+  (let* ((day (or (get-text-property (min (1- (point-max)) (point)) 'day)
 		  (error "Don't know which date to open in calendar")))
 		  (error "Don't know which date to open in calendar")))
 	 (date (calendar-gregorian-from-absolute day))
 	 (date (calendar-gregorian-from-absolute day))
 	 (calendar-move-hook nil)
 	 (calendar-move-hook nil)
@@ -8802,7 +8804,7 @@ This is a command that has to be installed in `calendar-mode-map'."
 (defun org-agenda-convert-date ()
 (defun org-agenda-convert-date ()
   (interactive)
   (interactive)
   (org-agenda-check-type t 'agenda 'timeline)
   (org-agenda-check-type t 'agenda 'timeline)
-  (let ((day (get-text-property (point) 'day))
+  (let ((day (get-text-property (min (1- (point-max)) (point)) 'day))
 	date s)
 	date s)
     (unless day
     (unless day
       (error "Don't know which date to convert"))
       (error "Don't know which date to convert"))

+ 18 - 6
lisp/org-src.el

@@ -590,6 +590,21 @@ the language, a switch telling if the content should be in a single line."
     (goto-char pos)
     (goto-char pos)
     (org-get-indentation)))
     (org-get-indentation)))
 
 
+(defun org-add-protective-commas (beg end &optional line)
+  "Add protective commas in region.
+Return the delta in size of the region."
+  (interactive "r")
+  (let ((org-re "^\\(.\\)")
+	(other-re "^\\([*]\\|[ \t]*#\\+\\)")
+	(delta 0))
+    (save-excursion
+      (goto-char beg)
+      (while (re-search-forward (if (derived-mode-p 'org-mode) org-re other-re)
+				end t)
+	(if (and line (eq (org-current-line) line)) (setq delta (1+ delta)))
+	(replace-match ",\\1")))
+    delta))
+
 (defun org-edit-src-exit (&optional context)
 (defun org-edit-src-exit (&optional context)
   "Exit special edit and protect problematic lines."
   "Exit special edit and protect problematic lines."
   (interactive)
   (interactive)
@@ -634,11 +649,8 @@ the language, a switch telling if the content should be in a single line."
 	(goto-char (point-min))
 	(goto-char (point-min))
 	(if (looking-at "\\s-*") (replace-match " ")))
 	(if (looking-at "\\s-*") (replace-match " ")))
       (when (org-bound-and-true-p org-edit-src-from-org-mode)
       (when (org-bound-and-true-p org-edit-src-from-org-mode)
-	(goto-char (point-min))
-	(while (re-search-forward
-		(if (derived-mode-p 'org-mode) "^\\(.\\)" "^\\([*]\\|[ \t]*#\\+\\)") nil t)
-	  (if (eq (org-current-line) line) (setq delta (1+ delta)))
-	  (replace-match ",\\1")))
+	(setq delta (+ delta (org-add-protective-commas
+			      (point-min) (point-max) line))))
       (when (org-bound-and-true-p org-edit-src-picture)
       (when (org-bound-and-true-p org-edit-src-picture)
 	(setq preserve-indentation nil)
 	(setq preserve-indentation nil)
 	(untabify (point-min) (point-max))
 	(untabify (point-min) (point-max))
@@ -813,7 +825,7 @@ fontification of code blocks see `org-src-fontify-block' and
 	      (get-buffer-create
 	      (get-buffer-create
 	       (concat " org-src-fontification:" (symbol-name lang-mode)))
 	       (concat " org-src-fontification:" (symbol-name lang-mode)))
 	    (delete-region (point-min) (point-max))
 	    (delete-region (point-min) (point-max))
-	    (insert string)
+	    (insert string " ") ;; so there's a final property change
 	    (unless (eq major-mode lang-mode) (funcall lang-mode))
 	    (unless (eq major-mode lang-mode) (funcall lang-mode))
 	    (font-lock-fontify-buffer)
 	    (font-lock-fontify-buffer)
 	    (setq pos (point-min))
 	    (setq pos (point-min))