浏览代码

Match `org-complex-heading-regexp' with a nil `case-fold-search'

* lisp/org-agenda.el (org-agenda-goto):
* lisp/org-clock.el (org-clock-in):
(org-clock-out):
(org-clock-put-overlay):
(org-clock-load):
* lisp/org-element.el (org-element-context):
* lisp/org-footnote.el (org-footnote--allow-reference-p):
* lisp/org-mobile.el:
* lisp/ox.el (org-export--get-subtree-options):
* lisp/org.el (org-insert-heading):
(org-edit-headline):
(org-open-at-point):
(org-refile-get-targets):
(org--get-outline-path-1):
(org-toggle-comment):
(org-set-tags-to):
(org-set-tags):
(org-entry-properties):
(org-delete-indentation):
(org-beginning-of-line):
(org-end-of-line):
(org-mode-flyspell-verify): Bind `case-fold-search' to nil when matching
`org-complex-heading-regexp'.

(org-complex-heading-regexp): Add a note about the necessity to have
`case-fold-search' bound to nil.
Nicolas Goaziou 8 年之前
父节点
当前提交
7bbe9202c2
共有 7 个文件被更改,包括 117 次插入89 次删除
  1. 3 2
      lisp/org-agenda.el
  2. 13 9
      lisp/org-clock.el
  3. 10 9
      lisp/org-element.el
  4. 6 4
      lisp/org-footnote.el
  5. 27 25
      lisp/org-mobile.el
  6. 55 38
      lisp/org.el
  7. 3 2
      lisp/ox.el

+ 3 - 2
lisp/org-agenda.el

@@ -8400,8 +8400,9 @@ When called with a prefix argument, include all archive files as well."
       (org-show-context 'agenda)
       (org-show-context 'agenda)
       (recenter (/ (window-height) 2))
       (recenter (/ (window-height) 2))
       (org-back-to-heading t)
       (org-back-to-heading t)
-      (if (re-search-forward org-complex-heading-regexp nil t)
-	  (goto-char (match-beginning 4))))
+      (let ((case-fold-search nil))
+	(when (re-search-forward org-complex-heading-regexp nil t)
+	  (goto-char (match-beginning 4)))))
     (run-hooks 'org-agenda-after-show-hook)
     (run-hooks 'org-agenda-after-show-hook)
     (and highlight (org-highlight (point-at-bol) (point-at-eol)))))
     (and highlight (org-highlight (point-at-bol) (point-at-eol)))))
 
 

+ 13 - 9
lisp/org-clock.el

@@ -1266,10 +1266,11 @@ the default behavior."
 	 (org-clock-history-push)
 	 (org-clock-history-push)
 	 (setq org-clock-current-task (nth 4 (org-heading-components)))
 	 (setq org-clock-current-task (nth 4 (org-heading-components)))
 	 (cond ((functionp org-clock-in-switch-to-state)
 	 (cond ((functionp org-clock-in-switch-to-state)
-		(looking-at org-complex-heading-regexp)
+		(let ((case-fold-search nil))
+		  (looking-at org-complex-heading-regexp))
 		(let ((newstate (funcall org-clock-in-switch-to-state
 		(let ((newstate (funcall org-clock-in-switch-to-state
 					 (match-string 2))))
 					 (match-string 2))))
-		  (if newstate (org-todo newstate))))
+		  (when newstate (org-todo newstate))))
 	       ((and org-clock-in-switch-to-state
 	       ((and org-clock-in-switch-to-state
 		     (not (looking-at (concat org-outline-regexp "[ \t]*"
 		     (not (looking-at (concat org-outline-regexp "[ \t]*"
 					      org-clock-in-switch-to-state
 					      org-clock-in-switch-to-state
@@ -1617,10 +1618,11 @@ to, overriding the existing value of `org-clock-out-switch-to-state'."
 		    (org-clock-out-when-done nil))
 		    (org-clock-out-when-done nil))
 		(cond
 		(cond
 		 ((functionp org-clock-out-switch-to-state)
 		 ((functionp org-clock-out-switch-to-state)
-		  (looking-at org-complex-heading-regexp)
+		  (let ((case-fold-search nil))
+		    (looking-at org-complex-heading-regexp))
 		  (let ((newstate (funcall org-clock-out-switch-to-state
 		  (let ((newstate (funcall org-clock-out-switch-to-state
 					   (match-string 2))))
 					   (match-string 2))))
-		    (if newstate (org-todo newstate))))
+		    (when newstate (org-todo newstate))))
 		 ((and org-clock-out-switch-to-state
 		 ((and org-clock-out-switch-to-state
 		       (not (looking-at (concat org-outline-regexp "[ \t]*"
 		       (not (looking-at (concat org-outline-regexp "[ \t]*"
 						org-clock-out-switch-to-state
 						org-clock-out-switch-to-state
@@ -1945,10 +1947,11 @@ This creates a new overlay and stores it in `org-clock-overlays', so that it
 will be easy to remove."
 will be easy to remove."
   (let (ov tx)
   (let (ov tx)
     (beginning-of-line)
     (beginning-of-line)
-    (when (looking-at org-complex-heading-regexp)
-      (goto-char (match-beginning 4)))
+    (let ((case-fold-search nil))
+      (when (looking-at org-complex-heading-regexp)
+	(goto-char (match-beginning 4))))
     (setq ov (make-overlay (point) (point-at-eol))
     (setq ov (make-overlay (point) (point-at-eol))
-    	  tx (concat (buffer-substring-no-properties (point) (match-end 4))
+	  tx (concat (buffer-substring-no-properties (point) (match-end 4))
 		     (org-add-props
 		     (org-add-props
 			 (make-string
 			 (make-string
 			  (max 0 (- (- 60 (current-column))
 			  (max 0 (- (- 60 (current-column))
@@ -2988,8 +2991,9 @@ The details of what will be saved are regulated by the variable
 			   (save-excursion
 			   (save-excursion
 			     (goto-char (cdr resume-clock))
 			     (goto-char (cdr resume-clock))
 			     (org-back-to-heading t)
 			     (org-back-to-heading t)
-			     (and (looking-at org-complex-heading-regexp)
-				  (match-string 4))))
+			     (let ((case-fold-search nil))
+			       (and (looking-at org-complex-heading-regexp)
+				    (match-string 4)))))
 			 ") "))))
 			 ") "))))
 	  (when (file-exists-p (car resume-clock))
 	  (when (file-exists-p (car resume-clock))
 	    (with-current-buffer (find-file (car resume-clock))
 	    (with-current-buffer (find-file (car resume-clock))

+ 10 - 9
lisp/org-element.el

@@ -5872,15 +5872,16 @@ Providing it allows for quicker computation."
 	       (throw 'objects-forbidden element)))))
 	       (throw 'objects-forbidden element)))))
 	;; At an headline or inlinetask, objects are in title.
 	;; At an headline or inlinetask, objects are in title.
 	((memq type '(headline inlinetask))
 	((memq type '(headline inlinetask))
-	 (goto-char (org-element-property :begin element))
-	 (looking-at org-complex-heading-regexp)
-	 (let ((end (match-end 4)))
-	   (if (not end) (throw 'objects-forbidden element)
-	     (goto-char (match-beginning 4))
-	     (when (let (case-fold-search) (looking-at org-comment-string))
-	       (goto-char (match-end 0)))
-	     (if (>= (point) end) (throw 'objects-forbidden element)
-	       (narrow-to-region (point) end)))))
+	 (let ((case-fold-search nil))
+	   (goto-char (org-element-property :begin element))
+	   (looking-at org-complex-heading-regexp)
+	   (let ((end (match-end 4)))
+	     (if (not end) (throw 'objects-forbidden element)
+	       (goto-char (match-beginning 4))
+	       (when (looking-at org-comment-string)
+		 (goto-char (match-end 0)))
+	       (if (>= (point) end) (throw 'objects-forbidden element)
+		 (narrow-to-region (point) end))))))
 	;; At a paragraph, a table-row or a verse block, objects are
 	;; At a paragraph, a table-row or a verse block, objects are
 	;; located within their contents.
 	;; located within their contents.
 	((memq type '(paragraph table-row verse-block))
 	((memq type '(paragraph table-row verse-block))

+ 6 - 4
lisp/org-footnote.el

@@ -284,10 +284,12 @@ otherwise."
        ;; heading itself or on the blank lines below.
        ;; heading itself or on the blank lines below.
        ((memq type '(headline inlinetask))
        ((memq type '(headline inlinetask))
 	(or (not (org-at-heading-p))
 	(or (not (org-at-heading-p))
-	    (and (save-excursion (beginning-of-line)
-				 (and (let ((case-fold-search t))
-					(not (looking-at "\\*+ END[ \t]*$")))
-				      (looking-at org-complex-heading-regexp)))
+	    (and (save-excursion
+		   (beginning-of-line)
+		   (and (let ((case-fold-search t))
+			  (not (looking-at-p "\\*+ END[ \t]*$")))
+			(let ((case-fold-search nil))
+			  (looking-at org-complex-heading-regexp))))
 		 (match-beginning 4)
 		 (match-beginning 4)
 		 (>= (point) (match-beginning 4))
 		 (>= (point) (match-beginning 4))
 		 (or (not (match-beginning 5))
 		 (or (not (match-beginning 5))

+ 27 - 25
lisp/org-mobile.el

@@ -996,7 +996,7 @@ be returned that indicates what went wrong."
        ((equal new "DONEARCHIVE")
        ((equal new "DONEARCHIVE")
 	(org-todo 'done)
 	(org-todo 'done)
 	(org-archive-subtree-default))
 	(org-archive-subtree-default))
-       ((equal new current) t) ; nothing needs to be done
+       ((equal new current) t)		; nothing needs to be done
        ((or (equal current old)
        ((or (equal current old)
 	    (eq org-mobile-force-mobile-change t)
 	    (eq org-mobile-force-mobile-change t)
 	    (memq 'todo org-mobile-force-mobile-change))
 	    (memq 'todo org-mobile-force-mobile-change))
@@ -1018,33 +1018,35 @@ be returned that indicates what went wrong."
 		 (or old "") (or current "")))))
 		 (or old "") (or current "")))))
 
 
      ((eq what 'priority)
      ((eq what 'priority)
-      (when (looking-at org-complex-heading-regexp)
-	(setq current (and (match-end 3) (substring (match-string 3) 2 3)))
-	(cond
-	 ((equal current new) t) ; no action required
-	 ((or (equal current old)
-	      (eq org-mobile-force-mobile-change t)
-	      (memq 'tags org-mobile-force-mobile-change))
-	  (org-priority (and new (string-to-char new))))
-	 (t (error "Priority was expected to be %s, but is %s"
-		   old current)))))
+      (let ((case-fold-search nil))
+	(when (looking-at org-complex-heading-regexp)
+	  (let ((current (and (match-end 3) (substring (match-string 3) 2 3))))
+	    (cond
+	     ((equal current new) t)	;no action required
+	     ((or (equal current old)
+		  (eq org-mobile-force-mobile-change t)
+		  (memq 'tags org-mobile-force-mobile-change))
+	      (org-priority (and new (string-to-char new))))
+	     (t (error "Priority was expected to be %s, but is %s"
+		       old current)))))))
 
 
      ((eq what 'heading)
      ((eq what 'heading)
-      (when (looking-at org-complex-heading-regexp)
-	(setq current (match-string 4))
-	(cond
-	 ((equal current new) t) ; no action required
-	 ((or (equal current old)
-	      (eq org-mobile-force-mobile-change t)
-	      (memq 'heading org-mobile-force-mobile-change))
-	  (goto-char (match-beginning 4))
-	  (insert new)
-	  (delete-region (point) (+ (point) (length current)))
-	  (org-set-tags nil 'align))
-	 (t (error "Heading changed in MobileOrg and on the computer")))))
+      (let ((case-fold-search nil))
+	(when (looking-at org-complex-heading-regexp)
+	  (let ((current (match-string 4)))
+	    (cond
+	     ((equal current new) t)	;no action required
+	     ((or (equal current old)
+		  (eq org-mobile-force-mobile-change t)
+		  (memq 'heading org-mobile-force-mobile-change))
+	      (goto-char (match-beginning 4))
+	      (insert new)
+	      (delete-region (point) (+ (point) (length current)))
+	      (org-set-tags nil 'align))
+	     (t (error "Heading changed in MobileOrg and on the computer")))))))
 
 
      ((eq what 'addheading)
      ((eq what 'addheading)
-      (if (org-at-heading-p) ; if false we are in top-level of file
+      (if (org-at-heading-p)	; if false we are in top-level of file
 	  (progn
 	  (progn
 	    ;; Workaround a `org-insert-heading-respect-content' bug
 	    ;; Workaround a `org-insert-heading-respect-content' bug
 	    ;; which prevents correct insertion when point is invisible
 	    ;; which prevents correct insertion when point is invisible
@@ -1059,7 +1061,7 @@ be returned that indicates what went wrong."
      ((eq what 'refile)
      ((eq what 'refile)
       (org-copy-subtree)
       (org-copy-subtree)
       (org-with-point-at (org-mobile-locate-entry new)
       (org-with-point-at (org-mobile-locate-entry new)
-	(if (org-at-heading-p) ; if false we are in top-level of file
+	(if (org-at-heading-p)	; if false we are in top-level of file
 	    (progn
 	    (progn
 	      (setq level (org-get-valid-level (funcall outline-level) 1))
 	      (setq level (org-get-valid-level (funcall outline-level) 1))
 	      (org-end-of-subtree t t)
 	      (org-end-of-subtree t t)

+ 55 - 38
lisp/org.el

@@ -4912,11 +4912,15 @@ Otherwise, these types are allowed:
   "Matches a headline and puts TODO state into group 2 if present.")
   "Matches a headline and puts TODO state into group 2 if present.")
 (defvar-local org-complex-heading-regexp nil
 (defvar-local org-complex-heading-regexp nil
   "Matches a headline and puts everything into groups:
   "Matches a headline and puts everything into groups:
+
 group 1: the stars
 group 1: the stars
 group 2: The todo keyword, maybe
 group 2: The todo keyword, maybe
 group 3: Priority cookie
 group 3: Priority cookie
 group 4: True headline
 group 4: True headline
-group 5: Tags")
+group 5: Tags
+
+Since TODO keywords are case-sensitive, `case-fold-search' is
+expected to be bound to nil when matching this regexp.")
 (defvar-local org-complex-heading-regexp-format nil
 (defvar-local org-complex-heading-regexp-format nil
   "Printf format to make regexp to match an exact headline.
   "Printf format to make regexp to match an exact headline.
 This regexp will match the headline of any node which has the
 This regexp will match the headline of any node which has the
@@ -8021,8 +8025,9 @@ unconditionally."
 		;; tags).
 		;; tags).
 		(let ((pos (point)))
 		(let ((pos (point)))
 		  (beginning-of-line)
 		  (beginning-of-line)
-		  (unless (looking-at org-complex-heading-regexp)
-		    (error "This should not happen"))
+		  (let ((case-fold-search nil))
+		    (unless (looking-at org-complex-heading-regexp)
+		      (error "This should not happen")))
 		  (when (and (match-beginning 4)
 		  (when (and (match-beginning 4)
 			     (> pos (match-beginning 4))
 			     (> pos (match-beginning 4))
 			     (< pos (match-end 4)))
 			     (< pos (match-end 4)))
@@ -8141,16 +8146,17 @@ Set it to HEADING when provided."
   (interactive)
   (interactive)
   (org-with-wide-buffer
   (org-with-wide-buffer
    (org-back-to-heading t)
    (org-back-to-heading t)
-   (when (looking-at org-complex-heading-regexp)
-     (let* ((old (match-string-no-properties 4))
-	    (new (save-match-data
-		   (org-trim (or heading (read-string "Edit: " old))))))
-       (unless (equal old new)
-	 (if old (replace-match new t t nil 4)
-	   (goto-char (or (match-end 3) (match-end 2) (match-end 1)))
-	   (insert " " new))
-	 (org-set-tags nil t)
-	 (when (looking-at "[ \t]*$") (replace-match "")))))))
+   (let ((case-fold-search nil))
+     (when (looking-at org-complex-heading-regexp)
+       (let* ((old (match-string-no-properties 4))
+	      (new (save-match-data
+		     (org-trim (or heading (read-string "Edit: " old))))))
+	 (unless (equal old new)
+	   (if old (replace-match new t t nil 4)
+	     (goto-char (or (match-end 3) (match-end 2) (match-end 1)))
+	     (insert " " new))
+	   (org-set-tags nil t)
+	   (when (looking-at "[ \t]*$") (replace-match ""))))))))
 
 
 (defun org-insert-heading-after-current ()
 (defun org-insert-heading-after-current ()
   "Insert a new heading with same level as current, after current subtree."
   "Insert a new heading with same level as current, after current subtree."
@@ -10842,10 +10848,12 @@ link in a property drawer line."
 	 ;; a link, a footnote reference or on tags.
 	 ;; a link, a footnote reference or on tags.
 	 ((and (memq type '(headline inlinetask))
 	 ((and (memq type '(headline inlinetask))
 	       ;; Not on tags.
 	       ;; Not on tags.
-	       (progn (save-excursion (beginning-of-line)
-				      (looking-at org-complex-heading-regexp))
-		      (or (not (match-beginning 5))
-			  (< (point) (match-beginning 5)))))
+	       (let ((case-fold-search nil))
+		 (save-excursion
+		   (beginning-of-line)
+		   (looking-at org-complex-heading-regexp))
+		 (or (not (match-beginning 5))
+		     (< (point) (match-beginning 5)))))
 	  (let* ((data (org-offer-links-in-entry (current-buffer) (point) arg))
 	  (let* ((data (org-offer-links-in-entry (current-buffer) (point) arg))
 		 (links (car data))
 		 (links (car data))
 		 (links-end (cdr data)))
 		 (links-end (cdr data)))
@@ -10873,10 +10881,11 @@ link in a property drawer line."
 	 ((eq type 'timestamp) (org-follow-timestamp-link))
 	 ((eq type 'timestamp) (org-follow-timestamp-link))
 	 ;; On tags within a headline or an inlinetask.
 	 ;; On tags within a headline or an inlinetask.
 	 ((and (memq type '(headline inlinetask))
 	 ((and (memq type '(headline inlinetask))
-	       (progn (save-excursion (beginning-of-line)
-				      (looking-at org-complex-heading-regexp))
-		      (and (match-beginning 5)
-			   (>= (point) (match-beginning 5)))))
+	       (let ((case-fold-search nil))
+		 (save-excursion (beginning-of-line)
+				 (looking-at org-complex-heading-regexp))
+		 (and (match-beginning 5)
+		      (>= (point) (match-beginning 5)))))
 	  (org-tags-view arg (substring (match-string 5) 0 -1)))
 	  (org-tags-view arg (substring (match-string 5) 0 -1)))
 	 ((eq type 'link)
 	 ((eq type 'link)
 	  ;; When link is located within the description of another
 	  ;; When link is located within the description of another
@@ -11737,7 +11746,8 @@ order.")
 		(setq org-outline-path-cache nil)
 		(setq org-outline-path-cache nil)
 		(while (re-search-forward descre nil t)
 		(while (re-search-forward descre nil t)
 		  (beginning-of-line)
 		  (beginning-of-line)
-		  (looking-at org-complex-heading-regexp)
+		  (let ((case-fold-search nil))
+		    (looking-at org-complex-heading-regexp))
 		  (let ((begin (point))
 		  (let ((begin (point))
 			(heading (match-string-no-properties 4)))
 			(heading (match-string-no-properties 4)))
 		    (unless (or (and
 		    (unless (or (and
@@ -11786,7 +11796,7 @@ optional argument USE-CACHE is non-nil, make use of a cache.  See
 Assume buffer is widened and point is on a headline."
 Assume buffer is widened and point is on a headline."
   (or (and use-cache (cdr (assq (point) org-outline-path-cache)))
   (or (and use-cache (cdr (assq (point) org-outline-path-cache)))
       (let ((p (point))
       (let ((p (point))
-	    (heading (progn
+	    (heading (let ((case-fold-search nil))
 		       (looking-at org-complex-heading-regexp)
 		       (looking-at org-complex-heading-regexp)
 		       (if (not (match-end 4)) ""
 		       (if (not (match-end 4)) ""
 			 ;; Remove statistics cookies.
 			 ;; Remove statistics cookies.
@@ -12469,7 +12479,8 @@ expands them."
   (interactive)
   (interactive)
   (save-excursion
   (save-excursion
     (org-back-to-heading)
     (org-back-to-heading)
-    (looking-at org-complex-heading-regexp)
+    (let ((case-fold-search nil))
+      (looking-at org-complex-heading-regexp))
     (goto-char (or (match-end 3) (match-end 2) (match-end 1)))
     (goto-char (or (match-end 3) (match-end 2) (match-end 1)))
     (skip-chars-forward " \t")
     (skip-chars-forward " \t")
     (unless (memq (char-before) '(?\s ?\t)) (insert " "))
     (unless (memq (char-before) '(?\s ?\t)) (insert " "))
@@ -15029,7 +15040,8 @@ If DATA is nil or the empty string, any tags will be removed."
   (when data
   (when data
     (save-excursion
     (save-excursion
       (org-back-to-heading t)
       (org-back-to-heading t)
-      (when (looking-at org-complex-heading-regexp)
+      (when (let ((case-fold-search nil))
+	      (looking-at org-complex-heading-regexp))
 	(if (match-end 5)
 	(if (match-end 5)
 	    (progn
 	    (progn
 	      (goto-char (match-beginning 5))
 	      (goto-char (match-beginning 5))
@@ -15143,7 +15155,8 @@ When JUST-ALIGN is non-nil, only align tags."
 	  (unless (equal current tags)
 	  (unless (equal current tags)
 	    (save-excursion
 	    (save-excursion
 	      (beginning-of-line)
 	      (beginning-of-line)
-	      (looking-at org-complex-heading-regexp)
+	      (let ((case-fold-search nil))
+		(looking-at org-complex-heading-regexp))
 	      ;; Remove current tags, if any.
 	      ;; Remove current tags, if any.
 	      (when (match-end 5) (replace-match "" nil nil nil 5))
 	      (when (match-end 5) (replace-match "" nil nil nil 5))
 	      ;; Insert new tags, if any.  Otherwise, remove trailing
 	      ;; Insert new tags, if any.  Otherwise, remove trailing
@@ -15815,13 +15828,14 @@ strings."
 			props)))
 			props)))
 	      (when specific (throw 'exit props)))
 	      (when specific (throw 'exit props)))
 	    (when (or (not specific) (string= specific "ITEM"))
 	    (when (or (not specific) (string= specific "ITEM"))
-	      (when (looking-at org-complex-heading-regexp)
-		(push (cons "ITEM"
-			    (let ((title (match-string-no-properties 4)))
-			      (if (org-string-nw-p title)
-				  (org-remove-tabs title)
-				"")))
-		      props))
+	      (let ((case-fold-search nil))
+		(when (looking-at org-complex-heading-regexp)
+		  (push (cons "ITEM"
+			      (let ((title (match-string-no-properties 4)))
+				(if (org-string-nw-p title)
+				    (org-remove-tabs title)
+				  "")))
+			props)))
 	      (when specific (throw 'exit props)))
 	      (when specific (throw 'exit props)))
 	    (when (or (not specific) (string= specific "TODO"))
 	    (when (or (not specific) (string= specific "TODO"))
 	      (let ((case-fold-search nil))
 	      (let ((case-fold-search nil))
@@ -21302,7 +21316,8 @@ With a non-nil optional argument, join it to the following one."
   (interactive "*P")
   (interactive "*P")
   (if (save-excursion
   (if (save-excursion
 	(beginning-of-line (if arg 1 0))
 	(beginning-of-line (if arg 1 0))
-	(looking-at org-complex-heading-regexp))
+	(let ((case-fold-search nil))
+	  (looking-at org-complex-heading-regexp)))
       ;; At headline.
       ;; At headline.
       (let ((tags-column (when (match-beginning 5)
       (let ((tags-column (when (match-beginning 5)
 			   (save-excursion (goto-char (match-beginning 5))
 			   (save-excursion (goto-char (match-beginning 5))
@@ -23786,7 +23801,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
      ;; of line: point is at the beginning of a visual line.  Bail
      ;; of line: point is at the beginning of a visual line.  Bail
      ;; out.
      ;; out.
      ((and (bound-and-true-p visual-line-mode) (not (bolp))))
      ((and (bound-and-true-p visual-line-mode) (not (bolp))))
-     ((looking-at org-complex-heading-regexp)
+     ((let ((case-fold-search nil)) (looking-at org-complex-heading-regexp))
       ;; At a headline, special position is before the title, but
       ;; At a headline, special position is before the title, but
       ;; after any TODO keyword or priority cookie.
       ;; after any TODO keyword or priority cookie.
       (let ((refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1)))
       (let ((refpos (min (1+ (or (match-end 3) (match-end 2) (match-end 1)))
@@ -23837,7 +23852,8 @@ With argument N not nil or 1, move forward N - 1 lines first."
      ((and special
      ((and special
 	   (save-excursion
 	   (save-excursion
 	     (beginning-of-line)
 	     (beginning-of-line)
-	     (looking-at org-complex-heading-regexp))
+	     (let ((case-fold-search nil))
+	       (looking-at org-complex-heading-regexp)))
 	   (match-end 5))
 	   (match-end 5))
       (let ((tags (save-excursion
       (let ((tags (save-excursion
 		    (goto-char (match-beginning 5))
 		    (goto-char (match-beginning 5))
@@ -25020,8 +25036,9 @@ ELEMENT is the element at point."
       ;; faster than relying on `org-element-at-point'.
       ;; faster than relying on `org-element-at-point'.
       (and (save-excursion (beginning-of-line)
       (and (save-excursion (beginning-of-line)
 			   (and (let ((case-fold-search t))
 			   (and (let ((case-fold-search t))
-				  (not (looking-at "\\*+ END[ \t]*$")))
-				(looking-at org-complex-heading-regexp)))
+				  (not (looking-at-p "\\*+ END[ \t]*$")))
+				(let ((case-fold-search nil))
+				  (looking-at org-complex-heading-regexp))))
 	   (match-beginning 4)
 	   (match-beginning 4)
 	   (>= (point) (match-beginning 4))
 	   (>= (point) (match-beginning 4))
 	   (or (not (match-beginning 5))
 	   (or (not (match-beginning 5))

+ 3 - 2
lisp/ox.el

@@ -1405,8 +1405,9 @@ for export.  Return options as a plist."
 	 (cache (list
 	 (cache (list
 		 (cons "TITLE"
 		 (cons "TITLE"
 		       (or (org-entry-get (point) "EXPORT_TITLE" 'selective)
 		       (or (org-entry-get (point) "EXPORT_TITLE" 'selective)
-			   (progn (looking-at org-complex-heading-regexp)
-				  (match-string-no-properties 4))))))
+			   (let ((case-fold-search nil))
+			     (looking-at org-complex-heading-regexp)
+			     (match-string-no-properties 4))))))
 	 ;; Look for both general keywords and back-end specific
 	 ;; Look for both general keywords and back-end specific
 	 ;; options, with priority given to the latter.
 	 ;; options, with priority given to the latter.
 	 (options (append (and backend (org-export-get-all-options backend))
 	 (options (append (and backend (org-export-get-all-options backend))