Emacs using Ido no longer remembers buffer list between sessions - emacs

When i C-x b to get the list of buffers (using ido) on my Linux installation of Emacs 24.3 i have a list of the recent buffers in grey. When i open a few buffers and the C-x b again these are now listed in white. So there appears to be two groups of buffers in the buffer list - 'opened this session' and 'opened previously'.
I recently installed Emacs 24.3 on Windows and this behaviour does not appear. I only have a 'opened this session' list of buffers when i C-x b. How can i add the 'opened previously' list?

the variable ido-use-virtual-buffers causes recently opened files to be listed in the C-x b list.
(setq ido-use-virtual-buffers t)
this variable is set in the package starter-kit.

Related

Why doesn't modifying the .emacs file change the behavior of GNU Emacs?

I'm running GNU Emacs 24.3.1 on Windows 7. As mentioned in this manual page, I can type
C-x d ~/ RET
to determine the location of my home directory. In my case, Emacs returns:
e:/EmacsDocs
which, according to Windows Explorer, indeed contains a file .emacs. When I open .emacs with Emacs, the file appears to be empty.
Now, I want to set Emacs so that it is in overwrite mode by default. According to this page, that can be done by adding the following to .emacs:
(setq-default overwrite-mode t)
But when I make this change to .emacs and close and reopen Emacs, Emacs does not overwrite when I select text and start typing. (Rather, it still operates in insertion mode, with new characters inserted before the cursor.)
I also tried, for example, adding this command to .emacs, which according to this page will disable cursor blinking:
(blink-cursor-mode 0)
but again, there is no change when I restart Emacs.
How can I tell if Emacs is actually reading the .emacs in the home directory (upon restarting Emacs)?
You are confusing what Emacs calls overwrite-mode with the requested behavior "overwrite when I select text and start typing".
In Emacs, the latter behavior is called delete-selection-mode, and overwrite-mode means that when you type text (without selecting anything), any existing text that follows the cursor is overwritten by what you type.
Most Emacs users do not turn on overwrite-mode by default, and they just hit the insert key (typically to the left of the home key) to toggle `overwrite-mode on/off when they need/want to.
One way to turn on delete-selection-mode by default is to put one of the following in your init file (.emacs):
(setq delete-selection-mode t)
or
(delete-selection-mode)
Another way is to customize the option delete-selection-mode using M-x customize-option RET delete-selection-mode RET and save the customized value.
Instead of editing the file outside of Emacs, just type
C-x C-f ~/.emacs
and add your configurations there. Save with
C-x C-s
and restart. This should work, since ~ in Emacs defaults to the home directory.

Bookmarks+ list bookmarks crashes Emacs

I am using Ubuntu 12.04 and GNU Emacs 23.3.1.
I just tried the bookmarks+ library (http://www.emacswiki.org/emacs/BookmarkPlus) I downloaded the files from that site, e.g. bookmarks+.el from http://www.emacswiki.org/emacs/download/bookmark%2b.el
I put the files in my ~/emacs directory, and I put
(setq load-path
(append (list nil "~/emacs")
load-path))
(require 'bookmark+)
in my ~/.emacs startup file. To debug I have deleted everything else in my ~/.emacs..
To make it simple, lets say I now start Emacs as follows:
bash$ emacs ~/.emacs &
Then I add a single bookmark using C-x p m, and then enter
C-x r l to bring up the bookmarks buffer, and I get the follwing screen shot:
Now there are several ways to make Emacs crash:
I can just wait some seconds
I can try to change buffer with C-x b
I can select the bookmark and then return to the .emacs buffer, and then press C-x b again..
When it crashes the frame is grayed and nothing happens, whereas in the Gnome terminal I get the error message
*** glibc detected *** emacs: realloc(): invalid next size: 0x000000000228e1a0 ***
If you have the same problem after trying a different Emacs build (order not too important, and items are not necessarily related -- i.e., try one or more of these things):
Remove nil from your sexp that updates load-path. And remove ~/.emacs, unless it is a directory. load-path should be a list of directory names. And it should include the directory where the Bookmark+ files are located. Typically, you do (add-to-list 'load-path "/some/directory") to add a directory to load-path.
For your testing, unless you have already done so, remove your bookmarks file. IOW start from zero, as you tried to do by emptying your .emacs. Start with no bookmarks.
What happens if you do the same things (e.g. C-x r l followed by C-x b) without loading Bookmark+, i.e., using the vanilla Emacs bookmark code?
Remove any byte-compiled Bookmark+ files, so you use *.el files, not *.elc. Then set debug-on-error to t. (But if Emacs is crashing then you probably won't get a Lisp backtrace.)
Try M-x debug-on-entry switch-to-buffer (or whatever other function you think the crash might occur in), and then step through the debugger using d (or skip through parts you don't care about, using c). For the most clarity (detail), load the Lisp source file that defines the function that you pass to debug-on-entry. E.g., if it is switch-to-buffer then in recent Emacs builds the file would be window.el. Do C-h f switch-to-buffer (or whatever function) to see just what file to load. Load the file using load-file or load-library (with an explicit .el suffix), not require, so you load the *.el.
Every Emacs crash indicates an Emacs bug (Emacs should never crash). If the crash creates a file emacs_backtrace.txt in the current directory then use M-x report-emacs-bug and include that file in your bug report.
If debugging this helps narrow down the cause of the crash, then consider using M-x report-emacs-bug to report the narrowed-down recipe to reproduce the crash.

Emacs 24.2 CUA-mode behaviour on Shift-up/down

I've set (cua-mode t) in my ~/.emacs in GNU Emacs 24.2 on Windows XP. However, when (with nothing selected) I type shift-up or shift-down no new selection is started, which is not the CUA behaviour as seen in MS Notepad, Eclipse etc. If I type shift-left/right then shift-up/down then indeed a new selection is created and extended as I continue to type shift-up/down.
Now, in Emacs 23.1 the initialisation sequence:
(pc-selection-mode)
(load "cua-mode")
(CUA-mode t)
did exhibit the expected behaviour, but all that is now obsolete AFAICS. So, any ideas on how to get the initial shift-selection working as in other Windows apps?

How to clear the Emacs buffer history?

When I press C-x b (ido-switch-buffer) I get a lot of buffers that I don't want to see. I'd like to clear the buffer history.
I tried evaluating this expression (using M-x eval-buffer):
(setq ido-buffer-history '())
And it took effect; I can tell because I looked at the variable with C-h v ido-buffer-history. However, the change did not get reflected in the minibuffer when I press C-x b.
What else should I do? Are there other variables I should be clearing?
UPDATE : The 'extra' buffers that I'm seeing are not active. Interestingly, C-x C-b (ido-fallback-command) shows exactly what I would expect. It is the buffer history that I'm interested in. (See the buffer-name-history and ido-buffer-history variables for more context.)
Note: Perhaps it will help to mention that I'm using the emacs-starter-kit which has ido-ubiquitous installed.
Add the following to your init.el: (setq ido-use-virtual-buffers nil)
For posterity:
Those are all the active buffers in your session. You can clean them with the following commands:
M-x clean-buffer-list will close any clean buffers you haven't used in a while
M-x kill-some-buffers will visit each buffer and ask if you want to close it
M-x kill-matching-buffers will prompt for a regex over buffer names, which you can just leave blank
Edit:
There's also the boring old buffer menu you get with C-x C-b. In this menu, you can hold d until it marks each buffer for deletion, then press x to commit.
Thanks to Chris, I learned about ido's virtual buffers. I don't want to disable ido-use-virtual-buffers altogether. I want to clear the history as needed; these commands accomplish that goal:
(setq ido-virtual-buffers '())
(setq recentf-list '())
(Note that clearing ido-virtual-buffers was not sufficient -- recentf-list also must be cleared.)
I found this entry on emacswiki.
The variable that stores the buffer history you are referring to is buffer-name-history
If you run M-x describe-variable RET buffer-name-history RET you will see all of the dead buffers that no longer really exist. The wiki recommends creating a hook that removes the buffer name from the list whenever you kill a buffer.
I just did: M-x eval-expression RET (setq buffer-name-history '()) RET
This seems to have worked. The next time I ran C-x b I only cycled-through my real buffers.
That said, setting the variable to nil seems to completely disable the functionality (the variable doesn't seem to be re-populated once I open more buffers).

Emacs nxhtml applying wrong mode when using Emacs-desktop

I have I standard Emacs/nxhtml install. My nxhtml-autoload.el has the following line (I use .djhtml for my django template files)
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . django-nxhtml-mumamo-mode))
I also use Emacs Desktop to re-open buffers ("save desktop state") when starting Emacs. When Emacs Desktop opens buffers, it fails to apply proper nxhtml mode however (django-nxhtml). I can apply the correct mode manually just fine and correct mode is used if I open new buffers.
Emacs desktop is placed at the very bottom of my init.el, so I don't understand why nxhtml is not applied when desktop recreates the old buffers?
Were the buffers in question opened prior to adding & evaluating that auto-mode-alist entry?
The desktop library saves the major mode and minor modes currently associated with each buffer, and re-applies only those modes when restoring them (in order to put you back in the exact same state); so saving and restoring the desktop will not have the desired effect if the buffers were not already in the correct mode.
If you have a lot of files open, you could use ibuffer to revert (reload) them, so that the auto-mode kicks in: M-x ibuffer RET % f \.djhtml RET V