From: Bastien <bzg@altern.org>
To: Sebastien Vauban <wxhgmqzgwmuf@spammotel.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [bug] Can't find remote table when name is downcased
Date: Sat, 21 Apr 2012 15:40:09 +0200 [thread overview]
Message-ID: <87pqb1xkxy.fsf@altern.org> (raw)
In-Reply-To: <80iphh2djt.fsf@somewhere.org> (Sebastien Vauban's message of "Tue, 03 Apr 2012 14:41:10 +0200")
[-- Attachment #1: Type: text/plain, Size: 245 bytes --]
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,
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Match-name-tblname-tblfm-along-with-uppercase-twins.patch --]
[-- Type: text/x-patch, Size: 16137 bytes --]
From 4e107031ad81b368e407f0815132294024f43610 Mon Sep 17 00:00:00 2001
From: Bastien Guerry <bzg@altern.org>
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 ++-
| 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)
--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
[-- Attachment #3: Type: text/plain, Size: 14 bytes --]
--
Bastien
prev parent reply other threads:[~2012-04-21 13:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-02 13:54 [bug] Can't find remote table when name is downcased Sebastien Vauban
2012-04-02 15:05 ` Bastien
2012-04-02 15:36 ` Sebastien Vauban
2012-04-02 15:49 ` Bastien
2012-04-02 21:01 ` Sebastien Vauban
2012-04-03 12:41 ` Sebastien Vauban
2012-04-21 13:40 ` Bastien [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pqb1xkxy.fsf@altern.org \
--to=bzg@altern.org \
--cc=emacs-orgmode@gnu.org \
--cc=wxhgmqzgwmuf@spammotel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).