1
0
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-12-23 10:34:17 +00:00

Backport commit 70341cab3 from Emacs

* lisp/ob-core.el (org-babel-results-keyword):
  Use `string-equal-ignore-case' instead of explicit `compare-strings'.
(org-babel-insert-result): Likewise.
* lisp/org-compat.el (string-equal-ignore-case):
  Define unless defined already.
(org-mode-flyspell-verify): Use `string-equal-ignore-case'.
* lisp/org-lint.el (org-lint-duplicate-custom-id): Likewise.
* lisp/ox.el (org-export-resolve-radio-link): Use
  `string-equal-ignore-case' and `string-clean-whitespace'.

string-equal-ignore-case: new function
70341cab3eb26e2f49bbc13d6bca247ab9403abc
Sam Steingold
Tue Jul 26 13:49:28 2022 -0400

[ km: Note that string-clean-whitespace also requires a compatibility
  kludge and the string-equal-ignore-case kludge was added to the
  wrong org-compat section.  These will be addressed in a follow-up
  commit. ]
This commit is contained in:
Sam Steingold 2022-07-26 13:47:03 -04:00 committed by Kyle Meyer
parent 1adbaca75a
commit e614a763ca
4 changed files with 21 additions and 20 deletions

View File

@ -136,8 +136,7 @@ used."
:type 'string
:safe (lambda (v)
(and (stringp v)
(eq (compare-strings "RESULTS" nil nil v nil nil t)
t))))
(string-equal-ignore-case "RESULTS" v))))
(defcustom org-babel-noweb-wrap-start "<<"
"String used to begin a noweb reference in a code block.
@ -2435,7 +2434,7 @@ INFO may provide the values of these header arguments (in the
;; Escape contents from "export" wrap. Wrap
;; inline results within an export snippet with
;; appropriate value.
((eq t (compare-strings type nil nil "export" nil nil t))
((string-equal-ignore-case type "export")
(let ((backend (pcase split
(`(,_) "none")
(`(,_ ,b . ,_) b))))
@ -2446,14 +2445,14 @@ INFO may provide the values of these header arguments (in the
backend) "@@)}}}")))
;; Escape contents from "example" wrap. Mark
;; inline results as verbatim.
((eq t (compare-strings type nil nil "example" nil nil t))
((string-equal-ignore-case type "example")
(funcall wrap
opening-line closing-line
nil nil
"{{{results(=" "=)}}}"))
;; Escape contents from "src" wrap. Mark
;; inline results as inline source code.
((eq t (compare-strings type nil nil "src" nil nil t))
((string-equal-ignore-case type "src")
(let ((inline-open
(pcase split
(`(,_)

View File

@ -934,6 +934,14 @@ Implements `define-error' for older emacsen."
(put name 'error-conditions
(copy-sequence (cons name (get 'error 'error-conditions))))))
(unless (fboundp 'string-equal-ignore-case)
;; From Emacs subr.el.
(defun string-equal-ignore-case (string1 string2)
"Like `string-equal', but case-insensitive.
Upper-case and lower-case letters are treated as equal.
Unibyte strings are converted to multibyte for comparison."
(eq t (compare-strings string1 0 nil string2 0 nil t))))
(unless (fboundp 'string-suffix-p)
;; From Emacs subr.el.
(defun string-suffix-p (suffix string &optional ignore-case)
@ -1125,10 +1133,8 @@ ELEMENT is the element at point."
(and log
(let ((drawer (org-element-lineage element '(drawer))))
(and drawer
(eq (compare-strings
log nil nil
(org-element-property :drawer-name drawer) nil nil t)
t)))))
(string-equal-ignore-case
log (org-element-property :drawer-name drawer))))))
nil)
(t
(cl-case (org-element-type element)

View File

@ -334,10 +334,8 @@ called with one argument, the key used for comparison."
ast
'node-property
(lambda (property)
(and (eq (compare-strings "CUSTOM_ID" nil nil
(org-element-property :key property) nil nil
t)
t)
(and (string-equal-ignore-case
"CUSTOM_ID" (org-element-property :key property))
(org-element-property :value property)))
(lambda (property _) (org-element-property :begin property))
(lambda (key) (format "Duplicate CUSTOM_ID property \"%s\"" key))))

View File

@ -80,6 +80,7 @@
(require 'org-element)
(require 'org-macro)
(require 'tabulated-list)
(require 'subr-x)
(declare-function org-src-coderef-format "org-src" (&optional element))
(declare-function org-src-coderef-regexp "org-src" (fmt &optional label))
@ -4436,15 +4437,12 @@ INFO is a plist used as a communication channel.
Return value can be a radio-target object or nil. Assume LINK
has type \"radio\"."
(let ((path (replace-regexp-in-string
"[ \r\t\n]+" " " (org-element-property :path link))))
(let ((path (string-clean-whitespace (org-element-property :path link))))
(org-element-map (plist-get info :parse-tree) 'radio-target
(lambda (radio)
(and (eq (compare-strings
(replace-regexp-in-string
"[ \r\t\n]+" " " (org-element-property :value radio))
nil nil path nil nil t)
t)
(and (string-equal-ignore-case
(string-clean-whitespace (org-element-property :value radio))
path)
radio))
info 'first-match)))