From: Lars Ingebrigtsen Date: Tue, 4 Jan 2022 14:50:56 +0000 (+0100) Subject: Improve pp-emacs-lisp-code for #' X-Git-Tag: emacs-29.0.90~3257 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0d315102fed8cecccbac15232304000df5b66406;p=emacs.git Improve pp-emacs-lisp-code for #' * lisp/emacs-lisp/pp.el (pp--insert-lisp): Format (function ...) as #'. --- diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el index a4dbd637553..d199716b2c5 100644 --- a/lisp/emacs-lisp/pp.el +++ b/lisp/emacs-lisp/pp.el @@ -24,6 +24,7 @@ ;;; Code: +(require 'cl-lib) (defvar font-lock-verbose) (defgroup pp nil @@ -233,13 +234,14 @@ Use the `pp-max-width' variable to control the desired line length." (cons (cond ((consp (cdr sexp)) (if (and (length= sexp 2) - (eq (car sexp) 'quote)) + (memq (car sexp) '(quote function))) (cond ((symbolp (cadr sexp)) (let ((print-quoted t)) (prin1 sexp (current-buffer)))) ((consp (cadr sexp)) - (insert "'") + (insert (if (eq (car sexp) 'quote) + "'" "#'")) (pp--format-list (cadr sexp) (set-marker (make-marker) (1- (point)))))) (pp--format-list sexp))) diff --git a/test/lisp/emacs-lisp/pp-resources/code-formats.erts b/test/lisp/emacs-lisp/pp-resources/code-formats.erts index 2b2001d0964..002a5cf1650 100644 --- a/test/lisp/emacs-lisp/pp-resources/code-formats.erts +++ b/test/lisp/emacs-lisp/pp-resources/code-formats.erts @@ -122,3 +122,9 @@ Name: code-formats11 (lambda () [(foo bar) (foo bar)]) =-=-= + +Name: code-formats12 + +=-= +(global-set-key (kbd "s-x") #'kill-region) +=-=-=