Fix scheme indent advice

Logical branches were incorrectly grouped. Also, I've documented my
other changes to the original function.
This commit is contained in:
Henrik Lissner 2020-05-01 01:22:14 -04:00
parent 8452788056
commit 504d1388cf
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -15,15 +15,18 @@ lists properly and names starting with 'default'."
(if (and (elt state 2) (if (and (elt state 2)
;; NOTE looking-at -> looking-at-p ;; NOTE looking-at -> looking-at-p
(not (looking-at-p "\\sw\\|\\s_"))) (not (looking-at-p "\\sw\\|\\s_")))
(unless (> (save-excursion (forward-line 1) (point)) (progn
calculate-lisp-indent-last-sexp) ;; NOTE (if (not ...) (progn ...)) -> (unless ... ...)
(goto-char calculate-lisp-indent-last-sexp) (unless (> (save-excursion (forward-line 1) (point))
(beginning-of-line) calculate-lisp-indent-last-sexp)
(parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)) (goto-char calculate-lisp-indent-last-sexp)
(backward-prefix-chars) (beginning-of-line)
(current-column) (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t))
(backward-prefix-chars)
(current-column))
(let* ((function (buffer-substring (let* ((function (buffer-substring
(point) (progn (forward-sexp 1) (point)))) (point) (progn (forward-sexp 1) (point))))
;; NOTE let -> let* & moved `method' def into let bindings
(method (or (get (intern-soft function) 'scheme-indent-function) (method (or (get (intern-soft function) 'scheme-indent-function)
(get (intern-soft function) 'scheme-indent-hook)))) (get (intern-soft function) 'scheme-indent-hook))))
(cond ((or (eq method 'defun) (cond ((or (eq method 'defun)
@ -32,11 +35,12 @@ lists properly and names starting with 'default'."
;; NOTE string-match -> string-match-p ;; NOTE string-match -> string-match-p
;; NOTE The original regexp is "\\`def" but it will mess ;; NOTE The original regexp is "\\`def" but it will mess
;; indentation with such names as 'default-...'. ;; indentation with such names as 'default-...'.
(string-match-p "\\`define" function))) (string-match-p "\\`def" function)))
(lisp-indent-defform state indent-point)) (lisp-indent-defform state indent-point))
;; NOTE Added this clause to handle alignment of keyword symbols ;; NOTE Added this clause to handle alignment of keyword symbols
((and (null method) ((and (null method)
(> (length function) 1) (> (length function) 1)
;; NOTE string-match -> string-match-p
(string-match-p "\\`:" function)) (string-match-p "\\`:" function))
(let ((lisp-body-indent 1)) (let ((lisp-body-indent 1))
(lisp-indent-defform state indent-point))) (lisp-indent-defform state indent-point)))