emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs Lisp code formatting


From: Michael Heerdegen
Subject: Re: Emacs Lisp code formatting
Date: Sun, 07 Nov 2021 02:37:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Lars Ingebrigtsen <larsi@gnus.org> writes:

> with `pp-emacs-lisp-code'.

Cool - thanks for that.

May I ask why something like (pp-emacs-lisp-code '(when t 1)) fails -
can you have a look please?  Seems there is a minor problem with edebug
spec inspection.

  (wrong-type-argument listp t)
  car(t)
  (consp (car edebug))
  (and (consp (car edebug)) (eq (car (car edebug)) '&rest))
  (if (and (consp (car edebug)) (eq (car (car edebug)) '&rest)) 
(pp--insert-binding (car-safe (prog1 sexp (setq sexp (cdr sexp))))) (if (null 
(car sexp)) (insert "()") (pp--insert-lisp (car sexp))) (car-safe (prog1 sexp 
(setq sexp (cdr sexp)))))
  (while (and (cl-plusp indent) sexp) (insert " ") (if (and (consp (car 
edebug)) (eq (car (car edebug)) '&rest)) (pp--insert-binding (car-safe (prog1 
sexp (setq sexp (cdr sexp))))) (if (null (car sexp)) (insert "()") 
(pp--insert-lisp (car sexp))) (car-safe (prog1 sexp (setq sexp (cdr sexp))))) 
(car-safe (prog1 edebug (setq edebug (cdr edebug)))) (setq indent (1- indent)))
  pp--format-definition((t 1) 1 t)
  (if indent (pp--format-definition sexp indent edebug) (let ((prev 0)) (while 
sexp (let ((start (point))) (pp--insert (if (> prev 1) "\n" " ") (car-safe 
(prog1 sexp (setq sexp ...)))) (setq prev (count-lines start (point)))))))
  (let* ((sym (car sexp)) (edebug (get sym 'edebug-form-spec)) (indent (get sym 
'lisp-indent-function)) (doc (get sym 'doc-string-elt))) (if (eq indent 'defun) 
(progn (setq indent 2))) (if doc (progn (setq indent (1- doc)))) (if (and (not 
indent) (eq sym 'closure)) (progn (setq indent 0))) (pp--insert "(" sym) 
(car-safe (prog1 sexp (setq sexp (cdr sexp)))) (if indent 
(pp--format-definition sexp indent edebug) (let ((prev 0)) (while sexp (let 
((start (point))) (pp--insert (if (> prev 1) "\n" " ") (car-safe (prog1 sexp 
...))) (setq prev (count-lines start (point))))))) (insert ")"))
  pp--format-function((when t 1))
  [...]

Thanks,

Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]