2012-11-18

[emacs]go to end-of-buffer ignore whitespaces





init.el




;;we always need goto end-of-buffer, so we bind it to C-. for simple.
;;sometimes we need goto end-of-buffer, but ignore whitespaces at end-of-buffer
;;so by give end-of-buffer an advice, it'll switch between these points, when you
;;continue typing C-.
(defadvice end-of-buffer (around move-backward-skip-whitespace)
  "Never use tabs for alignment."
  (let ((point-before-move (point)))
    ad-do-it
    (if (and (eq point-before-move (point)) (eq last-command this-command))
        (progn (search-backward-regexp "[^\n\s-]\\W*")
               (forward-char)))
    ))
(ad-activate 'end-of-buffer)
(define-key my-keys-minor-mode-map (kbd "C-.") 'end-of-buffer)

-->