Wednesday, August 4, 2010

ignoring emacs auto buffers in (next/previous)-buffer

I am about 2 yr old emacs user now. I've been doing basic stuff with emacs for long and now trying to transition into emacs power user after getting inspiration from screencasts like this one. More such vids can be found at emacs wiki.

Anyway, The traditional commands for going to next and previous buffers in emacs are "C-x <left/right arrow>". I read a pro tip somewhere that whenever you use next/prev buffer commands, you almost never want to go to one of emacs auto buffers such as *scratch*, *Messages* etc and that unnecessarily slows you down. It sounded so true to me and I got the itch to write elisp for it that ignores those buffers and here it is(I'm sure it could be done better, but then I'm a noob :) )
(defun emacs-buffer-p (name)
(string-match-p "\\*.*\\*" name))

(defun next-non-emacs-buffer (&optional original)
"Similar to next-buffer, but ignores emacs buffer such as *scratch*, *messages* etc."
(interactive)
(let ((tmp-orig (or original (buffer-name))))
(next-buffer)
(if (and
(not (eq (buffer-name) tmp-orig))
(emacs-buffer-p (buffer-name)))
(next-non-emacs-buffer tmp-orig))))

(defun previous-non-emacs-buffer (&optional original)
"Similar to previous-buffer, but ignores emacs buffer such as *scratch*, *messages* etc."
(interactive)
(let ((tmp-orig (or original (buffer-name))))
(previous-buffer)
(if (and
(not (eq (buffer-name) tmp-orig))
(emacs-buffer-p (buffer-name)))
(previous-non-emacs-buffer tmp-orig))))

and re-mapped "C-b", "M-b"(I never used their default keybindings anyway) to them
(global-set-key (kbd "C-b") 'next-non-emacs-buffer)
(global-set-key (kbd "M-b") 'previous-non-emacs-buffer)

Now if, occasionally, I want to goto emacs auto buffers then I can still use "C-x <left/right arrow>".

Sunday, August 1, 2010

how to prove it - a retrospection

I just finished working through velleman's how to prove it. All of my notes and solution to exercises can be found here. After reading it, here is what I think.

What I expected before I started reading it?
I expected to learn how mathematicians *think* when they encounter a conjecture. And, hoped that this would make it easy for me to read/understand any proof based books like cormen et al.

What I found?
Essential logic theory, A *solid* understanding of the abstract *structures* used in proofs and how these structures come from logic. You learn set, relations and functions for free as side effects :)

It helped a lot to have some understanding of (propositional)logic and quantifiers before I started reading this book. After working through this book when you will look at any proof, you will first understand the abstract structure behind the proof(in fact you'll just get it without even thinking about it) and then understand the specific details of the particular proof.

In short, I'm glad I read it. Thanks to Ravi for pointing me to it.