Upon save ( I think ), my emacs is deleting trailing white space. I don't want to commit those changes, only the parts I manually modify. Is there a way to disable that behaviour?
This behaviour is not standard. It is however a very common customization that you might have borrowed somewhere. Look for something like the following in you init file and comment out those lines to get rid of this behaviour (and have Emacs save files as they are, without removing whitespace altogether):
(add-to-list 'write-file-functions 'delete-trailing-whitespace)
or
(add-hook 'before-save-hook 'delete-trailing-whitespace)
This emacswiki page gives tons of advice on handling trailing whitespace.
If you want to delete trailing whitespace only on lines you modify, you could try the ws-trim package
Like suggested in this answer the deleting-trailing-whitespace hook might have been added to the before-save-hook hook.
To disable this eval (remove-hook 'before-save-hook 'delete-trailing-whitespace) (type M-:).
Take a look at ethan-wspace. It will clean up any whitespace that you made dirty yourself. However any incorrect whitespace that was there when you opened the file is left intact. This way you can avoid those messy diffs full of whitespace changes
Related
I usually change dictionaries when writing a git commit, however since I have a mapping to to change dictionary and run (flyspell-buffer) right after I see that flyspell goes beyond the commit message to check also comment lines starting with #.
How can I tell "flyspell, please ignore lines starting with # symbol"?
I've read that I can use flyspell-generic-check-word-predicate however my elisp is far from good :(, I came up with this:
(defun flyspell-ignore-comments ()
"Used for 'flyspell-generic-check-word-predicate' to ignore comments."
(not (string-match "^ *#" (thing-at-point 'line t))))
(put 'git-commit-mode 'flyspell-mode-predicate 'flyspell-ignore-comments)
However it doesn't work. What I'm doing wrong?
Ok, thanks to #KyleMeyer for make me doubt about my configuration, the issue was that I had enabled flyspell in a text-mode-hook, and that was interfering with the config for the git-commit-mode. Removing flyspell for loading in the text-mode-hook solved the problem.
Thanks.
Upon save ( I think ), my emacs is deleting trailing white space. I don't want to commit those changes, only the parts I manually modify. Is there a way to disable that behaviour?
This behaviour is not standard. It is however a very common customization that you might have borrowed somewhere. Look for something like the following in you init file and comment out those lines to get rid of this behaviour (and have Emacs save files as they are, without removing whitespace altogether):
(add-to-list 'write-file-functions 'delete-trailing-whitespace)
or
(add-hook 'before-save-hook 'delete-trailing-whitespace)
This emacswiki page gives tons of advice on handling trailing whitespace.
If you want to delete trailing whitespace only on lines you modify, you could try the ws-trim package
Like suggested in this answer the deleting-trailing-whitespace hook might have been added to the before-save-hook hook.
To disable this eval (remove-hook 'before-save-hook 'delete-trailing-whitespace) (type M-:).
Take a look at ethan-wspace. It will clean up any whitespace that you made dirty yourself. However any incorrect whitespace that was there when you opened the file is left intact. This way you can avoid those messy diffs full of whitespace changes
Thanks to this post, I was able to remove some of the ugly underlining semantic utilizes with it's inline parsing, but I still have a hyphen appearing at each of my function calls (and sometimes else where) that I would really like to remove. How can I do this? I have also looked through http://www.gnu.org/software/emacs/manual/html_mono/semantic.html#Tag-Decoration-Mode.
Reference image:
I'd suggest looking at your CEDET config instead.
You're probably calling semantic-load-enable-excessive-code-helpers.
And this function got its name for a reason.
So instead of enabling a function that has excessive it its name,
and then trying to remove the excessive features, why not just stick with the basics?
Just to show you my CEDET setup:
(load "~/git/cedet/cedet-devel-load")
(add-to-list 'semantic-lex-c-preprocessor-symbol-file
"~/Software/deal.II/include/deal.II/base/config.h")
(semantic-add-system-include "~/Software/deal.II/include/" 'c++-mode)
(set-default 'semantic-case-fold t)
(semantic-mode 1)
But if there some extra cool functionality that
only semantic-load-enable-excessive-code-helpers provides, please let me know.
It turns out that the hyphen was part of the semantic tag folding mode, which functions to collapse and expand code blocks in the gui version of emacs. I am not sure the same functionality is achieved in the terminal interface; but regardless, to remove these hyphens from my code, all I had to do was turn off
(global-semantic-tag-folding-mode)
i am using emacs 23.2 and reference configurations from purcell https://github.com/purcell/emacs.d
i met a problem when i am edit ruby file and rails file, see below
steps:
1. move the cursor to somewhere
2. hit "RET" key to add more new line, then move the cursor to somewhere
3. the red space happened at the last new line.
do you know how to turn this mark off?
What's your problem with this feature? The red space goes away as soon as you
start typing doesn't it?
The feature is show-trailing-whitespace, and it's meant to help you see
spurious space at EOL. Which is very helpful for team development
environment, as checking in such code will annoy your teammates.
What you should do is add a before-save-hook that removes spurious
whitespace see:
http://www.emacswiki.org/emacs/DeletingWhitespace#toc3
code:
(add-hook 'before-save-hook 'delete-trailing-whitespace)
If you want to disable show-trailing-whitespace as well:
(add-hook 'ruby-mode-hook (lambda ()
(setq show-trailing-whitespace nil)))
You might like to look at the ws-trim.el library, which removes trailing whitespace from lines which you edit, but by default does not remove them from other lines*.
I find this best for version-control (compared to deleting all trailing whitespace upon saving), as you do not introduce changes in other people's work if you edit the same file.
(*) although it is also nicely configurable if you want it to do more than that.
I personally keep all lines under 80 characters, but I also work on projects in teams where other programmers don't care about line length.
I love using whitespace-mode, but the long line visualization is really annoying when I'm working on projects where I shouldn't interfere with the long lines. It seems like it should be easy to turn off the long line visualization---I hit m-x global-whitespace-toggle-options l, and then can hit m-x global-whitespace-toggel-options ? to confirm that the "long-line visualization" is turned off. But long lines are still highlighted. I kill buffers and reload them, and highlighting is still there. I'm definitely using global, not local, whitespace-mode.
Why can't I turn off the long line visualization?
The last time I customized whitespace-mode, I noticed that my changes to the settings didn't have any effect in buffers that already existed; try recreating the buffer, or leaving and reentering whitespace-mode. In case you don't already know, you can use M-x customize-group whitespace to turn off that particular option entirely, rather than doing it manually.
Edit: Specifically you want to customize the whitespace-style variable. This lets you turn on and off individual styles. In this case you should turn off the ones labelled "(Face) Lines" and "(Face) Lines, only overlong part". The former changes the face of the whole line when it is overly long, while the latter only changes the face of the part that extends past the threshold.
(Other options in this group define the faces that whitespace-mode will use to highlight the styles you've turned on, the regexes it uses to identify certain situations, etc, but usually you only care about whitespace-style).
Set whitespace-line-column to a higher value (default is 80), so the highlighting of long lines doesn't kick in:
(setq whitespace-line-column 250)
I'm assuming that you already have whitespace-mode activated somewhere in your init.el or similar. If so, you can adapt duma's comment above, and either
Edit the elisp that sets whitespace-style to remove lines-tail. E.g., Emacs Prelude sets
(setq whitespace-style '(face tabs empty trailing lines-tail))
Simply change that to
(setq whitespace-style '(face tabs empty trailing))
If you don't want to directly edit that elisp, but rather override it later with your own code, do something like
(setq whitespace-style (delete 'lines-tail whitespace-style))
Unfortunately, if running Prelude with auto-loaded buffers (using something like Emacs Desktop), the initial setting will take precedence: for each buffer on which you want to see whitespace-style displayed as directed, you must [1]
kill the buffer
re-open the buffer
[1]: Note to OP: if there's another way to reload a buffer, please edit or comment this answer. I was hoping to find something like M-x reload-buffer but am not seeing anything like that with C-h a buffer.