From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: [bug] Can't find remote table when name is downcased Date: Sat, 21 Apr 2012 15:40:09 +0200 Message-ID: <87pqb1xkxy.fsf@altern.org> References: <80398mutmp.fsf@somewhere.org> <87aa2uxjgt.fsf@gnu.org> <808viegn8a.fsf@somewhere.org> <87obraw2vm.fsf@gnu.org> <801uo5etl1.fsf@somewhere.org> <80iphh2djt.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:42968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SLaWq-0008Oa-3l for emacs-orgmode@gnu.org; Sat, 21 Apr 2012 09:39:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SLaWl-0002vD-8t for emacs-orgmode@gnu.org; Sat, 21 Apr 2012 09:39:07 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:55198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SLaWk-0002v7-Sf for emacs-orgmode@gnu.org; Sat, 21 Apr 2012 09:39:03 -0400 Received: by werj55 with SMTP id j55so8565899wer.0 for ; Sat, 21 Apr 2012 06:39:01 -0700 (PDT) In-Reply-To: <80iphh2djt.fsf@somewhere.org> (Sebastien Vauban's message of "Tue, 03 Apr 2012 14:41:10 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Sebastien Vauban Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hi Sébastien, can you test the attached patch? It takes care of matching #+tblname/#+name/#+tblfm along with #+TBLNAME/#+NAME/#+TBLFM. Please test it heavily -- I'm sure you have some secret stuff in your config to make it fail :) Thanks, --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Match-name-tblname-tblfm-along-with-uppercase-twins.patch >From 4e107031ad81b368e407f0815132294024f43610 Mon Sep 17 00:00:00 2001 From: Bastien Guerry Date: Sat, 21 Apr 2012 15:36:04 +0200 Subject: [PATCH] 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. --- lisp/ob.el | 37 ++++++++++++++++++++----------------- lisp/org-capture.el | 4 ++-- lisp/org-clock.el | 3 ++- lisp/org-colview-xemacs.el | 3 ++- lisp/org-colview.el | 3 ++- lisp/org-exp.el | 3 ++- lisp/org-footnote.el | 2 +- lisp/org-table.el | 29 +++++++++++++++-------------- lisp/org.el | 10 ++++++---- 9 files changed, 52 insertions(+), 42 deletions(-) diff --git a/lisp/ob.el b/lisp/ob.el index 160c63a..4332110 100644 --- a/lisp/ob.el +++ b/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 diff --git a/lisp/org-capture.el b/lisp/org-capture.el index f0afc70..109a5c2 100644 --- a/lisp/org-capture.el +++ b/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) diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 25a36cf..abd75ea 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2199,6 +2199,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) @@ -2373,7 +2374,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)))) diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el index be9a0b2..5a6ffdd 100644 --- a/lisp/org-colview-xemacs.el +++ b/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)) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 58fc962..5409701 100644 --- a/lisp/org-colview.el +++ b/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)) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 689b92c..5b56a28 100644 --- a/lisp/org-exp.el +++ b/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) diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el index eb6059b..b0472f3 100644 --- a/lisp/org-footnote.el +++ b/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)) diff --git a/lisp/org-table.el b/lisp/org-table.el index 305fd3f..9331391 100644 --- a/lisp/org-table.el +++ b/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) @@ -4342,7 +4342,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) @@ -4720,7 +4721,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 @@ -4739,7 +4740,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)) diff --git a/lisp/org.el b/lisp/org.el index add28f2..0367f1f 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -18628,7 +18628,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)))) @@ -18782,10 +18782,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) -- 1.7.9.4 --=-=-= Content-Type: text/plain -- Bastien --=-=-=--