1
votes

When opening a file in emacs using Window Explorer or GNOME Nautilus File, the file opened in split view and the bottom window contain the emacs welcome screen.

Is there any way that the file opens as a single window and remaining buffer like *scratch", message etc remains open but hidden.

3

3 Answers

1
votes

Here's how to do it for Ubuntu: Write to file /usr/local/share/applications/emacsclient.desktop:

[Desktop Entry]
Name=Emacsclient
GenericName=Text Editor
Comment=View and edit files
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=/usr/local/bin/emacsclient %F
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
StartupWMClass=Emacs

Just make sure that emacsclient is indeed located in /usr/local/bin/emacsclient (you can use which emacsclient in bash to see this). Then execute from bash:

sudo update-desktop-database

Finally, add to your ~/.emacs:

(require 'server)
(or (server-running-p) (server-start))

After this, once an Emacs instance is running, clicking on a file in Nautilus will open it in the current window of Emacs, without changing the window configuration.

1
votes

If you want that behaviour permanently you can use:

(add-hook 'find-file-hook 'delete-other-windows)

in your emacs-initialization.

0
votes

In general, the function display-buffer (or its related family of functions, e.g., pop-to-buffer) defaults to a split-window if no other settings control the window / frame selection. If you have further problems, one of your initial buffer choices is likely using something like that -- or you have a display-buffer-alist setting which is causing it.

Using (setq initial-buffer-choice t) will eliminate the Welcome screen and leave you with just a *scratch* buffer.

I use this in my Emacs setup file:

(setq initial-scratch-message nil)

(setq initial-buffer-choice t)

Depending upon whether you have desktop-save-mode active, you may need something like this also . . . I have modified the desktop-read function so that I can use it subsequent to the after-init-hook (which loads before the emacs-startup-hook).

(add-hook 'emacs-startup-hook (lambda ()
  (bury-buffer "*scratch*") ))