"Open Recent" in Emacs - emacs

Does Emacs have the capability to open recent files (e.g. a menu like File > Open Recent...)?
I know that Aquamacs, for OS X, has this feature. But is it common to all Emacs versions?

The most idiomatic method of providing this functionality that I know of is through the use of recentf-mode (more here). I enable it in my initialization file with:
(require 'recentf)
(recentf-mode 1)
It then provides an interactive function, recentf-open-files, which I bind to C-x f, which provides a numbered menu of recently opened files that spans sessions, i.e. even if you shut down emacs and restart it, it will retain your recently opened files. You can bind the function to an accelerator with another line in your initialization file, like:
(global-set-key "\C-xf" 'recentf-open-files)
(Optional)
If you make extensive use of Tramp, recentf will track those files too, and do it's periodic cleanup thing which can be a real mess since the files are remote. Prevent this by putting this in your startup file:
(setq recentf-auto-cleanup 'never)

Ordinary GNU Emacs doesn't have a menu showing recently open files. However, all Emacs commands have history, including find-file (C-x C-f). Selecting “File | Open” in the menu or opening a file with emacsclient also adds to this history. After you press C-x C-f, press up and down to navigate the history of opened files.
The history is saved between sessions if you enable session saving with the desktop package.

If you just want to save the minibuffer history between emacs invocations you can put the following in your .emacs:
(savehist-mode 1)
Unlike the desktop package that can save all your open buffers across invocations, this does just the minibuffer history (e.g. when opening a file you can use the up arrow to navigate the list of files you opened in a previous session).

GNU Emacs does include library recentf.el, since Emacs 22. Just do as indicated by R.P. Dillon.

Related

Emacs does not create new windows for new buffers

I am very new to emacs. I just started using it. After a fresh install of spacemacs on my macbook when I opened a file from neo tree or command line it used to appear in a new window. Now it's opening in the same window and the file that was already open gets hidden. I don't know what I did wrong. I even reinstalled spacemacs from scratch but it is of no use.
Also, I can't find a way to open a file in a new frame and close it in the frame that it's already in.
it used to appear in a new window. Now it's opening in the same
window and the file that was already open gets hidden.
I don't know about spacemacs, but for Emacs generally it's completely
normal when visiting a file for the current window to be re-used.
The pop-up-windows user option would affect this some of the time,
but that's non-nil by default, so you probably have that enabled
already?
M-x customize-option RET pop-up-windows RET
Naturally there are other rules and settings around this behaviour
(which is very flexible), so I would also recommend reading about it
in the manual:
C-hig (emacs)Window Choice
You can use the command find-file-other-window to make Emacs display
the buffer in the 'other' window (creating a new window if necessary).
This is usually bound to C-x4f but
spacemacs may be different?
Refer to: C-hig (emacs)Pop Up Window
Also, I can't find a way to open a file in a new frame and close it
in the frame that it's already in.
Similarly to the above, by default:
C-x5f calls find-file-other-frame
C-x50 calls delete-frame
Refer to: C-hig (emacs)Creating Frames

gnu-emacs drag and drop does not work on window

I have problem with drag-n-drop from outside to gnu emacs.
To investigate the cause,
I wrote and executed these code:
(defun dnd-handler (event &optional new-frame)
(interactive "e")
(message "Got dnd signal"))
(global-set-key [drag-n-drop] 'dnd-handler)
No message appeared, when I dragged a file from desktop to emacs.
Emacs documentation states:
(drag-n-drop position files)
This kind of event is generated when a
group of files is selected in an application outside of Emacs, and
then dragged and dropped onto an Emacs frame. The element position is
a list describing the position of the event, in the same format as
used in a mouse-click event (see Click Events), and files is the list
of file names that were dragged and dropped. The usual way to handle
this event is by visiting these files.
This kind of event is generated, at present, only on some kinds of systems.
Does it mean my system is not supported?
My system consists of
GNU Emacs 24.3.1 (i386-mingw-nt6.1.7601)
of 2013-03-18 on MARVIN
Window 7 Enterprise 64Bit.
Any advice is welcome. Thanks.
Make sure you're not running Emacs with elevated security, as this can block drag and drop operations from other processes not on the same level.
If you're launching Emacs from a shortcut (.lnk file), right click on it, Properties, Advanced, turn off Run as Administrator.
The same thing can happen if you launch Emacs from a console with elevated security.

unable to toggle read-only mode in emacs

I am using emacs-live as my emacs starter config. I have .jade files which when opened in emacs say Buffer is read only.
However these same files I am able to edit in Sublime Text.
I tried toggling the read only by C-xC-q to no effect.
How do I resolve it ?
File permissions shouldn't prevent Emacs from allowing you to toggle the read-only state of an associated buffer.
Can you try M-x toggle-read-only RET instead, to check whether it's the function or just the key binding that isn't working?
I'm assuming that C-xC-q is working in general for other buffers?

How to Save all edited-situations and resume all the situations from the last time when opening Emacs again

I learned that to add those codes in .emacs can make Emacs saves automatically all situations before quitting and start it next time, Emacs can show the last situation and go on editing it.
(load "desktop")
(desktop-load-default)
(desktop-read)
(add-hook 'kill-emacs-hook
'(lambda()(desktop-save "~/")))
but this codes makes a problem that you only can open one Emacs, when you want to start another Emacs at the same time, only the previous one can run.
I want the function saving all situations for the next use, but I also need to start one more Emacs, How can I get the two sides work simultaneously?
Thank you for your help. I am waiting......
Use different desktop files; or use emacsclient instead of emacs to start new editing buffers once you have your main Emacs up and running. There are multiple examples in Google of an emacs alias / function / whatever to start Emacs if it is not running, and otherwise run emacsclient.

how to disable copy file on drag-and-drop

According to a doc
Emacs supports “drag and drop”: dropping a file into an ordinary Emacs window visits the file using that window. As an exception, dropping a file into a window displaying a Dired buffer moves or copies the file into the displayed directory.
How can I disable move or copy of a file in a dired mode so that emacs would visit the file in any mode?
Set dired-dnd-protocol-alist to nil.
(setq dired-dnd-protocol-alist nil)
...or use M-x customize to do it.