el/dot-emacs.el: Advise `rename-file' to rename buffers at the same time.
[profile] / el / dot-emacs.el
index 9688aa8..23b2c97 100644 (file)
@@ -169,6 +169,17 @@ library."
     (set-frame-parameter frame 'menu-bar-lines 0)
     (set-frame-parameter frame 'menu-bar-lines old)))
 
+;; Page motion.
+
+(defun mdw-fixup-page-position ()
+  (unless (eq (char-before (point)) ?\f)
+    (forward-line 0)))
+
+(defadvice backward-page (after mdw-fixup compile activate)
+  (mdw-fixup-page-position))
+(defadvice forward-page (after mdw-fixup compile activate)
+  (mdw-fixup-page-position))
+
 ;; Splitting windows.
 
 (unless (fboundp 'scroll-bar-columns)
@@ -577,6 +588,15 @@ Even if an existing window in some random frame looks tempting."
 Pretend they don't exist.  They might be on other display devices."
   (ad-set-arg 2 nil))
 
+;; Rename buffers along with files.
+
+(defadvice rename-file (after mdw-rename-buffers (from to &optional forcep)
+                       compile activate)
+  (let ((buffer (get-file-buffer from)))
+    (when buffer
+      (with-current-buffer buffer
+       (set-visited-file-name to nil t)))))
+
 ;;;--------------------------------------------------------------------------
 ;;; Improved compilation machinery.
 
@@ -861,6 +881,11 @@ Use this to arrange for per-server settings.")
                                              :key #'car))))
     ad-do-it))
 
+;; Preferred programs.
+
+(setq mailcap-user-mime-data
+      '(((type . "application/pdf") (viewer . "mupdf %s"))))
+
 ;;;--------------------------------------------------------------------------
 ;;; Utility functions.
 
@@ -1275,7 +1300,14 @@ case."
   (set (make-local-variable 'mdw-do-misc-mode-hacking) t)
   (local-set-key [C-return] 'newline)
   (make-local-variable 'page-delimiter)
-  (setq page-delimiter "\f\\|^.*-\\{6\\}.*$")
+  (setq page-delimiter (concat       "^" "\f"
+                              "\\|" "^"
+                                    ".\\{0,4\\}"
+                                    "-\\{5\\}"
+                                    "\\(" " " ".*" " " "\\)?"
+                                    "-+"
+                                    ".\\{0,2\\}"
+                                    "$"))
   (setq comment-column 40)
   (auto-fill-mode 1)
   (setq fill-column mdw-text-width)