AUCTeX column marker - emacs

I am using Emacs and just built AUCTeX for LaTeX. Anyway, as I was using column-marker extension while writing in LaTeX without AUCTeX, it is not working anymore with it. I was looking over the internet but couldn't find any help. Is there an elisp code line that allows to use column-marker on AUCTeX?

It works for me in emacs 24.3.1 with the built-in auctex and column-marker.el Update #: 312.
Here you have got an example (right window):
The deviation from the straight line comes from the different fonts/font sizes used for the caret and exponent, for the section titles and so on.
Inspite of that column-marker shows one the column with the specific character distance from the beginning of line.

Related

How to write text inside a rectangle in emacs artist-mode?

I am learning artist-mode in emacs and finding it pretty interesting.
I want to create shapes and write text inside them as we can do with other software where one can draw shapes.
However, when I type some characters inside a rectangle, the shape gets distorted. The vertical line gets shifted by some characters.
Please see attached image.
Is there something I can do to fix it? Or is it a bug in artist-mode. I watched some screencasts and videos and did not remember anyone mentioning anything about this odd behavior.
I am on Mac and my emacs version is
GNU Emacs 25.1.1 (x86_64-apple-darwin16.0.0, NS appkit-1504.00 Version 10.12 (Build 16A323))
Try this before you type text into a rectangle.
C-x h (Select the whole buffer.)
M-x untabify <RET>
This will make you buffer tab free, which should solve the problem when you are typing.
Note that you should avoid using backspace for deleting text. Move your cursor and overwrite them instead.
There is a workaround I found for this cases.
select text mode
add the relevant text, RET
type term RET (here we specify the font)
RET (No ARGS for figlet, might also depend upon use-cases)
It may be a bit clumsy, but I usually do
select text mode
press Insert (Ovwrt)
add text
enter artist mode
I'm surprised not to see overwrite-mode. This replaces text at point rather than inserting it.
People have mentioned untabify to change tabs to spaces. Use whitespace-mode to see where those tabs (and spaces) are.

show repeated selected text in emacs

I don't know which text editor have it but when you select text it show up where the same text appear in text with a box. It's usefull when you select variable and it show up where it's use in the code.
The text can show up with different backgorund when I copy the text and then call the function and dissapear when position of the cursor change.
Is it possible to do this in Emacs (probably is but how)?
Yes, Emacs has that (highlight matches of a given symbol or other pattern). Sounds like any of these correspond to what you are looking for:
Incremental search (aka isearch): C-s or C-M-s, then type what you want to match (or use C-w... to pick it up from the buffer).
Library highlight-symbol.
Library highlight, command hlt-highlight-symbol. (And see option `hlt-auto-faces-flag.) Does what library highlight-symbol does, and more.
Emacs 24.4 (i.e., current development snapshot), command hi-lock-face-symbol-at-point.
If you use library mouse3.el then right-clicking the mouse gives you the last two alternatives for the symbol under the mouse pointer.
You can maybe try to use cedet with ECB on Emacs.
You can install it with Meta+x list-packages or you can try another IDE like Kdevelop.

Emacs - How to keep text formatted to other editors?

I'm a beginner with emacs. Altough I'm finding it amusing and challenging, I still don't know some basic things, like, when I open a text or a piece of script wrote in another editors, emacs don't show the text formatted properly (missing all tabs, all text left-aligned) and vice-versa.
Also, when I copy a link with emacs with M-w, my clipboard is still empty and I can't paste it in a browser. I already did my "homework". I've read the tutorial and I'm almost finishing the manual and didn't see anything to address that.
tnx in advance.
Some editors, like Intellij IDEA for example, will indent code based on how they understand it and not based on how it was actually indented, there's no Emacs mode that operates in the same way, not to my best knowledge. If you were using something like Eclipse or MS Visual Studio before - then you probably just have a different size of tab character (this is why some programmers insist on indenting code with spaces rather than tabs). But the width of the tab character is adjustable. In order to customize it you would:
add in your initialization file (usually .emacs file in your $HOME directory, you can create one, if it is not there yet):
;; makes tab character as wide as four space characters
(setq default-tab-width 4)
though some other major editing modes override this variable, you would need to tell what language you are dealing with to get better instructions.
Clipboard, see this answer: How to copy text from Emacs to another application on Linux if you are on Linux, then likely you need to set x-select-enable-clipboard to t.
Aligning text to the right (or left for LTR languages) is not possible in Emacs, as far as I understand. You could align block of text, if you split it into lines and align on the line ends, but that would mean aligning by adding spaces at the beginning - something you don't really want to do.
Tabs should work (you might need to fix the width). Use mouse to select to the clipboard, or use CtrlInsert to copy and ShiftDelete to cut.
Assuming emacs has picked the right mode for the file - it usually does - you can press C-x h to select all, then TAB to indent all selected lines. What other editors are you using, and what platform(s)?
As for the clipboard issue, some builds of emacs work correctly with the native clipboard, some don't. You might want to investigate CUA mode.

emacs + latex + yasnippet: Why are newlines inserted after a snippet?

Everytime I insert a snippet (with yasnippet) in a .tex document, I obtain a newline after the snippet. This is quite annoying for small snippets that are typically used in text style. How can I avoid that?
I read a bit about the problem (http://code.google.com/p/yasnippet/issues/detail?id=115 or http://yasnippet.googlecode.com/svn/trunk/doc/faq.html) but couldn't find a solution. Reproduce it as follows (I work with Aquamacs 2.3a on Mac OS X 10.6.8 with yasnippet version 0.6.1c):
Define ~/Library/Preferences/Aquamacs Emacs/Preferences.el to be:
(require 'yasnippet)
(yas/initialize)
(yas/load-directory "~/Library/Preferences/Aquamacs Emacs/plugins/yasnippet-0.6.1c/snippets")
define the following snippet (call it "bm.yasnippet" [bm = boldmath]; the star * symbolizes where the cursor ends -- note that there is no newline after the snippet)
# name: \bm{}{}
# key: bm
# --
\bm{$1}*
restart Aquamacs and open a .tex file and type in bm + Tab [this should insert the snippet]
A newline is added after the snippet. This is quite inconvenient since \bm{foo} is typically used in text style, so for example in "The vector \bm{x} is not the null vector". A typical cause of this is that the snippet ends with a newline which is then inserted, too. However, I specifically obtain this behavior even the snippet does not end with a newline.
I can't repro it with plain Emacs. In fact, I had this exact issue, but my problem is I had require-final-newline set to t. So Emacs was adding a newline at the end of my template.
My setup is a little more complicated but the solution for you is probably to set mode-require-final-newline to nil and restart Emacs.
To verify this is the problem, open up the template and check for the final newline.
Thanks to the answers in Temporarly disable adding of newlines in Emacs, I'm using a function to only temporarily disable the adding of final newlines in the current buffer:
(defun disable-final-newline ()
(interactive)
(set (make-local-variable 'require-final-newline) nil))
the reason why u got a new line is that your snippet has space or tab at the end.
Ctrl+e and Ctrl+k to kill them will make it works, nearly 1 hour to figure it out...
I had a similar issue with a few snippets, one of that was \frac{}{} which I use quite often.
The snippet version of frac that I use is not the one bundled with yasnippets.
The issue was that I edited some of the snippets in VIM and when you save the file, VIM automatically appends a newline to it.
To resolve it I had to remove the newline in a different editor e.g. emacs.

Emacs remember text selection

I decided that I was ready to try something new, after a few years of using gEdit for most of my coding needs, and try to learn using Emacs. I knew this would be difficult, as I have heard how complex Emacs can be, but I was lured by its power. The hardest thing has been getting used to writing ELisp in the .emacs file to change things about the editor. I can't currently do it myself, but I have found a few helpful snippets here and there to change some options.
One thing I have been having a lot of problems with is getting Emacs to remember the text I have selected after a command. For instance, I commonly highlight a section of code to mass indent it. However, if I do this in Emacs, it will move the selected text only once before unselecting all of the text. Does anyone know a way around this?
Anyway, I apologize for what seems to me to be an easy question, but after an hour of Google searching and looking around here on SO, I thought it was worth asking. I have a few more questions about Emacs, but I will save them and ask separately after I get this straightened out. Thanks!
UPDATE
A few people have asked about what mod I am using and what type of text I am entering. While I don't know much about Emacs modes, I am editing a pure text file at the moment. Something like this:
Hello, I am a simple text file
that is made up of three separate
lines.
If I highlight all three lines and hit TAB, I get this:
Hello, I am a simple text file
that is made up of three separate
lines.
This is great, however, if I use C-x C-x like some suggest below to reselect the text and hit TAB again, I get this:
Hello, I am a simple text file
that is made up of three separate
lines.
I hope this helps!
FWIW, here is the reason for the behaviour of your newly-added example. (I'm not 'solving' the issue here, but I'm posting it to demystify what you're seeing.)
This was determined with emacs -q which disables my customisations, so the following is default behaviour for emacs 23.2.
You are in text-mode. You should see (Text) or similar in the mode line at the bottom of the screen, and C-h m will tell you (under the list of minor modes) "Text mode: Major mode for editing text written for humans to read." Emacs decides (by way of the auto-mode-alist variable) that it should switch to text-mode if you visit a filename matching certain extensions (such as .txt).
In text-mode pressing TAB with a region highlighted causes indent-according-to-mode to be called on each line of the region in sequence. The slightly convoluted path to finding this out starts at C-h k TAB, which tells us that TAB is bound to indent-for-tab-command, which in this instance calls indent-region -- that function name is not stated explicitly in the help, but can be seen in the code -- which checks the buffer-local indent-region-function variable, which is nil, and: "A value of nil means really run indent-according-to-mode on each line."
indent-according-to-mode checks the indent-line-function variable, which has the buffer-local value indent-relative.
Use C-h f indent-relative RET to see the help for this function. (Read this).
Although you probably won't yet have had the experience to know how to check all that (or necessarily even want to!), and fully understand everything it tells you, this is an example of how the self-documenting aspect of Emacs enables a user to figure out what is going on (which then makes it feasible to change things). I essentially just used C-h k (describe-key), C-h f (describe-function), and C-h v (describe-variable) to follow the documentation. Looking at the source code for indent-for-tab-command was as simple as clicking the file name shown as part of its help page.
I suggest doing the following to help see what is happening when indent-relative runs on each line:
M-x set-variable x-stretch-cursor t
M-x set-variable ruler-mode-show-tab-stops t
M-x ruler-mode
Now for each line in turn, put the cursor at the very start of the line and press TAB. You'll end up with all three lines indented to the first tab-stop ('T' in the ruler).
Now repeat this -- again, ensure you are at the very start of each line, in front of the existing indentation.
The first character of the first line (which is currently a tab) is once again indented to the first tab-stop, as there is no preceding line for it to examine.
Next, the first character of the second line is indented to match the position of the first non-white-space character of the preceding line. Because the first character of the second line is also a tab, the actual text of the second line is pushed one tab further along.
The third line follows suit. Its first tab character is lined up with the first non-white-space character of the second line, with the same relative effect as before, giving you the final state in your example.
To emphasise, note what happens if you now put enter the line "a b c" above the existing lines, then move back to the start of the next line (what was previously the first line) and press TAB. The first tab character will now be indented in line with the 'b'. Provided that the indent-tabs-mode variable is true (meaning you have actual tab characters), then this will have no practical effect on the position of the words in the line, as 'indenting' a tab with spaces will not have an effect until the number of spaces exceeds the width of the tab (but that's another kettle of fish entirely!)
All this really means is that text-mode in Emacs doesn't behave the way you'd like it to in this situation. Other major modes can do completely different things when you press TAB, of course.
As is invariably the case with Emacs, things you don't like can be changed or circumvented with elisp. Some searching (especially at the Emacs Wiki) will frequently turn up useful solutions to problems you encounter.
Try typing C-x C-x after Emacs unselects it.
Then, instead of hitting tab (I never knew that tab does what you said! That's totally whacked.), do M-8 C-x C-i. Pity it's so many keys, but it ought to do what you want -- namely, shove everything over 8 columns. Obviously replace the M-8 with something else if you want some other number of columns.
What I usually do is simply type C-x C-x (exchange-point-and-mark) after a command that deactives the region.
How are you indenting, and in which mode?
The indentation rules in any programming mode should generally just get it right. (If they don't, that's probably more indicative that you want to configure the rules for that mode differently, but I suspect that's a different question which has been asked already).
If you're in text-mode or similar and just using TAB, then I can see the problem.
Note that if you're using indent-rigidly (C-x C-i, or C-x TAB which is the same thing) then you can repeatedly indent the same region simply by repeating the command, even if the highlighting has disappeared from view.
You can also use a prefix arg to indent-rigidly to make it indent many times. e.g. C-u C-u C-x C-i (easier to type than it looks) will indent 16 spaces (4 x 4, as the prefix arg defaults to 4, and it multiplies on each repeat). Similarly, M-8 C-x C-i indents 8 spaces. This is fine in some circumstances, and way too cumbersome in others.
Personally I suggest putting (cua-selection-mode 1) into your .emacs and using that for rigid indentation. Trey Jackson made a handy blog about it. With this, you can C-RET to start rectangle selection, down as many lines as you need, TAB repeatedly to indent the lines, and C-RET to exit the mode.
While the rectangle is active, RET cycles through the corners. For left-hand corners, typing inserts in front. For right-hand corners, typing inserts after. For the single-column rectangle, bottom counts as 'left' and top counts as 'right' for this purpose.
Trey's blog lists all the available features (or look in the source file: cua-base.el)
Be warned that indentation in Emacs is generally an unexpectedly complicated topic.
You can do this with something like the following:
(add-hook 'text-mode-hook (lambda ()
(set (make-local-variable 'indent-region-function)
(lambda (s e)
(indent-rigidly s e tab-width)))))
Then selecting a region and hitting TAB. will indent the region by a tab-width. You can then exchange point and mark with C-x C-x and hit TAB again to repeat.
I do, however, agree with the previous answers that suggest using indent-rigidly directly.