How to view the files loaded in emacs at startup - emacs

How to view the files that are loaded by the emacs at start up.
I have put the following line in my .emacs file
(setq load-path (cons "~/org/org-mode/lisp/" load-path))
(require 'org-install)
and expect the file org-install.el to be displayed in the *Messages* buffer,
I have looked at the *Messages* buffer and not able to find any info on the org-install.* file name.

I use "load" rather than "require" in my .emacs because it appends a message to *Messages* regardless of whether is fails or succeeds.
If you are still confused, say ESC ESC : (load "~/org/org-mode/lisp/org-install.el") RET, and tell us what new messages have appeared in *Messages*.

Related

How to program .emacs file to end up in a specific buffer?

I have this code in my .emacs file:
(load "ielm" nil t)
(switch-to-buffer "*ielm*")
(inferior-emacs-lisp-mode)
(set-buffer-modified-p nil)
In emacs 21 and earlier, I ended up with *ielm* as the current buffer, but starting with emacs 22 I end up with *GNU Emacs* as the current buffer. What changed in emacs 22 to cause the new behavior, and what can I do to automatically end up in the *ielm* buffer?
The Emacs manual, node Entering Emacs tells you:
You can also force Emacs to display a file or directory at startup by
setting the variable initial-buffer-choice to a string naming that
file or directory. The value of initial-buffer-choice may also be a
function (of no arguments) that should return a buffer which is then
displayed. If initial-buffer-choice is non-nil, then if you specify
any files on the command line, Emacs still visits them, but does not
display them initially.
You can find this node in the manual by using C-h r (open the manual) followed by i startup TAB (search the index for "startup"), and choose startup screen. (Other index choices will also take you there.)
Thanks, #Drew.
Adding the following to my .emacs file gives me the behavior I desire.
(if (= (length command-line-args) 1)
(setq initial-buffer-choice
(lambda () (get-buffer "*ielm*"))))

Want to view EMACS Messages buffer while EMACS loads

I use
(message "..some text...")
in my init file to send messages to the Message buffer while EMACS loads. This is a quick way for me to see where a change I have just made crashes the startup.
However, I have not been able to find a way view that buffer during the load and watch the messages scroll. I always have to switch to it after a loading failure to see where it occcured.
Is there anyway to view the messages being sent to the Messages buffer (not the echo line) while Emacs is processing the init file?
How about putting
(view-echo-area-messages)
at the beginning of your init.el?
Or if you instead want the messages buffer to take up the whole screen,
(with-current-buffer (messages-buffer)
(goto-char (point-max))
(switch-to-buffer (current-buffer)))
However, putting messages in your init-file is a crude workaround. You probably actually want to launch Emacs with the --debug-init option:
$ emacs --debug-init
This will halt on the error and present you with a backtrace.
Or alternatively, you could just M-x toggle-debug-on-error and reload your init-file (M-x load-file RET ~/.emacs.d/init.el RET).

Elisp: possible to automatically open Emacs init file if error at start-up?

Here's the idea: if I restart Emacs after making a change to my Emacs init file, it would be very convenient if, in the event of an error at start-up, Emacs automatically opened my init file for editing
For example, if there's an error at start-up, Emacs could show the error/debug message in one window and my init file in the other window.
I'm new to Emacs Lisp and am not familiar with error-handling procedures. Are there any error-handling mechanisms/settings that could be useful? (Am honestly not sure where to even start with this one, hence the lack of any experimental code in this post...)
If you really want to do that, you can try this:
Wrap the contents of your init file in this, where CONTENTS is your originaly init file, and FILE is the absolute name (i.e., location) of your init file:
(condition-case err
(progn
(setq debug-on-error t)
CONTENTS
)
(error (find-file FILE)
(error "*INIT ERROR*: %s" (error-message-string err))))
Or perhaps a little better: Put what is in your init file now in another file - called ORIG-INIT here (again, an absolute file name), and use this as the (only) content of your init file:
(condition-case err
(progn (setq debug-on-error t)
(load-file ORIG-INIT))
(error (find-file ORIG-INIT)
(error "*INIT ERROR*: %s" (error-message-string err))))
Actually, I normally have one emacs open with the .emacs file. Then I open and close a new emacs every time I've made changes. Not as cool, I know, but then even your cursor will be where you were working.
Another thing I do is just edit a piece of code in a scrap buffer (scratch or a newly made temporary file) and execute it using C-x C-e (while standing at the end of the expression).

Emacs: How do I stop "*Buffer List*" from showing when opening 3+ files

When I open 3+ files in emacs, I get a split window with one of my files in the upper buffer and Buffer List in the lower buffer.
How can I get emacs to NOT put Buffer List there, but instead show another one of my files.
thanks. -John
Try this:
(setq inhibit-startup-buffer-menu t)
Documentation can be found here.
Note: This option was introduced in Emacs 22.
For Emacs 21 and before, you could add the following workaround to your .emacs which will force Emacs to only have one window visible upon startup:
(add-hook 'after-init-hook 'delayed-delete-other-windows)
(defun delayed-delete-other-windows ()
"need the call to happen after startup runs, so wait for idle"
(run-with-idle-timer 0 nil 'delete-other-windows))

How do I get list of recent files in GNU Emacs?

When I use Emacs I want to be able to easily display and navigate through a list of files I worked on from not just the current session but from previous sessions. (BTW, running Emacs 22.2 on Windows)
From Joe Grossberg's blog (no longer available):
But if you're using GNU Emacs 21.2
(the latest version, which includes
this as part of the standard distro),
you can just put the following lines
into your .emacs file
;; recentf stuff
(require 'recentf)
(recentf-mode 1)
(setq recentf-max-menu-items 25)
(global-set-key "\C-x\ \C-r" 'recentf-open-files)
Then, when you launch emacs, hit
CTRL-X CTRL-R. It will show a list of
the recently-opened files in a buffer.
Move the cursor to a line and press
ENTER. That will open the file in
question, and move it to the top of
your recent-file list.
(Note: Emacs records file names.
Therefore, if you move or rename a
file outside of Emacs, it won't
automatically update the list. You'll
have to open the renamed file with the
normal CTRL-X CTRL-F method.)
Jayakrishnan Varnam has a page
including screenshots of how this
package works.
Note: You don't need the (require 'recentf) line.
Even if you don't have recentf turned on, Emacs is saving a list of files entered via the minibuffer in the variable file-name-history. Also, executing (savehist-mode 1) in your .emacs file makes that variable persist across invocations of Emacs.
So here's a little function that displays the files that actually exist from that list (anyone is welcome to use/build on this):
(defun dir-of-recent-files ()
"See the list of recently entered files in a Dired buffer."
(interactive)
(dired (cons
"*Recent Files*"
(seq-filter
'file-exists-p
(delete-dups
(mapcar (lambda (s) (string-trim-right s "/*"))
file-name-history)
))))
)
I find this quite useful and have it bound to one of those little special function keys on my desktop keyboard. (And so I have not seen the point of turning on recentf...)