How to disable Emacs highlighting whitespace in parenthesis? - emacs

In the above screenshot, it can be seen that Emacs highlights the whitespace between parentheses, unless I move my cursor one place to either side.
I have smartparens enabled in my emacs config, but even if I disable them, this problem still persists.
I also don't have whitespace-mode enabled.
Any idea what may be causing this?
The relevant part of my config:
(require 'smartparens-config)
(smartparens-global-mode t)
(show-smartparens-global-mode t)
Thanks.

Unfortunately the solution given by Ignacy Moryc, didn't help me, but this one helped:
(setq sp-highlight-pair-overlay nil)

This looks like show-paren-mode
If you have (show-paren-mode t) anywhere in your config file, you might want to remove it. Or you can change the show-paren-style variable value to parenthesis
(setq show-paren-style 'parenthesis)

Related

How to enable auto filling in emacs' c-mode?

all
Now I'm editing c sources with emacs under c-mode. How ever auto-fill-mode doesn't seem to work at all. Here how I enabled and tried to use it.
M-x auto-fill-mode (enable auto-fill-mode)
Typed in a line longer than auto-fill size(which 80 characters for now) --> didn't break the line
Tried to auto-filled by issuing M-q
However above attempt didn't work out at all.
Could anybody point out that what have I done wrong?
Thanks for your help in advance.
When you use auto-fill-mode in c-mode, the default behavior is to wrap text only when writing text, as in a comment. You can override this by customizing the value of c-ignore-auto-fill. Note that emacs will wrap and indent your code as text, which is probably not what you want.
A better solution is probably to bind space to a function like this:
(defun insert-space-or-newline-and-indent ()
(interactive)
(if (>= (current-column) fill-column)
(newline-and-indent)
(insert-char ? )))

emacs: ruby mode after reindent-then-newline-and-indent

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.

matching opening and closing braces in emacs

I am a newbie to emacs and have been using it only for a month.
My queries are:
I want to track the matching opening and closing braces in the editor. Is there a command for this?
When trying to use emacs using cygwin in Windows, C-x C-c to close emacs does not work!
Is there a way I can get this to work?
I personally like mic-paren, which has many options for customizing how to show matching parentheses, including showing you the line of the matching paren in the minibuffer when it is off-screen.
I set it up as follows:
(setq paren-dont-touch-blink t)
(require 'mic-paren)
(paren-activate)
(setq paren-match-face 'highlight)
(setq paren-sexp-mode t)
show-paren-mode will highlight matching parentheses, at least when the cursor is on one or the other.
A more powerful alternative is highlight parentheses mode. This will highlight all the parentheses around point (the cursor), so you see the scope of all the enclosing parentheses as you navigate your code.
There are other options as well, listed on the wiki.

How to make parenthesis matching work in XEmacs?

I tried using all options in the menu setting Options|Display|Paren Highlighting, but nothing works - no parenthesis match is performed. I also tried setting explicitly (paren-mode 'blink-paren t) in my init file, but that did not help either. Any ideas what may be happening and how do I fix it?
Thanks.
I have had paren mode working long enough in my XEmacs that I forget what exactly I did to turn it on, but I did dig these things out which might help.
From my .xemacs/init.el:
(require 'paren)
From my .xemacs/custom.el as part of custom-set-variables:
'(paren-mode (quote sexp) nil (paren))
'(show-paren-mode t)
-John

How configure delete-selection-mode to only delete?

I am using GNU Emacs 22.3.1 on Windows.
In my Emacs I have enabled delete-selection-mode, and it's very useful to select a region and delete or replace it. But I have a drawback.
When I write or press DEL over the selection, Emacs does not only remove the text, but it kills (a.k.a. send to the clipboard*). This is very annoying for me, because I don't have control of my kill-ring (a.k.a. clipboard) and may cause unexpected effects.
There is a way that delete-selection-mode does not kill the text, just delete it? Perhaps modify the source code?
(*: I have synchronized the kill-ring and the Windows clipboard, so for me (for practical purposes) it's the same)
Edit[Jun 24, 2009]
Thanks, danielpoe. Even with the idea of Trey Jackson the selection is still killing. And I found the reason.
I discovered that the problem was not in delete-selection-mode. The problem is, when I selected the region, I did it with the mouse. And never have imagined that it was the mouse who was copying the text. Using the set-mark command and the arrow keys the text finally aren't killed, only deleted.
I disabled this behavior writing this in my .emacs:
(require 'delsel)
(setq mouse-drag-copy-region nil)
(global-unset-key (kbd "<mouse-2>"))
(global-unset-key (kbd "<mouse-3>"))
Thanks for the advice. If this method of disable this mouse behavior can cause conflicts with other options, please comment.
Have you tried starting emacs with -Q. If I do so and only enable M-x: delete-selection-mode, I can't reproduce what you describe. Nothing is killed only deleted?! Can you check?
It looks as though you just need to modify a small part of the source, namely make this change:
(defun delete-active-region (&optional killp)
(delete-region (point) (mark))
t)
The original code looked at the argument killp and used that to decide whether to add the region to the kill-ring, and you said you don't ever want that. This change forces the region to always be deleted.
Now, you don't need to actually modify the source, just place that function definition after the (require 'delsel) in your .emacs (or after the (delete-selection-mode)).