How do I make Emacs start without so much fanfare? - emacs

Every time I start Emacs I see a page of help text and a bunch of messages suggesting that I try the tutorial. How do I stop this from happening?

Emacs has a couple of variables which inhibit these actions. If you edit your emacs control file (.emacs) and insert the following:
;; inhibit-startup-echo-area-message MUST be set to a hardcoded
;; string of your login name
(setq inhibit-startup-echo-area-message "USERNAME")
(setq inhibit-startup-message t)
that should solve your problem. They basically set the inhibit parameters to true to prevent the behavior you want to get rid of.

Put the following in your .emacs:
(setq inhibit-startup-message t)
(setq inhibit-startup-echo-area-message t)

You can customize message in minibuffer therefore remove fanfare:
;; Hide advertisement from minibuffer
(defun display-startup-echo-area-message ()
(message ""))

Put the following in your personal init file (ususally ~/.emacs.el):
(setq inhibit-startup-message t)
(Or (setq inhibit-startup-screen t) in with older Emacs versions.)
You can also turn off the message "For information about GNU Emacs and the GNU system, type C-h C-a." in the echo with the variable inhibit-startup-echo-area-message, but it is not enough to set it to t; you must set it to your username. See the documentation for inhibit-startup-echo-area-message.

If your init file is byte-compiled, use the following form instead:
(eval '(setq inhibit-startup-echo-area-message "YOUR-USER-NAME"))

Add the below to your init file
(setq inhibit-startup-message t
inhibit-startup-echo-area-message t)

Related

Org-refile with ido, not using ido as the completion engine

I'm trying to setup a capture/refile workflow using org-mode, and I'm having trouble getting ido working as the completion engine.
I have ido enabled:
(require 'ido)
(setq ido-everywhere t)
(ido-mode t)
And then later in my configuration I try to setup ido completion with org-refile using the following configuration
(setq org-agenda-files
'("~/org/captured.org"
"~/org/work.org"
"~/org/learning.org"
"~/org/life.org"))
(setq org-refile-targets '((nil :maxlevel . 6)
(org-agenda-files :maxlevel . 6)))
(setq org-refile-use-outline-path 'file)
(setq org-completion-use-ido t)
I would expect that with these settings, when I try to call org-refile I would be presented with an ido completion interface in the minibuffer, listing the files and headings that I can refile to, structured like a directory tree.
What I see, however, is just a blank space, like the non-ido completion interface. I am able to do completion with this interface. For example I can type wo[Tab]em[Tab] to get work/email, but I would much prefer ido.
Is there something wrong with how I've configured this?
After some further poking, and reading on StackOverflow, I realized what the problem was.
I had been experimenting with the variable org-outline-path-complete-in-steps and I had set it to t at some point. Making sure that this variable was set to nil allowed ido to work as I expected.
Thanks to this answer for helping me out: https://stackoverflow.com/a/26682891/173292

Insert current entry into BBDB

I've read that "The easiest way to insert an entry for a person into BBDB is to press : (colon) in the Summary buffer when a message from him is the selected one. If the person is in the database already, nothing happens; otherwise, Emacs asks you if you want to insert him into the database."
That does not work for me, I guess because I'm using BBDB 3.
EDIT: ':' runs the command 'bbdb-mua-display-sender'.
Is there a workaround to this?
This is what I use in my .emacs to work with BBDB-3 in Gnus, it will give this functionality to the ; key:
(require 'bbdb-autoloads)
(require 'bbdb)
;; initialization
(bbdb-initialize 'gnus 'message)
(bbdb-mua-auto-update-init 'gnus 'message)
;; size of the bbdb popup
(setq bbdb-pop-up-window-size 0.15)
(setq bbdb-mua-pop-up-window-size 0.15)
;; What do we do when invoking bbdb interactively
(setq bbdb-mua-update-interactive-p '(query . create))
;; Make sure we look at every address in a message and not only the
;; first one
(setq bbdb-message-all-addresses t)
;; use ; on a message to invoke bbdb interactively
(add-hook
'gnus-summary-mode-hook
(lambda ()
(define-key gnus-summary-mode-map (kbd ";") 'bbdb-mua-edit-field)))
I got this information from somewhere on the net, but can't quite locate where just now; maybe this can set you on the correct path?

Cua-copy/paste and System clipboard in emacs

I've set this in emacs:
(setq x-select-enable-clipboard t)
And it works just fine.
That is, until I copy something from within emacs using cua-copy (bound to C-c).
Then, whenever I try to copy something from other programs and paste it into emacs, it keeps pasting the same entry it last copied using cua-copy.
The clipboard itself still works - the same entry is pasted regularly in any other program.
So far I tried defining several things but to no avail:
(setq x-select-enable-primary nil)
(setq x-select-enable-clipboard t)
(setq select-active-regions t)
(global-set-key [mouse-2] 'mouse-yank-primary)
(setq yank-pop-change-selection t)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
Only when I forcefully paste from the clipboard using the command x-clipboard-yank does it resolve to its proper state, until I use cua-copy again.
Did anyone Ever encountered such a problem, or have any idea how to solve it?
I don't know enough about Emacs to offer any insights, but I can share what works for me (on Ubuntu) since i also have copy/paste bound to C-c/C-v with this in my ~/.emacs:
(cua-mode t)
And per this post: Integrate Emacs copy/paste with System copy/paste I have copying and pasting to/from Emacs without the problem you describe with these lines in ~/.emacs:
(setq x-select-enable-clipboard t)
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
I see you already tried the two lines above, but did you try them alone without the other lines which might be conflicting with them?
This Answer doesn't work for Emacs 24. Adding these lines to my .emacs is what worked for me:
(setq select-active-regions nil)
(setq mouse-drag-copy-region t)

Invalid function warning in Emacs

I wanted to get rid of that automatic "splash screen" that Emacs visits (called GNU Emacs). I added the following line to my .emacs file:
(add-hook 'after-init-hook '(kill-buffer "GNU Emacs"))
Well, it works, but I get the following warning message in the echo area:
"Invalid function: (kill-buffer "GNU Emacs")
I don't see what's invalid. Anyone know?
Thanks,
P.S. I'm sure a better approach would be to get Emacs to just not visit the GNU Emacs in the first place, but I haven't figured out how to do that (maybe something in the default.el file?)
Take a look at the variable inhibit-startup-screen.
(setq inhibit-startup-screen t)
The function add-hook expects a function as its second argument; '(kill-buffer ...) evaluates to a list, which is not a function. One way to turn it into a function is to use the lambda operator:
(add-hook 'after-init-hook (lambda () (kill-buffer "GNU Emacs")))
(setq inhibit-default-init 1) is one way to do it. Didn't it work for you?

How to automatically evaluate certain lisp code after starting an emacsclient?

When starting Emacs, init.el (or .emacs.el) is evaluated. However, when starting emacsclient, no similar lisp code is evaluated.
How can I get a lisp file to be evaluated every time I open a new emacsclient?
(This would be handy for frame specific customizations.)
I assume the answer is to use some hook, but I can't seem to find the correct hook to use.
I look forward to your answers.
You can add a function to the hook 'server-visit-hook, which is run every time the server is called (every time you call emacsclient).
I use the following code to automatically change the behavior of server buffers. I use it especially with the Firefox extension It's All Text. In that extension, buffers are named according to the domain name, so you can figure out which rule to apply by using string-match to match the name of the file.
(defun server-edit-presets ()
(cond
;; When editing mail, set the goal-column to 72.
((string-match "mail\\.google\\.com\\.[0-9a-z]+\\.txt" (buffer-name))
(longlines-mode-off)
(auto-fill-mode 1)
(set-fill-column 72)
(save-excursion
;; Don't know if this is necessary, but it seems to help.
(set-buffer (buffer-name))
(goto-char (point-min))
;; Replace non-breaking strange space characters
(while (search-forward (char-to-string 160) nil t)
(replace-match " "))))))
(add-hook 'server-visit-hook 'server-edit-presets)
(add-hook 'server-visit-hook '(lambda () (longlines-mode 1)))
If you really want new frame customizations, there's create-frame-hook which takes one arg (the new frame)...
If you mean gnuclient, you can use the command-line option "-eval" to evaluate something (and then just make an alias to always eval your customizations).
#LSW:
Try 'window-setup-hook. This addresses the annoyance since it is called even if emacsclient is not passed a file.
It seems that those hooks are no more, so here's the new version.
(add-hook 'server-after-make-frame-hook 'consult-recent-file)