From: npostavs@users.sourceforge.net
To: Drew Adams <drew.adams@oracle.com>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 19362@debbugs.gnu.org
Subject: bug#19362: 25.0.50; Fix `pp.el' in line with new `elisp-mode.el'
Date: Wed, 06 Jul 2016 20:26:49 -0400 [thread overview]
Message-ID: <87bn2acmye.fsf@users.sourceforge.net> (raw)
In-Reply-To: <126bba1e-3f86-4ae3-b7b5-59532f62e4f6@default> (Drew Adams's message of "Wed, 6 Jul 2016 23:51:47 +0000 (UTC)")
[-- Attachment #1: Type: text/plain, Size: 709 bytes --]
tags 19362 notabug
close 19362
quit
Drew Adams <drew.adams@oracle.com> writes:
>
> Sorry, but I have no more time to devote to this. I pointed to a
> time where the code was more or less the same between the two, and
> to a time where it had been changed to be really quite different.
Well, we could have all saved some time if you had taken your own advice
to diff the code; not pp.el vs elisp-mode.el, but emacs-24.5's
lisp-mode.el vs the new elisp-mode.el. You can see in the attached diff
(exerpted to leave only the relevant functions) that the only changes
are renaming of functions, and some minor refactoring in
elisp--preceding-sexp (it now handles ‘foo’ as well as `foo').
[-- Attachment #2: diff excerpts --]
[-- Type: text/x-diff, Size: 8838 bytes --]
--- /home/npostavs/src/emacs/emacs-24.5/lisp/emacs-lisp/lisp-mode.el 2016-05-21 14:56:43.119505998 -0400
+++ /home/npostavs/src/emacs/emacs-25/lisp/progmodes/elisp-mode.el 2016-06-27 00:32:51.740892449 -0400
@@ -879,14 +970,14 @@
(defun last-sexp-setup-props (beg end value alt1 alt2)
- "Set up text properties for the output of `eval-last-sexp-1'.
+ "Set up text properties for the output of `elisp--eval-last-sexp'.
BEG and END are the start and end of the output in current-buffer.
VALUE is the Lisp value printed, ALT1 and ALT2 are strings for the
alternative printed representations that can be displayed."
(let ((map (make-sparse-keymap)))
- (define-key map "\C-m" 'last-sexp-toggle-display)
+ (define-key map "\C-m" 'elisp-last-sexp-toggle-display)
(define-key map [down-mouse-2] 'mouse-set-point)
- (define-key map [mouse-2] 'last-sexp-toggle-display)
+ (define-key map [mouse-2] 'elisp-last-sexp-toggle-display)
(add-text-properties
beg end
`(printed-value (,value ,alt1 ,alt2)
@@ -897,7 +988,7 @@
printed-value)))))
-(defun last-sexp-toggle-display (&optional _arg)
+(defun elisp-last-sexp-toggle-display (&optional _arg)
"Toggle between abbreviated and unabbreviated printed representations."
(interactive "P")
(save-restriction
@@ -920,7 +1011,7 @@
(nth 1 value))
(goto-char (min (point-max) point)))))))
-(defun prin1-char (char)
+(defun prin1-char (char) ;FIXME: Move it, e.g. to simple.el.
"Return a string representing CHAR as a character rather than as an integer.
If CHAR is not a character, return nil."
(and (integerp char)
@@ -956,19 +1047,20 @@
(= (car (read-from-string string)) char)
string))))
-
-(defun preceding-sexp ()
+(defun elisp--preceding-sexp ()
"Return sexp before the point."
(let ((opoint (point))
- ignore-quotes
+ (left-quote ?‘)
expr)
(save-excursion
(with-syntax-table emacs-lisp-mode-syntax-table
- ;; If this sexp appears to be enclosed in `...'
+ ;; If this sexp appears to be enclosed in `...' or ‘...’
;; then ignore the surrounding quotes.
- (setq ignore-quotes
- (or (eq (following-char) ?\')
- (eq (preceding-char) ?\')))
+ (cond ((eq (preceding-char) ?’)
+ (progn (forward-char -1) (setq opoint (point))))
+ ((or (eq (following-char) ?\')
+ (eq (preceding-char) ?\'))
+ (setq left-quote ?\`)))
(forward-sexp -1)
;; If we were after `?\e' (or similar case),
;; use the whole thing, not just the `e'.
@@ -992,43 +1084,37 @@
(forward-sexp -1))))
(save-restriction
- ;; vladimir@cs.ualberta.ca 30-Jul-1997: skip ` in
- ;; `variable' so that the value is returned, not the
- ;; name
- (if (and ignore-quotes
- (eq (following-char) ?`))
+ (if (eq (following-char) left-quote)
+ ;; vladimir@cs.ualberta.ca 30-Jul-1997: Skip ` in `variable' so
+ ;; that the value is returned, not the name.
(forward-char))
+ (when (looking-at ",@?") (goto-char (match-end 0)))
(narrow-to-region (point-min) opoint)
(setq expr (read (current-buffer)))
- ;; If it's an (interactive ...) form, it's more
- ;; useful to show how an interactive call would
- ;; use it.
- (and (consp expr)
- (eq (car expr) 'interactive)
+ ;; If it's an (interactive ...) form, it's more useful to show how an
+ ;; interactive call would use it.
+ ;; FIXME: Is it really the right place for this?
+ (when (eq (car-safe expr) 'interactive)
(setq expr
- (list 'call-interactively
- (list 'quote
- (list 'lambda
- '(&rest args)
- expr
- 'args)))))
+ `(call-interactively
+ (lambda (&rest args) ,expr args))))
expr)))))
+(define-obsolete-function-alias 'preceding-sexp 'elisp--preceding-sexp "25.1")
-
-(defun eval-last-sexp-1 (eval-last-sexp-arg-internal)
+(defun elisp--eval-last-sexp (eval-last-sexp-arg-internal)
"Evaluate sexp before point; print value in the echo area.
-With argument, print output into current buffer.
-With a zero prefix arg, print output with no limit on the length
-and level of lists, and include additional formats for integers
-\(octal, hexadecimal, and character)."
+If EVAL-LAST-SEXP-ARG-INTERNAL is non-nil, print output into
+current buffer. If EVAL-LAST-SEXP-ARG-INTERNAL is `0', print
+output with no limit on the length and level of lists, and
+include additional formats for integers \(octal, hexadecimal, and
+character)."
(let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t)))
;; Setup the lexical environment if lexical-binding is enabled.
- (eval-last-sexp-print-value
- (eval (eval-sexp-add-defvars (preceding-sexp)) lexical-binding)
+ (elisp--eval-last-sexp-print-value
+ (eval (eval-sexp-add-defvars (elisp--preceding-sexp)) lexical-binding)
eval-last-sexp-arg-internal)))
-
-(defun eval-last-sexp-print-value (value &optional eval-last-sexp-arg-internal)
+(defun elisp--eval-last-sexp-print-value (value &optional eval-last-sexp-arg-internal)
(let ((unabbreviated (let ((print-length nil) (print-level nil))
(prin1-to-string value)))
(print-length (and (not (zerop (prefix-numeric-value
@@ -1055,7 +1141,7 @@
))))
-(defvar eval-last-sexp-fake-value (make-symbol "t"))
+(defvar elisp--eval-last-sexp-fake-value (make-symbol "t"))
(defun eval-sexp-add-defvars (exp &optional pos)
"Prepend EXP with all the `defvar's that precede it in the buffer.
@@ -1092,16 +1178,16 @@
this command arranges for all errors to enter the debugger."
(interactive "P")
(if (null eval-expression-debug-on-error)
- (eval-last-sexp-1 eval-last-sexp-arg-internal)
+ (elisp--eval-last-sexp eval-last-sexp-arg-internal)
(let ((value
- (let ((debug-on-error eval-last-sexp-fake-value))
- (cons (eval-last-sexp-1 eval-last-sexp-arg-internal)
+ (let ((debug-on-error elisp--eval-last-sexp-fake-value))
+ (cons (elisp--eval-last-sexp eval-last-sexp-arg-internal)
debug-on-error))))
- (unless (eq (cdr value) eval-last-sexp-fake-value)
+ (unless (eq (cdr value) elisp--eval-last-sexp-fake-value)
(setq debug-on-error (cdr value)))
(car value))))
-(defun eval-defun-1 (form)
+(defun elisp--eval-defun-1 (form)
"Treat some expressions specially.
Reset the `defvar' and `defcustom' variables to the initial value.
\(For `defcustom', use the :set function if there is one.)
@@ -1144,17 +1230,17 @@
(put face-symbol 'face-override-spec nil))
form)
((eq (car form) 'progn)
- (cons 'progn (mapcar 'eval-defun-1 (cdr form))))
+ (cons 'progn (mapcar #'elisp--eval-defun-1 (cdr form))))
(t form)))
-(defun eval-defun-2 ()
+(defun elisp--eval-defun ()
"Evaluate defun that point is in or before.
The value is displayed in the echo area.
If the current defun is actually a call to `defvar',
then reset the variable using the initial value expression
even if the variable already has some other value.
\(Normally `defvar' does not change the variable's value
-if it already has a value.\)
+if it already has a value.)
Return the result of evaluation."
;; FIXME: the print-length/level bindings should only be applied while
@@ -1177,7 +1263,7 @@
(setq end (point)))
;; Alter the form if necessary.
(let ((form (eval-sexp-add-defvars
- (eval-defun-1 (macroexpand form)))))
+ (elisp--eval-defun-1 (macroexpand form)))))
(eval-region beg end standard-output
(lambda (_ignore)
;; Skipping to the end of the specified region
@@ -1220,563 +1306,269 @@
(eval-defun (not edebug-all-defs)))
(t
(if (null eval-expression-debug-on-error)
- (eval-defun-2)
- (let ((old-value (make-symbol "t")) new-value value)
- (let ((debug-on-error old-value))
- (setq value (eval-defun-2))
+ (elisp--eval-defun)
+ (let (new-value value)
+ (let ((debug-on-error elisp--eval-last-sexp-fake-value))
+ (setq value (elisp--eval-defun))
(setq new-value debug-on-error))
- (unless (eq old-value new-value)
+ (unless (eq elisp--eval-last-sexp-fake-value new-value)
(setq debug-on-error new-value))
value)))))
-;; May still be used by some external Lisp-mode variant.
-(define-obsolete-function-alias 'lisp-comment-indent
- 'comment-indent-default "22.1")
-(define-obsolete-function-alias 'lisp-mode-auto-fill 'do-auto-fill "23.1")
+;;; ElDoc Support
next prev parent reply other threads:[~2016-07-07 0:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-13 2:46 bug#19362: 25.0.50; Fix `pp.el' in line with new `elisp-mode.el' Drew Adams
2016-04-30 16:26 ` Lars Ingebrigtsen
2016-04-30 17:36 ` Drew Adams
2016-04-30 17:43 ` Lars Ingebrigtsen
2016-04-30 18:16 ` Drew Adams
2016-04-30 18:33 ` Lars Ingebrigtsen
2016-07-01 2:04 ` npostavs
2016-07-01 3:07 ` Drew Adams
2016-07-06 20:39 ` Noam Postavsky
2016-07-06 22:35 ` Drew Adams
2016-07-06 23:36 ` Noam Postavsky
2016-07-06 23:51 ` Drew Adams
2016-07-07 0:26 ` npostavs [this message]
2016-07-07 2:34 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bn2acmye.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=19362@debbugs.gnu.org \
--cc=drew.adams@oracle.com \
--cc=larsi@gnus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.