--- /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