diff --git a/lisp/org-gnus.el b/lisp/org-gnus.el index 67fb396c6..717c0c2b7 100644 --- a/lisp/org-gnus.el +++ b/lisp/org-gnus.el @@ -159,7 +159,7 @@ If `org-store-link' was called with a prefix arg the meaning of (header (with-current-buffer gnus-summary-buffer (gnus-summary-article-header))) (from (mail-header-from header)) - (message-id (org-remove-angle-brackets (mail-header-id header))) + (message-id (org-unbracket-string "<" ">" (mail-header-id header))) (date (org-trim (mail-header-date header))) (subject (copy-sequence (mail-header-subject header))) (to (cdr (assq 'To (mail-header-extra header)))) @@ -202,7 +202,7 @@ If `org-store-link' was called with a prefix arg the meaning of (let ((gcc (car (last (message-unquote-tokens (message-tokenize-header (mail-fetch-field "gcc" nil t) " ,"))))) - (id (org-remove-angle-brackets (mail-fetch-field "Message-ID"))) + (id (org-unbracket-string "<" ">" (mail-fetch-field "Message-ID"))) (to (mail-fetch-field "To")) (from (mail-fetch-field "From")) (subject (mail-fetch-field "Subject")) diff --git a/lisp/org-lint.el b/lisp/org-lint.el index 330eef997..cfdf5df4d 100644 --- a/lisp/org-lint.el +++ b/lisp/org-lint.el @@ -552,7 +552,8 @@ Use :header-args: instead" (org-element-map ast 'keyword (lambda (k) (when (equal (org-element-property :key k) "SETUPFILE") - (let ((file (org-remove-double-quotes + (let ((file (org-unbracket-string + "\"" "\"" (org-element-property :value k)))) (and (not (file-remote-p file)) (not (file-exists-p file)) @@ -567,7 +568,7 @@ Use :header-args: instead" (path (and (string-match "^\\(\".+\"\\|\\S-+\\)[ \t]*" value) (save-match-data - (org-remove-double-quotes (match-string 1 value)))))) + (org-unbracket-string "\"" "\"" (match-string 1 value)))))) (if (not path) (list (org-element-property :post-affiliated k) "Missing location argument in INCLUDE keyword") diff --git a/lisp/org-macro.el b/lisp/org-macro.el index 18e24deca..856089186 100644 --- a/lisp/org-macro.el +++ b/lisp/org-macro.el @@ -58,7 +58,6 @@ (declare-function org-element-type "org-element" (element)) (declare-function org-file-contents "org" (file &optional noerror)) (declare-function org-mode "org" ()) -(declare-function org-remove-double-quotes "org" (s)) (declare-function vc-backend "vc-hooks" (f)) (declare-function vc-call "vc-hooks" (fun file &rest args) t) (declare-function vc-exec-after "vc-dispatcher" (code)) @@ -104,7 +103,7 @@ Return an alist containing all macro templates found." (push (cons name template) templates)))) ;; Enter setup file. (let ((file (expand-file-name - (org-remove-double-quotes val)))) + (org-unbracket-string "\"" "\"" val)))) (unless (member file files) (with-temp-buffer (setq default-directory diff --git a/lisp/org-mhe.el b/lisp/org-mhe.el index 9dcd77912..2412f9ee8 100644 --- a/lisp/org-mhe.el +++ b/lisp/org-mhe.el @@ -92,7 +92,7 @@ supported by MH-E." :subject subject :message-id message-id) (setq desc (org-email-link-description)) (setq link (concat "mhe:" (org-mhe-get-message-real-folder) "#" - (org-remove-angle-brackets message-id))) + (org-unbracket-string "<" ">" message-id))) (org-add-link-props :link link :description desc) link)))) diff --git a/lisp/org-rmail.el b/lisp/org-rmail.el index 35bf0734d..f24e25b94 100644 --- a/lisp/org-rmail.el +++ b/lisp/org-rmail.el @@ -68,7 +68,7 @@ (org-store-link-props :type "rmail" :from from :to to :date date :subject subject :message-id message-id) - (setq message-id (org-remove-angle-brackets message-id)) + (setq message-id (org-unbracket-string "<" ">" message-id)) (setq desc (org-email-link-description)) (setq link (concat "rmail:" folder "#" message-id)) (org-add-link-props :link link :description desc) diff --git a/lisp/org.el b/lisp/org.el index fae497d39..701d3de03 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -5307,7 +5307,7 @@ Return value contains the following keys: `archive', `category', (unless buffer-read-only ; Do not check in Gnus messages. (let ((f (and (org-string-nw-p value) (expand-file-name - (org-remove-double-quotes value))))) + (org-unbracket-string "\"" "\"" value))))) (when (and f (file-readable-p f) (not (member f files))) (with-temp-buffer (setq default-directory (file-name-directory f)) @@ -10429,7 +10429,7 @@ be used as the default description." ;; Convert to bracket link (setq remove (list (match-beginning 0) (match-end 0)) link (read-string "Link: " - (org-remove-angle-brackets (match-string 0))))) + (org-unbracket-string "<" ">" (match-string 0))))) ((member complete-file '((4) (16))) ;; Completing read for file names. (setq link (org-file-complete-link complete-file))) @@ -10494,7 +10494,7 @@ Use TAB to complete link prefixes, then RET for type-specific completion support (when (and (string-match org-plain-link-re link) (not (string-match org-ts-regexp link))) ;; URL-like link, normalize the use of angular brackets. - (setq link (org-remove-angle-brackets link))) + (setq link (org-unbracket-string "<" ">" link))) ;; Check if we are linking to the current file with a search ;; option If yes, simplify the link by using only the search @@ -10668,7 +10668,7 @@ This is still an experimental function, your mileage may vary." ;; A typical message link. Planner has the id after the final slash, ;; we separate it with a hash mark (setq path (concat (match-string 1 path) "#" - (org-remove-angle-brackets (match-string 2 path)))))) + (org-unbracket-string "<" ">" (match-string 2 path)))))) (cons type path)) (defun org-find-file-at-mouse (ev) @@ -10996,7 +10996,7 @@ there is one, return it." (cond ((not (string-match org-bracket-link-regexp l)) (princ (format "[%c] %s\n" (cl-incf cnt) - (org-remove-angle-brackets l)))) + (org-unbracket-string "<" ">" l)))) ((match-end 3) (princ (format "[%c] %s (%s)\n" (cl-incf cnt) (match-string 3 l) (match-string 1 l)))) @@ -11345,20 +11345,16 @@ or to another Org file, automatically push the old position onto the ring." (goto-char m) (when (or (outline-invisible-p) (org-invisible-p2)) (org-show-context 'mark-goto)))) -;;; TODO: Use string-remove-prefix and -suffix once we only support -;;; Emacs 24.4+ (defun org-remove-angle-brackets (s) - (when (equal (substring s 0 1) "<") (setq s (substring s 1))) - (when (equal (substring s -1) ">") (setq s (substring s 0 -1))) - s) + (org-unbracket-string "<" ">" s)) +(make-obsolete 'org-remove-angle-brackets 'org-unbracket-string "Org 9.0") (defun org-add-angle-brackets (s) (unless (equal (substring s 0 1) "<") (setq s (concat "<" s))) (unless (equal (substring s -1) ">") (setq s (concat s ">"))) s) (defun org-remove-double-quotes (s) - (when (equal (substring s 0 1) "\"") (setq s (substring s 1))) - (when (equal (substring s -1) "\"") (setq s (substring s 0 -1))) - s) + (org-unbracket-string "\"" "\"" s)) +(make-obsolete 'org-remove-double-quotes 'org-unbracket-string "Org 9.0") ;;; Following specific links diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index 912cb2558..112d21ebf 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -1218,7 +1218,8 @@ the file including them will be republished as well." "\\`\\(\".+?\"\\|\\S-+\\)\\(?:\\s-+\\|$\\)" value) (let ((m (match-string 1 value))) - (org-remove-double-quotes + (org-unbracket-string + "\"" "\"" ;; Ignore search suffix. (if (string-match "\\(::\\(.*?\\)\\)\"?\\'" m) (substring m 0 (match-beginning 0)) diff --git a/lisp/ox.el b/lisp/ox.el index aeb5d4909..80aba050a 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1474,7 +1474,7 @@ Assume buffer is in Org mode. Narrowing, if any, is ignored." ((equal key "SETUPFILE") (let ((file (expand-file-name - (org-remove-double-quotes (org-trim val))))) + (org-unbracket-string "\"" "\"" (org-trim val))))) ;; Avoid circular dependencies. (unless (member file files) (with-temp-buffer @@ -1621,7 +1621,7 @@ an alist where associations are (VARIABLE-NAME VALUE)." (push (read (format "(%s)" val)) alist) ;; Enter setup file. (let ((file (expand-file-name - (org-remove-double-quotes val)))) + (org-unbracket-string "\"" "\"" val)))) (unless (member file files) (with-temp-buffer (setq default-directory @@ -3289,8 +3289,7 @@ storing and resolving footnotes. It is created automatically." (setq matched (replace-match "" nil nil matched 1))) (expand-file-name - (org-remove-double-quotes - matched) + (org-unbracket-string "\"" "\"" matched) dir))) (setq value (replace-match "" nil nil value))))) (only-contents