Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 3 commits
  • 4 files changed
  • 2 commit comments
  • 1 contributor
View
2  etc/Lisp
@@ -1162,6 +1162,7 @@ set-buffer-fold-type-window
set-buffer-fold-type-window-update
set-buffer-fold-width
set-buffer-modified-p
+set-buffer-package
set-default
set-default-directory
set-default-fold-width
@@ -1595,6 +1596,7 @@ zerop
*filer-secondary-directory*
*filer-secondary-file-mask*
*filer-use-recycle-bin*
+*find-buffer-package-hook*
*find-file-auto-mode-function*
*find-file-file-not-found-hook*
*find-file-hooks*
View
2  lisp/cmds.l
@@ -655,7 +655,7 @@
(defun set-buffer-package (package-name)
(interactive
(list (completing-read
- "Package:" #1=(mapcar #'package-name (list-all-packages))
+ "Package: " #1=(mapcar #'package-name (list-all-packages))
:case-fold t
:default (or *buffer-package* "user")
:must-match t)))
View
63 lisp/lispmode.l
@@ -22,7 +22,7 @@
(defvar *lisp-mode-hook* nil)
(defvar *lisp-popup-completion-list* nil)
(defvar *lisp-interaction-mode-hook* nil)
-(defvar *find-buffer-package-hook* '())
+(defvar *find-buffer-package-hook* nil)
(defvar *lisp-indent-offset* nil)
(defvar *lisp-body-indention* 2)
(defvar *lisp-body-indent* 2)
@@ -192,21 +192,36 @@
(and ep (< ep p) (decf p 2))
p))))))))
+(defvar *lisp-search-in-package-regexp*
+ (compile-regexp
+ "^(\\(?:\\(?:lisp|cl|common-lisp\\)::?\\)?in-package\\([^)]+\\))"))
+
(defun lisp-search-in-package ()
(ignore-errors
- (save-excursion
- (or (scan-buffer "(\\(lisp:|lisp::\\)?in-package\\([^)]+\\))" :reverse t :regexp t)
- (scan-buffer "(\\(lisp:|lisp::\\)?in-package\\([^)]+\\))" :reverse nil :regexp t))
- (let (*read-eval*)
- (find-package (read-from-string (match-string 2)))))))
+ (protect-match-data
+ (save-excursion
+ (or (scan-buffer *lisp-search-in-package-regexp* :reverse t)
+ (scan-buffer *lisp-search-in-package-regexp* :reverse nil))
+ (let (*read-eval*)
+ (find-package (read-from-string (match-string 1))))))))
(defun find-buffer-package ()
(or (and (stringp *buffer-package*)
(find-package *buffer-package*))
- (dolist (func *find-buffer-package-hook*)
- (let ((ret (funcall func)))
- (when ret
- (return ret))))
+ (let ((result (ignore-errors
+ (run-hook-with-args-until-success
+ '*find-buffer-package-hook*))))
+ (cond ((packagep result) result)
+ ((or (symbolp result)
+ (stringp result))
+ (find (string result)
+ (mapcan
+ #'(lambda (p)
+ (copy-list
+ (cons (package-name p)
+ (package-nicknames p))))
+ (list-all-packages))
+ :test #'equalp))))
*package*))
(defun calc-lisp-indent (opoint)
@@ -349,25 +364,25 @@
(defun eval-region (from to &optional stream)
(interactive "r")
- (let ((result nil))
+ (let ((result nil)
+ (*package* (find-buffer-package)))
(when (> from to)
(rotatef from to))
(let ((s (make-buffer-stream (selected-buffer) from to)))
(handler-case
- (let ((*package* (find-buffer-package)))
- (while (< (buffer-stream-point s) to)
- (let ((form (read s nil '#1=#:eof)))
- (when (eq form '#1#)
- (return))
- (setq result (multiple-value-list (eval form))))))
+ (while (< (buffer-stream-point s) to)
+ (let ((form (read s nil '#1=#:eof)))
+ (when (eq form '#1#)
+ (return))
+ (setq result (multiple-value-list (eval form)))))
((or error reader-error quit) (c)
- (when (<= (buffer-stream-point s) to)
- (goto-char (buffer-stream-point s))
- (when stream
- (eval-region-print stream
- (format t "~A~%" c)))
- (let ((si:*trace-on-error* nil))
- (error c))))))
+ (when (<= (buffer-stream-point s) to)
+ (goto-char (buffer-stream-point s))
+ (when stream
+ (eval-region-print stream
+ (format t "~A~%" c)))
+ (let ((si:*trace-on-error* nil))
+ (error c))))))
(eval-region-print stream
(if (null stream)
(message "~s" (car result))
View
4 reference/reference.xml
@@ -1253,7 +1253,7 @@ eval-region時パッケージの決定は以下の順序になります。
2.*find-buffer-package-hook*の評価結果
補足:
- xyzzy 0.2.2.239? から利用可能です。
+ xyzzy 0.2.2.239 から利用可能です。
</description>
<seealso>eval-region</seealso>
<seealso>*buffer-package*</seealso>
@@ -24292,7 +24292,7 @@ buffer-fileio-encodingで参照することができます。
*buffer-package*を設定するコマンドです。
補足:
- xyzzy 0.2.2.239? から利用可能です。
+ xyzzy 0.2.2.239 から利用可能です。
</description>
<seealso>eval-region</seealso>
<seealso>*buffer-package*</seealso>

Showing you all comments on commits in this comparison.

@southly

orのバックスラッシュが抜けてますよ。
"^(\\(?:\\(?:lisp\\|cl\\|common-lisp\\)::?\\)?in-package\\([^)]+\\))" では?

@snmsts
Owner

ありがとうございます…xyzzyの正規表現を忘れてる…

Something went wrong with that request. Please try again.