how do I disable Flyspell? - emacs

It sounds easy but I can't fix it: I want to permanently disable automatic spell-checking in emacs. There must be a simple line for my init.el. Can somebody help me?

Figure out why it's on in the first place (it isn't enabled by default), then fix that. Either your init file is turning it on, or else some system-wide init file is. Read about those files: http://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html

From a brief look, the simplest way I can see is to redefine the function:
(eval-after-load "flyspell"
'(defun flyspell-mode (&optional arg)))
or you could use advice to force the argument to always be -1 (see C-h f turn-off-flyspell), but that would be slightly more complex and less efficient for no good reason.
If you want to know what is running it in the first place, you could use M-x debug-on-entry flyspell-mode, which will show a stack trace when the function is called (q to exit the debugger; C-h m to list other commands; M-: (info "(elisp)debugger") for help). Use M-x cancel-debug-on-entry to remove that breakpoint.

(flyspell-mode 0)

I found mine in ~/.emacs.d/usk/text.el
I deleted the block of code having to do with FlySpell and closed emacs.
After reopening emacs, I still saw the spelling error (red underline). However, I simply deleted and retyped the "misspelled" words and then, emacs didn't underline. Problem solved.
I'm running Debian.

In my case flyspell-mode has been gaining ground in the .emacs.desktop file.
This was not the first time that desktop-mode causes pain in restoring obsolete things. In this case it restored all modes on a per-file basis, although in .emacs.el I had already disabled flyspell-mode and flyspell-prog-mode everywhere.
Solution: either edit the .emacs.desktop file or delete it.

Using Emacs graphical mode you can just right click above "Fly" minor mode bellow and select "Turn Off minor mode" like this:

Related

Emacs - suppress Completion Buffer

In Emacs, I don't want the *Completions* buffer to pop up, even when I press tab to autocomplete in the minibuffer and there are multiple results.
It's distracting and jarring.
How can I do this?
Even better, I would like an alternative that isn't distracting or jarring -- such as requiring one tab for autocomplete if available, but requiring two tabs to open a Completions buffer. This way, I don't get the Completions buffer when I'm expecting an autocomplete. This is what the OS X terminal does to show tab completion possibilities.
I think the cause is the minibuffer-completion-help command, which is run automatically, described here: https://www.gnu.org/software/emacs/manual/html_node/elisp/Completion-Commands.html
I use ido and smex, but the problem occurs in a vanilla Emacs too.
EDIT: I found a hack to fix this. Using M-x find-function, I found and copied the function definition of minibuffer-completion-help into my .emacs.d/init.el file. Then, I renamed the version I copied my-minibuffer-completion-help and changed (with-displayed-buffer-window *Completions* to '(with-displayed-buffer-window *Completions* (putting a quote in front so it is just interpreted as a string. Finally, I overrode the call to minibuffer-completion-help by putting
(advice-add 'minibuffer-completion-help
:override #'my-minibuffer-completion-help)
after the my-minibuffer-completion-help function in my .emacs.d/init.el file. There must be a better way.
EDIT 2: quoting out (message "Making completion list...") in my-minibuffer-completion-help has the added benefit of getting rid of the flicker in autocomplete that is caused by flashing another message during autocomplete. Is it possible to do this another way?
I believe you just want to set completion-auto-help to nil:
(setq completion-auto-help nil)
I believe what you're looking for is either temporarily modifying display-buffer-alist, probably setting it to use display-buffer-no-window for *Completions* or M-x customize-group completion and setting Completion Show Help to nil

How do I revert a sparse-tree view in org mode?

I am learning org mode, and just found out about sparse trees (C-c / t and its kin). How can I go back to the original, unsparse, view of my org document?
I found out by trial and error that TAB-cycling the top node works, is there a better way?
C-c C-c should clear out the sparse-tree hiding and highlighting, but as far as I know, you can't just go back to the "last view" you had of it. If you want to go back to the full-view, use Shift-Tab to cycle all entries.
So, it's now 2018 and (AFAIK) this feature still doesn't exist.
The best workaround I've found so far, is to create an indirect buffer (C-x 4 c) and then run org-sparse-tree in there. The original window remains unaffected, so you keep your view, and changes to the indirect buffer will update the original buffer (and vice-versa). When you're done, you just close the indirect buffer.
I usually just run the org-mode command which seems to get me back to square one.
Ben K. was on the right track. Indirect buffers are one of emacs' most powerful features.
This function does what I would have expected org-show-todo-tree to do: create a new buffer showing undone TODO items, don't screw up my org file's tree state, and clear the unnecessary occur highlighting.
(defun org-todo-buffer ()
"Create new indirect buffer with sparse tree of undone TODO items"
(interactive)
(clone-indirect-buffer "*org TODO undone*" t)
(org-show-todo-tree nil) ; mimics interactive usage
(org-remove-occur-highlights)
)
In this new buffer you can change TODO item states which are reflected in your org file, and you can simply kill the indirect buffer when you are done with it.
Coming to this very late, I noticed that selecting all tags then un-highlighting/un-narrowing seems to do the right thing.
C-c \ *
C-c C-c
TAB-cycling anywhere only hides the entries highlighted by org-sparse-tree.
To remove the overlays, you need to actually edit the buffer.
As you said, you can there by visibility cycling with S-TAB, but I personally don't like visibility cycling because I'm never sure where I am in the cycle.
So I just created this simple org-agenda-custom-command that shows everything without highlighting. Just add it to your .emacs file.
(setq org-agenda-custom-commands
; ... other commands
`(("z" "All" occur-tree "."
((org-show-entry-below t)
(org-highlight-sparse-tree-matches nil)))))
There probably is a better way to do this, and the beauty of SO is someone will tell us :).
What I usually do to work around this is to use C-x C-v RET (find-alternate-file) or M-x revert-buffer. This works only if you don't have unsaved edits.
I found that the (setq org-agenda-custom-commands.. answer works the best for me.
Use with (sorry, it wasn't obvious to me):
C-c a z

Notify out-of-date buffers in the mode-line

Sometimes I use an alternative method (usually sed) to edit a file
that's already being edited by Emacs. Later, if I try to edit the file
in Emacs without reverting the changes first, I get an error message
and a prompt asking me what to do.
That's all fine. The problem is that I tend to forget very often when
I've made some parallel changes, so I'd like Emacs to
remind me by showing a red "M" in the mode-line.
I know how to customize the mode-line (by adding strings to the
mode-line-format variable), but I have no idea how to check if a
file has been modified outside of Emacs.
Is there a function to check whether an Emacs buffer is up to date
with the file it corresponds?
Try
(verify-visited-file-modtime (current-buffer))
See Section 27.6 Buffer Modification Time.
Not really a direct answer to the question, but you can avoid this problem by turning on auto-revert globally in emacs with (global-auto-revert-mode t).

How to work out which package is unsetting keybindings?

Something in my config is unsetting/overwriting some standard keybindings for C-c C-e so that commands in various major modes don't work properly. In AUCTeX C-c C-e should start the "insert environment" dialogue and in org-mode the same keys should start the export/publish dialogue, but in both of these modes C-c C-e is undefined and emacs just waits for more input.
I know I could start emacs with -Q and load packages until something breaks (and if I load emacs that way and open a file in org-mode, the keybindings work as they should) but, like lots of people, at some point my init file became monstrously big. Is there a quicker, smarter way?
[EDIT] Nothing in my config is unsetting C-c C-e explicitly.
The debugger might give you enough clues to sort it out. Try adding the following to the beginning of your .emacs:
(debug-on-entry 'global-unset-key)
You might need to try 'local-unset-key as well. For details see the debugger manual.
Binary search is your friend.
Go to the middle of your .emacs and add (error "here"), then launch Emacs and see if the problem persists.
If it does, then insert another error line half way between the current and the top of the file, if not, comment out the current error and add one half way between the current and the bottom.
Repeat the bisection process until you isolate the line or two which are responsible for causing the problem.
You could use C-h k C-c C-e to find out which function is bound to your combination.
In the popped up help buffer, you will get the function name, its documentation and a link to the file where it is defined. Follow that link and you will end up at the place of the function definition.
At this point, it should be simple to identify which package that is responsible for redefinition of your keybinding using the name of the file.
If this does not help, you could M-x rgrep in your customization directory for 'C-c C-e' or 'C-e' and manually check everything.

emacs M-e doesn't work properly in tex-mode

I'm using emacs and auctex to write LaTeX documents. For some reason, M-e doesn't move to the end of the sentence in tex-mode as it did when I went through the tutorial. It moves to the end of the paragraph. (That is, it moves to just before the next double line break)
What is wrong? Do I need to turn on/off some mode to skip to the next full stop? How do I check which modes are active?
I noticed that the same happens in my Emacs. The problem is that the variable sentence-end-double-space is set to t. This means that Emacs expects a sentence to end with a double space. By setting to nil things work properly, i.e., Emacs recognizes a period followed by a single space as the end of sentences.
The first thing to check is what M-e is bound to. In tex-mode, for me, it is bound to forward-sentence. You find this out by C-h k M-e.
It sounds as though it's bound to forward-paragraph, in which case I'd check your .emacs file to see if you've got any overrides in tex-mode hooks, or other things. You can also try running without your .emacs: emacs -q, and seeing what M-e is bound to (to determine if it truly is your .emacs). You can also start without the site lisp file emacs -q --no-site-file - in case your administrators have added anything.