I recently upgraded to 23.1.5 from 23.0.6, and a few of my customizations broke - not many, but I also made a number of changes to my configuration, so I figured I’d cover them all here. Overall, it was a pretty easy process - the only customization that broke that I still haven’t figured out is Slime breaking. It works if I run everything up to and including the call to slime, but not if I then continue running my other customizations.
These first customizations modify general Emacs behavior. debug-on-error will give a backtrace when an error is encountered in any running elisp code; this makes it much easier to debug problems. If display-battery-mode is on, your battery level and heat is shown in the mode line. apropos-do-all will make apropos do everything; it is much more useful this way. Setting pop-up-windows to nil will stop emacs from changing your window configuration, and confirm-nonexistent-file-or-buffer will stop emacs from prompting you whenever you create a new file.
(setq debug-on-error t) (display-battery-mode t) (setq apropos-do-all t) (setq pop-up-windows nil) (setq temporary-file-directory "~/.emacs.d/tmp/") (setq confirm-nonexistent-file-or-buffer nil)
I also noticed that hitting the spacebar now inserted a space character in my minibuffer. This is essentially never what I want, so I changed it to completion with:
(define-key minibuffer-local-map (kbd "SPC") 'minibuffer-complete)
The next set of customizations I added modified the behaviour of shell modes. The first one will cause cycling to skip unique values; if you run the same command twice, M-p twice will take you to a different commands. The other two are fairly self-explanatory, and are for showing as much as possible in the buffer.
(setq comint-input-ignoredups t) (setq comint-scroll-show-maxiumum-output) (setq comint-scroll-to-bottom-on-input t)
Finally, I added a few functions to help out. M-x google will now prompt me for a search string and then open a browser with a query for that string. Line-matches is used programatically in order to tell if the line point is on matches the given regular expression.
(defun google (query) "googles a query" (interactive "sQuery:") (browse-url (concat "http://www.google.com/search?q=" query))) (defun line-matches (regexp) "Returns non-nil if the current line matches the given regexp, nil otherwise." (save-excursion (end-of-line) (let ((end (point))) (beginning-of-line) (re-search-forward regexp end t))))
Tags: emacs
Re: your google function. Have you seen webjump? It’s part of GNU Emacs and XEmacs now.
http://www.neilvandyke.org/webjump/
I think you can simplify line-matches by using line-end-position:
(defun line-matches (regexp)
“Returns non-nil if the current line matches the given regexp, nil otherwise.”
(save-excursion
(beginning-of-line)
(re-search-forward regexp (line-end-position) t)))
Additionally, as this is to be used from elisp and not interactively, I’d opt for using the -p convention for predicates and protecting the match data:
(defun line-matches-p (regexp)
“Return non-nil if the current line matches the given regexp, nil otherwise.”
(save-excursion
(beginning-of-line)
(let ((inhibit-changing-match-data t))
(re-search-forward regexp (line-end-position) t))))