Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help with creating shortcuts

11 views
Skip to first unread message

C K Kashyap

unread,
Jun 24, 2012, 3:57:28 AM6/24/12
to help-gn...@gnu.org
Hi All,
I've been defining functions to create shortcuts 

(defun (hw) (progn 
       (delete-fun) ; This is another function that deletes the actual function name from the buffer
       (insert "Hello World"))

I invoke it as follows - (hw)C-X-e, this removes (hw) and replaces it with Hello World.

the problem is that I have to type parenthesis. I explored abbreviations but they cannot seem to be parameterized. Can someone please suggest an alternative?

Regards,
Kashyap

Pascal J. Bourguignon

unread,
Jun 24, 2012, 9:51:32 AM6/24/12
to
Write it like this:

(defun hw ()
(interactive) ; makes it a command.
(insert "Hello World"))

Call it like this:

M-x hw RET


--
__Pascal Bourguignon__ http://www.informatimago.com/
A bad day in () is better than a good day in {}.

Mark Skilbeck

unread,
Jun 24, 2012, 6:14:19 PM6/24/12
to C K Kashyap, help-gn...@gnu.org
Adding to the previous answer, you might then be interested in the
YASnippet extension[1].

[1] https://github.com/capitaomorte/yasnippet#readme

On Sun, Jun 24, 2012 at 01:27:28PM +0530, C K Kashyap wrote:
> Hi All,
> I've been defining functions to create shortcuts
>
> (defun (hw) (progn
> (delete-fun) ; This is another function that deletes the actual
> function name from the buffer
> (insert "Hello World"))
>
> I invoke it as follows - (hw)C-X-e, this removes (hw) and replaces it with
> Hello World.
>
> the problem is that I have to type parenthesis. I explored abbreviations
> but they cannot seem to be parameterized. Can someone please suggest an
> alternative?
>
> Regards,
> Kashyap

--
- mgs.

if all you young men / were fish in the water
how many young girls / would undress and dive after

C K Kashyap

unread,
Jun 25, 2012, 4:31:06 AM6/25/12
to Mark Skilbeck, help-gn...@gnu.org
Thank you Mark,

I think, this will do.

Regards,
Kashyap
0 new messages