compat: Use org- wrapper for string-equal-ignore-case compatibility

* lisp/org-compat.el (org-string-equal-ignore-case): New compatibility
function.
(org-mode-flyspell-verify):
* lisp/ob-core.el (org-babel-results-keyword):
(org-babel-insert-result):
* lisp/org-lint.el (org-lint-duplicate-custom-id):
* lisp/ox.el (org-export-resolve-radio-link):
Use org-string-equal-ignore-case.

Prefer an explicit org- wrapper to isolate the kludge and avoid any
confusion about where it is defined.

This is a follow-up to the port of Emacs's 70341cab3.
This commit is contained in:
Kyle Meyer 2022-10-04 17:42:27 -04:00
parent 75d63533d3
commit 07b6a0e044
4 changed files with 13 additions and 10 deletions

View File

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

View File

@ -76,6 +76,9 @@
(declare-function org-fold-show-all "org-fold" (&optional types)) (declare-function org-fold-show-all "org-fold" (&optional types))
(declare-function org-fold-show-children "org-fold" (&optional level)) (declare-function org-fold-show-children "org-fold" (&optional level))
(declare-function org-fold-show-entry "org-fold" (&optional hide-drawers)) (declare-function org-fold-show-entry "org-fold" (&optional hide-drawers))
;; `org-string-equal-ignore-case' is in _this_ file but isn't at the
;; top-level.
(declare-function org-string-equal-ignore-case "org-compat" (string1 string2))
(defvar calendar-mode-map) (defvar calendar-mode-map)
(defvar org-complex-heading-regexp) (defvar org-complex-heading-regexp)
@ -116,9 +119,10 @@ the symbol of the calling function, for example."
(when (not (equal attr cachedattr)) (when (not (equal attr cachedattr))
(puthash sym attr org-file-has-changed-p--hash-table))))) (puthash sym attr org-file-has-changed-p--hash-table)))))
(unless (fboundp 'string-equal-ignore-case) (if (fboundp 'string-equal-ignore-case)
(defalias 'org-string-equal-ignore-case #'string-equal-ignore-case)
;; From Emacs subr.el. ;; From Emacs subr.el.
(defun string-equal-ignore-case (string1 string2) (defun org-string-equal-ignore-case (string1 string2)
"Like `string-equal', but case-insensitive. "Like `string-equal', but case-insensitive.
Upper-case and lower-case letters are treated as equal. Upper-case and lower-case letters are treated as equal.
Unibyte strings are converted to multibyte for comparison." Unibyte strings are converted to multibyte for comparison."
@ -1358,7 +1362,7 @@ ELEMENT is the element at point."
(and log (and log
(let ((drawer (org-element-lineage element '(drawer)))) (let ((drawer (org-element-lineage element '(drawer))))
(and drawer (and drawer
(string-equal-ignore-case (org-string-equal-ignore-case
log (org-element-property :drawer-name drawer)))))) log (org-element-property :drawer-name drawer))))))
nil) nil)
(t (t

View File

@ -383,7 +383,7 @@ called with one argument, the key used for comparison."
ast ast
'node-property 'node-property
(lambda (property) (lambda (property)
(and (string-equal-ignore-case (and (org-string-equal-ignore-case
"CUSTOM_ID" (org-element-property :key property)) "CUSTOM_ID" (org-element-property :key property))
(org-element-property :value property))) (org-element-property :value property)))
(lambda (property _) (org-element-property :begin property)) (lambda (property _) (org-element-property :begin property))

View File

@ -82,7 +82,6 @@
(require 'org-element) (require 'org-element)
(require 'org-macro) (require 'org-macro)
(require 'tabulated-list) (require 'tabulated-list)
(require 'subr-x)
(declare-function org-src-coderef-format "org-src" (&optional element)) (declare-function org-src-coderef-format "org-src" (&optional element))
(declare-function org-src-coderef-regexp "org-src" (fmt &optional label)) (declare-function org-src-coderef-regexp "org-src" (fmt &optional label))
@ -4457,7 +4456,7 @@ has type \"radio\"."
(let ((path (org-string-clean-whitespace (org-element-property :path link)))) (let ((path (org-string-clean-whitespace (org-element-property :path link))))
(org-element-map (plist-get info :parse-tree) 'radio-target (org-element-map (plist-get info :parse-tree) 'radio-target
(lambda (radio) (lambda (radio)
(and (string-equal-ignore-case (and (org-string-equal-ignore-case
(org-string-clean-whitespace (org-element-property :value radio)) (org-string-clean-whitespace (org-element-property :value radio))
path) path)
radio)) radio))