aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/org
diff options
context:
space:
mode:
authorSam Steingold2022-07-26 13:47:03 -0400
committerSam Steingold2022-07-26 13:49:28 -0400
commit70341cab3eb26e2f49bbc13d6bca247ab9403abc (patch)
treefb26eac43aef57c9400769d101a8064ce3b9ec20 /lisp/org
parent015cf7824ea511180329dabcb67c533661da3fff (diff)
downloademacs-70341cab3eb26e2f49bbc13d6bca247ab9403abc.tar.gz
emacs-70341cab3eb26e2f49bbc13d6bca247ab9403abc.zip
string-equal-ignore-case: new function
* lisp/cedet/semantic/complete.el (semantic-collector-calculate-completions): Use `string-prefix-p' instead of explicit `compare-strings'. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add `string-equal-ignore-case'. * lisp/emacs-lisp/cl-extra.el (cl-equalp): Use `string-equal-ignore-case'. * lisp/emacs-lisp/shadow.el (load-path-shadows-find): Likewise. * lisp/emacs-lisp/shortdoc.el (string): Add `string-equal-ignore-case'. * lisp/files.el (file-truename): Use `string-equal-ignore-case'. (file-relative-name): Likewise. * lisp/gnus/gnus-art.el (article-hide-boring-headers): Use `string-equal-ignore-case' instead of `gnus-string-equal'. * lisp/gnus/gnus-util.el (gnus-string-equal): Remove, use `string-equal-ignore-case' instead. * lisp/international/mule-cmds.el (describe-language-environment): Use `string-equal-ignore-case'. (locale-charset-match-p): Likewise. * lisp/man.el (Man-softhyphen-to-minus): Use `string-prefix-p'. * lisp/minibuffer.el (completion--string-equal-p): Remove, use `string-equal-ignore-case' instead. (completion--twq-all): Use `string-equal-ignore-case'. (completion--do-completion): Likewise. * lisp/net/browse-url.el (browse-url-default-windows-browser): Use `string-prefix-p' instead of explicit `compare-strings'. * lisp/org/ob-core.el (org-babel-results-keyword): Use `string-equal-ignore-case' instead of explicit `compare-strings'. (org-babel-insert-result): Likewise. * lisp/org/org-compat.el (string-equal-ignore-case): Define unless defined already. (org-mode-flyspell-verify): Use `string-equal-ignore-case'. * lisp/org/org-lint.el (org-lint-duplicate-custom-id): Likewise. * lisp/org/ox.el (org-export-resolve-radio-link): Use `string-equal-ignore-case' and `string-clean-whitespace'. * lisp/progmodes/flymake-proc.el (flymake-proc--check-patch-master-file-buffer): Use `string-prefix-p' instead of explicit `compare-strings'. * lisp/progmodes/idlwave.el (idlwave-class-or-superclass-with-tag): Use `string-equal-ignore-case' instead of explicit `compare-strings'. * lisp/subr.el (member-ignore-case): Use `string-equal-ignore-case'. (string-equal-ignore-case): Compare strings ignoring case. * lisp/textmodes/bibtex.el (bibtex-string=): Remove. (bibtex-format-entry, bibtex-font-lock-url, bibtex-autofill-entry) (bibtex-print-help-message, bibtex-validate, bibtex-validate-globally) (bibtex-clean-entry, bibtex-completion-at-point-function, (bibtex-url): Use `string-equal-ignore-case' instead of `bibtex-string='. * lisp/textmodes/sgml-mode.el (sgml-get-context): Use `string-equal-ignore-case' instead of explicit `compare-strings'. (sgml-calculate-indent): Likewise * test/lisp/subr-tests.el (string-comparison-test): Add tests for `string-equal-ignore-case'.
Diffstat (limited to 'lisp/org')
-rw-r--r--lisp/org/ob-core.el9
-rw-r--r--lisp/org/org-compat.el14
-rw-r--r--lisp/org/org-lint.el6
-rw-r--r--lisp/org/ox.el12
4 files changed, 21 insertions, 20 deletions
diff --git a/lisp/org/ob-core.el b/lisp/org/ob-core.el
index 04af84d2e44..3d159ed38a9 100644
--- a/lisp/org/ob-core.el
+++ b/lisp/org/ob-core.el
@@ -136,8 +136,7 @@ used."
136 :type 'string 136 :type 'string
137 :safe (lambda (v) 137 :safe (lambda (v)
138 (and (stringp v) 138 (and (stringp v)
139 (eq (compare-strings "RESULTS" nil nil v nil nil t) 139 (string-equal-ignore-case "RESULTS" v))))
140 t))))
141 140
142(defcustom org-babel-noweb-wrap-start "<<" 141(defcustom org-babel-noweb-wrap-start "<<"
143 "String used to begin a noweb reference in a code block. 142 "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
2435 ;; Escape contents from "export" wrap. Wrap 2434 ;; Escape contents from "export" wrap. Wrap
2436 ;; inline results within an export snippet with 2435 ;; inline results within an export snippet with
2437 ;; appropriate value. 2436 ;; appropriate value.
2438 ((eq t (compare-strings type nil nil "export" nil nil t)) 2437 ((string-equal-ignore-case type "export")
2439 (let ((backend (pcase split 2438 (let ((backend (pcase split
2440 (`(,_) "none") 2439 (`(,_) "none")
2441 (`(,_ ,b . ,_) b)))) 2440 (`(,_ ,b . ,_) b))))
@@ -2446,14 +2445,14 @@ INFO may provide the values of these header arguments (in the
2446 backend) "@@)}}}"))) 2445 backend) "@@)}}}")))
2447 ;; Escape contents from "example" wrap. Mark 2446 ;; Escape contents from "example" wrap. Mark
2448 ;; inline results as verbatim. 2447 ;; inline results as verbatim.
2449 ((eq t (compare-strings type nil nil "example" nil nil t)) 2448 ((string-equal-ignore-case type "example")
2450 (funcall wrap 2449 (funcall wrap
2451 opening-line closing-line 2450 opening-line closing-line
2452 nil nil 2451 nil nil
2453 "{{{results(=" "=)}}}")) 2452 "{{{results(=" "=)}}}"))
2454 ;; Escape contents from "src" wrap. Mark 2453 ;; Escape contents from "src" wrap. Mark
2455 ;; inline results as inline source code. 2454 ;; inline results as inline source code.
2456 ((eq t (compare-strings type nil nil "src" nil nil t)) 2455 ((string-equal-ignore-case type "src")
2457 (let ((inline-open 2456 (let ((inline-open
2458 (pcase split 2457 (pcase split
2459 (`(,_) 2458 (`(,_)
diff --git a/lisp/org/org-compat.el b/lisp/org/org-compat.el
index a65bf6f677a..085e32d6774 100644
--- a/lisp/org/org-compat.el
+++ b/lisp/org/org-compat.el
@@ -934,6 +934,14 @@ Implements `define-error' for older emacsen."
934 (put name 'error-conditions 934 (put name 'error-conditions
935 (copy-sequence (cons name (get 'error 'error-conditions)))))) 935 (copy-sequence (cons name (get 'error 'error-conditions))))))
936 936
937(unless (fboundp 'string-equal-ignore-case)
938 ;; From Emacs subr.el.
939 (defun string-equal-ignore-case (string1 string2)
940 "Like `string-equal', but case-insensitive.
941Upper-case and lower-case letters are treated as equal.
942Unibyte strings are converted to multibyte for comparison."
943 (eq t (compare-strings string1 0 nil string2 0 nil t))))
944
937(unless (fboundp 'string-suffix-p) 945(unless (fboundp 'string-suffix-p)
938 ;; From Emacs subr.el. 946 ;; From Emacs subr.el.
939 (defun string-suffix-p (suffix string &optional ignore-case) 947 (defun string-suffix-p (suffix string &optional ignore-case)
@@ -1125,10 +1133,8 @@ ELEMENT is the element at point."
1125 (and log 1133 (and log
1126 (let ((drawer (org-element-lineage element '(drawer)))) 1134 (let ((drawer (org-element-lineage element '(drawer))))
1127 (and drawer 1135 (and drawer
1128 (eq (compare-strings 1136 (string-equal-ignore-case
1129 log nil nil 1137 log (org-element-property :drawer-name drawer))))))
1130 (org-element-property :drawer-name drawer) nil nil t)
1131 t)))))
1132 nil) 1138 nil)
1133 (t 1139 (t
1134 (cl-case (org-element-type element) 1140 (cl-case (org-element-type element)
diff --git a/lisp/org/org-lint.el b/lisp/org/org-lint.el
index 83c2d08a907..6d8cf3f2374 100644
--- a/lisp/org/org-lint.el
+++ b/lisp/org/org-lint.el
@@ -334,10 +334,8 @@ called with one argument, the key used for comparison."
334 ast 334 ast
335 'node-property 335 'node-property
336 (lambda (property) 336 (lambda (property)
337 (and (eq (compare-strings "CUSTOM_ID" nil nil 337 (and (string-equal-ignore-case
338 (org-element-property :key property) nil nil 338 "CUSTOM_ID" (org-element-property :key property))
339 t)
340 t)
341 (org-element-property :value property))) 339 (org-element-property :value property)))
342 (lambda (property _) (org-element-property :begin property)) 340 (lambda (property _) (org-element-property :begin property))
343 (lambda (key) (format "Duplicate CUSTOM_ID property \"%s\"" key)))) 341 (lambda (key) (format "Duplicate CUSTOM_ID property \"%s\"" key))))
diff --git a/lisp/org/ox.el b/lisp/org/ox.el
index 55258bc79da..1bdf4dead89 100644
--- a/lisp/org/ox.el
+++ b/lisp/org/ox.el
@@ -80,6 +80,7 @@
80(require 'org-element) 80(require 'org-element)
81(require 'org-macro) 81(require 'org-macro)
82(require 'tabulated-list) 82(require 'tabulated-list)
83(require 'subr-x)
83 84
84(declare-function org-src-coderef-format "org-src" (&optional element)) 85(declare-function org-src-coderef-format "org-src" (&optional element))
85(declare-function org-src-coderef-regexp "org-src" (fmt &optional label)) 86(declare-function org-src-coderef-regexp "org-src" (fmt &optional label))
@@ -4436,15 +4437,12 @@ INFO is a plist used as a communication channel.
4436 4437
4437Return value can be a radio-target object or nil. Assume LINK 4438Return value can be a radio-target object or nil. Assume LINK
4438has type \"radio\"." 4439has type \"radio\"."
4439 (let ((path (replace-regexp-in-string 4440 (let ((path (string-clean-whitespace (org-element-property :path link))))
4440 "[ \r\t\n]+" " " (org-element-property :path link))))
4441 (org-element-map (plist-get info :parse-tree) 'radio-target 4441 (org-element-map (plist-get info :parse-tree) 'radio-target
4442 (lambda (radio) 4442 (lambda (radio)
4443 (and (eq (compare-strings 4443 (and (string-equal-ignore-case
4444 (replace-regexp-in-string 4444 (string-clean-whitespace (org-element-property :value radio))
4445 "[ \r\t\n]+" " " (org-element-property :value radio)) 4445 path)
4446 nil nil path nil nil t)
4447 t)
4448 radio)) 4446 radio))
4449 info 'first-match))) 4447 info 'first-match)))
4450 4448