Browse Source

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'.
Nicolas Goaziou 2 months ago
parent
commit
c76bacc483
1 changed files with 56 additions and 55 deletions
  1. 56 55
      lisp/ob-core.el

+ 56 - 55
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)