浏览代码

Backport commit 3c94c7bc0 and db9c924d3 from Emacs

* lisp/ob-core.el (org-babel-string-read):
* lisp/org-agenda.el:
(org-agenda-add-entry-to-org-agenda-diary-file):
* lisp/org-element.el (org-element-keyword-parser):
* lisp/org-list.el (org-list-indent-item-generic):
* lisp/org-mhe.el (org-mhe-get-message-folder-from-index):
* lisp/org-mobile.el (org-mobile-apply):
* lisp/org-mouse.el (org-mouse-context-menu):
* lisp/org-plot.el (org-plot/gnuplot):
* lisp/org-protocol.el (org-protocol-flatten-greedy):
* lisp/org-table.el (org-table-copy-down)
(org-table-formula-make-cmp-string)
(org-table-get-stored-formulas, org-table-recalculate)
(org-table-edit-formulas):
* lisp/org.el (org-translate-link-from-planner)
(org-fill-line-break-nobreak-p):
* lisp/ox-ascii.el (org-ascii-item):
* lisp/ox-latex.el (org-latex-clean-invalid-line-breaks):
* lisp/ox.el (org-export-expand-include-keyword):
Fix regular-expression infelicities and typos.

Fix regular-expression glitches and typos
3c94c7bc02fcacb4a101188dddb0c44d53444178
Paul Eggert
Mon Mar 4 18:00:58 2019 -0800

More regexp corrections and tweaks
db9c924d3d53f46846ad8fd74a5d08f4586a520e
Paul Eggert
Fri Mar 8 09:09:40 2019 -0800

Note(km): These two commits are ported together because, with respect
to Org files, db9c924d3 is a fix of an error from 3c94c7bc0.
Paul Eggert 6 年之前
父节点
当前提交
602f2280e3
共有 14 个文件被更改,包括 22 次插入21 次删除
  1. 1 1
      lisp/ob-core.el
  2. 1 1
      lisp/org-agenda.el
  3. 1 1
      lisp/org-element.el
  4. 1 1
      lisp/org-list.el
  5. 1 1
      lisp/org-mhe.el
  6. 2 2
      lisp/org-mobile.el
  7. 1 1
      lisp/org-mouse.el
  8. 1 1
      lisp/org-plot.el
  9. 1 1
      lisp/org-protocol.el
  10. 6 5
      lisp/org-table.el
  11. 2 2
      lisp/org.el
  12. 2 2
      lisp/ox-ascii.el
  13. 1 1
      lisp/ox-latex.el
  14. 1 1
      lisp/ox.el

+ 1 - 1
lisp/ob-core.el

@@ -2972,7 +2972,7 @@ If the table is trivial, then return it as a scalar."
 (defun org-babel-string-read (cell)
 (defun org-babel-string-read (cell)
   "Strip nested \"s from around strings."
   "Strip nested \"s from around strings."
   (org-babel-read (or (and (stringp cell)
   (org-babel-read (or (and (stringp cell)
-                           (string-match "\\\"\\(.+\\)\\\"" cell)
+                           (string-match "\"\\(.+\\)\"" cell)
                            (match-string 1 cell))
                            (match-string 1 cell))
                       cell) t))
                       cell) t))
 
 

+ 1 - 1
lisp/org-agenda.el

@@ -9480,7 +9480,7 @@ the resulting entry will not be shown.  When TEXT is empty, switch to
     (goto-char (point-min))
     (goto-char (point-min))
     (cl-case type
     (cl-case type
      (anniversary
      (anniversary
-      (or (re-search-forward "^*[ \t]+Anniversaries" nil t)
+      (or (re-search-forward "^\\*[ \t]+Anniversaries" nil t)
 	  (progn
 	  (progn
 	    (or (org-at-heading-p t)
 	    (or (org-at-heading-p t)
 		(progn
 		(progn

+ 1 - 1
lisp/org-element.el

@@ -2150,7 +2150,7 @@ containing `:key', `:value', `:begin', `:end', `:post-blank' and
     ;; this corner case.
     ;; this corner case.
     (let ((begin (or (car affiliated) (point)))
     (let ((begin (or (car affiliated) (point)))
 	  (post-affiliated (point))
 	  (post-affiliated (point))
-	  (key (progn (looking-at "[ \t]*#\\+\\(\\S-+*\\):")
+	  (key (progn (looking-at "[ \t]*#\\+\\(\\S-*\\):")
 		      (upcase (match-string-no-properties 1))))
 		      (upcase (match-string-no-properties 1))))
 	  (value (org-trim (buffer-substring-no-properties
 	  (value (org-trim (buffer-substring-no-properties
 			    (match-end 0) (point-at-eol))))
 			    (match-end 0) (point-at-eol))))

+ 1 - 1
lisp/org-list.el

@@ -2657,7 +2657,7 @@ Return t if successful."
 		(error "Cannot outdent beyond margin")
 		(error "Cannot outdent beyond margin")
 	      ;; Change bullet if necessary.
 	      ;; Change bullet if necessary.
 	      (when (and (= (+ top-ind offset) 0)
 	      (when (and (= (+ top-ind offset) 0)
-			 (string-match "*"
+			 (string-match "\\*"
 				       (org-list-get-bullet beg struct)))
 				       (org-list-get-bullet beg struct)))
 		(org-list-set-bullet beg struct
 		(org-list-set-bullet beg struct
 				     (org-list-bullet-string "-")))
 				     (org-list-bullet-string "-")))

+ 1 - 1
lisp/org-mhe.el

@@ -142,7 +142,7 @@ So if you use sequences, it will now work."
   "Return the name of the message folder in an index folder buffer."
   "Return the name of the message folder in an index folder buffer."
   (save-excursion
   (save-excursion
     (mh-index-previous-folder)
     (mh-index-previous-folder)
-    (if (re-search-forward "^\\(+.*\\)$" nil t)
+    (if (re-search-forward "^\\(\\+.*\\)$" nil t)
 	(message "%s" (match-string 1)))))
 	(message "%s" (match-string 1)))))
 
 
 (defun org-mhe-get-message-folder ()
 (defun org-mhe-get-message-folder ()

+ 2 - 2
lisp/org-mobile.el

@@ -859,11 +859,11 @@ If BEG and END are given, only do this in that region."
 	    (cl-incf cnt-error)
 	    (cl-incf cnt-error)
 	    (throw 'next t))
 	    (throw 'next t))
 	  (move-marker bos-marker (point))
 	  (move-marker bos-marker (point))
-	  (if (re-search-forward "^** Old value[ \t]*$" eos t)
+	  (if (re-search-forward "^\\** Old value[ \t]*$" eos t)
 	      (setq old (buffer-substring
 	      (setq old (buffer-substring
 			 (1+ (match-end 0))
 			 (1+ (match-end 0))
 			 (progn (outline-next-heading) (point)))))
 			 (progn (outline-next-heading) (point)))))
-	  (if (re-search-forward "^** New value[ \t]*$" eos t)
+	  (if (re-search-forward "^\\** New value[ \t]*$" eos t)
 	      (setq new (buffer-substring
 	      (setq new (buffer-substring
 			 (1+ (match-end 0))
 			 (1+ (match-end 0))
 			 (progn (outline-next-heading)
 			 (progn (outline-next-heading)

+ 1 - 1
lisp/org-mouse.el

@@ -633,7 +633,7 @@ This means, between the beginning of line and the point."
 	 ,@(org-mouse-list-options-menu (mapcar 'car org-startup-options)
 	 ,@(org-mouse-list-options-menu (mapcar 'car org-startup-options)
 					'org-mode-restart))))
 					'org-mode-restart))))
      ((or (eolp)
      ((or (eolp)
-	  (and (looking-at "\\(  \\|\t\\)\\(+:[0-9a-zA-Z_:]+\\)?\\(  \\|\t\\)+$")
+	  (and (looking-at "\\(  \\|\t\\)\\(\\+:[0-9a-zA-Z_:]+\\)?\\(  \\|\t\\)+$")
 	       (looking-back "  \\|\t" (- (point) 2)
 	       (looking-back "  \\|\t" (- (point) 2)
 			     (line-beginning-position))))
 			     (line-beginning-position))))
       (org-mouse-popup-global-menu))
       (org-mouse-popup-global-menu))

+ 1 - 1
lisp/org-plot.el

@@ -336,7 +336,7 @@ line directly before or after the table."
                    (insert "\n")
                    (insert "\n")
                    (insert-file-contents (plist-get params :script))
                    (insert-file-contents (plist-get params :script))
                    (goto-char (point-min))
                    (goto-char (point-min))
-                   (while (re-search-forward "$datafile" nil t)
+                   (while (re-search-forward "\\$datafile" nil t)
                      (replace-match data-file nil nil)))
                      (replace-match data-file nil nil)))
 	  (insert (org-plot/gnuplot-script data-file num-cols params)))
 	  (insert (org-plot/gnuplot-script data-file num-cols params)))
 	;; Graph table.
 	;; Graph table.

+ 1 - 1
lisp/org-protocol.el

@@ -330,7 +330,7 @@ returned list."
 	 (len 0)
 	 (len 0)
 	 dir
 	 dir
 	 ret)
 	 ret)
-    (when (string-match "^\\(.*\\)\\(org-protocol:/+[a-zA-z0-9][-_a-zA-z0-9]*:/+\\)\\(.*\\)" trigger)
+    (when (string-match "^\\(.*\\)\\(org-protocol:/+[a-zA-Z0-9][-_a-zA-Z0-9]*:/+\\)\\(.*\\)" trigger)
       (setq dir (match-string 1 trigger))
       (setq dir (match-string 1 trigger))
       (setq len (length dir))
       (setq len (length dir))
       (setcar l (concat dir (match-string 3 trigger))))
       (setcar l (concat dir (match-string 3 trigger))))

+ 6 - 5
lisp/org-table.el

@@ -1156,7 +1156,7 @@ to a number.  In the case of a timestamp, increment by days."
 			      (- (org-time-string-to-absolute txt)
 			      (- (org-time-string-to-absolute txt)
 				 (org-time-string-to-absolute txt-up)))
 				 (org-time-string-to-absolute txt-up)))
 			     ((string-match org-ts-regexp3 txt) 1)
 			     ((string-match org-ts-regexp3 txt) 1)
-			     ((string-match "\\([-+]\\)?\\(?:[0-9]+\\)?\\(?:\.[0-9]+\\)?" txt-up)
+			     ((string-match "\\([-+]\\)?[0-9]*\\(?:\\.[0-9]+\\)?" txt-up)
 			      (- (string-to-number txt)
 			      (- (string-to-number txt)
 				 (string-to-number (match-string 0 txt-up))))
 				 (string-to-number (match-string 0 txt-up))))
 			     (t 1)))
 			     (t 1)))
@@ -2327,7 +2327,7 @@ LOCATION instead."
 	      "\n"))))
 	      "\n"))))
 
 
 (defsubst org-table-formula-make-cmp-string (a)
 (defsubst org-table-formula-make-cmp-string (a)
-  (when (string-match "\\`$[<>]" a)
+  (when (string-match "\\`\\$[<>]" a)
     (let ((arrow (string-to-char (substring a 1))))
     (let ((arrow (string-to-char (substring a 1))))
       ;; Fake a high number to make sure this is sorted at the end.
       ;; Fake a high number to make sure this is sorted at the end.
       (setq a (org-table-formula-handle-first/last-rc a))
       (setq a (org-table-formula-handle-first/last-rc a))
@@ -2375,7 +2375,7 @@ LOCATION is a buffer position, consider the formulas there."
 		       (cond
 		       (cond
 			((not (match-end 2)) m)
 			((not (match-end 2)) m)
 			;; Is it a column reference?
 			;; Is it a column reference?
-			((string-match-p "\\`$\\([0-9]+\\|[<>]+\\)\\'" m) m)
+			((string-match-p "\\`\\$\\([0-9]+\\|[<>]+\\)\\'" m) m)
 			;; Since named columns are not possible in
 			;; Since named columns are not possible in
 			;; LHS, assume this is a named field.
 			;; LHS, assume this is a named field.
 			(t (match-string 2 string)))))
 			(t (match-string 2 string)))))
@@ -3236,7 +3236,7 @@ known that the table will be realigned a little later anyway."
 		    (cond
 		    (cond
 		     ((string-match "\\`@-?I+" old-lhs)
 		     ((string-match "\\`@-?I+" old-lhs)
 		      (user-error "Can't assign to hline relative reference"))
 		      (user-error "Can't assign to hline relative reference"))
-		     ((string-match "\\`$[<>]" old-lhs)
+		     ((string-match "\\`\\$[<>]" old-lhs)
 		      (let ((new (org-table-formula-handle-first/last-rc
 		      (let ((new (org-table-formula-handle-first/last-rc
 				  old-lhs)))
 				  old-lhs)))
 			(when (assoc new eqlist)
 			(when (assoc new eqlist)
@@ -3659,7 +3659,8 @@ Parameters get priority."
       (setq startline (org-current-line))
       (setq startline (org-current-line))
       (dolist (entry eql)
       (dolist (entry eql)
 	(let* ((type (cond
 	(let* ((type (cond
-		      ((string-match "\\`$\\([0-9]+\\|[<>]+\\)\\'" (car entry))
+		      ((string-match "\\`\\$\\([0-9]+\\|[<>]+\\)\\'"
+				     (car entry))
 		       'column)
 		       'column)
 		      ((equal (string-to-char (car entry)) ?@) 'field)
 		      ((equal (string-to-char (car entry)) ?@) 'field)
 		      (t 'named)))
 		      (t 'named)))

+ 2 - 2
lisp/org.el

@@ -10058,7 +10058,7 @@ This is still an experimental function, your mileage may vary."
    ((and (equal type "lisp") (string-match "^/" path))
    ((and (equal type "lisp") (string-match "^/" path))
     ;; Planner has a slash, we do not.
     ;; Planner has a slash, we do not.
     (setq type "elisp" path (substring path 1)))
     (setq type "elisp" path (substring path 1)))
-   ((string-match "^//\\(.?*\\)/\\(<.*>\\)$" path)
+   ((string-match "^//\\(.*\\)/\\(<.*>\\)$" path)
     ;; A typical message link.  Planner has the id after the final slash,
     ;; A typical message link.  Planner has the id after the final slash,
     ;; we separate it with a hash mark
     ;; we separate it with a hash mark
     (setq path (concat (match-string 1 path) "#"
     (setq path (concat (match-string 1 path) "#"
@@ -21994,7 +21994,7 @@ assumed to be significant there."
   (save-excursion
   (save-excursion
     (skip-chars-backward "[ \t]")
     (skip-chars-backward "[ \t]")
     (skip-chars-backward "\\\\")
     (skip-chars-backward "\\\\")
-    (looking-at "\\\\\\\\\\($\\|[^\\\\]\\)")))
+    (looking-at "\\\\\\\\\\($\\|[^\\]\\)")))
 
 
 (defun org-fill-paragraph-with-timestamp-nobreak-p ()
 (defun org-fill-paragraph-with-timestamp-nobreak-p ()
   "Non-nil when a new line at point would split a timestamp."
   "Non-nil when a new line at point would split a timestamp."

+ 2 - 2
lisp/ox-ascii.el

@@ -1472,8 +1472,8 @@ contextual information."
 		   (replace-regexp-in-string
 		   (replace-regexp-in-string
 		    "-" "•"
 		    "-" "•"
 		    (replace-regexp-in-string
 		    (replace-regexp-in-string
-		     "+" "⁃"
-		     (replace-regexp-in-string "*" "‣" bul))))))))
+		     "\\+" "⁃"
+		     (replace-regexp-in-string "\\*" "‣" bul))))))))
 	 (indentation (if (eq list-type 'descriptive) org-ascii-quote-margin
 	 (indentation (if (eq list-type 'descriptive) org-ascii-quote-margin
 			(string-width bullet))))
 			(string-width bullet))))
     (concat
     (concat

+ 1 - 1
lisp/ox-latex.el

@@ -1610,7 +1610,7 @@ INFO is a plist used as a communication channel."
 
 
 (defun org-latex-clean-invalid-line-breaks (data _backend _info)
 (defun org-latex-clean-invalid-line-breaks (data _backend _info)
   (replace-regexp-in-string
   (replace-regexp-in-string
-   "\\(\\end{[A-Za-z0-9*]+}\\|^\\)[ \t]*\\\\\\\\[ \t]*$" "\\1"
+   "\\(\\\\end{[A-Za-z0-9*]+}\\|^\\)[ \t]*\\\\\\\\[ \t]*$" "\\1"
    data))
    data))
 
 
 
 

+ 1 - 1
lisp/ox.el

@@ -3300,7 +3300,7 @@ storing and resolving footnotes.  It is created automatically."
 			   (setq value (replace-match "" nil nil value)))))
 			   (setq value (replace-match "" nil nil value)))))
 		   (lines
 		   (lines
 		    (and (string-match
 		    (and (string-match
-			  ":lines +\"\\(\\(?:[0-9]+\\)?-\\(?:[0-9]+\\)?\\)\""
+			  ":lines +\"\\([0-9]*-[0-9]*\\)\""
 			  value)
 			  value)
 			 (prog1 (match-string 1 value)
 			 (prog1 (match-string 1 value)
 			   (setq value (replace-match "" nil nil value)))))
 			   (setq value (replace-match "" nil nil value)))))