[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sly b501b43350 2/2: Fix #514: Unconfuse sly-package-fu--cr
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sly b501b43350 2/2: Fix #514: Unconfuse sly-package-fu--create-new-import-from |
Date: |
Sat, 4 Jun 2022 10:58:42 -0400 (EDT) |
branch: elpa/sly
commit b501b4335096fd4306c2c1eb86382b69e91c09e5
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>
Fix #514: Unconfuse sly-package-fu--create-new-import-from
This function was trying to go again to the relevant DEFPACKAGE
definition, except that point IS already at such a place. Apparently,
sly-current-package returns nil in some situations and so this
needless repetition was actually harmful.
Charles Jackson <charles.b.jackson@protonmail.com>, discovered this
problem and put forth a fix. This is a simplified version of that
fix.
* contrib/sly-package-fu.el
(sly-package-fu--create-new-import-from): Don't go to source definition
again.
(sly-package-fu--add-or-update-import-from-form): Clean up comments.
(sly-package-fu--search-import-from): Remove spurious newline.
---
contrib/sly-package-fu.el | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/contrib/sly-package-fu.el b/contrib/sly-package-fu.el
index f13d9cfb68..6e57b6761f 100644
--- a/contrib/sly-package-fu.el
+++ b/contrib/sly-package-fu.el
@@ -349,7 +349,6 @@ symbol in the Lisp image if possible."
;;
(defun sly-package-fu--search-import-from (package)
-
(let* ((normalized-package (sly-package-fu--normalize-name package))
(regexp (format "(:import-from[ \t']*\\(:\\|#:\\)?%s"
(regexp-quote (regexp-quote normalized-package)))))
@@ -357,7 +356,8 @@ symbol in the Lisp image if possible."
(defun sly-package-fu--create-new-import-from (package symbol)
- (sly-goto-package-source-definition (sly-current-package))
+ "Add new :IMPORT-FROM subform for PACKAGE. Add SYMBOL.
+Assumes point just before start of DEFPACKAGE form"
(forward-sexp)
;; Now, search last :import-from or :use form
(cond
@@ -391,7 +391,7 @@ package. For example above, return \"with-gensyms\"."
symbol)))
(simple-symbol (sly-cl-symbol-name symbol)))
(save-excursion
- ;; First go to package definition form
+ ;; First go to just before relevant DEFPACKAGE form
;;
(sly-goto-package-source-definition (sly-current-package))
@@ -402,8 +402,8 @@ package. For example above, return \"with-gensyms\"."
,(sly-current-package)
,package))
(if (sly-package-fu--search-import-from package)
- ;; If the (:import-from PACKAGE... ) subform exists, attempt
- ;; to insert SYMBOL (qualified as simple-symbol) there.
+ ;; If specific (:IMPORT-FROM PACKAGE... ) subform exists,
+ ;; attempt to insert package-less SYMBOL there.
(let ((imported-symbols (mapcar #'sly-package-fu--normalize-name
(sly-package-fu--read-symbols))))
(unless (cl-member simple-symbol
@@ -411,8 +411,9 @@ package. For example above, return \"with-gensyms\"."
:test 'cl-equalp)
(sly-package-fu--insert-symbol simple-symbol)
(when sly-package-fu-save-file (save-buffer))))
- ;; Else add a new :import-from PACKAGE subform, after the last
- ;; existing :import-from or :use subform.
+ ;; Else, point is unmoved. Add a new (:IMPORT-FROM PACKAGE)
+ ;; subform after any other existing :IMPORT-FROM or :USE
+ ;; subforms.
(sly-package-fu--create-new-import-from package
simple-symbol)
(when sly-package-fu-save-file (save-buffer)))