Commits

Fuco  committed c8a67ec

Fixed the my-special-buffer-back-to-top / bottom functions to properly define the new functions

  • Participants
  • Parent commits 2daaafc

Comments (0)

Files changed (1)

File files/keys.el

 ;; Jump to "logical" top/bottom of buffer in listing buffers
 
 (defmacro my-special-buffer-back-to-top (mode &rest forms)
-  (let ((fname (make-symbol (concat "my-" (symbol-name mode) "-back-to-top")))
-        (mode-map) (make-symbol (concat (symbol-name mode) "-mode-map")))
+  (declare (indent 1))
+  (let ((fname (intern (concat "my-" (symbol-name mode) "-back-to-top")))
+        (mode-map (intern (concat (symbol-name mode) "-mode-map")))
+        (mode-hook (intern (concat (symbol-name mode) "-mode-hook"))))
     `(progn
        (defun ,fname ()
          (interactive)
          (beginning-of-buffer)
-         ,@forms
-         )
-       (define-key ,mode-map [remap beginning-of-buffer] (quote ,fname)))))
+         ,@forms)
+       (add-hook ',mode-hook (lambda () (define-key ,mode-map [remap beginning-of-buffer] ',fname))))))
 
 (defmacro my-special-buffer-jump-to-bottom (mode &rest forms)
-  (let ((fname (make-symbol (concat "my-" (symbol-name mode) "-jump-to-bottom")))
-        (mode-map) (make-symbol (concat (symbol-name mode) "-mode-map")))
+  (declare (indent 1))
+  (let ((fname (intern (concat "my-" (symbol-name mode) "-jump-to-bottom")))
+        (mode-map (intern (concat (symbol-name mode) "-mode-map")))
+        (mode-hook (intern (concat (symbol-name mode) "-mode-hook"))))
     `(progn
        (defun ,fname ()
          (interactive)
          (end-of-buffer)
-         ,@forms
-         )
-       (define-key ,mode-map [remap end-of-buffer] (quote ,fname)))))
+         ,@forms)
+       (add-hook ',mode-hook (lambda () (define-key ,mode-map [remap end-of-buffer] ',fname))))))
 
-;; dired & sunrise
-(defun my-special-buffer-back-to-top (dired)
+(my-special-buffer-back-to-top dired
   (dired-next-line (if dired-omit-mode 2 4)))
-
-(defun my-special-buffer-jump-to-bottom (dired)
+(my-special-buffer-jump-to-bottom dired
   (dired-previous-line 1))
 
-;; occur mode
-(defun my-special-buffer-back-to-top (occur)
+(my-special-buffer-back-to-top occur
   (occur-next 1))
-
-(defun my-special-buffer-jump-to-bottom (occur)
+(my-special-buffer-jump-to-bottom occur
   (occur-prev 1))
 
-;; ibuffer
-(defun my-special-buffer-back-to-top (ibuffer)
+(my-special-buffer-back-to-top ibuffer
   (ibuffer-forward-line 1))
+(my-special-buffer-jump-to-bottom ibuffer
+  (ibuffer-backward-line 1))
 
-(defun my-special-buffer-jump-to-bottom (ibuffer)
-  (ibuffer-backward-line 1))
+(my-special-buffer-back-to-top vc-dir
+  (vc-dir-next-line 1))
+(my-special-buffer-jump-to-bottom vc-dir
+  (vc-dir-previous-line 1))