help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: on adding a function call to a s-exp


From: Robert Girault
Subject: Re: on adding a function call to a s-exp
Date: Sun, 10 Jun 2018 21:59:58 -0300

Noam Postavsky <npostavs@gmail.com> writes:

> On 9 June 2018 at 18:05, Robert Girault <rfrancoisgirault@gmail.com> wrote:
>> In Lisp mode, when I select a region, in whatever way of selecting it,
>> and press (, it surrounds the region with parentheses, (...|), but it
>
> Hmm, that must be some package you have installed, by default ( just
> inserts a ( at point without wrapping anything.

You're correct.  I had actually:

(show-paren-mode)
(electric-pair-mode)
(autoload 'enable-paredit-mode "paredit"
    "Turn on pseudo-structural editing of Lisp code."
     t)
(add-hook 'M-mode-hook 'enable-paredit-mode)

>> puts the point where ``|'' is.  I'd like the point to be at (|...) so
>> I can add a function call to that region without having to move the
>> point back to the beginning of the region.
>>
>> I'm surprised this isn't the default behavior.
>
> In emacs -Q M-( does what you want.
>
>   M-( runs the command insert-parentheses (found in global-map), which
>   is an interactive compiled Lisp function in ‘lisp.el’.
>
>   It is bound to M-(.
>
>   (insert-parentheses &optional ARG)
>
>   Enclose following ARG sexps in parentheses.
>   Leave point after open-paren.
>   [...]
>   If region is active, insert enclosing characters at region boundaries.

Where the point ends up depends on how one selects the region.  If the
region is selected from end to beginning, the point ends up on the
opening (.  If from beginning to end, after the closing ).

My desire is to always leave it after the opening ( because I think
whenever I surround a region with parentheses, it's usually because I'll
apply a function to that region.  This is the default behavior in
DrRacket.

Is there any minor mode that does or should I hack something up?  Thanks!


reply via email to

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