summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2020-05-13 15:43:55 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2020-05-13 18:13:18 +0200
commitc76bacc4832ca677fd500168e9e80c98b0dcc14f (patch)
tree1d8a8c1a2d672b63a97355d9cdafeb40c17e6668
parent89c759f3adc378530be3d83a87b62a6c1947f012 (diff)
downloadorg-mode-c76bacc4832ca677fd500168e9e80c98b0dcc14f.tar.gz
ob: Ignore RESULTS keyword case
* lisp/ob-core.el (org-babel-current-result-hash): (org-babel-hide-hash): (org-babel-hide-all-hashes): (org-babel-result-hide-all): (org-babel-hide-result-toggle-maybe): (org-babel-hide-result-toggle): (org-babel--clear-results-maybe): (org-babel-remove-result): Bind `case-fold-search' to t before looking for `org-babel-result-regexp'.
-rw-r--r--lisp/ob-core.el111
1 files changed, 56 insertions, 55 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 489f58a..2471857 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1311,10 +1311,9 @@ CONTEXT specifies the context of evaluation. It can be `:eval',
"Return the current in-buffer hash."
(let ((result (org-babel-where-is-src-block-result nil info)))
(when result
- (org-with-wide-buffer
- (goto-char result)
- (looking-at org-babel-result-regexp)
- (match-string-no-properties 1)))))
+ (org-with-point-at result
+ (let ((case-fold-search t)) (looking-at org-babel-result-regexp))
+ (match-string-no-properties 1)))))
(defun org-babel-hide-hash ()
"Hide the hash in the current results line.
@@ -1322,7 +1321,8 @@ Only the initial `org-babel-hash-show' characters of the hash
will remain visible."
(add-to-invisibility-spec '(org-babel-hide-hash . t))
(save-excursion
- (when (and (re-search-forward org-babel-result-regexp nil t)
+ (when (and (let ((case-fold-search t))
+ (re-search-forward org-babel-result-regexp nil t))
(match-string 1))
(let* ((start (match-beginning 1))
(hide-start (+ org-babel-hash-show start))
@@ -1340,11 +1340,12 @@ Only the initial `org-babel-hash-show' characters of each hash
will remain visible. This function should be called as part of
the `org-mode-hook'."
(save-excursion
- (while (and (not org-babel-hash-show-time)
- (re-search-forward org-babel-result-regexp nil t))
- (goto-char (match-beginning 0))
- (org-babel-hide-hash)
- (goto-char (match-end 0)))))
+ (let ((case-fold-search t))
+ (while (and (not org-babel-hash-show-time)
+ (re-search-forward org-babel-result-regexp nil t))
+ (goto-char (match-beginning 0))
+ (org-babel-hide-hash)
+ (goto-char (match-end 0))))))
(add-hook 'org-mode-hook 'org-babel-hide-all-hashes)
(defun org-babel-hash-at-point (&optional point)
@@ -1373,9 +1374,10 @@ portions of results lines."
(interactive)
(org-babel-show-result-all)
(save-excursion
- (while (re-search-forward org-babel-result-regexp nil t)
- (save-excursion (goto-char (match-beginning 0))
- (org-babel-hide-result-toggle-maybe)))))
+ (let ((case-fold-search t))
+ (while (re-search-forward org-babel-result-regexp nil t)
+ (save-excursion (goto-char (match-beginning 0))
+ (org-babel-hide-result-toggle-maybe))))))
(defun org-babel-show-result-all ()
"Unfold all results in the current buffer."
@@ -1387,52 +1389,50 @@ portions of results lines."
"Toggle visibility of result at point."
(interactive)
(let ((case-fold-search t))
- (if (save-excursion
- (beginning-of-line 1)
- (looking-at org-babel-result-regexp))
- (progn (org-babel-hide-result-toggle)
- t) ;; to signal that we took action
- nil))) ;; to signal that we did not
+ (and (org-match-line org-babel-result-regexp)
+ (progn (org-babel-hide-result-toggle) t))))
(defun org-babel-hide-result-toggle (&optional force)
"Toggle the visibility of the current result."
(interactive)
(save-excursion
(beginning-of-line)
- (if (re-search-forward org-babel-result-regexp nil t)
- (let ((start (progn (beginning-of-line 2) (- (point) 1)))
- (end (progn
- (while (looking-at org-babel-multi-line-header-regexp)
- (forward-line 1))
- (goto-char (- (org-babel-result-end) 1)) (point)))
- ov)
- (if (memq t (mapcar (lambda (overlay)
- (eq (overlay-get overlay 'invisible)
- 'org-babel-hide-result))
- (overlays-at start)))
- (when (or (not force) (eq force 'off))
- (mapc (lambda (ov)
- (when (member ov org-babel-hide-result-overlays)
- (setq org-babel-hide-result-overlays
- (delq ov org-babel-hide-result-overlays)))
- (when (eq (overlay-get ov 'invisible)
- 'org-babel-hide-result)
- (delete-overlay ov)))
- (overlays-at start)))
- (setq ov (make-overlay start end))
- (overlay-put ov 'invisible 'org-babel-hide-result)
- ;; make the block accessible to isearch
- (overlay-put
- ov 'isearch-open-invisible
- (lambda (ov)
- (when (member ov org-babel-hide-result-overlays)
- (setq org-babel-hide-result-overlays
- (delq ov org-babel-hide-result-overlays)))
- (when (eq (overlay-get ov 'invisible)
- 'org-babel-hide-result)
- (delete-overlay ov))))
- (push ov org-babel-hide-result-overlays)))
- (error "Not looking at a result line"))))
+ (let ((case-fold-search t))
+ (unless (re-search-forward org-babel-result-regexp nil t)
+ (error "Not looking at a result line")))
+ (let ((start (progn (beginning-of-line 2) (1- (point))))
+ (end (progn
+ (while (looking-at org-babel-multi-line-header-regexp)
+ (forward-line 1))
+ (goto-char (1- (org-babel-result-end)))
+ (point)))
+ ov)
+ (if (memq t (mapcar (lambda (overlay)
+ (eq (overlay-get overlay 'invisible)
+ 'org-babel-hide-result))
+ (overlays-at start)))
+ (when (or (not force) (eq force 'off))
+ (mapc (lambda (ov)
+ (when (member ov org-babel-hide-result-overlays)
+ (setq org-babel-hide-result-overlays
+ (delq ov org-babel-hide-result-overlays)))
+ (when (eq (overlay-get ov 'invisible)
+ 'org-babel-hide-result)
+ (delete-overlay ov)))
+ (overlays-at start)))
+ (setq ov (make-overlay start end))
+ (overlay-put ov 'invisible 'org-babel-hide-result)
+ ;; make the block accessible to isearch
+ (overlay-put
+ ov 'isearch-open-invisible
+ (lambda (ov)
+ (when (member ov org-babel-hide-result-overlays)
+ (setq org-babel-hide-result-overlays
+ (delq ov org-babel-hide-result-overlays)))
+ (when (eq (overlay-get ov 'invisible)
+ 'org-babel-hide-result)
+ (delete-overlay ov))))
+ (push ov org-babel-hide-result-overlays)))))
;; org-tab-after-check-for-cycling-hook
(add-hook 'org-tab-first-hook 'org-babel-hide-result-toggle-maybe)
@@ -1975,7 +1975,7 @@ point, along with related contents. Do nothing if HASH is nil.
Return a non-nil value if results were cleared. In this case,
leave point where new results should be inserted."
(when hash
- (looking-at org-babel-result-regexp)
+ (let ((case-fold-search t)) (looking-at org-babel-result-regexp))
(unless (string= (match-string 1) hash)
(let* ((e (org-element-at-point))
(post (copy-marker (org-element-property :post-affiliated e))))
@@ -2489,7 +2489,8 @@ INFO may provide the values of these header arguments (in the
(defun org-babel-remove-result (&optional info keep-keyword)
"Remove the result of the current source block."
(interactive)
- (let ((location (org-babel-where-is-src-block-result nil info)))
+ (let ((location (org-babel-where-is-src-block-result nil info))
+ (case-fold-search t))
(when location
(save-excursion
(goto-char location)