emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/names 8a009ac 07/44: Merge branch 'elpa'


From: Stefan Monnier
Subject: [elpa] externals/names 8a009ac 07/44: Merge branch 'elpa'
Date: Sat, 27 Mar 2021 14:40:08 -0400 (EDT)

branch: externals/names
commit 8a009acc659b1d6cd48edc046e044b795b243570
Merge: 6a9b829 a11ba77
Author: Artur Malabarba <bruce.connor.am@gmail.com>
Commit: Artur Malabarba <bruce.connor.am@gmail.com>

    Merge branch 'elpa'
---
 UsageExample.org |  4 ++--
 names-dev.el     |  4 +---
 names.el         | 26 +++++++++++++++++++++++++-
 3 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/UsageExample.org b/UsageExample.org
index db49887..b27160e 100644
--- a/UsageExample.org
+++ b/UsageExample.org
@@ -10,7 +10,7 @@ The important items are already listed in the Readme:
 ;;; example.el --- Just an example
 
 ;;; You have to add this requirement!!
-;; Package-Requires: ((names "0.5"))
+;; Package-Requires: ((names "0.5") (emacs "24"))
 
 ;;; Code:
 
@@ -83,7 +83,7 @@ To see this expansion yourself.
 
 Follow these steps:
 
-1. Remember to list =names= as a dependency, and =require= it.
+1. Remember to list =names= as a dependency.
 2. Wrap all code that's to be namespaced inside a =(define-namespace NAME 
...)= macro.
 3. Pleasantly remove all that redundant repetition from you code!
 4. When quoting function names, use =#' = instead of = ' =.
diff --git a/names-dev.el b/names-dev.el
index cdaa681..0133604 100644
--- a/names-dev.el
+++ b/names-dev.el
@@ -211,9 +211,7 @@ Argument EVAL-LAST-SEXP-ARG-INTERNAL is the same as 
`eval-print-last-sexp'."
 (defalias 'find-function-read 'names--find-function-read)
 
 (defun names--find-function-read (&optional type)
-  "Identical to `eval-print-last-sexp', except it works for forms inside 
namespaces.
-Argument EVAL-LAST-SEXP-ARG-INTERNAL is the same as `eval-print-last-sexp'."
-  (interactive "P")
+  "Identical to `find-function-read', except it works inside namespaces."
   (let ((buf (current-buffer)))
     (names--wrapped-in-namespace
       (names--find-function-read-original type) nil t
diff --git a/names.el b/names.el
index b019231..2f9087b 100644
--- a/names.el
+++ b/names.el
@@ -584,6 +584,30 @@ Also adds `version' to `names--fbound' and `names--bound'."
                                      (cdr-safe def))
                                byte-compile-macro-environment))))))))
 
+;;;###autoload
+(defadvice find-function-search-for-symbol
+    (around names-around-find-function-search-for-symbol-advice
+            (symbol type library) activate)
+  "Make sure `find-function-search-for-symbol' understands namespaces."
+  ad-do-it
+  (ignore-errors
+    (unless (cdr ad-return-value)
+      (with-current-buffer (car ad-return-value)
+        (search-forward-regexp "^(define-namespace\\_>")
+        (skip-chars-forward "\r\n[:blank:]")
+        (let* ((names--regexp
+                (concat "\\`" (regexp-quote
+                               (symbol-name (read (current-buffer))))))
+               (short-symbol
+                ;; We manually implement `names--remove-namespace'
+                ;; because it might not be loaded.
+                (let ((name (symbol-name symbol)))
+                  (when (string-match names--regexp name)
+                    (intern (replace-match "" nil nil name))))))
+          (when short-symbol
+            (ad-set-arg 0 short-symbol)
+            ad-do-it))))))
+
 (defun names--extract-autoloads (body)
   "Return a list of the forms in BODY preceded by :autoload."
   (let (acons)
@@ -666,7 +690,7 @@ are namespaced become un-namespaced."
   (delq nil (mapcar 'names--remove-namespace (apply 'append lists))))
 
 (defun names--remove-namespace (symbol)
-  "Return SYMBOL with namespace removed, or nil if S wasn't namespaced."
+  "Return SYMBOL with namespace removed, or nil if it wasn't namespaced."
   (names--remove-regexp symbol names--regexp))
 
 (defun names--remove-protection (symbol)



reply via email to

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