I am currently using emacs and auctex to author my latex documents. This is, of course, fantastic. However, I would like to have emacs and/or auctex auto-fill the section label when using C-c C-e to make a new header. It should end up looking like this:
\section{This is a section title}
\label{sec:this-is-a-section-title}
with the label for the header the same as the title, but with no spaces. I don't know lisp or elisp, and I'd have no idea where to start. If anyone could help that would be great!
If you use RefTeX then C-c ( will do what you want (giving you the opportunity to change the label if you wish). Also C-c ) will insert \ref{...}, popping up a buffer to choose which label to use. It also does other stuff including working with bibliographies. You should definitely look into it.
I think it's now part of the AUCTeX distribution so that all you should have to do is add
(add-hook 'LaTeX-mode-hook (function turn-on-reftex))
(setq reftex-plug-into-AUCTeX t)
to your .emacs.
Related
I prefer not to use indentation in my LaTeX documents because it makes cooperating with users of other editors more difficult. This is typically pretty easy to achieve, except that Auctex likes to automatically indent whenever I use (fill-paragraph).
For example, if I have something like:
\begin{abstract}
Some series of sentences here.
\end{abstract}
When I run (fill-paragraph) I get something like
\begin{abstract}
Some series of
sentences here.
\end{abstract}
I don't want the filled text to be indented.
Note that I don't want to disable this functionality Emacs-wide, because I like being able to fill indented comments and such in other modes. I just don't want it to happen in Auctex.
How can I achieve this?
I've already seen this question [1], but it only has a partial solution for latex-mode, not Auctex.
[1] Emacs: Turn off indentation when doing a paragraph fill in LaTeX mode
If you set the customization variables LaTeX-indent-level and LaTeX-item-indent to 0 you'll get rid of most or all of AucTex's indentation.
You could do something like
(add-hook 'LaTeX-mode-hook
(lambda ()
(kill-local-variable 'line-indent-function)))
so as to disable LaTeX's indentation algorithm.
In org-mode, typing M-RET at the end of a headline will create a new headline of the same level on a new line. Can I replicate this functionality in rst-mode (especially for lists)? Currently M-RET is not defined, and it would be great if I can just press M-RET and rst-mode would intelligently add another list header. For example,
- Item1 <M-RET>
renders
- Item1
-
automatically.
It turns out that the rst.el included in the particular version of Emacs I'm using is old. You can get the newer rst.el from the Subversion repository, and put it into your load-path. Then, you can make rst-mode specific key binding to rst-insert-list:
(eval-after-load "rst"
'(progn
(define-key rst-mode-map (kbd "<M-RET>")
(lambda ()
(interactive)
(rst-insert-list)))))
Then you can use M-RET to make new list.
Thanks for Stefan Merten for his kind instructions in the mailing list.
You can also take a look at the Installation section of the Emacs Support for reStructuredText documentation.
all
Now I'm editing c sources with emacs under c-mode. How ever auto-fill-mode doesn't seem to work at all. Here how I enabled and tried to use it.
M-x auto-fill-mode (enable auto-fill-mode)
Typed in a line longer than auto-fill size(which 80 characters for now) --> didn't break the line
Tried to auto-filled by issuing M-q
However above attempt didn't work out at all.
Could anybody point out that what have I done wrong?
Thanks for your help in advance.
When you use auto-fill-mode in c-mode, the default behavior is to wrap text only when writing text, as in a comment. You can override this by customizing the value of c-ignore-auto-fill. Note that emacs will wrap and indent your code as text, which is probably not what you want.
A better solution is probably to bind space to a function like this:
(defun insert-space-or-newline-and-indent ()
(interactive)
(if (>= (current-column) fill-column)
(newline-and-indent)
(insert-char ? )))
I am trying to use setnu.el to give me line numbers in emacs, which as you might imagine I want in pretty much every mode. It seemed like the preffered way of doing this in Emacs is to use
(add-hook 'text-mode-hook 'turn-on-setnu-mode)
but this isn't working for me. Using
(add-hook 'emacs-lisp-mode-hook 'turn-on-setnu-mode)
works just fine when I am editing emacs lisp files, but I want line numbers in all my text viewing and don't want to have a special case for each kind of file in my init.d file. Help would be much appreciated.
Linum seems to be distributed with emacs >=22.
Try:
(require 'linum)
Then toggle the display of line numbers with
M-x linum-mode
http://web.student.tuwien.ac.at/~e0225855/linum/linum.html
I'm kind of a newb when it comes to emacs. I know about the .emacs file but have very little idea as to do anything more advanced than elementary stuff.
Whenever I enter latex-mode, I'd also like to automatically turn on flyspell-mode, reftex-mode, auto-fill-mode, and also set fill-column to 120. How do I edit my .emacs file to do this?
Thanks!
(add-hook 'latex-mode-hook
(function (lambda ()
(flymake-mode)
(reftex-mode)
(auto-fill-mode)
(setq fill-column 120))))
for example should work.
You can set a so-called hook to a major mode. Have a look at this page of the manual for some examples.