浏览代码

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

Bastien Guerry 11 年之前
父节点
当前提交
9f6c5897b3
共有 6 个文件被更改,包括 89 次插入146 次删除
  1. 62 27
      contrib/lisp/org-index.el
  2. 5 2
      lisp/ob-exp.el
  3. 6 15
      lisp/org-element.el
  4. 3 61
      lisp/org.el
  5. 12 1
      testing/lisp/test-ob-exp.el
  6. 1 40
      testing/lisp/test-org-element.el

+ 62 - 27
contrib/lisp/org-index.el

@@ -68,10 +68,13 @@
 ;;
 ;;  The latest tested version of this file can always be found at:
 ;;
-;;    http://orgmode.org/w/org-mode.git?p=org-mode.git;a=blob;f=contrib/lisp/org-index.el;hb=HEAD
+;;    http://orgmode.org/w/org-mode.git?p=org-mode.git;a=blob_plain;f=contrib/lisp/org-index.el;hb=HEAD
 
 ;;; Change Log:
 
+;;   [2014-01-28 Tu] Version 2.4.1:
+;;   - Follow mode in occur-buffer
+;;
 ;;   [2014-01-02 Th] Version 2.4.0:
 ;;   - New command "put" to store a nodes reference in a property
 ;;   - New functions org-index-new-line and org-index-get-line 
@@ -166,6 +169,7 @@
 (defvar org-index--below-cursor)   ; Word below cursor
 (defvar org-index--within-node)    ; True, if we are within node of the index table
 (defvar org-index--active-window-index nil) ; Active window with index table (if any)
+(defvar org-index--occur-follow-mode nil)   ; True, if follow mode in occur-buffer is on    
 
 (setq org-index--commands '(occur head ref link leave put enter goto help + reorder fill sort update highlight unhighlight missing statistics)) ; list of commands available
 
@@ -1723,7 +1727,7 @@ retrieves the value of the count-column for reference 12.
       message-text))
 
 
-(defun org-index--do-head (ref link)
+(defun org-index--do-head (ref link &optional other)
     
   (if ref (setq org-index--last-ref ref))
     
@@ -1764,9 +1768,17 @@ retrieves the value of the count-column for reference 12.
               (if (eq buffer org-index--buffer)
                   (setq org-index--point-before nil))
               (setq message-text (format "Found '%s'" (or ref link)))
-              (org-pop-to-buffer-same-window buffer)
-              (goto-char point)
-              (org-reveal))
+              (if other
+                  (progn
+                    (pop-to-buffer buffer)
+                    (goto-char point)
+                    (org-reveal t)
+                    (recenter)
+                    (pop-to-buffer "*org-index-occur*"))
+                (org-pop-to-buffer-same-window buffer)
+                (goto-char point)
+                (org-reveal t)
+                (recenter)))
           (setq message-text (format "Did not find '%s'" (or ref link))))))
     message-text))
 
@@ -1783,12 +1795,14 @@ retrieves the value of the count-column for reference 12.
         start-of-help              ; start of displayed help (if any)
         left-off-at                ; stack of last positions in index table
         after-inserted             ; in occur-buffer
+        at-end                     ; in occur-buffer
         lines-visible              ; in occur-buffer
         below-hline-bol            ; below-hline and at bol
         exit-gracefully            ; true if normal exit
         in-c-backspace             ; true while processing C-backspace
         show-headings              ; true, if headings should be shown
-        fun-on-ret                 ; function to be executed, if return has been pressed
+        fun-on-ret                 ; function to be executed, if return is pressed
+        fun-on-tab                 ; function to be executed, if letter TAB is pressed
         ret from to key)
         
     ;; clear buffer
@@ -1801,12 +1815,19 @@ retrieves the value of the count-column for reference 12.
       (let ((keymap (make-sparse-keymap)))
 
         (set-keymap-parent keymap org-mode-map)
-        (setq fun-on-ret (lambda () (interactive) 
-                           (let ((ref (org-index--get-field :ref)) 
-                                 (link (org-index--get-field :link)))
-                             (message (org-index--do-head ref link)))))
-        
+        (setq fun-on-ret (lambda () (interactive) (org-index--occur-find-heading nil)))
         (define-key keymap (kbd "RET") fun-on-ret)
+        (setq fun-on-tab (lambda () (interactive)
+                           (org-index--occur-find-heading t)
+                           (setq org-index--occur-follow-mode (not org-index--occur-follow-mode))))
+        (define-key keymap (kbd "<tab>") fun-on-tab)
+        (define-key keymap [(control ?i)] fun-on-tab)
+        (define-key keymap (kbd "<up>") (lambda () (interactive)
+                                          (forward-line -1)
+                                          (if org-index--occur-follow-mode (org-index--occur-find-heading t))))
+        (define-key keymap (kbd "<down>") (lambda () (interactive)
+                                            (forward-line 1)
+                                            (if org-index--occur-follow-mode (org-index--occur-find-heading t))))
         (use-local-map keymap)))
 
     (with-current-buffer org-index--buffer
@@ -1824,7 +1845,7 @@ retrieves the value of the count-column for reference 12.
           
           ;; fill in header
           (erase-buffer)
-          (insert (concat "Incremental search, showing one window of matches. TAB toggles help.\n\n"))
+          (insert (concat "Incremental search, showing one window of matches. '?' toggles help.\n\n"))
           (setq start-of-lines (point))
           (setq start-of-help start-of-lines)
           (setq cursor-type 'hollow)
@@ -1835,9 +1856,9 @@ retrieves the value of the count-column for reference 12.
 
           ;; fill initially
           (setq ret (org-index--get-matching-lines nil lines-to-show below-hline-bol))
-          (when (car ret)
-            (insert (cdr ret))
-            (setq left-off-at (cons (car ret) nil))
+          (when (nth 0 ret)
+            (insert (nth 1 ret))
+            (setq left-off-at (cons (nth 0 ret) nil))
             (setq after-inserted (cons (point) nil)))
 
           ;; read keys
@@ -1863,7 +1884,7 @@ retrieves the value of the count-column for reference 12.
                                          (if (string= search-text "") "" " ")
                                          hint))))
                     (setq hint "")
-                    (setq exit-gracefully (member key (list 'up 'down 'left 'right 'RET ?\C-g ?\C-m)))))
+                    (setq exit-gracefully (member key (list 'up 'down 'left 'right 'RET ?\C-g ?\C-m 'C-return ?\C-i 'TAB)))))
                 
                 (not exit-gracefully))
             
@@ -1936,7 +1957,7 @@ retrieves the value of the count-column for reference 12.
               (setq word ""))
 
 
-             ((member key (list 'TAB ?\C-i))    ; tab: toggle display of headlines
+             ((eq key ??)    ; tab: toggle display of headlines and help
               (setq show-headings (not show-headings))
               (goto-char start-of-lines)
               (if show-headings
@@ -1945,7 +1966,7 @@ retrieves the value of the count-column for reference 12.
                     (kill-line)
                     (setq start-of-help (point))
                     (if (display-graphic-p)
-                        (insert "<backspace> and <c-backspace> erase, cursor keys move. RET finds node, C-RET all matches.\nComma seperates words, any other key adds to search word.\n\n")
+                        (insert "<backspace> and <c-backspace> erase, cursor keys move. RET finds node, C-RET all matches.\nTAB finds in other window. Comma seperates words, any other key adds to search word.\n\n")
                       (insert "BACKSPACE to erase,  to finish. Then cursor keys and RET to find node.\n\n"))
                     (insert org-index--headings))
                 (delete-region start-of-help start-of-lines)
@@ -1987,9 +2008,10 @@ retrieves the value of the count-column for reference 12.
                                                          (- lines-to-show lines-visible) 
                                                          (car left-off-at)))
 
-                (when (car ret)
-                  (insert (cdr ret))
-                  (setcar left-off-at (car ret))
+                (when (nth 0 ret)
+                  (insert (nth 1 ret))
+                  (setq at-end (nth 2 ret))
+                  (setcar left-off-at (nth 0 ret))
                   (setcar after-inserted (point))))
 
               ;; highlight longer word
@@ -2013,11 +2035,11 @@ retrieves the value of the count-column for reference 12.
               (forward-line 1)))
 
           ;; get all the rest
-          (when (eq key 'C-return)
+          (when (eq key (kbd "<c-return>"))
             (message "Getting all matches ...")
             (setq ret (org-index--get-matching-lines (cons word words) 0 (car left-off-at)))
             (message "done.")
-            (insert (cdr ret))))
+            (insert (nth 1 ret))))
       
       ;; postprocessing even for non graceful exit
       (setq cursor-type t)
@@ -2026,10 +2048,10 @@ retrieves the value of the count-column for reference 12.
         (goto-char start-of-lines)
         (delete-region (point-min) (point))
         (insert (format  (concat (if exit-gracefully "Search is done;" "Search aborted;")
-                                 (if (eq key 'C-return) 
+                                 (if (or at-end (eq key 'C-return)) 
                                      " showing all %d matches." 
                                    " showing only some matches.")
-                                 " Use cursor keys to move, press RET to find node.\n\n")
+                                 " Use cursor keys to move, press RET or TAB to find node.\n\n")
                          numlines))
         (if show-headings (insert "\n\n" org-index--headings)))
       (forward-line))
@@ -2043,6 +2065,9 @@ retrieves the value of the count-column for reference 12.
      ((member key (list 'RET ?\C-m))
       (funcall fun-on-ret))
 
+     ((member key (list 'TAB ?\C-i))
+      (funcall fun-on-tab))
+
      ((eq key 'up)
       (forward-line -1))
 
@@ -2055,6 +2080,14 @@ retrieves the value of the count-column for reference 12.
      ((eq key 'right)
       (forward-char 1)))))
 
+(defun org-index--occur-find-heading (x) 
+  "helper for keymap of occur"
+  (interactive)
+  (save-excursion
+    (let ((ref (org-index--get-field :ref)) 
+          (link (org-index--get-field :link)))
+      (message (org-index--do-head ref link x)))))
+
 
 (defun org-index--do-new-line (create-ref)
   "Do the common work for org-index-new-line and org-index"
@@ -2098,7 +2131,7 @@ retrieves the value of the count-column for reference 12.
 (defun org-index--get-matching-lines (words numlines start-from)
   (let ((numfound 0)
         pos
-        initial line lines)
+        initial line lines at-end)
     
     (with-current-buffer org-index--buffer
 
@@ -2119,11 +2152,13 @@ retrieves the value of the count-column for reference 12.
         (forward-line 1)
         (setq pos (point)))
 
+      (setq at-end (not (org-at-table-p)))
+
       ;; return to initial position
       (goto-char initial))
 
     (unless lines (setq lines ""))
-    (cons pos lines)))
+    (list pos lines at-end)))
 
 
 (defun org-index--test-words (words line)

+ 5 - 2
lisp/ob-exp.el

@@ -311,7 +311,7 @@ The function respects the value of the :exports header argument."
 	     (org-babel-exp-code info)))))
 
 (defcustom org-babel-exp-code-template
-  "#+BEGIN_SRC %lang%flags\n%body\n#+END_SRC"
+  "#+BEGIN_SRC %lang%switches%flags\n%body\n#+END_SRC"
   "Template used to export the body of code blocks.
 This template may be customized to include additional information
 such as the code block name, or the values of particular header
@@ -321,6 +321,7 @@ and the following %keys may be used.
  lang ------ the language of the code block
  name ------ the name of the code block
  body ------ the body of the code block
+ switches -- the switches associated to the code block
  flags ----- the flags passed to the code block
 
 In addition to the keys mentioned above, every header argument
@@ -343,8 +344,10 @@ replaced with its value."
    org-babel-exp-code-template
    `(("lang"  . ,(nth 0 info))
      ("body"  . ,(org-escape-code-in-string (nth 1 info)))
+     ("switches" . ,(let ((f (nth 3 info)))
+		      (and (org-string-nw-p f) (concat " " f))))
      ("flags" . ,(let ((f (assq :flags (nth 2 info))))
-		   (when f (concat " " (cdr f)))))
+		   (and f (concat " " (cdr f)))))
      ,@(mapcar (lambda (pair)
 		 (cons (substring (symbol-name (car pair)) 1)
 		       (format "%S" (cdr pair))))

+ 6 - 15
lisp/org-element.el

@@ -796,8 +796,8 @@ Return a list whose CAR is `headline' and CDR is a plist
 containing `:raw-value', `:title', `:alt-title', `:begin',
 `:end', `:pre-blank', `:contents-begin' and `:contents-end',
 `:level', `:priority', `:tags', `:todo-keyword',`:todo-type',
-`:scheduled', `:deadline', `:closed', `:quotedp', `:archivedp',
-`:commentedp' and `:footnote-section-p' keywords.
+`:scheduled', `:deadline', `:closed', `:archivedp', `:commentedp'
+and `:footnote-section-p' keywords.
 
 The plist also contains any property set in the property drawer,
 with its name in upper cases and colons added at the
@@ -816,10 +816,6 @@ Assume point is at beginning of the headline."
 	   (tags (let ((raw-tags (nth 5 components)))
 		   (and raw-tags (org-split-string raw-tags ":"))))
 	   (raw-value (or (nth 4 components) ""))
-	   (quotedp
-	    (let ((case-fold-search nil))
-	      (string-match (format "^%s\\( \\|$\\)" org-quote-string)
-			    raw-value)))
 	   (commentedp
 	    (let ((case-fold-search nil))
 	      (string-match (format "^%s\\( \\|$\\)" org-comment-string)
@@ -869,14 +865,12 @@ Assume point is at beginning of the headline."
 				     (skip-chars-backward " \r\t\n")
 				     (forward-line)
 				     (point)))))
-      ;; Clean RAW-VALUE from any quote or comment string.
-      (when (or quotedp commentedp)
+      ;; Clean RAW-VALUE from any comment string.
+      (when commentedp
 	(let ((case-fold-search nil))
 	  (setq raw-value
 		(replace-regexp-in-string
-		 (concat
-		  (regexp-opt (list org-quote-string org-comment-string))
-		  "\\(?: \\|$\\)")
+		 (concat (regexp-quote org-comment-string) "\\(?: \\|$\\)")
 		 ""
 		 raw-value))))
       ;; Clean TAGS from archive tag, if any.
@@ -905,8 +899,7 @@ Assume point is at beginning of the headline."
 				       end)
 			  :footnote-section-p footnote-section-p
 			  :archivedp archivedp
-			  :commentedp commentedp
-			  :quotedp quotedp)
+			  :commentedp commentedp)
 		    time-props
 		    standard-props))))
 	(let ((alt-title (org-element-property :ALT_TITLE headline)))
@@ -937,11 +930,9 @@ CONTENTS is the contents of the element."
 		 (and tag-list
 		      (format ":%s:" (mapconcat 'identity tag-list ":")))))
 	 (commentedp (org-element-property :commentedp headline))
-	 (quotedp (org-element-property :quotedp headline))
 	 (pre-blank (or (org-element-property :pre-blank headline) 0))
 	 (heading (concat (make-string (org-reduced-level level) ?*)
 			  (and todo (concat " " todo))
-			  (and quotedp (concat " " org-quote-string))
 			  (and commentedp (concat " " org-comment-string))
 			  (and priority
 			       (format " [#%s]" (char-to-string priority)))

+ 3 - 61
lisp/org.el

@@ -429,12 +429,6 @@ not contribute to the agenda listings.")
 An entry can be toggled between COMMENT and normal with
 \\[org-toggle-comment].")
 
-(defconst org-quote-string "QUOTE"
-  "Entries starting with this keyword will be exported in fixed-width font.
-Quoting applies only to the text in the entry following the headline, and does
-not extend beyond the next headline, even if that is lower level.
-An entry can be toggled between QUOTE and normal with
-\\[org-toggle-fixed-width-section].")
 
 ;;;; LaTeX Environments and Fragments
 
@@ -1554,8 +1548,7 @@ the list structure."
 (defcustom org-enable-fixed-width-editor t
   "Non-nil means lines starting with \":\" are treated as fixed-width.
 This currently only means they are never auto-wrapped.
-When nil, such lines will be treated like ordinary lines.
-See also the QUOTE keyword."
+When nil, such lines will be treated like ordinary lines."
   :group 'org-edit-structure
   :type 'boolean)
 
@@ -6324,9 +6317,7 @@ needs to be inserted at a specific position in the font-lock sequence.")
 	   '(org-activate-code (1 'org-code t))
 	   ;; COMMENT
 	   (list (format org-heading-keyword-regexp-format
-			 (concat "\\("
-				 org-comment-string "\\|" org-quote-string
-				 "\\)"))
+			 (concat "\\(" org-comment-string "\\)"))
 		 '(2 'org-special-keyword t))
 	   ;; Blocks and meta lines
 	   '(org-fontify-meta-lines-and-blocks))))
@@ -19275,7 +19266,6 @@ boundaries."
 (org-defkey org-mode-map "\C-c}"    'org-table-toggle-coordinate-overlays)
 (org-defkey org-mode-map "\C-c{"    'org-table-toggle-formula-debugger)
 (org-defkey org-mode-map "\C-c\C-e" 'org-export-dispatch)
-(org-defkey org-mode-map "\C-c:"    'org-toggle-fixed-width-section)
 (org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize)
 (org-defkey org-mode-map "\C-c\C-xf"    'org-footnote-action)
 (org-defkey org-mode-map "\C-c\C-x\C-mg"    'org-mobile-pull)
@@ -21668,7 +21658,7 @@ contexts are:
 :clocktable       in a clocktable
 :src-block        in a source block
 :link             on a hyperlink
-:keyword          on a keyword: SCHEDULED, DEADLINE, CLOSE, COMMENT, QUOTE.
+:keyword          on a keyword: SCHEDULED, DEADLINE, CLOSE, COMMENT.
 :target           on a <<target>>
 :radio-target     on a <<<radio-target>>>
 :latex-fragment   on a LaTeX fragment
@@ -22831,54 +22821,6 @@ range.  Otherwise, translate both parts."
 
 ;;; Other stuff.
 
-(defun org-toggle-fixed-width-section (arg)
-  "Toggle the fixed-width export.
-If there is no active region, the QUOTE keyword at the current headline is
-inserted or removed.  When present, it causes the text between this headline
-and the next to be exported as fixed-width text, and unmodified.
-If there is an active region, this command adds or removes a colon as the
-first character of this line.  If the first character of a line is a colon,
-this line is also exported in fixed-width font."
-  (interactive "P")
-  (let* ((cc 0)
-	 (regionp (org-region-active-p))
-	 (beg (if regionp (region-beginning) (point)))
-	 (end (if regionp (region-end)))
-	 (nlines (or arg (if (and beg end) (count-lines beg end) 1)))
-	 (case-fold-search nil)
-	 (re "[ \t]*\\(:\\(?: \\|$\\)\\)")
-	 off)
-    (if regionp
-	(save-excursion
-	  (goto-char beg)
-	  (setq cc (current-column))
-	  (beginning-of-line 1)
-	  (setq off (looking-at re))
-	  (while (> nlines 0)
-	    (setq nlines (1- nlines))
-	    (beginning-of-line 1)
-	    (cond
-	     (arg
-	      (org-move-to-column cc t)
-	      (insert ": \n")
-	      (forward-line -1))
-	     ((and off (looking-at re))
-	      (replace-match "" t t nil 1))
-	     ((not off) (org-move-to-column cc t) (insert ": ")))
-	    (forward-line 1)))
-      (save-excursion
-	(org-back-to-heading)
-	(cond
-	 ((looking-at (format org-heading-keyword-regexp-format
-			      org-quote-string))
-	  (goto-char (match-end 1))
-	  (looking-at (concat " +" org-quote-string))
-	  (replace-match "" t t)
-	  (when (eolp) (insert " ")))
-	 ((looking-at org-outline-regexp)
-	  (goto-char (match-end 0))
-	  (insert org-quote-string " ")))))))
-
 (defun org-reftex-citation ()
   "Use reftex-citation to insert a citation into the buffer.
 This looks for a line like

+ 12 - 1
testing/lisp/test-ob-exp.el

@@ -303,10 +303,21 @@ Here is one at the end of a line. =2=
       (org-export-execute-babel-code)
       (buffer-string)))))
 
+(ert-deftest ob-export/export-src-block-with-switches ()
+  "Test exporting a source block with switches."
+  (should
+   (string-match
+    "\\`#\\+BEGIN_SRC emacs-lisp -n -r$"
+    (org-test-with-temp-text
+	"#+BEGIN_SRC emacs-lisp -n -r\n\(+ 1 1)\n#+END_SRC"
+      (org-export-execute-babel-code)
+      (buffer-string)))))
+
 (ert-deftest ob-export/export-src-block-with-flags ()
   "Test exporting a source block with a flag."
   (should
-   (string-match "\\`#\\+BEGIN_SRC emacs-lisp -some-flag$"
+   (string-match
+    "\\`#\\+BEGIN_SRC emacs-lisp -some-flag$"
     (org-test-with-temp-text
 	"#+BEGIN_SRC emacs-lisp :flags -some-flag\n\(+ 1 1)\n#+END_SRC"
       (org-export-execute-babel-code)

+ 1 - 40
testing/lisp/test-org-element.el

@@ -934,40 +934,6 @@ Some other text
 
 ;;;; Headline
 
-(ert-deftest test-org-element/headline-quote-keyword ()
-  "Test QUOTE keyword recognition."
-  ;; Reference test.
-  (org-test-with-temp-text "* Headline"
-    (let ((org-quote-string "QUOTE"))
-      (should-not (org-element-property :quotedp (org-element-at-point)))))
-  ;; Standard position.
-  (org-test-with-temp-text "* QUOTE Headline"
-    (let* ((org-quote-string "QUOTE")
-	   (headline (org-element-at-point)))
-      (should (org-element-property :quotedp headline))
-      ;; Test removal from raw value.
-      (should (equal (org-element-property :raw-value headline) "Headline"))))
-  ;; Case sensitivity.
-  (org-test-with-temp-text "* QUOTE Headline"
-    (let* ((org-quote-string "Quote")
-	   (headline (org-element-at-point)))
-      (should-not (org-element-property :quotedp headline))
-      (should (equal (org-element-property :raw-value headline)
-		     "QUOTE Headline"))))
-  ;; With another keyword.
-  (org-test-with-temp-text "* TODO QUOTE Headline"
-    (let* ((org-quote-string "QUOTE")
-	   (org-todo-keywords '((sequence "TODO" "DONE")))
-	   (headline (org-element-at-point)))
-      (should (org-element-property :quotedp headline))
-      (should (equal (org-element-property :raw-value headline) "Headline"))))
-  ;; With the keyword only.
-  (org-test-with-temp-text "* QUOTE"
-    (let* ((org-quote-string "QUOTE")
-	   (headline (org-element-at-point)))
-      (should (org-element-property :quotedp headline))
-      (should (equal (org-element-property :raw-value headline) "")))))
-
 (ert-deftest test-org-element/headline-comment-keyword ()
   "Test COMMENT keyword recognition."
   ;; Reference test.
@@ -2199,12 +2165,7 @@ Outside list"
    (equal (let ((org-comment-string "COMMENT"))
 	    (org-test-parse-and-interpret "* COMMENT Headline"))
 	  "* COMMENT Headline\n"))
-  ;; 6. With quote section.
-  (should
-   (equal (let ((org-quote-string "QUOTE"))
-	    (org-test-parse-and-interpret "* QUOTE Headline"))
-	  "* QUOTE Headline\n"))
-  ;; 7. Keep same number of blank lines before body.
+  ;; 6. Keep same number of blank lines before body.
   (should
    (equal (org-test-parse-and-interpret
 	   "* Headline\n\n\nText after two blank lines.")