[Top][All Lists]

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

Re: [AUCTeX] adding function to LaTeX-math-list

From: Ivan Andrus
Subject: Re: [AUCTeX] adding function to LaTeX-math-list
Date: Wed, 12 Jan 2011 12:40:49 +0100

I'm afraid I learned it the slow hard way. :-(  However you might find
"Writing GNU Emacs Extensions" helpful.  I read it after I already knew
some, but it seemed like it might be nice starting at the beginning.  It's 
old, so somethings are out of date, but the main ideas should be useful.

Other than that, there is GNU's introduction:

and Xahlee's which has a lot of examples:

I haven't read either.


On Jan 11, 2011, at 10:11 PM, Michael Massmann wrote:

> Dear Ivan,
> many thanks for your kind response. Your solution works perfectly. I had
> indeed tried to modify the existing LaTeX-math-cal function but didn't
> realise that the (intercative) statement was necessary and I must have
> deleted it in the process of simplifying that function a little (it
> contains a further if statement, if I remember correctly).
> Can you recommend a consise Elisp tutorial that explains all of its main
> features, without going into as much detail as the manual? That would be
> handy in the future, I think.
> Thanks again for your help!
> Regards,
> Michael
> On 11/01/11 13:32, Ivan Andrus wrote:
>> On Jan 6, 2011, at 1:21 PM, Massmann, M. (Michael) wrote:
>>> Dear all,
>> I'm sorry noone has gotten back to you yet (unless they did so
>> off list).
>>> I’m new to Emacs: I hope my question is not too stupid.
>> Welcome.
>>> I’m trying to augment my LaTeX-math-list by a keybinding to insert
>>> \mathsf{}, akin to the \mathcal{} provided by Auctex by default. 
>> Actually I'm pretty sure that it provides \mathsf{} as well.  See
>> for example LaTeX-font-list, but perhaps you wanted something
>> else.  Ah, now I see that ` c x inserts \mathcal{x}.
>>> I have added
>>> (?\M-s LaTeX-math-sf)
>>> to LaTeX-math-list and then defined
>>> (defun LaTeX-math-sf (char)
>>>  "Insert a {\\mathscr CHAR}."
>>>  (insert "\\mathsf{" (char-to-string char) "}")
>>> )
>>> Yet when I execute the keybinding I get an error message saying:
>>> “Wrong type argument: commandp, LaTeX-math-sf”
>> In Emacs, a command is a special type of function which can be
>> called by the used.  It has to have an "interactive"
>> specification so that Emacs knows how to get the argument when
>> called from a keybinding.  So something like
>> (defun LaTeX-math-sf (char)
>>  "Insert a {\\mathscr CHAR}."
>>  (interactive "*c")
>>  (insert "\\mathsf{" (char-to-string char) "}"))
>> should work.  In fact, if I were you, I would just copy
>> `LaTeX-math-cal' and change the \mathcal to \mathsf.  That way
>> you know it's going to work the same for both.
>>> I’d be most grateful if someone could indicate what I’m doing wrong.
>>> Any hint is most welcome. Thanks!
>> I hope that helps.
>> -Ivan

reply via email to

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