bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25823: 26.0.50; describe-function: Don't require cl-lib at runtime


From: Tino Calancha
Subject: bug#25823: 26.0.50; describe-function: Don't require cl-lib at runtime
Date: Tue, 21 Feb 2017 12:39:29 +0900

X-Debbugs-CC: Stefan Monnier <monnier@iro.umontreal.ca>

emacs -Q:

I)
(progn
  (describe-function 'dolist)
  (delete-other-windows)
  (featurep 'cl-lib))
=> t

The patch below prevent to load cl-lib in this case.

II) After the patch, we still load extra libs in _interactive_ calls.
;; (Applied patch below)

(progn
  (describe-function 'mapc)
  (delete-other-windows)
  (featurep 'cl-lib))
=> nil

;; Now interactively.
M-x describe-function RET
mapc RET

M-: (featurep 'cl-lib) RET
=> t
;; Becase it loads map.el which depends on seq.el, and
;; this one depends on cl-lib.
;;
;; IMO, an input "mapc" should not load map.el,
;; because "mapc" doesn't match a prefix "map-".
;; Does it have sense for you?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>From ff83f7b3d8f48eeef037f6e7606ba3c3be3fb3c2 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Tue, 21 Feb 2017 12:20:35 +0900
Subject: [PATCH] help-mode: Don't require cl-lib at run-time

* lisp/help-mode.el: Require cl-lib at compile time (Bug#25823).
(help--find-symbol): New defun.
(help-make-xrefs): Use it instead of cl-some.
* lisp/help-fns.el: Require cl-lib at compile time.
(describe-symbol): Use help--find-symbol.
---
 lisp/help-fns.el  |  8 +++-----
 lisp/help-mode.el | 10 +++++++---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index 742c66919a..479d109ce9 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -32,7 +32,7 @@
 
 ;;; Code:
 
-(require 'cl-lib)
+(eval-when-compile (require 'cl-lib))
 (require 'help-mode)
 (require 'radix-tree)
 
@@ -1089,8 +1089,7 @@ describe-symbol
 current buffer and the selected frame, respectively."
   (interactive
    (let* ((v-or-f (symbol-at-point))
-          (found (cl-some (lambda (x) (funcall (nth 1 x) v-or-f))
-                          describe-symbol-backends))
+          (found (help--find-symbol v-or-f))
           (v-or-f (if found v-or-f (function-called-at-point)))
           (found (or found v-or-f))
           (enable-recursive-minibuffers t)
@@ -1100,8 +1099,7 @@ describe-symbol
                                  "Describe symbol: ")
                                obarray
                                (lambda (vv)
-                                  (cl-some (lambda (x) (funcall (nth 1 x) vv))
-                                           describe-symbol-backends))
+                                  (help--find-symbol vv))
                                t nil nil
                                (if found (symbol-name v-or-f)))))
      (list (if (equal val "")
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index 3fb793e7aa..0196577206 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -30,7 +30,7 @@
 ;;; Code:
 
 (require 'button)
-(require 'cl-lib)
+(eval-when-compile (require 'cl-lib))
 (eval-when-compile (require 'easymenu))
 
 (defvar help-mode-map
@@ -400,6 +400,11 @@ describe-symbol-backends
             (get symbol 'variable-documentation)))
      ,#'describe-variable)))
 
+(defun help--find-symbol (sym)
+  (catch 'found
+    (cl-loop for seq the elements of describe-symbol-backends
+             do (when (funcall (nth 1 seq) sym)
+                  (throw 'found t)))))
 ;;;###autoload
 (defun help-make-xrefs (&optional buffer)
   "Parse and hyperlink documentation cross-references in the given BUFFER.
@@ -502,8 +507,7 @@ help-make-xrefs
                             ;;       (pop-to-buffer (car location))
                             ;;         (goto-char (cdr location))))
                             (help-xref-button 8 'help-function-def sym))
-                           ((cl-some (lambda (x) (funcall (nth 1 x) sym))
-                                     describe-symbol-backends)
+                           ((help--find-symbol sym)
                             (help-xref-button 8 'help-symbol sym)))))))
                 ;; An obvious case of a key substitution:
                 (save-excursion
-- 
2.11.0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.7)
 of 2017-02-21
Repository revision: 96cea19842b577eb4f2e057d702aea54d736233e





reply via email to

[Prev in Thread] Current Thread [Next in Thread]