all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: 16116@debbugs.gnu.org, Steve Purcell <steve@sanityinc.com>
Subject: bug#16116: 24.3.50; smie-indent-close aligns inner closing paren with the outer opening paren
Date: Sun, 15 Dec 2013 04:44:35 +0200	[thread overview]
Message-ID: <52AD1793.50901@yandex.ru> (raw)
In-Reply-To: <jwv61qqyjgi.fsf-monnier+emacsbugs@gnu.org>

On 15.12.2013 03:50, Stefan Monnier wrote:
>> I believe this argument also works against doing it in the rules
>> function, and in favor of adding a defvar.
>
> I don't think so: setting the var is a one-liner, adding the rule to the
> rule-function is also a one-liner.  So either way is just as easy for
> the major-mode.

I mean in terms of code reuse: the rules function is also specific to a 
major mode. The rule itself doesn't look like it'll take just one line 
to me, AFAICS it'll have to duplicate most of the code in 
`smie-indent-close':

     (`(:before . ,(or `")" `"]" `"}"))
      (save-excursion
        (forward-char 1)
        (condition-case nil
           (progn
             (backward-sexp 1)
             (cons 'column . (smie-indent-virtual)))
          (scan-error nil))))

If any other major mode wants to do the same, they have to duplicate 
this, or extract this code to a helper function in smie.el.

Using the rules function will also add 2-3 lines to `smie-indent-close'.

> By contrast, setting smie-indent-functions buffer-locally, then
> removing smie-indent-close from it and adding some other function
> requires a lot more code, and a lot more brittle as well (the ordering
> in smie-indent-functions is important, the set of functions in there and
> their order is not guaranteed to stay unchanged in future versions, the
> replacement function needs to be written (delegating to
> smie-indent-close seems like it might not work), ...

Looks like three lines to me. :)

(setq-local smie-indent-functions (copy-sequence smie-indent-functions))
(setcar (memq 'smie-indent-close smie-indent-functions)
         'ruby--smie-indent-close)

And the replacement function wouldn't be much longer than the added rule.





  reply	other threads:[~2013-12-15  2:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-12  1:57 bug#16116: 24.3.50; smie-indent-close aligns inner closing paren with the outer opening paren Dmitry Gutov
2013-12-12 12:55 ` Stefan Monnier
2013-12-12 16:30   ` Dmitry Gutov
2013-12-14  8:23 ` Steve Purcell
2013-12-14 14:13   ` Stefan Monnier
2013-12-14 15:04     ` Dmitry Gutov
2013-12-14 15:32       ` Stefan Monnier
2013-12-14 18:25         ` Dmitry Gutov
2013-12-15  1:50           ` Stefan Monnier
2013-12-15  2:44             ` Dmitry Gutov [this message]
2013-12-15 13:00               ` Stefan Monnier
2013-12-15 23:22                 ` Dmitry Gutov
2013-12-16 14:23                   ` Stefan Monnier
2013-12-17  3:03                     ` Dmitry Gutov

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=52AD1793.50901@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=16116@debbugs.gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    --cc=steve@sanityinc.com \
    /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.