emacs: spell checking: mark all typos - emacs

When using emacs, is there a way to mark all typos in a document in one go, instead of going from one typo to the next?
It would be nice if that would be possible such that code sections could be ignored by the user (see my question emacs: restrict spell check to certain environments).

I summarize my three comments in this answer, in the hope that it is helpful:
From https://emacs.stackexchange.com/a/39199: You can use the emacs command flyspell-buffer.
I found it easier to see the typos when I change the flyspell markers as suggested by
https://www.reddit.com/r/emacs/comments/a0sswd/how_do_i_change_the_highlighting_of_spelling/ in .emacs:
'(flyspell-duplicate ((t nil)))
'(flyspell-incorrect ((t (:inverse-video t)))))
(saved from customize-face).

Related

Debugging "Error setting nil" in Elisp

I have this piece of Elisp code in my Emacs configuration file:
(when (string= (getenv "TERM") "screen")
(custom-set-variables
(custom-set-faces
'(font-lock-comment-face ((((class color)
(min-colors 8)
(background dark))
(foreground red)))))))
When I start Emacs I get Error setting nil: (setting-constant nil) from this code. Though it seems to work fine I'm aware that this might be a sign of some hidden problem. I don't know Elisp too well thus I need help. Can anyone offer an explanation of this error and tell me how to eliminate it? I'm using Emacs 24.3.1
There's quite a lot wrong with that, I'm afraid.
custom-set-faces and custom-set-variables are two separate forms; you shouldn't be calling one inside the other.
You shouldn't be wrapping a call to either of those functions in a conditional expression. Both forms are generated and updated automatically when you use the customize interface, and Emacs won't find them if they're not top-level forms in your init file. Which means it will create an additional copy of each one when it needs to. Which leads to...
You mustn't have multiple instances of these forms. In fact Emacs includes the following warning comments when it generates the form:
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
Right now you are encouraging that situation to occur.

Highlighted header not readable in emacs rst-mode

Emacs has a built-in rst-mode, but the header highlight literally makes it unreadable. Is there some quick fix for this?
The screenshot above is produced on a Mac OS X using iTerm2, with emacs -Q command (which means no customized .emacs will be used). I am using emacs version 24.4.1.
To find out the name of a face, put your point on it and call
describe-face. This tells you that it is rst-level-1. Looking at
the value, you probably want to change 'Background'.
(custom-set-faces
'(rst-level-1 ((t (:background "white")))))
See the face customization
node in the manual for more details.

Emacs - Toggling between Visual Markers?

I'm trying to figure out if this functionality exists, or if not how difficult it would be to program.
Essentially what I'm looking for is the ability to mark multiple lines in a file with some form of highlighting to point out that they're important lines. From there on it would be great to be able to toggle on/off the marker, and be able to toggle through them - for larger files it would be great to be able to do this for important lines.
The markers don't have to persist, just for that session would be great.
I took a look into the "Overview of Markers" page - but I'm not sure this is exactly what I want, and if it's worth the time to try and implement it if it's not.
Thanks for any/all help!
It looks like bm.el does exactly what you want.
You want quick, perhaps temporary bookmarks that highlight the location (e.g. line): Bookmark+.
Autonamed bookmarks: hit the same key to create/delete.
Temporary bookmarks: any bookmarks can be temporary; quick to toggle temp/permanent.
Highlighting bookmark locations: any bookmarks can be highlighted, in various ways.
FWIW, Bookmark+ does everything bm.el does, and more.
This is somewhat similar to what highlight-regexp does, except arbitrary text instead of a regexp. Based on that, I think something like this should work:
(defun highlight-text ()
"Highlight the current region."
(interactive)
(let ((overlay (make-overlay (region-beginning) (region-end))))
(overlay-put overlay 'face 'hi-yellow)))

Colorize snippets of text in emacs

Suppose I have a few words I would like to highlight, so I want to change the color of those few words only to, say, green.
Is there an easy way to do this in emacs?
Thank you.
This is what I've done, using font-lock-add-keywords. I wanted to highlight the words TODO:, HACK:, and FIXME: in my code.
(defface todo-face
'((t ()))
"Face for highlighting comments like TODO: and HACK:")
(set-face-background 'todo-face cyan-name)
;; Add keywords we want highlighted
(defun add-todo-to-current-mode ()
(font-lock-add-keywords nil
'(("\\(TODO\\|HACK\\|FIXME\\):" 1 'todo-face prepend))
t))
Use library HighLight. You can use overlays or text properties. You can save the highlighting permanently or let it be temporary. You can highlight in many ways (regexp, mouse-drag,...). Lots of possibilities.
The highlight package has hlt-highlight-regexp-region and hlt-highlight-regexp-to-end, which do exactly what you want.
http://www.emacswiki.org/cgi-bin/wiki/highlight.el
Use the function font-lock-add-keywords to define a new matcher for the string in question, binding that matcher to some face you've defined that will display as green. For example:
(font-lock-add-keywords nil
'("\\<foo\\>" 0 my-green-face))
Note that you can specify a particular mode where I wrote nil above, and the matching forms can take on any of six different styles. See the documentation for the variable font-lock-keywords for the rules and a few examples.
If you want them highlighted only temporarily, I find M-x highlight-regexp command very helpful, it is especially nice for looking through log files of sorts. For example you made yourself a logging class that outputs some tracing info like MyClass::function() > when function is run and MyClass::function() < when it exits (can be especially useful sometimes when debugging multithreading issues) then you just ask emacs to highlight some of them green and other red and then you can see how did the execution go.
I use what Dimitri suggested. In particular, I have the following two lines in my .emacs
(global-hi-lock-mode t)
(global-set-key (kbd "C-M-h") 'highlight-regexp)
Every-time I need to highlight a certain word (or regex) in a buffer, I hit "C-M-h", which then prompts me for the word (or regex) I want to be displayed differently and then for a face to display it in.

Emacs - recolor matching lines in ERC

Is there a way to get ERC to highlight all lines that come in that match a certain regexp? For context, I'm using ERC to connect to a bitlbee server and wish that when I issue a 'blist' command, my friends who are online are highlighted in green and those away are highlighted in red.
With erc come several modules. Customise erc-modules so it contains the match module. Then customise erc-keywords, which can contain regexps and cons cells where the regexp is in the car and the face in the cdr.
Don't know about the regexp to distinguish online and away. Is the output from blist different for both?
Edit:
I can't figure out, how to insert custom faces (I mean not existing symbols like the default face) in the customize buffer. So here it is with setting the variable directly:
(setq erc-keywords '(("online-regexp" (:foreground "green"))
("away-regexp" (:foreground "red"))))
I never used ERC, but highlight regex search in emacs can be actived by M-x highlight-regexp