Browse Source

Match #+name/#+tblname/#+tblfm along with uppercase twins.

* org.el: Use (case-fold-search t).
(org-edit-special, org-ctrl-c-ctrl-c): Ditto.

* org-table.el:
(org-table-store-formulas, org-table-get-stored-formulas)
(org-table-fix-formulas, org-table-edit-formulas)
(org-old-auto-fill-inhibit-regexp, orgtbl-ctrl-c-ctrl-c)
(orgtbl-toggle-comment, org-table-get-remote-range): Ditto.

* org-footnote.el:
(org-footnote-goto-local-insertion-point): Ditto.

* org-exp.el: Ditto.

* org-colview.el:
(org-dblock-write:columnview, org-dblock-write:columnview):
Ditto.

* org-colview-xemacs.el:
(org-dblock-write:columnview): Ditto.

* org-clock.el (org-clocktable-write-default): Ditto.

* org-capture.el (org-capture-place-table-line): Ditto.

* ob.el (org-babel-data-names, org-babel-goto-named-src-block)
(org-babel-src-block-names)
(org-babel-where-is-src-block-result, org-babel-result-end)
(org-babel-where-is-src-block-head)
(org-babel-find-named-result, org-babel-result-names): Ditto.
Bastien Guerry 8 years ago
parent
commit
1c203d8d19
9 changed files with 52 additions and 42 deletions
  1. 20 17
      lisp/ob.el
  2. 2 2
      lisp/org-capture.el
  3. 2 1
      lisp/org-clock.el
  4. 2 1
      lisp/org-colview-xemacs.el
  5. 2 1
      lisp/org-colview.el
  6. 2 1
      lisp/org-exp.el
  7. 1 1
      lisp/org-footnote.el
  8. 15 14
      lisp/org-table.el
  9. 6 4
      lisp/org.el

+ 20 - 17
lisp/ob.el

@@ -439,7 +439,7 @@ specific header arguments as well.")
   '((:session . "none") (:results . "replace") (:exports . "results"))
   "Default arguments to use when evaluating an inline source block.")
 
-(defvar org-babel-data-names '("TBLNAME" "RESULTS" "NAME"))
+(defvar org-babel-data-names '("tblname" "results" "name"))
 
 (defvar org-babel-result-regexp
   (concat "^[ \t]*#\\+"
@@ -1464,7 +1464,7 @@ to the table for reinsertion to org-mode."
 Return the point at the beginning of the current source
 block.  Specifically at the beginning of the #+BEGIN_SRC line.
 If the point is not on a source block then return nil."
-  (let ((initial (point)) top bottom)
+  (let ((initial (point)) (case-fold-search t) top bottom)
     (or
      (save-excursion ;; on a source name line or a #+header line
        (beginning-of-line 1)
@@ -1501,6 +1501,7 @@ If the point is not on a source block then return nil."
   "Go to a named source-code block."
   (interactive
    (let ((completion-ignore-case t)
+	 (case-fold-search t)
 	 (under-point (thing-at-point 'line)))
      (list (org-icompleting-read
 	    "source-block name: " (org-babel-src-block-names) nil t
@@ -1548,7 +1549,7 @@ org-babel-named-src-block-regexp."
   "Returns the names of source blocks in FILE or the current buffer."
   (save-excursion
     (when file (find-file file)) (goto-char (point-min))
-    (let (names)
+    (let ((case-fold-search t) names)
       (while (re-search-forward org-babel-src-name-w-name-regexp nil t)
 	(setq names (cons (match-string 3) names)))
       names)))
@@ -1571,23 +1572,24 @@ org-babel-named-src-block-regexp."
 Return the location of the result named NAME in the current
 buffer or nil if no such result exists."
   (save-excursion
-    (goto-char (or point (point-min)))
-    (catch 'is-a-code-block
-      (when (re-search-forward
-	     (concat org-babel-result-regexp
-		     "[ \t]" (regexp-quote name) "[ \t\n\f\v\r]+") nil t)
-	(when (and (string= "name" (downcase (match-string 1)))
-		   (or (beginning-of-line 1)
-		       (looking-at org-babel-src-block-regexp)
-		       (looking-at org-babel-multi-line-header-regexp)))
-	  (throw 'is-a-code-block (org-babel-find-named-result name (point))))
-	(beginning-of-line 0) (point)))))
+    (let ((case-fold-search t))
+      (goto-char (or point (point-min)))
+      (catch 'is-a-code-block
+	(when (re-search-forward
+	       (concat org-babel-result-regexp
+		       "[ \t]" (regexp-quote name) "[ \t\n\f\v\r]+") nil t)
+	  (when (and (string= "name" (downcase (match-string 1)))
+		     (or (beginning-of-line 1)
+			 (looking-at org-babel-src-block-regexp)
+			 (looking-at org-babel-multi-line-header-regexp)))
+	    (throw 'is-a-code-block (org-babel-find-named-result name (point))))
+	  (beginning-of-line 0) (point))))))
 
 (defun org-babel-result-names (&optional file)
   "Returns the names of results in FILE or the current buffer."
   (save-excursion
     (when file (find-file file)) (goto-char (point-min))
-    (let (names)
+    (let ((case-fold-search t) names)
       (while (re-search-forward org-babel-result-w-name-regexp nil t)
 	(setq names (cons (match-string 4) names)))
       names)))
@@ -1685,7 +1687,8 @@ source block.  Specifically at the beginning of the results line.
 If no result exists for this block then create a results line
 following the source block."
   (save-excursion
-    (let* ((on-lob-line (save-excursion
+    (let* ((case-fold-search t)
+	   (on-lob-line (save-excursion
 			  (beginning-of-line 1)
 			  (looking-at org-babel-lob-one-liner-regexp)))
 	   (inlinep (when (org-babel-get-inline-src-block-matches)
@@ -2008,7 +2011,7 @@ code ---- the results are extracted in the syntax of the source
      ((org-at-item-p) (let* ((struct (org-list-struct))
 			     (prvs (org-list-prevs-alist struct)))
 			(org-list-get-list-end (point-at-bol) struct prvs)))
-     ((looking-at "^\\([ \t]*\\):RESULTS:")
+     ((let ((case-fold-search t)) (looking-at "^\\([ \t]*\\):results:"))
       (progn (re-search-forward (concat "^" (match-string 1) ":END:"))
 	     (forward-char 1) (point)))
      (t

+ 2 - 2
lisp/org-capture.el

@@ -1000,9 +1000,9 @@ it.  When it is a variable, retrieve the value.  Return whatever we get."
       (setq beg (1+ (point-at-eol))
 	    end (save-excursion (outline-next-heading) (point)))))
     (if (re-search-forward org-table-dataline-regexp end t)
-	(let ((b (org-table-begin)) (e (org-table-end)))
+	(let ((b (org-table-begin)) (e (org-table-end)) (case-fold-search t))
 	  (goto-char e)
-	  (if (looking-at "[ \t]*#\\+TBLFM:")
+	  (if (looking-at "[ \t]*#\\+tblfm:")
 	      (forward-line 1))
 	  (narrow-to-region b (point)))
       (goto-char end)

+ 2 - 1
lisp/org-clock.el

@@ -2204,6 +2204,7 @@ from the dynamic block definition."
 	 (ntcol (max 1 (or (plist-get params :tcolumns) 100)))
 	 (rm-file-column (plist-get params :one-file-with-archives))
 	 (indent (plist-get params :indent))
+	 (case-fold-search t)
 	 range-text total-time tbl level hlc formula pcol
 	 file-time entries entry headline
 	 recalc content narrow-cut-p tcol)
@@ -2378,7 +2379,7 @@ from the dynamic block definition."
 	   (t (error "invalid formula in clocktable")))
 	;; Should we rescue an old formula?
 	(when (stringp (setq content (plist-get params :content)))
-	  (when (string-match "^\\([ \t]*#\\+TBLFM:.*\\)" content)
+	  (when (string-match "^\\([ \t]*#\\+tblfm:.*\\)" content)
 	    (setq recalc t)
 	    (insert "\n" (match-string 1 (plist-get params :content)))
 	    (beginning-of-line 0))))

+ 2 - 1
lisp/org-colview-xemacs.el

@@ -1402,6 +1402,7 @@ PARAMS is a property list of parameters:
 	(maxlevel (plist-get params :maxlevel))
 	(content-lines (org-split-string (plist-get params :content) "\n"))
 	(skip-empty-rows (plist-get params :skip-empty-rows))
+	(case-fold-search t)
 	tbl id idpos nfields tmp recalc line
 	id-as-string view-file view-pos)
     (when (setq id (plist-get params :id))
@@ -1467,7 +1468,7 @@ PARAMS is a property list of parameters:
       (while (setq line (pop content-lines))
 	(when (string-match "^#" line)
 	  (insert "\n" line)
-	  (when (string-match "^[ \t]*#\\+TBLFM" line)
+	  (when (string-match "^[ \t]*#\\+tblfm" line)
 	    (setq recalc t))))
       (if recalc
 	  (progn (goto-char pos) (org-table-recalculate 'all))

+ 2 - 1
lisp/org-colview.el

@@ -1222,6 +1222,7 @@ PARAMS is a property list of parameters:
 	(maxlevel (plist-get params :maxlevel))
 	(content-lines (org-split-string (plist-get params :content) "\n"))
 	(skip-empty-rows (plist-get params :skip-empty-rows))
+	(case-fold-search t)
 	tbl id idpos nfields tmp recalc line
 	id-as-string view-file view-pos)
     (when (setq id (plist-get params :id))
@@ -1287,7 +1288,7 @@ PARAMS is a property list of parameters:
       (while (setq line (pop content-lines))
 	(when (string-match "^#" line)
 	  (insert "\n" line)
-	  (when (string-match "^[ \t]*#\\+TBLFM" line)
+	  (when (string-match "^[ \t]*#\\+tblfm" line)
 	    (setq recalc t))))
       (if recalc
 	  (progn (goto-char pos) (org-table-recalculate 'all))

+ 2 - 1
lisp/org-exp.el

@@ -2011,7 +2011,8 @@ When it is nil, all comments will be removed."
 
 (defun org-export-handle-table-metalines ()
   "Remove table specific metalines #+TBLNAME: and #+TBLFM:."
-  (let ((re "^[ \t]*#\\+TBL\\(NAME\\|FM\\):\\(.*\n?\\)")
+  (let ((re "^[ \t]*#\\+tbl\\(name\\|fm\\):\\(.*\n?\\)")
+	(case-fold-search t)
 	pos)
     (goto-char (point-min))
     (while (or (looking-at re)

+ 1 - 1
lisp/org-footnote.el

@@ -844,7 +844,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
   (beginning-of-line 0)
   (while (and (not (bobp)) (= (char-after) ?#))
     (beginning-of-line 0))
-  (if (looking-at "[ \t]*#\\+TBLFM:") (beginning-of-line 2))
+  (if (let ((case-fold-search t)) (looking-at "[ \t]*#\\+tblfm:")) (beginning-of-line 2))
   (end-of-line 1)
   (skip-chars-backward "\n\r\t ")
   (forward-line))

+ 15 - 14
lisp/org-table.el

@@ -2090,13 +2090,13 @@ When NAMED is non-nil, look for a named equation."
   (setq alist (sort alist 'org-table-formula-less-p))
   (save-excursion
     (goto-char (org-table-end))
-    (if (looking-at "\\([ \t]*\n\\)*[ \t]*#\\+TBLFM:\\(.*\n?\\)")
+    (if (looking-at "\\([ \t]*\n\\)*[ \t]*\\(#\\+tblfm:\\)\\(.*\n?\\)")
 	(progn
 	  ;; don't overwrite TBLFM, we might use text properties to store stuff
-	  (goto-char (match-beginning 2))
-	  (delete-region (match-beginning 2) (match-end 0)))
+	  (goto-char (match-beginning 3))
+	  (delete-region (match-beginning 3) (match-end 0)))
       (org-indent-line-function)
-      (insert "#+TBLFM:"))
+      (insert (match-string 2)))
     (insert " "
 	    (mapconcat (lambda (x)
 			 (concat
@@ -2133,10 +2133,10 @@ When NAMED is non-nil, look for a named equation."
 (defun org-table-get-stored-formulas (&optional noerror)
   "Return an alist with the stored formulas directly after current table."
   (interactive)
-  (let (scol eq eq-alist strings string seen)
+  (let ((case-fold-search t) scol eq eq-alist strings string seen)
     (save-excursion
       (goto-char (org-table-end))
-      (when (looking-at "\\([ \t]*\n\\)*[ \t]*#\\+TBLFM: *\\(.*\\)")
+      (when (looking-at "\\([ \t]*\n\\)*[ \t]*#\\+tblfm: *\\(.*\\)")
 	(setq strings (org-split-string (org-match-string-no-properties 2)
 					" *:: *"))
 	(while (setq string (pop strings))
@@ -2164,7 +2164,7 @@ KEY is \"@\" or \"$\".  REPLACE is an alist of numbers to replace.
 For all numbers larger than LIMIT, shift them by DELTA."
   (save-excursion
     (goto-char (org-table-end))
-    (when (looking-at "[ \t]*#\\+TBLFM:")
+    (when (let ((case-fold-search t)) (looking-at "[ \t]*#\\+tblfm:"))
       (let ((re (concat key "\\([0-9]+\\)"))
 	    (re2
 	     (when remove
@@ -3144,7 +3144,7 @@ Parameters get priority."
 (defun org-table-edit-formulas ()
   "Edit the formulas of the current table in a separate buffer."
   (interactive)
-  (when (save-excursion (beginning-of-line 1) (looking-at "[ \t]*#\\+TBLFM"))
+  (when (save-excursion (beginning-of-line 1) (let ((case-fold-search t)) (looking-at "[ \t]*#\\+TBLFM")))
     (beginning-of-line 0))
   (unless (org-at-table-p) (error "Not at a table"))
   (org-table-get-specials)
@@ -3833,7 +3833,7 @@ Use COMMAND to do the motion, repeat if necessary to end up in a data line."
   "Local variable used by `orgtbl-mode'.")
 
 (defconst orgtbl-line-start-regexp
-  "[ \t]*\\(|\\|#\\+\\(TBLFM\\|ORGTBL\\|TBLNAME\\):\\)"
+  "[ \t]*\\(|\\|#\\+\\(tblfm\\|orgtbl\\|tblname\\):\\)"
   "Matches a line belonging to an orgtbl.")
 
 (defconst orgtbl-extra-font-lock-keywords
@@ -4081,13 +4081,13 @@ to execute outside of tables."
 If it is a table to be sent away to a receiver, do it.
 With prefix arg, also recompute table."
   (interactive "P")
-  (let ((pos (point)) action consts-str consts cst const-str)
+  (let ((case-fold-search t) (pos (point)) action consts-str consts cst const-str)
     (save-excursion
       (beginning-of-line 1)
       (setq action (cond
 		    ((looking-at "[ \t]*#\\+ORGTBL:.*\n[ \t]*|") (match-end 0))
 		    ((looking-at "[ \t]*|") pos)
-		    ((looking-at "[ \t]*#\\+TBLFM:") 'recalc))))
+		    ((looking-at "[ \t]*#\\+tblfm:") 'recalc))))
     (cond
      ((integerp action)
       (goto-char action)
@@ -4346,7 +4346,8 @@ First element has index 0, or I0 if given."
 (defun orgtbl-toggle-comment ()
   "Comment or uncomment the orgtbl at point."
   (interactive)
-  (let* ((re1 (concat "^" (regexp-quote comment-start) orgtbl-line-start-regexp))
+  (let* ((case-fold-search t)
+	 (re1 (concat "^" (regexp-quote comment-start) orgtbl-line-start-regexp))
 	 (re2 (concat "^" orgtbl-line-start-regexp))
 	 (commented (save-excursion (beginning-of-line 1)
 			     (cond ((looking-at re1) t)
@@ -4724,7 +4725,7 @@ FORM is a field or range descriptor like \"@2$3\" or \"B3\" or
 The return value is either a single string for a single field, or a
 list of the fields in the rectangle ."
   (save-match-data
-    (let ((id-loc nil)
+    (let ((case-fold-search t) (id-loc nil)
 	  ;; Protect a bunch of variables from being overwritten
 	  ;; by the context of the remote table
 	  org-table-column-names org-table-column-name-regexp
@@ -4743,7 +4744,7 @@ list of the fields in the rectangle ."
 	  (save-excursion
 	    (goto-char (point-min))
 	    (if (re-search-forward
-		 (concat "^[ \t]*#\\+TBLNAME:[ \t]*" (regexp-quote name-or-id) "[ \t]*$")
+		 (concat "^[ \t]*#\\+tblname:[ \t]*" (regexp-quote name-or-id) "[ \t]*$")
 		 nil t)
 		(setq buffer (current-buffer) loc (match-beginning 0))
 	      (setq id-loc (org-id-find name-or-id 'marker))

+ 6 - 4
lisp/org.el

@@ -18638,7 +18638,7 @@ When in an #+include line, visit the include file.  Otherwise call
    ((or (org-at-table-p)
 	(save-excursion
 	  (beginning-of-line 1)
-	  (looking-at "[ \t]*#\\+TBLFM:")))
+	  (let ((case-fold-search )) (looking-at "[ \t]*#\\+tblfm:"))))
     (call-interactively 'org-table-edit-formulas))
    (t (call-interactively 'ffap))))
 
@@ -18792,10 +18792,12 @@ This command does many different things, depending on context:
       (beginning-of-line 1)
       (save-excursion (org-update-dblock)))
      ((save-excursion
-	(beginning-of-line 1)
-	(looking-at "[ \t]*#\\+\\([A-Z]+\\)"))
+	(let ((case-fold-search t))
+	  (beginning-of-line 1)
+	  (looking-at "[ \t]*#\\+\\([a-z]+\\)")))
       (cond
-       ((equal (match-string 1) "TBLFM")
+       ((or (equal (match-string 1) "TBLFM")
+	    (equal (match-string 1) "tblfm"))
 	;; Recalculate the table before this line
 	(save-excursion
 	  (beginning-of-line 1)