aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2023-11-18 10:13:37 +0200
committerEli Zaretskii2023-11-18 10:13:37 +0200
commitbb64e3a7985c5473f7b15ebcfe5f6b87d2237d92 (patch)
treed26306fd42228f35087d7ba2d8dc1e5f5e3c5158
parentae06e0275d6197e82eae5b8cb9bb30d33b863cee (diff)
downloademacs-bb64e3a7985c5473f7b15ebcfe5f6b87d2237d92.tar.gz
emacs-bb64e3a7985c5473f7b15ebcfe5f6b87d2237d92.zip
Avoid loading cl-lib as result of invoking 'load-library'
* lisp/emacs-lisp/find-func.el (find-function--any-subform-p): Don't use 'cl-destructuring-bind'. (find-library--from-load-history): Don't use 'cl-loop'. * lisp/thingatpt.el (thing-at-point): Don't use 'cl-loop'. This avoids loading cl-lib whenever thingatpt.el is loaded, for example, as result of "M-x load-library".
-rw-r--r--lisp/emacs-lisp/find-func.el25
-rw-r--r--lisp/thingatpt.el14
2 files changed, 23 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el
index d393ccc759a..24d31fefd7d 100644
--- a/lisp/emacs-lisp/find-func.el
+++ b/lisp/emacs-lisp/find-func.el
@@ -42,8 +42,6 @@
42 42
43;;; Code: 43;;; Code:
44 44
45(eval-when-compile (require 'cl-lib))
46
47;;; User variables: 45;;; User variables:
48 46
49(defgroup find-function nil 47(defgroup find-function nil
@@ -247,13 +245,19 @@ LIBRARY should be a string (the name of the library)."
247 ;; LIBRARY may be "foo.el" or "foo". 245 ;; LIBRARY may be "foo.el" or "foo".
248 (let ((load-re 246 (let ((load-re
249 (concat "\\(" (regexp-quote (file-name-sans-extension library)) "\\)" 247 (concat "\\(" (regexp-quote (file-name-sans-extension library)) "\\)"
250 (regexp-opt (get-load-suffixes)) "\\'"))) 248 (regexp-opt (get-load-suffixes)) "\\'"))
251 (cl-loop 249 (alist load-history)
252 for (file . _) in load-history thereis 250 elt file found)
253 (and (stringp file) (string-match load-re file) 251 (while (and alist (null found))
254 (let ((dir (substring file 0 (match-beginning 1))) 252 (setq elt (car alist)
255 (basename (match-string 1 file))) 253 alist (cdr alist)
256 (locate-file basename (list dir) (find-library-suffixes))))))) 254 file (car elt)
255 found (and (stringp file) (string-match load-re file)
256 (let ((dir (substring file 0 (match-beginning 1)))
257 (basename (match-string 1 file)))
258 (locate-file basename (list dir)
259 (find-library-suffixes))))))
260 found))
257 261
258(defvar find-function-C-source-directory 262(defvar find-function-C-source-directory
259 (let ((dir (expand-file-name "src" source-directory))) 263 (let ((dir (expand-file-name "src" source-directory)))
@@ -469,7 +473,8 @@ Return t if any PRED returns t."
469 ((not (consp form)) nil) 473 ((not (consp form)) nil)
470 ((funcall pred form) t) 474 ((funcall pred form) t)
471 (t 475 (t
472 (cl-destructuring-bind (left-child . right-child) form 476 (let ((left-child (car form))
477 (right-child (cdr form)))
473 (or 478 (or
474 (find-function--any-subform-p left-child pred) 479 (find-function--any-subform-p left-child pred)
475 (find-function--any-subform-p right-child pred)))))) 480 (find-function--any-subform-p right-child pred))))))
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el
index 5d4f4df9131..88efbf73beb 100644
--- a/lisp/thingatpt.el
+++ b/lisp/thingatpt.el
@@ -52,7 +52,6 @@
52 52
53;;; Code: 53;;; Code:
54 54
55(require 'cl-lib)
56(provide 'thingatpt) 55(provide 'thingatpt)
57 56
58(defvar thing-at-point-provider-alist nil 57(defvar thing-at-point-provider-alist nil
@@ -175,11 +174,14 @@ See the file `thingatpt.el' for documentation on how to define
175a symbol as a valid THING." 174a symbol as a valid THING."
176 (let ((text 175 (let ((text
177 (cond 176 (cond
178 ((cl-loop for (pthing . function) in thing-at-point-provider-alist 177 ((let ((alist thing-at-point-provider-alist)
179 when (eq pthing thing) 178 elt result)
180 for result = (funcall function) 179 (while (and alist (null result))
181 when result 180 (setq elt (car alist)
182 return result)) 181 alist (cdr alist))
182 (and (eq (car elt) thing)
183 (setq result (funcall (cdr elt)))))
184 result))
183 ((get thing 'thing-at-point) 185 ((get thing 'thing-at-point)
184 (funcall (get thing 'thing-at-point))) 186 (funcall (get thing 'thing-at-point)))
185 (t 187 (t