From: Rupert Swarbrick <rswarbrick@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: elisp questions for Advanced Closing brackets function
Date: Wed, 21 May 2008 11:28:18 +0100 [thread overview]
Message-ID: <g10tg2$r9p$1@news.albasani.net> (raw)
In-Reply-To: mailman.11944.1211359652.18990.help-gnu-emacs@gnu.org
"Lorenzo Isella" <lorenzo.isella@gmail.com> writes:
> Dear All,
> My questions are even more basic than the ones expressed here.
> I would like to do some "trivial" emacs customization.
> First of all, I should say I am not a lisp programmer at all and that
> my .emacs file
> is at the present a patchwork of examples I found online.
> Yet, what I would like to do should be quite simple.
> A few examples:
> (1) I often use auctex, but when I open a tex file I would like to
> have pdflatex as
> the default, so I would like to skip the tedious C-c C-t C-p.
> How can I include this command in the .emacs file? Obviously it should
> be executed only when I am opening and reading a .tex file.
Ok, I didn't know the answer to this at first, so here's how I found it:
Firstly, what does C-c C-t C-p run? (I know what it does, but what
function name?) Use C-h c which tells you the name of the function
bound to the given key sequence.
C-h c C-c C-t C-p gives TeX-PDF-mode. Now, what does that do? Well,
let's look at its docs: C-h f TeX-PDF-mode
Gives:
,----
| TeX-PDF-mode is an interactive compiled Lisp function in <long stuff>
| It is bound to C-c C-t C-p.
| (TeX-PDF-mode &optional ARG)
|
| Minor mode for using PDFTeX.
|
| If enabled, PDFTeX will be used as an executable by default.
| You can customize an initial value, and you can use the
| function `TeX-global-PDF-mode' for toggling this value.
`----
Ahah! So we want to know about TeX-global-PDF-mode! Roight, let's look
at that function, using C-h f TeX-global-PDF-mode. Well that says:
,----
| TeX-global-PDF-mode is an interactive compiled Lisp func <blah blah>
| (TeX-global-PDF-mode &optional ARG)
|
| Toggle default for `TeX-PDF-mode'.
`----
(Ye gods, will we ever get there?!) But TeX-PDF-mode is a variable,
which is looking promising. Maybe we can use customise. Finally (!)
call C-h v TeX-PDF-mode and you'll see near the bottom of the help
page a link to customise the variable. Tada!
I realise this is a roundabout way to get the answer, but maybe this
answer will help you solve the next problem you come across.
> (2) Here is something I do not understand. I found online the
> following handy function for automatically inserting another "$" sign
> when I type one and moving back the cursor:
>
> (defun TeX-insert-dollar () "custom redefined insert-dollar" (interactive)
> (insert "$$") ;in LaTeX mode, typing "$" automatically insert "$$"
> (backward-char 1)) ;and go between them: no more matching problems!
>
> Then, I tried doing something similar when quoting:
>
> (defun TeX-insert-quote () "custom redefined insert-quote" (interactive)
> (insert "``''")
> (backward-char 2))
>
> and it worked. However, when I tried doing the same with brackets:
>
> (defun TeX-insert-curly () "custom redefined insert-curly" (interactive)
> (insert "{}")
> (backward-char 1))
>
> I did not get any error message, but it surely does not work on my
> system.
What is happening is that you are (successfully) *redefining* the
functions TeX-insert-quote and TeX-insert-dollar, which were
originally defined somewhere in the depths of auctex and bound to the
keys " and $ respectively.
What you need to do is get auctex to run your TeX-insert-curly when
you hit { in the same way. The following should work:
(local-set-key "{" 'TeX-insert-curly)
But it needs to get run whenever you enter tex mode, so you can't just
plonk it in your .emacs (otherwise it would apply to emacs lisp mode,
I think) and instead need to run it on what is called a mode
hook. Since you haven't done much elisp and this is a bit obscure, the
magic incantation to put in your .emacs is
(add-hook 'TeX-mode-hook
(lambda () (local-set-key "{" 'TeX-insert-curly)))
(after you've defined TeX-insert-curly)
Rupert
next parent reply other threads:[~2008-05-21 10:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.11944.1211359652.18990.help-gnu-emacs@gnu.org>
2008-05-21 10:28 ` Rupert Swarbrick [this message]
2008-05-21 10:33 ` elisp questions for Advanced Closing brackets function Rupert Swarbrick
2008-05-21 18:30 ` Ralf Angeli
2008-05-21 18:40 ` Rupert Swarbrick
2008-05-21 20:14 ` Ralf Angeli
[not found] <mailman.11908.1211307132.18990.help-gnu-emacs@gnu.org>
2008-05-21 9:09 ` Tim X
2008-05-21 8:47 Lorenzo Isella
-- strict thread matches above, loose matches on Subject: below --
2008-05-20 18:12 TheLonelyStar
2008-05-20 18:24 ` Drew Adams
2008-05-20 20:04 ` TheLonelyStar
2008-05-20 20:19 ` Drew Adams
2008-05-21 6:18 ` Pierre Lorenzon
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='g10tg2$r9p$1@news.albasani.net' \
--to=rswarbrick@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).