emacs-devel
[Top][All Lists]
Advanced

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

Re: paren-close-dwim: elisp function of a newbie; feedback welcome


From: Davis Herring
Subject: Re: paren-close-dwim: elisp function of a newbie; feedback welcome
Date: Thu, 26 Sep 2013 14:38:14 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110717 Lanikai/3.1.11

>> (defun paren-close-dwim ()
>>   "Insert closing parenthesis from syntax table.
>> Use a normal parenthesis if not inside any."
>>   (interactive "*")
>>   (insert (or (ignore-errors
>>                 (save-excursion (backward-up-list)
>>                                 (cdr (syntax-after (point)))))
>>               ?\))))
> 
> I'm a total illiterate in elisp but the narrative so far sounds like a
> this code might do something really useful.
> 
> Can someone describe briefly how this would work, maybe with a small
> example, when repairing my own perl code?

I'm not sure what you mean about "repairing ... code".  This command
simply inserts ')', ']', or '}' (and perhaps '>' or so) to match the
most recent unclosed ([{<.

(If it is "really useful", know that it's not my idea; you just quoted
my reimplementation of Florian's code.)

Davis

-- 
This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.



reply via email to

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