Emacs -- How to create a vertical strike-through effect - emacs

I'm looking for some suggestions, please, of how to create the visual effect of a vertical strike-through (with the character on top of the vertical bar ("\u007C") still being visible). If layering is possible, then the vertical bar should be underneath so that the letter is mostly visible.
I searched for a method of superimposing characters, layering overlays, and I looked at some xpm images, however, I have not found anything remotely close to what I'm looking for. The goal is to have a true cross-hairs effect similar to the image below -- the gray background would be replaced with a yellow vertical strike-through so that the letters would still be visible.

Feature Request #17684 (crosshairs) [ https://debbugs.gnu.org/cgi/bugreport.cgi?bug=17684 ] and Feature Request 22873 (multiple fake cursors) [ https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22873 ] are a work in progress. Although it is unknown whether these features will ever be incorporated into the official Emacs, there is a working draft proof concept that has been posted to both of the above-mentioned feature requests. The features require modifications to both the C and Lisp internals prior to building a GUI version of Emacs from the master branch -- X11, Windows or NS.
EXAMPLE 1 of 3:
The following code snippet works with some fonts on some operating systmes -- e.g., it works out of the box on Windows; however, it does not work for this author on OSX 10.6.8 Snow Leopard or Snow Leopard Server 10.6.8. [See bug report number 20537 -- https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20537 -- even though the bug report has been officially closed by the Emacs development team, this author has never been able to get that feature working on Snow Leopard subsequent to the "bug fix". :( ] The user may wish to experiment with the glyph reference points, and the variable reference-point-alist in composite.el has a detailed doc-string in relation thereto. The user may also wish to experiment with using an after-string or before-string display property. The library vline.el at http://www.emacswiki.org/emacs/vline.el has a variable named vline-style, which can be set to 'face, 'compose, or 'mixed -- the latter two settings cause vline to use a slight variation of this code snippet [see lines 362 to 370 of said library].
(let* (
(point-min (point-min))
(point-max (point-max))
(pt (point))
(pt+1 (1+ pt))
(char (char-after pt))
(line-char (string-to-char "|"))
(str (when char (compose-chars char '(tc . tc) line-char))) )
(overlay-put (make-overlay pt pt+1) 'display str)
(sit-for 2)
(remove-overlays point-min point-max 'display str))
EXAMPLE 2 of 3:
The following code snippet uses a unicode character known as a zero-with space (i.e., uFEFF). Because a space cannot receive a foreground color, a background color is used to give the zero-width space the apparance of a thin vertical line that stretches the entire line height. As used in the context of this code snippet, the zero-width space has a width of 1 pixel and the concatenated charcter is reduced in size so that the two combined characters have a width equal to the frame-char-width. Testing of this snippet was done on an OSX operating system using the default font of -*-Monaco-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1. The cursor is removed for a short duration during this example so that the overlay can be seen more clearly.
(let* (
(point-min (point-min))
(point-max (point-max))
(pt (point))
(pt+1 (1+ pt))
(char (char-after pt))
(char-str (when char (char-to-string char)))
(ln-char-str (char-to-string ?\uFEFF))
(str (when char
(concat
(propertize ln-char-str 'face '(:background "red"))
(propertize char-str 'face '(:height 100))))) )
(internal-show-cursor nil nil)
(overlay-put (make-overlay pt pt+1) 'display str)
(sit-for 2)
(internal-show-cursor nil t)
(remove-overlays point-min point-max 'display str))
EXAMPLE 3 of 3:
The following is an example using an overlay with an xpm image for graphical Emacs versions that support xpm image format. It is 11 pixels wide; 20 pixels high; and has 4 preselected colors. I am on a Mac running Snow Leopard 10.6.8 and the font I prefer when using Emacs is -*-Courier-normal-normal-normal-*-18-*-*-*-m-0-iso10646-1 -- the frame-char-width is 11 and the frame-char-height is 20. I have added a thin vertical yellow line to the left of the capital letter "A" as an example of how to draw custom images. Substitution of the character at point can be made programmatically using (char-after (point)) and taking that number -- which in this case is 65 for the capital letter "A" -- and substituting the appropriate variable -- e.g., (cond ((eq (char-after (point)) 65) cap-ltr-a-xpm) . . . -- and using that variable in the the overlay placement -- e.g., (overlay-put (make-overlay (point) (1+ (point))) 'display cap-ltr-a-xpm). This works very nicely for both truncated buffers and also with word-wrap because the display overlay property on a character in the middle of a word does not cause word-wrap to think that the first part of the word belongs at the end of the previous line. Naturally, it will take time to create a custom library of favorite xpm images. The cursor is removed for a short duration during this example so that the overlay can be seen more clearly.
ImageMagick is capable of producing a semi-accurate xpm of a particular character based on a specific font family and size, but it was not as precise as I had hoped -- here is a link to instructions for using that external utility: https://stackoverflow.com/a/14168154/2112489 In a nutshell, the user should be prepared to spend time customizing the xpm images to his / her liking.
(let* (
(pt (point))
(pt+1 (1+ pt))
(point-min (point-min))
(point-max (point-max))
(cap-ltr-a-xpm `(image :type xpm :mask nil :ascent center :data
"/* XPM */
static char * letters_xpm[] = {
/* columns rows colors chars-per-pixel */
/* columns = 1 pixel in width -- see also (frame-char-width) */
/* rows = 1 pixel in height -- see also (frame-char-height) */
\"11 20 4 1\",
\". c #000000\",
\"+ c #FF0000\",
\"# c #7F0000\",
\"% c yellow\",
\"%..........\",
\"%....++....\",
\"%....++....\",
\"%..++..++..\",
\"%..++..++..\",
\"%++......++\",
\"%++......++\",
\"%++......++\",
\"%++......++\",
\"%++......++\",
\"%++......++\",
\"%++++++++++\",
\"%++++++++++\",
\"%++......++\",
\"%++......++\",
\"%++......++\",
\"%++......++\",
\"%++......++\",
\"%++......++\",
\"%..........\"};")) )
(internal-show-cursor nil nil)
(overlay-put (make-overlay pt pt+1) 'display cap-ltr-a-xpm)
(sit-for 2)
(internal-show-cursor nil t)
(remove-overlays point-min point-max 'display cap-ltr-a-xpm))
The following code snippet is similar to the one above, except it uses the after-string display property. The cursor is removed for a short duration during this function so that the overlay can be seen more clearly.
(let* (
(point-min (point-min))
(point-max (point-max))
(peol (point-at-eol))
(pilcrow `(image :type xpm :mask nil :ascent center :data
"/* XPM */
static char * pilcrow_xpm[] = {
\"11 20 4 1\",
\". c #000000\",
\"+ c orange\",
\"# c #7F0000\",
\"% c yellow\",
\"%..........\",
\"%..........\",
\"%..........\",
\"%..........\",
\"%..++++++..\",
\"%.++++.+...\",
\"%.++++.+...\",
\"%.++++.+...\",
\"%..+++.+...\",
\"%....+.+...\",
\"%....+.+...\",
\"%....+.+...\",
\"%....+.+...\",
\"%....+.+...\",
\"%..........\",
\"%..........\",
\"%..........\",
\"%..........\",
\"%..........\",
\"%..........\"};"))
(pilcrow-str (propertize " " 'display pilcrow)) )
(overlay-put (make-overlay peol peol) 'after-string pilcrow-str)
(sit-for 2)
(remove-overlays point-min point-max 'after-string pilcrow-str))
The following screenshot was made using the second example.

Related

How create fringes without spaces in emacs

How to remove bottom vertical space between fringes ?
fringes-example
I have the following code
(defun test--fringe()
(interactive)
(save-excursion (let ((ov (make-overlay (point)
(+ 1 (point)))))
(overlay-put ov 'before-string (propertize "x" 'display '(left-fringe
filled-rectangle
error))))
(forward-line)
(let ((ov (make-overlay (point)
(+ 1 (point)))))
(overlay-put ov 'before-string (propertize "x" 'display '(left-fringe
filled-rectangle
error))))))
Do you see that if you start Emacs using emacs -Q? I don't. If you don't, then bisect your init file to find the culprit.
Perhaps you or some code you use has customized option line-spacing? C-h v says:
line-spacing is a variable defined in C source code.
Its value is nil
Automatically becomes buffer-local when set.
Documentation:
Additional space to put between lines when displaying a buffer.
The space is measured in pixels, and put below lines on graphic displays,
see display-graphic-p.
If value is a floating point number, it specifies the spacing relative
to the default frame line height. A value of nil means add no extra space.
You can customize this variable.
This variable was introduced, or its default value was changed, in
version 22.1 of Emacs.

Emacs overwrites ligatures

I am trying to get ligatures working in emacs with "Fantasque Sans Mono Nerd Font Mono" (that's its name...)
My script is the following:
(provide 'add-fantasque-ligatures)
(defconst fantasque-fontlock-keywords-alist
(mapcar (lambda (regex-char-pair)
`(,(car regex-char-pair)
(0 (prog1 ()
(compose-region (match-beginning 1)
(match-end 1)
,(concat (list ?\C-i)
(list (decode-char 'ucs (cadr regex-char-pair)))))))))
'(("\\(!=\\)" #xe10a)
("\\(==\\)" #xe103)
("\\(->\\)" #xe112)
("\\(<-\\)" #xe121)
("[^<]\\(<=\\)" #xe11b)
("\\(&&\\)" #xe038)
("[^>]\\(>=\\)" #xe10c))))
(defun add-fantasque-ligatures ()
(font-lock-add-keywords nil fantasque-fontlock-keywords-alist))
(add-hook 'prog-mode-hook
#'add-fantasque-ligatures)
It works fine, except for the &&. Emacs displays a play button in a filled circle. I penta-checked it, and U+e038 is its unicode value.
I have an idea, though, what emacs does here.
There are some other ligatures I checked too, like ||, and emacs displayed a play button in an unfilled circle. I changed the font, and the && and || still did not work.
I think there are some unicode characters, that emacs overwrites to make them font-independent. Is there a way though to overcome this problem, and display the correct ligatures?

How to automatically add / remove scroll-bars as needed by text height

Many commercial word processors have a default behavior that automatically hides the vertical scroll bars when the lines of text in the document are less than the visible window; and, the scroll bars appear automatically when the lines of text in the document are greater than the visible window. Emacs is missing that ability and I'd like that to be the default behavior in a variety of different modes.
Does anyone have some ideas how to automatically remove or add the scroll-bars on the fly as the size (lines of text) of the document increases or decreases?
I was thinking of perhaps weaving it into the the functions for line numbers using a prior sample by #phils in a related thread:  https://stackoverflow.com/a/10593165/2112489
I'd like it work even when I'm not using linum-mode. However, I don't think the scroll-bar function should run after every single command -- it should run only when a new line is added or subtracted, taking into consideration visual-line-mode (i.e., wrapping being active) potentially being active.
The following snippet was inspired by a previous answer from #abo-abo in a related thread: https://stackoverflow.com/a/20923695/2112489
(cond
((not (> (count-lines (point-min) (point-max)) (window-height)))
(set-window-scroll-bars (get-buffer-window (buffer-name) (selected-frame)) 0 nil))
((and
(> (count-lines (point-min) (point-max)) (window-height))
(not (equal (window-scroll-bars) `(15 2 t nil))))
(set-window-scroll-bars (get-buffer-window (buffer-name) (selected-frame)) 15 'right)))
EDIT (January 17, 2014):  Working draft based upon the helpful answer to this thread by #Drew.
EDIT (January 19, 2014):  Added a function to count each word-wrapped line using vertical-motion. Setting the initial-frame-default seems to be read by Emacs after the initial frame is created, so the scroll bars are visible for a split second -- to avoid seeing this, modifying the frame parameters of the initial frame seems to fix this visual issue. Now using window-text-height instead of window-height -- The returned height does not include dividers, the mode line, any header line, nor any partial-height lines at the bottom of the text area. Copied the method used by linum-mode in terms of using -- the post-command-hook, the change-major-mode-hook, and the window-configuration-change-hook). Added window-live-p condition to avoid post-command-hook errors when starting Emacs while various buffers are loading out of sight. Added condition to deal with narrow-to-region -- still unsure why that situation causes Emacs to freeze in a loop or something -- the workaround is needed for now. The latest version of Emacs Trunk from January 19, 2014 appears to fix visual display issues experienced in prior versions -- as such, redraw-frame is no longer necessary. Added (redisplay t) to the function count-vertical-lines, which speeds up displaying the new buffer when switching buffers. Added regexp for buffers that will always have scroll bars or never have scroll bars.
EDIT (January 20, 2014):  Added just one main condition that there be a live window, and removed the same conditions from the various branches of the lawlist-scroll-bar function. Added additional condition for a narrow-to-region situation such that removing the scroll bars only need occur if scroll bars were present prior to narrowing.
EDIT (January 21, 2014):  With this revision, it is no longer necessary to count lines (which causes a slow-down in large buffers). The new method is a much simpler mathematical calculation based on four (4) points that are determined in a mere fraction of a second -- i.e., point-min, point-max, window-start and window-end. If point-min moves off the screen, scroll bars are added -- I think this behavior makes sense -- although, I did stop to ponder whether the scroll-bar should also serve as a visual representation of whether the characters within the parameters of point-min to point-max could actually fit into the window regardless of whether point-min had moved beyond the window. None of the hooks in this example are able to deal with a display-buffer situation (targeting the same window of the same frame that both already have focus) -- so, I created my own display-buffer-hook (which is beyond the scope of this example).
;;;;;;;;;;;;;;;;;;;;;;;;;; LAWLIST SCROLL BAR MODE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar regexp-always-scroll-bar '("\\.yes" "\\*Scroll-Bar\\*")
"Regexp matching buffer names that will always have scroll bars.")
(defvar regexp-never-scroll-bar '("\\.off" "\\.not")
"Regexp matching buffer names that will never have scroll bars.")
(add-to-list 'default-frame-alist '(vertical-scroll-bars . nil))
(modify-all-frames-parameters (list (cons 'vertical-scroll-bars nil)))
(defun lawlist-scroll-bar ()
(when (window-live-p (get-buffer-window (current-buffer)))
(redisplay t)
(cond
;; not regexp matches | not narrow-to-region
((and
(not (regexp-match-p regexp-always-scroll-bar (buffer-name)))
(not (regexp-match-p regexp-never-scroll-bar (buffer-name)))
(equal (- (point-max) (point-min)) (buffer-size)))
(cond
;; Lines of text are less-than or equal-to window height,
;; and scroll bars are present (which need to be removed).
((and
(<= (- (point-max) (point-min)) (- (window-end) (window-start)))
(equal (window-scroll-bars) `(15 2 right nil)))
(set-window-scroll-bars (selected-window) 0 'right nil))
;; Lines of text are greater-than window height, and
;; scroll bars are not present and need to be added.
((and
(> (- (point-max) (point-min)) (- (window-end) (window-start)))
(not (equal (window-scroll-bars) `(15 2 right nil))))
(set-window-scroll-bars (selected-window) 15 'right nil))))
;; Narrow-to-region is active, and scroll bars are present
;; (which need to be removed).
((and
(not (equal (- (point-max) (point-min)) (buffer-size)))
(equal (window-scroll-bars) `(15 2 right nil)))
(set-window-scroll-bars (selected-window) 0 'right nil))
;; not narrow-to-region | regexp always scroll-bars
((and
(equal (- (point-max) (point-min)) (buffer-size))
(regexp-match-p regexp-always-scroll-bar (buffer-name)))
(set-window-scroll-bars (selected-window) 15 'right nil))
;; not narrow-to-region | regexp never scroll-bars
((and
(equal (- (point-max) (point-min)) (buffer-size))
(regexp-match-p regexp-never-scroll-bar (buffer-name)))
(set-window-scroll-bars (selected-window) 0 'right nil)))))
(define-minor-mode lawlist-scroll-bar-mode
"This is a custom scroll bar mode."
:lighter " sc"
(if lawlist-scroll-bar-mode
(progn
(add-hook 'post-command-hook 'lawlist-scroll-bar nil t)
;; (add-hook 'change-major-mode-hook 'lawlist-scroll-bar nil t)
;; (add-hook 'window-configuration-change-hook 'lawlist-scroll-bar nil t)
)
(remove-hook 'post-command-hook 'lawlist-scroll-bar t)
(remove-hook 'change-major-mode-hook 'lawlist-scroll-bar t)
(remove-hook 'window-configuration-change-hook 'lawlist-scroll-bar t)))
(define-globalized-minor-mode global-lawlist-scroll-bar-mode
lawlist-scroll-bar-mode lawlist-scroll-bar-on)
(defun lawlist-scroll-bar-on ()
(unless (minibufferp)
(lawlist-scroll-bar-mode 1)))
(global-lawlist-scroll-bar-mode)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Supporting regexp function:
;; https://github.com/kentaro/auto-save-buffers-enhanced
;; `regexp-match-p` function modified by #sds on stackoverflow
;; https://stackoverflow.com/questions/20343048/distinguishing-files-with-extensions-from-hidden-files-and-no-extensions
(defun regexp-match-p (regexps string)
(and string
(catch 'matched
(let ((inhibit-changing-match-data t)) ; small optimization
(dolist (regexp regexps)
(when (string-match regexp string)
(throw 'matched t)))))))
If you just want to toggle scroll bars on/off interactively, or on a hook, or from your code, then scroll-bar-mode should be all you need.
You can also use menu-bar-no-scroll-bar, menu-bar-left-scroll-bar, and menu-bar-right-scroll-bar. Or just do what each of those commands does: (customize-set-variable 'scroll-bar-mode WHATEVER). Or use set-scroll-bar-mode or set-window-scroll-bars, similarly. It depends on what behavior you are looking for.
I recommend M-x apropos scroll-bar. (Or if you use Icicles, just C-h f scroll-bar S-TAB, then repeat C-M-down...)
You can add it to mode-line-position, so that update of the mode line automatically triggers turning scroll bars on/off. This pretty much works, for instance:
(setq-default
mode-line-position
'(:eval
(progn
(if (> (count-lines (point-min) (point-max)) (window-height))
(set-window-scroll-bars nil 20 t)
(set-window-scroll-bars nil 0 t))
`((-3 ,(propertize
"%p"
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Buffer position, mouse-1: Line/col menu"))
(line-number-mode
((column-number-mode
(10 ,(propertize
" (%l,%c)"
'face (and (> (current-column)
modelinepos-column-limit)
'modelinepos-column-warning)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line and column, mouse-1: Line/col menu"))
(6 ,(propertize
" L%l"
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line number, mouse-1: Line/col menu"))))
((column-number-mode
(5 ,(propertize
" C%c"
'face (and (> (current-column)
modelinepos-column-limit)
'modelinepos-column-warning)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Column number, mouse-1: Line/col menu")))))))))
You can alternatively use the following, which employs Stefan's suggestion
to make it work better with scaled text, visual-line-mode, images, etc. However, in that case, scroll bars kick in whenever some text is outside the window because of scrolling, regardless of whether that text would fit in the window. Whether that is a feature or not is for you to decide. ;-)
(setq-default
mode-line-position
'(:eval
(let ((scroll-bars (nth 2 (window-scroll-bars))))
(if (or (> (point-max) (window-end)) (< (point-min) (window-start)))
(unless scroll-bars (set-window-scroll-bars nil 20 t))
(when scroll-bars (set-window-scroll-bars nil 0 t)))
(unless (equal scroll-bars (nth 2 (window-scroll-bars))) (redraw-frame))
`((-3 ,(propertize
"%p"
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Buffer position, mouse-1: Line/col menu"))
(line-number-mode
((column-number-mode
(10 ,(propertize
" (%l,%c)"
'face (and (> (current-column)
modelinepos-column-limit)
'modelinepos-column-warning)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line and column, mouse-1: Line/col menu"))
(6 ,(propertize
" L%l"
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Line number, mouse-1: Line/col menu"))))
((column-number-mode
(5 ,(propertize
" C%c"
'face (and (> (current-column)
modelinepos-column-limit)
'modelinepos-column-warning)
'local-map mode-line-column-line-number-mode-map
'mouse-face 'mode-line-highlight
'help-echo "Column number, mouse-1: Line/col menu")))))))))
If you are used to using scroll bars only as visual indicator of where you are in the buffer (rather than looking at the modeline for that), you might like a package like yascroll. It uses the fringe for displaying the scroll bar, and it does not show it if lines of text in the document are less than the visible window, as you want.
Advantage is that there is no widgets taking up real state from your screen.
Disadvantage is that you cannot use the scroll bars with the mouse (some users never do that, anyways)

How to configure Emacs to use variable fonts to display the previsualisation of LaTeX formulas?

I would like to use Emacs 24.2.1 in orgmode 7.9.3 on a data projector in class.
I can pre-visualize latex formulas using org-preview-latex-fragment (C-c C-x C-l), and
I can increase the font used to display the text using text-scale-increase (C-+).
The problem is that the math fonts are not increasing along the text fonts.
Is there a way to configure Emacs so that the math fonts are variable too?
Was this solved in a later version of orgmode (I was planning to wait for the end of the term to upgrade to version 8+, being afraid of having to invest a lot of time in updating my configuration).
A poor man's solution that works with advices and hooks is shown below.
Paste the code into your .emacs configuration file and re-start emacs. Afterwards, the equation images should be scaled at along with the text if you press C-+/-/0. They are just previews and their The bad thing is that the resolution is not enlarged. To get equation images with a good resolution hit C-c C-x C-l to regenerate the images. Note, that this sets the :scale property of the customization variable org-format-latex-options. The customization of this variable will be lost for the current emacs session.
You need a gnu-emacs with built-in imagemagick. Should be standard by now.
(defvar text-scale-mode-hook nil
"Hook run at end of command `text-scale-mode'.")
(defadvice text-scale-mode (after text-scale-mode-hooks nil activate)
"Run `text-scale-mode-hook' at end of command `text-scale-mode'."
(if (functionp text-scale-mode-hook)
(funcall text-scale-mode-hook)
(loop for hook in text-scale-mode-hook do
(if (eq hook 't)
(run-hooks (default-value text-scale-mode-hook))
(run-hooks hook)))))
(defun org-text-scale-eye ()
"Scale equation images according to text-scale-mode-amount."
(when (boundp 'text-scale-mode-amount)
(let ((relwidth (* (expt text-scale-mode-step text-scale-mode-amount))))
(loop for ol in (overlays-in (point-min) (point-max)) do
(when (eq (overlay-get ol 'org-overlay-type) 'org-latex-overlay)
(unless (overlay-get ol 'org-image-original-width)
(overlay-put ol 'org-image-original-width (car (image-size (overlay-get ol 'display) t))))
(let ((ol-disp-plist (cdr (overlay-get ol 'display))))
(setq ol-disp-plist (plist-put ol-disp-plist :type 'imagemagick))
(setq ol-disp-plist (plist-put ol-disp-plist :width (round (* relwidth (overlay-get ol 'org-image-original-width)))))
(overlay-put ol 'display (append '(image) ol-disp-plist))
))))
(force-window-update)
))
(add-hook 'org-mode-hook '(lambda () (add-hook 'text-scale-mode-hook 'org-text-scale-eye)))
(defadvice org-format-latex (before set-scale activate)
"Set :scale in `org-format-latex-options' to the scaling factor resulting from `text-scale-mode' and clear cache."
(let ((relwidth (expt text-scale-mode-step text-scale-mode-amount)))
(unless (= (plist-get org-format-latex-options :scale) relwidth)
(plist-put org-format-latex-options :scale relwidth))))
Actually, I had a look at the code in org.el:
The font height is regarded in the function org-create-formula-image-with-dvipng and the resolution option -D is set. Maybe, there goes something wrong. Furthermore, pityingly, in org-format-latex the images are cached and not reproduced after font size changes.
If you want to increase the size of the latex-formulas for one session in general with good quality you can set the :scale value of the customization option "Org Format Latex Options" in the group "org-latex" to a higher value.
Edit 2013-10-10 (marked as italic throughout the answer except the code, naturally): The :scale property of the option org-format-latex-options is now set automagically. Therefore, the above hack should be quite usable (such as the latex version mentioned below).
The same problem as you describe in the original-post exists for latex-preview. But, for that case there is a better solution:
(require 'face-remap)
(defadvice preview-inherited-face-attribute (after preview-inherit-local-face nil activate)
"Scale preview images with respect to buffer-local face"
(when (and text-scale-mode (eq attribute :height))
(setq ad-return-value (* (expt text-scale-mode-step text-scale-mode-amount) ad-return-value))))
After C-+/-/0 type C-c C-p C-d to re-generate all formulas of the document. Afterwards, the formulas have just the right size and the right resolution.
If switching to latex documents with preview is an option for you I would recommend it. I use org only for notes and time-tables with easy links.
For more descriptive documents I use latex documents with auctex/preview. But, I actually compile them only very seldom to a final pdf document. The preview is good enough. See the following Figure.

Emacs: TODO indicator on left fringe has a strange side-effect - deleting characters

I just read Emacs :TODO indicator at left side, and tried it out. It seems intriguing. The little indicator triangles appear, but I'm getting a weird side effect: the text itself is being altered. Characters are being deleted.
Before:
After:
The mode-line does indicate that the buffer has been altered after running annotate-todo.
What explains this?
(I'm using emacs 22.2.1 on Windows)
Ahhh... I see the error of my ways earlier. Here's a new version.
(defun annotate-todo ()
"put fringe marker on TODO: lines in the curent buffer"
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "TODO:" nil t)
(let ((overlay (make-overlay (- (point) 5) (point))))
(overlay-put overlay 'before-string (propertize (format "A")
'display '(left-fringe right-triangle)))))))
The first solution used a the 'display text property, which changes how the specified text is displayed, in this case it was replaced by the triangle in the left fringe. What I needed to do was to use a 'before-string overlay instead. Which doesn't change the string being displayed.
Another advantage, the cut/paste of the code annotated by this does not carry the markup.
I've updated the code in the original question to reflect this change as well.