Emacs: setting "comment-column" for all buffers - emacs

I am trying to set the comment-column local variable to 70 by default for every buffer I am opening.
I thought that the only thing I had to do is to put the following line in my .emacs file, and to reload Emacs:
(setq-default comment-column 70)
However, when I restart Emacs, it is still to set to 40.
I also tried equivalent like:
(set-default 'comment-column 70)
I am obviously missing something obvious, but I can't find what. I think there is something I don't know about the local variables such as comment-column.

I cite the help on comment-column:
Documentation: Column to indent right-margin comments to. Each mode
may establish a different default value for this variable; you can set
the value for a particular mode using that mode's hook. Comments might
be indented to a different value in order not to go beyond
`comment-fill-column' or in order to align them with surrounding
comments.
Could the bold-faced part be the problem?
I have tried it at my place. There, most programming modes use the global default value whereas modelica-mode uses its own default value.

Related

Shift selection in Emacs 24 does not highlight text

I must be stupid, but I just switched to Emacs 24, and holding Shift while moving the point no longer highlights text. Mouse selection works as before. What am I missing? Did I turn it off by chance? Or has Shift selection been deemed unergonomical so we have some other, better keyboard-based selection at hand?
Shift selection is enabled by default in Emacs 24.
You can always run emacs -Q to disable your init file and any other default libraries, in order to determine what Emacs' default behaviour is.
You can also run emacs -q which will disable only your init file (other system-wide init files can be loaded).
If the feature works without your init file and does not work with it, you can then start to narrow down what part of your init file is at fault (often by commenting out functionality until the feature starts working as expected -- note Drew's comment).
In this case I suggest that you firstly verify (using C-hv) that the shift-select-mode variable is non-nil (when running with your normal configuration), as a nil value means that shift selection is disabled.
I also found it useful to look at load-path variable, C-h v load-path, which directed me to the culprits, old elpa packages.

How to make mouse click set the point, not the mark in aquamacs

In Aquamacs 2.2 I could do the following:
1) Set the mark with C-SPACE
2) Click somewhere to set the point
Consequently this would define the region. Since Aquamacs-2.3 this behaviour is gone: A click sets both the mark and the point. Is there a way to customize aquamacs to have the old behaviour?
For Emacs 24, here's what worked for me (and may also apply to Aquamacs): Unset the binding for the <down-mouse-1> event, which is what is setting the mark (but not the point; the point is set by a different binding, for the up-event <mouse-1>).
That seems to provide the behavior you are asking for: clicking the mouse after setting the mark via C-space sets the point, and one can see the corresponding region highlighted.
I determined this by reading the help for the bindings above, by doing:
M-x helpkclick, and reading the *Help* text, which explains that <down-mouse-1> is bound to command mouse-drag-region (which sets the mark).
I then tested the resulting behavior by interactively disabling the binding, by doing:
M-x global-unset-key and then clicking; but it is probably much safer to do it programmatically, e.g. in the scratch buffer, by evaluating:
(global-unset-key [down-mouse-1])
If you like the behavior that results, then just copy the above line into your .emacs
Employing the solution described above does seem to cause mouse-dragging to be a little funky, in that it does not highlight the selected region during the drag (but you still get to see what the region is once you let go, and you can now fine tune its end point via single clicks, which may be useful in some circumstances.)

show hidden files in speedbar

Is there a way to display what the docs call level 2 hidden files in the speedbar? E.g. .emacs
Long Answer
It turns out that the unshown files are controlled by a regular expression
Which is usually "^\\(\\..*\\)\\'", which I think means everything that starts with a dot
Setting that regexp with:
(setq speedbar-directory-unshown-regexp "^$")
does the trick of showing everything.
While looking at this, I discovered that there is a bug in the default value of
speedbar-directory-unshown-regexp causing the problem. It should be redefined like this:
(setq speedbar-directory-unshown-regexp "^\\(CVS\\|RCS\\|SCCS\\|\\.\\.*$\\)\\'")
or to whatever you think makes the most sense.

Why do I start iswitchb-mode this way?

According to the emacs info page, here's how you enable iswitchb-mode:
To enable Iswitchb mode, type M-x iswitchb-mode, or customize the
variable iswitchb-mode to t
So I put the following in my .emacs:
(setq iswitchb-mode t)
However, this doesn't seem to work. After searching the emacs wiki, I found that I need to use this:
(iswitchb-mode 1)
Could someone explain why I need to enable it this way? I'd like to get a better understanding of elisp rather than just copying and pasting things from places.
Typically a mode will define both a variable and a function with the same name. The function will set the variable properly when it's called, but it's the function that turns on the mode, not just the variable (that only tracks the mode's state).
In your specific case, you were told told customize the variable, but you simply set it instead. The difference is that when the value of the variable changes, custom knows to do something and `setq' knows nothing of this. If you look at the help for this variable (C-h v iswitchb-mode) you'd get:
iswitchb-mode is a variable defined in `iswitchb.el'.
Its value is t
Documentation:
Non-nil if Iswitchb mode is enabled.
See the command `iswitchb-mode' for a description of this minor mode.
Setting this variable directly does not take effect;
either customize it (see the info node `Easy Customization')
or call the function `iswitchb-mode'.
You can customize this variable.

Why isn't return bound to newline-and-indent by default on emacs

I have tried emacs on and off for a while now and every time I start emacs, I go through the same routine. Customizing. The first one is binding return to newline-and-indent. (g)Vim does this by default. Showing matching parenthesis is also done by default on (g)Vim. It is grea that I can customize emacs to my heart's content but why doesn't emacs have nice and easy defaults? For reference, I am now using Emacs 23 on a RHEL5 box.
Probably because RMS didn't want it, that and because changing long-standing defaults is just an issue of politics. Like vi, Emacs has a hard-core following and basic changes like these are minefields.
Note: if you saved your customizations, then you wouldn't have to re-do them every time...
To have those nice and easy defaults, install Emacs Starter Kit. It enables by default a bunch of useful and convenient features make even the advanced Emacs users more productive.
Otherwise, as TJ pointed out, Emacs Customization Mode (type M-x customize) allows you to save permanently any of the settings. You can even store them in a separate file from your dotemacs―(setq custom-file "~/.emacs-custom.el")―so you can use it in every computer you work on.
The title of your question doesn't really reflect what your question is (and has been answered by Trey and Torok), but I'll tell you why I like it being bound to just newline: useless whitespace. Say you are nested inside a conditional in a function etc. and hit return a couple times to leave a blank line. The blank line now has a bunch of space chars on it. Yes, you can (and I do) remove trailing whitespace before saving, but I also have visual whitespace mode on and I can see it there taunting me.