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

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

[elpa] master c13c3dc 06/11: Improve names--top-of-namespace


From: Artur Malabarba
Subject: [elpa] master c13c3dc 06/11: Improve names--top-of-namespace
Date: Thu, 18 Jun 2015 17:30:25 +0000

branch: master
commit c13c3dcb567677df570d3fc75ea8daaaf19bdb4d
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    Improve names--top-of-namespace
---
 names-dev.el |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/names-dev.el b/names-dev.el
index 87a6d58..0c2dc20 100644
--- a/names-dev.el
+++ b/names-dev.el
@@ -152,12 +152,17 @@ If KILL is non-nil, kill the temp buffer afterwards."
            (kill-buffer b))))))
 
 (defun names--top-of-namespace ()
-  ""
-  (progn
-    (beginning-of-defun)
-    (ignore-errors
-      (backward-up-list))
-    (names--looking-at-namespace)))
+  "Move to the top of current namespace, and return non-nil.
+If not inside a namespace, return nil and don't move point."
+  (let ((top (save-excursion
+               (beginning-of-defun)
+               (ignore-errors
+                 (backward-up-list))
+               (when (names--looking-at-namespace)
+                 (point)))))
+    (when top
+      (goto-char top)
+      t)))
 
 (defun names-eval-defun (edebug-it)
   "Identical to `eval-defun', except it works for forms inside namespaces.
@@ -207,11 +212,11 @@ Argument EVAL-LAST-SEXP-ARG-INTERNAL is the same as 
`eval-print-last-sexp'."
 (defun names-pprint ()
   "Pretty-print an expansion of the namespace around point."
   (interactive)
-  (let ((ns (save-excursion
-              (names--top-of-namespace)
-              (cdr-safe (read (current-buffer))))))
-    (pp-macroexpand-expression
-     (macroexpand (cons 'names-print ns)))))
+  (save-excursion
+    (when (names--top-of-namespace)
+      (let ((ns (cdr (read (current-buffer)))))
+        (pp-macroexpand-expression
+         (macroexpand (cons 'names-print ns)))))))
 
 
 ;;; Find stuff



reply via email to

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