Subject: bug#21922: Patch for fixing the "straight-quote" case

From: Luis Henriquez-Perez <[email-masked]>
Date: Mon, 23 Sep 2019 23:16:40 -0400

Hi,

In regards to the issue on the indentation of quoted lists, I'd like to
propose a patch.

It would be changing the predicate of this conditional in the function
`calculate-lisp-indent`.

(if
    (= (point) calculate-lisp-indent-last-sexp)
    ;; Containing sexp has nothing before this line
    ;; except the first element.  Indent under that element.
    nil
  ;; Skip the first element, find start of second (the first
  ;; argument of the function call) and indent under.
  (progn (forward-sexp 1)
         (parse-partial-sexp (point)
                             calculate-lisp-indent-last-sexp
                             0 t)))

It would to this:

(or
 (= (point) calculate-lisp-indent-last-sexp)

 (when-let (point (char-before containing-sexp))
   (char-equal point ?'))

 (let ((quoted-p nil)
       (point nil)
       (positions (nreverse (butlast (elt state 9)))))
   (while (and positions (not quoted-p))
     (setq point (pop positions))
     (setq quoted-p
           (or
            (and (char-before point)
                 (char-equal (char-before point) ?'))
            (save-excursion
              (goto-char (1+ point))
              (looking-at-p "quote[\t\n\f\s]+(")))))
   quoted-p))

This code checks if the `containing-sexp` is quoted and if so indents it
normally (under the first element).

It works for forms quoted with the quote abbreviation ie:
'(a b c d
  e f g)

It also works for explicit quoting:
(quote (a b c
            d e))

Additionally it works for nested lists that are quoted.

'((a b c
   d e))

Please let me know what you think.