all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Luis Henriquez-Perez <luishenriquezperez@gmail.com>
To: 21922@debbugs.gnu.org
Subject: bug#21922: Patch for fixing the "straight-quote" case
Date: Mon, 23 Sep 2019 23:16:40 -0400	[thread overview]
Message-ID: <CAKVVwxe9ESd_Xwdu0vaj3C=woHSOcRS=YTvqUy61MfTs4v1jQg@mail.gmail.com> (raw)
In-Reply-To: <56477DA2.70104@live.com>

[-- Attachment #1: Type: text/plain, Size: 1584 bytes --]

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.

[-- Attachment #2: Type: text/html, Size: 3101 bytes --]

  parent reply	other threads:[~2019-09-24  3:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-14 18:29 bug#21922: Indentation of Emacs Lisp list constants is surprising Clément Pit--Claudel
2015-11-15 19:28 ` Eli Zaretskii
2015-11-16  0:33 ` Dmitry Gutov
2019-09-24  3:16 ` Luis Henriquez-Perez [this message]
2019-10-09  3:41   ` bug#21922: Patch for fixing the "straight-quote" case Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKVVwxe9ESd_Xwdu0vaj3C=woHSOcRS=YTvqUy61MfTs4v1jQg@mail.gmail.com' \
    --to=luishenriquezperez@gmail.com \
    --cc=21922@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.