Emacs: desktop does not retrieve frame names - emacs

All the frames in my session have an explicit name set with set-frame-name, but when the session is restored through desktop, the names of the frames are not retrieved.
Tried emacs -Q: after starting I change the frame name with set-frame-name, then desktop-save and quit emacs. I reboot with emacs -Q and do desktop-read, but the frame name is not restored. I have looked at .emacs.desktop and I don't see the name of the frame.
Do I need any specific configuration to get the frames to recover their names?
I am using emacs 27.1 with Ubuntu 20.04

I have found a solution by checking the frameset.el file.
It was enough for me to put the following line in the init.el (or .emacs) file:
(push '(name . nil) frameset-filter-alist)
Now desktop.el already retrieves the names of the frames set with set-frame-name
This work because frameset-filter-alist is a copy of frameset-persistent-filter-alist and the name parameter is initially set to neither save (desktop-save) nor retrieve (desktop-read)
With (push '(name . nil) frameset-filter-alist) this behavior is override.

Related

Is it possible to prevent emacs from creating " .#files " [duplicate]

When I modify a buffer, Emacs automatically creates a temporary symlink in the same directory as the file being edited (e.g. foo.c):
.#foo.c -> user#host.12345:1296583136
where '12345' is Emacs' PID (I don't know what the last number means).
Why does Emacs create these links, and how do I prevent it from doing that?
Note that I have turned off auto save mode (M-x auto-save-mode) and disabled backup files (M-x set-variable -> make-backup-files -> nil). When I save a modified buffer, or undo the changes to it, the symlink disappears.
In particular, I'm trying to prevent Emacs from creating these links because they cause the directory timestamp to be modified, which causes our build system to rebuild an entire module instead of compiling and linking for one changed file :/
Thanks for any input!
Update: In order to prevent Emacs from creating interlocking files permanently, you can change src/filelock.c and build a custom binary:
void
lock_file (fn)
Lisp_Object fn;
{
return;
// Unused code below...
}
Update 2: Arne's answer is correct. It's now possible to disable lock files in the latest Emacs (24.3.1), by adding this to your .emacs file:
(setq create-lockfiles nil)
Update: Emacs 24.3 has been released with full support for this new setting!
In the current trunk of emacs, you can simply customize the variable create-lockfiles:
C-h v create-lockfiles
Documentation:
Non-nil means use lockfiles to avoid editing collisions.
In your init file, you can set
(setq create-lockfiles nil)
Get it via
bzr branch bzr://bzr.savannah.gnu.org/emacs/trunk emacs-trunk
make
src/emacs
(I found out about this, because I decided to get active and just add an option like that myself… :) )
The symbolic link is emacs' file interlocking system: the symbolic link indicates that an instance of emacs is editing this file. If another instance tries to edit the same file, emacs will issue a warning. See http://www.gnu.org/software/emacs/manual/html_node/emacs/Interlocking.html
This has nothing to do with auto-save.
I cannot find how to modify or disable file locking from within emacs.

Bookmark+ using a temporary file, despite having asked for a specific file

After typing C-x r l I get a buffer called *Bookmark List*
In this buffer I see:
Bookmark file:
/tmp/bmkp-temp/19236bkt
If I open help (i.e. press h), I see:
Bookmark file: /tmp/bmkp-temp-19236bkt
Sorted:
Filtering: none
Marked: 0
Omitted: 0
Autosave bookmarks: no
Autosave list display: yes
This is even though I have the following in my .emacs file:
(setq bookmark-file "~/.emacs.d/bookmarks")
(setq bookmark-default-file "~/.emacs.d/bookmarks")
(setq bmkp-default-bookmark-file "~/.emacs.d/bookmarks")
(setq bmkp-last-as-first-bookmark-file nil)
Why is it using a different bookmark file from the one I specified?
I also noticed that when I load Emacs the following happens:
Emptying bookmark file `/tmp/bmkp-temp-23808OMn'...
Saving file /tmp/bmkp-temp-23808OMn...
Wrote /tmp/bmkp-temp-23808OMn
Emptying bookmark file `/tmp/bmkp-temp-23808OMn'...done
...
Helm completion enabled
Emptying bookmark file `/tmp/bmkp-temp-23808bWt'...
Saving file /tmp/bmkp-temp-23808bWt...
Wrote /tmp/bmkp-temp-23808bWt
Emptying bookmark file `/tmp/bmkp-temp-23808bWt'...done
...
Emacs goes on a spree deleting temporary bookmark files. ?
Perhaps you were trying to use "bookmark-file bookmarks"? Or anyways, accidently hit C-x p x?
These are claimed to correspond, at EmacsWiki: Bookmark Plus / Bookmark-File Bookmarks, where they say, "bmkp-set-bookmark-file-bookmark, bound to C-x p x". For my Emacs, this is not true.
By typing C-x p C-h, I can check key-bindings that start with C-x p. I find
C-x p x is bound to bmkp-toggle-autotemp-on-set, and
C-x p y is bound to bmkp-set-bookmark-file-bookmark.
Then, the link should say C-x p y instead.
It looks like something, somewhere (e.g. check your .emacs file) has turned on bmkp-temporary-bookmarking-mode. When that mode is on, any bookmarks you create are for the current session only -- they are not saved to your bookmark file.
And that means that your bookmark-file location settings are ignored. (Note, BTW, that bmkp-default-bookmark-file is a function, not a variable -- it is not something that you set. And you don't need all of those bookmark-file settings; some are redundant: old names from old versions of Emacs bookmarking.)
I don't know why you are getting multiple temporary bookmark-file creations and saves. You didn't provide a complete recipe. You should get only one such. This is all I see in *Messages* in this regard, for instance:
Emptying bookmark file `c:/DOCUME~1/me/LOCALS~1/Temp/bmkp-temp-5348su1'...
Saving file c:/Documents and Settings/me/Local Settings/Temp/bmkp-temp-5348su1...
Wrote c:/Documents and Settings/me/Local Settings/Temp/bmkp-temp-5348su1
Emptying bookmark file `c:/DOCUME~1/me/LOCALS~1/Temp/bmkp-temp-5348su1'...done
It also appears that you have a lot of stuff going on (Helm etc.). When trying to understand or debug a problem, it helps to narrow things down as much as possible. Who can tell what other interactions might be involved here?
All of that said, my advice would be to not start out using the temporary bookmarking mode. I would not suggest you use that until you are quite familiar with Bookmark+. You can use temporary bookmarks without using this mode.
Here is the doc about using temporary bookmarks:
http://www.emacswiki.org/cgi-bin/wiki/BookmarkPlus#toc55
Finally, as Stefan suggested, please follow up by email. It's a lot easier for debugging/discussing things in detail.
Thx -- Drew
Update 2019-04-21:
I think what might have happened is that you quit Emacs with bmkp-temporary-bookmarking-mode enabled. Although Bookmark+ (correctly) does not save the file of temporary bookmarks it was not preventing the recording of bmkp-last-as-first-bookmark-file from being updated to point to the temporary file. In your next Emacs session that temporary file (if it still existed) was loaded because of bmkp-last-as-first-bookmark-file.
That should be OK now. Enabling bmkp-temporary-bookmarking-mode now resets bmkp-last-as-first-bookmark-file to nil, so if you quit with the temp mode still enabled, then when you load your bookmark file in a new session the file that is read is the value of bookmark-default-file. (The value of bookmark-default-file is never changed, except by your
customizations.)
It's quite an old question, but since I had just the same problem and the other answers didn't help me I'll post my solution:
I'm using desktop files from desktop.el and the temporary mode was set there in the desktop file! Removing that setting from all my desktop files fixed the problem.
This might be handy:
find ~ -name .emacs.desktop -print0 | xargs -0 grep -l bmkp-temporary-bookmarking-mode

Emacs: How can I automatically start a python interpreter in python-mode?

After every Emacs startup in python-mode I need to open the interpreter in a different buffer and
change the size of the new buffer that it fits emacs-code-browser's history. I want to automate
this activity.
How can I automate that an interactive python shell always appears (after Emacs startup) in an extra buffer like in the screenshot?
UPDATE: See below: workgroups.el and emacs-code-browser seem to collide. See screenshot
Before Editing
After Editing
I use Emacs23, emacs-code-browser and python-mode.el.
UPDATE: I tried to use workgroups.el. I defined a new python workgroup and added the following line to my .emacs: (wg-load "~/.emacs.d/workgroups/python_workgroup.wg"). The windows are, however, messed up. You can see it on the screenshot below:
It think that emacs-code-browser and the settings of my workgroup collide. Is there a way
to avoid this behavior?
also you may try desktop-save-mode:
desktop-save-mode is an interactive autoloaded Lisp
function.
(desktop-save-mode &optional ARG)
Toggle desktop saving (Desktop Save mode).
With a prefix argument ARG, enable Desktop Save mode if ARG is
positive, and disable it otherwise. If called from Lisp, enable
the mode if ARG is omitted or nil.
If Desktop Save mode is enabled, the state of Emacs is saved from
one session to another. See variable desktop-save' and function
desktop-read' for details.
How about using workgroups.el ?
It is used for saving your window configuration which is exactly what you need.
This way you can create a workgroup called for example Python, adjust buffers (including one containing interactive python shell) and everything and save the group, and next time you just open workgroup Python and all buffers open as they were before. If you want it to open automatically when emacs is started, just set your saved Python workgroup as a default workgroup.

What is the correct path to the C source files for Emacs?

So, way back in January, I went here:
http://emacsformacosx.com/
I downloaded Emacs and have been using it on my Mac and I like it. I've started trying to get into Elisp programming. To learn more, I'd like to look up some functions. So for instance I do:
C-h f
and then type "scroll-down"
This gives me the following text:
>scroll-down is an interactive built-in function in `window.c'.
>
>It is bound to <kp-prior>, <prior>, C-1, C-x C-1, M-v.
>
>(scroll-down &optional ARG)
>
>Scroll text of selected window down ARG lines.
>If ARG is omitted or nil, scroll down by a near full screen.
>A near full screen is `next-screen-context-lines' less than a full screen.
>Negative ARG means scroll upward.
>If ARG is the atom `-', scroll upward by nearly full screen.
>When calling from a program, supply as argument a number, nil, or `-'.
And the text "window.c" is a link. So I click on the link and I get:
find-function-C-source: The C source file window.c is not available
I'm getting this error a lot while doing a lot of different things. Where do I find the right path, and how do I tell Emacs what that path is?
I did just recently install some ELPA packages, so maybe one of them is causing some chaos?
The variable source-directory will point to the location where the C sources are. If you have a separately downloaded copy, you'll have to point this variable to that directory.
Most packagers don't include the sources, or split them off into a separate package. Install the sources (and maybe tweak an init script to tell Emacs where you put them, if it's not the default location. The pertinent variable is find-function-C-source-directory).
If you didn't manually build Emacs from the source code and patch the C source code, value of source-directory or find-function-C-source-directory would be wrong.
You can manually download Emacs source code, unpack it somewhere and set above two variables accordingly like following
(setq source-directory "/path/to/your-emacs-repo")
;; OR
(setq find-function-C-source-directory "/path/to/your-emacs-repo/src")
GNU Emacs source code and development is hosted on savannah.gnu.org. You can find all the tags here and download the one that matches your M-x emacs-version.

How do I change Emacs' default font size and font type?

I am using Emacs 23.3. How can I change the font size and font type?
You can also do the following in your .emacs file.
Emacs 23.1
(set-frame-font "Inconsolata 12" nil t)
Older versions of Emacs
(set-default-font "Inconsolata 12" nil t)
You can use the menu bar. Go to Options->Set Default Font....
After you choose a font, don't forget to press Options->Save Options—otherwise your new font will not be saved after you close Emacs.
Get current font by:
M-x describe-font
(Hit Enter if you see Font name (default current choice for ASCII chars): )
This will show a list of attributes which can be set in init.el. After you've had a look the values, minimize the message buffer by C-x 1.
Now do a M-x customize-face and:
Scroll down to the "Default" section
Change the value of "Font Family"
Change the value of "Height"
Hit Enter on "State" and then 1 = Save for Future Sessions
Alternatively, in init.el you could have something like:
(set-face-attribute 'default nil :font "Monospace" :height 160)
Note: If you have a preset for window size (width and height), the height attribute of the font is going to interfere with that layout.
To get an extended list of customization use
M-x customize-face RET
In my answer, I'll concentrate on setting the default font size through X resources. The use of X resources has already been mentioned in the answer mentioning ~/.Xdefaults; I'll give more details (the same which I have already described in https://unix.stackexchange.com/a/426914/4319. Apart from the height of the "default" "face" in Emacs, one can similarly set other font parameters.
To set a specific default font height for Emacs, I have put into /etc/X11/Xresources-site (/etc/X11/Xresources is also OK, though can be overwritten by your distro):
Emacs.default.attributeHeight: 94
This would affect also remote X clients which are Emacs (e.g., emacs started on a remote host via ssh).
/etc/X11/Xresources-site and /etc/X11/Xresources (and probably ~/.Xresources and ~/.Xdefaults) are usually read at the start of your X session; to affect your current X resources immediately, run something like xrdb -merge /etc/X11/Xresources-site. The X resources can be viewed by xrdb -query.
Actually, in my case, /etc/X11/Xresources-site is being read thanks to a line in /etc/X11/Xresources (which is read by the start scripts):
#include "/etc/X11/Xresources-site"
so /etc/X11/Xresources is the thing that is read for sure.
There are also some files with the same syntax which are read each time an X program like emacs starts. In my case, they are: ~/.Xdefaults-MY_HOST_NAME, /etc/X11/app-defaults/Emacs (only for emacs-athena, not for emacs-gtk3), /usr/share/X11/app-defaults/Emacs etc. (But I like the idea of loaded X resources more -- shown with xrdb -query; so that remote X clients read the same X resources.)
Other X resources which Emacs understands are described at https://www.gnu.org/software/emacs/manual/html_node/emacs/Table-of-Resources.html#Table-of-Resources.
Emacs 24.3 had a bug which made it not honor the attributes for the default face coming from the X resources, such as in my example above. This was fixed since 24.4.
Emacs 25.1 on macOS has Menlo 12 as default. I wanted to increase the size.
C-x C-f ~/.emacs
Add this to end of the ~/.emacs file:
(set-default-font "Menlo 14")
To see the change take effect immediately while staying in ~/.emacs:
M-x eval-buffer [RET]
If you use Linux/X11, you may need to set this in ~/.Xdefaults. I
have set the font there since the other answers here have no effect.
I'm able to see available font settings by running in Emacs:
helm-select-xfont
Then I start typing Conso and I see entries like:
-Consolas-normal-normal-normal-*-*-*-*-*-m-0-iso10646-1
...
So then I put it into ~/.Xdefaults, setting size 12 as:
Emacs.font: xft:-*-Consolas-normal-normal-normal-*-12-*-*-*-m-0-iso10646-1
and restart Emacs.
The Emacs way
M-x customize-group
Enter faces
Click on "Basic Faces"
Open / Expand "Default"
Change the font name (like "Inconsolata") and deselect "foundry"
Click "Apply and save"
Simply press M-x, and then type in set-frame-font. All available fonts which exist in your machine will be displayed.
Choose the one you look for. I use this way to change font-type in my Emacs so simply; rather than altering the .spacemacs or .emacs file.