emacs font customization for tired eyes - emacs

I've been using the emacs that is bundled with the Mac OS X Terminal and it is fine, but it is an older version. I like it because I can easily control the entire Terminal font size in OS X easily.
I installed the most recent version of emacs which appears to be a different animal. It's a pseudo-gui with buttons and it is outside the Terminal environment. I've been trying to figure out how to adjust the font size of the screen with no luck. Anyone can help?
Maybe I'm dumb but I rather prefer the text-only nature of the older emacs version I was using. Trying to force a menu/mouse system in there seems to go against the primitive beauty of the system.

Your basic reference for font customization is: http://www.emacswiki.org/emacs/CustomizingFaces
If you don't want to do customization via the emacs customize feature (I don't care for it myself), then this question has a good answer: How to set the font size in Emacs?
As for the gui jibba jabba, here's what I have in my .emacs:
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
Turns all of that off. :-)
edit:
I suggest using the same emacs file and have a test for the NextStep libraries used in the GUI....
(when (featurep 'ns)
;; do GUI stuff like font fiddling
)

Type this:
M-x text-scale-adjust
Then you can use the key:
+: Increasing the default face height by one step.
-: Decreasing the default face height by one step.
0: Reset the default face height to the global default.

Related

Aquamacs 2.4 -- WordWrap / Visual Line Mode -- bug workaround?

Has anyone found a workaround to the inability of Aquamacs 2.4 to correctly WordWrap at the window boundary?
The modes I use most often are text-mode and latex-mode.
I've removed the built-in hooks of text mode to try and isolate the bug and come up with a workaround:
(remove-hook 'text-mode-hook 'smart-spacing-mode)
(remove-hook 'text-mode-hook 'auto-detect-wrap)
The following code gives me a fancy indicator in the status bar WordWrap, but words are still fragmented at the window boundary.
(add-hook 'latex-mode-hook 'set-word-wrap)
(add-hook 'text-mode-hook 'set-word-wrap)
The following code gives me a pretty status bar indicator of vl WordWrap, but the words are still fragmented at the window boundary.
(setq-default global-visual-line-mode t)
The following code seems to have no appreciable effect:
(setq longlines-wrap-follows-window-size t)
I've really never seen this feature working, so I'm not sure it is even possible with Aquamacs 2.4.
The expected behavior is that words should stay together by automatically wrapping to the next line at the window boundary. As I resize the window, this should happen on the fly. As I type a line, this should happen automatically when I reach the window edge.
Just in case this is a conflict, I'll mention that I have Yasnippets, local and global whitespace, and flyspell all enabled. I also have line numbers, highlight the current line, size indication, and column numbers.
Perhaps someone could just give me the name of the el / elc file that is responsible for this behavior, and I'll take it from a 24.3 version and paste it into Aquamacs 2.4. I am primarily interested in this version because of the ease of which it handles LaTeX documents.
Have you tried in the "Options" menu the submenu "Line wrapping in this buffer"?
Alternatively,
(add-hook 'text-mode-hook #'visual-line-mode)
or
(global-visual-line-mode 1)
The nightly builds of Emacs / Aquamacs have fixed this issue.

Set column width for visual lines in Emacs

Is there an equivalent to the fill-column variable for the "Wrap" mode (visual-line-mode) in Emacs? If not, how could I set a limit on the length of visual lines when the window/frame of the buffer is wider ?
In response to this question I created a minor mode called window-margin that accomplishes what #Stefan suggested in his answer.
Turn on window-margin-mode with:
(add-hook 'text-mode-hook 'turn-on-window-margin-mode)
The way you can still do it without installing window-margin is to use the longlines-mode that ships with Emacs, but is being phased out since there are some problems with longlines-mode, but here's the old way to do it if you want:
Turn on longlines-mode with something like:
(add-hook 'text-mode-hook 'longlines-mode)
which wraps text at the fill-column.
longlines-mode has been removed. For visual-line-mode, the simplest way is to make the window as narrow as you want it to be. You can do that with C-x 3 and then adjusting the size of the window. Or you can set a wide margin or wide fringes.

clicking on emacs blows away x selection

Much of the time when I use the mouse to click on an emacs window, the x selection which I hope to paste into the buffer is blown away. This seems to be caused by the slight shift of the hand as I apply the left click causing an inadvertant "drag copy." I do not believe I will be able to break this particular habit.
One solution I have found to prevent this is to set:
(setq mouse-drag-copy-region nil)
however this has the unfortunate side effect of preventing me from using the mouse drag functionality at all in emacs. Is there a way to control mouse drag behavior so that a click is ignored unless it spands two or more characters within the buffer?
I am coding on Centos 5.x + GNOME 2 with GNU emacs 23.3.1 in case it makes a difference.
This appears to be a GTK/X issue; I can produce similar behavior with other apps.
The easiest solution to this is to modify the function mouse-drag-track, which can be found in mouse.el. To find the function definition, M-x find-function mouse-drag-track RET.
Copy that into your .emacs file and make one small change. Find the and statement that looks like:
(and mouse-drag-copy-region
do-mouse-drag-region-post-process
(let (deactivate-mark)
(copy-region-as-kill region-commencement
region-termination)))
And modify it to have the check to ensure the region is at least 2 characters. I've made this check to be 10 characters for easier testing:
(and mouse-drag-copy-region
(>= (abs (- region-commencement region-termination)) 10) ;; THIS IS NEW
do-mouse-drag-region-post-process
(let (deactivate-mark)
(copy-region-as-kill region-commencement
region-termination)))
I don't see a clean way to do this via advice or hooks or variable settings.
Be sure to have a (require 'mouse) before your definition of mouse-drag-track to ensure you override the built-in definition, as opposed to it overriding yours. You also might want to add a check to your .emacs right above the re-definition to remind you to check for new versions of the library/function you're overwriting:
(unless (eq emacs-major-version 23)
(error "check for new mouse-drag-track"))
This is a bug in emacs that was introduced into the source code history in 2001. I have posted a patch that can be applied to local installations. Hopefully the emacs maintainers will investigate further.
Here is my patch and discussion:
http://lists.gnu.org/archive/html/emacs-devel/2011-08/msg00818.html

What causes this graphical error in emacs with linum-mode on OS X?

I get this graphical error with linum-mode in my Emacs. I tried upgrading from 23 to 24 (via git) and I've tried both with various supplied binaries online and with my home-compiled version. What I'm really interested in is where to start diagnosing the problem.
The problem goes away if I scroll the torn line numbers off screen and back in.
I have experienced the same problem and spent quite some time trying to resolve it. The graphical error is a result of a clash between linum-mode and how the fringe is rendered. Unfortunately, I was unable to resolve the problem in linum.el, and the fringe display code is part of the C-source.
It can still be done! The easiest way to fix it is to just turn off the fringe.
M-x fringe-mode RET none RET
To make the fringe permanently stay off, I recommend customizing the settings with M-x customize-group RET fringe because some compiled versions of Emacs for Mac OS X have their own fringe settings that can override parts of your .emacs file.
I don't really need those line wrap indicators, so not having a fringe doesn't bother me. However, I did miss a slight separation between the line numbers and the buffer text. I followed the advice of a post on the Emacs Wiki to get that spacing back. In version 0.9x of linum, change line 160 from
(setq width (max width (length str)))
to
(setq width (max width (+ (length str) 1)))
The inspiration for this change is here: http://www.emacswiki.org/emacs/LineNumbers
There are arguments at the source link to set the linum-format variable instead of modifying linum.el. While I understand where they are coming from, most color-themes these days would color the extra space and not provide what I am looking for (a separation of about a space that is the background color). If you do edit linum.el, make sure to run
M-x emacs-lisp-byte-compile-and-load
to make the changes persistent. You can see the result of this by looking at the space before the cursor in the picture found here: http://i.stack.imgur.com/TxyMr.png (I don't have enough reputation to embed images).
No more graphical artifacts!
I had the same problem and I figured out a solution and while it's not the prettiest, due to an extra space to the left of the line number, it's much more elegant than changing the linum.el. Here is the pertinent part of my ~/.emacs:
;; Linum mode
(global-linum-mode t)
;; Offset the number by two spaces to work around some weird fringe glitch
(setq linum-format " %d ")
This removes the fringe overlay issue and does not have any other impact other than offsetting the line number.
to make a separation between the line numbers and the buffer text, the follow change will be better:
In version 0.9x of linum, change line 150 from
(concat "%" (number-to-string w) "d")))))
to
(concat "%" (number-to-string w) "d ")))))
This make the separation have the same background color with line numbers'.
This is how I have it setup in my .emacs and I don't have the problem, although I also don't use emacs with gtk or any other gui.
(linum-mode +1)
(setq linum-format "%d ")
You might want to hack around with (setq linum-format) to see if you can get good results. Also don't forget to browse emacswiki on linum.
The problem was still here on emacs 24.4, OS X 10.10.1.
The solution I worked out:
after loading the theme of your choice:
(load-theme 'whatever)
(set-face-attribute 'fringe nil :background (face-background 'default))

How do I highlight CVS changes in Emacs?

I'm using emacs with cvs and have cvs mode enabled. I'd like to get line-by-line highlighting of changes from the latest version in CVS. I've seen this done in intellij where there is a green indication for lines added and another indication for lines modified and a third symbol for lines deleted.
Is there a cvs highlighting mode for emacs to show changes from the latest version of cvs? I'm not looking for a cvs diff type functionality that would open in a new buffer, but something that would indicate in my current buffer what lines have been modified.
In the following image there is a blue rectangle on the left side in what Intellij calls the "gutter" to indicate that the code is different than what is in source control.
(source: jetbrains.com)
I'm looking for similar functionality in emacs.
You can now check out diff-hl, which provides highlighting on the left window fringe.
So far I've tested it only on a few modern DVCSes, but if you're still using CVS, and it doesn't work as well, please file an issue.
Here's another answer that doesn't do what you want either, but may be useful.
C-x v g
runs the command vc-annotate.
That'll pop up a new buffer (I know, you didn't want one), but it'll have all the lines marked with who touched them when. And, bonus, they're color coded with a heatmap (red is most recent, blue is least), for easy identification of recent changes.
Of course the built-in version of vc-annotate doesn't scroll the buffer appropriately, so you'll want this advice:
(defadvice vc-annotate (around vc-annotate-and-scroll)
"scroll buffer to view current line in the annotated buffer"
(let ((pos (count-lines (point-min) (point))))
ad-do-it
(let ((orig-window (selected-window))
(window (other-window-for-scrolling)))
(select-window window)
(goto-line pos)
(select-window orig-window))))
(ad-activate 'vc-annotate)
You want vc-diff, which is on C-x v = by default. This gives you raw diff output in a temp buffer. The buffer uses diff-mode, which has a few neat tricks ... for example, you can use C-c C-e to apply the diff as a patch to another file. Use describe-mode (C-h m by default) in the diff buffer to find the other tricks.
Perhaps you'd like Ediff, which appears to do exactly what you want.