Emacs: Add next-register and prev-register.
This commit is contained in:
parent
3a5f6d7a1c
commit
ff420e32f0
|
@ -1,6 +1,6 @@
|
||||||
;;; common.el --- Common settings for text files. -*- lexical-binding: t; -*-
|
;;; common.el --- Common settings for text files. -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
;; Time-stamp: <2020-02-18T19:27:15+0100>
|
;; Time-stamp: <2020-02-19T01:15:14+0100>
|
||||||
|
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
|
@ -16,9 +16,54 @@
|
||||||
(fill-column 80) ; Documents are 80 chars wide by default.
|
(fill-column 80) ; Documents are 80 chars wide by default.
|
||||||
(word-wrap t) ; Wrap at word for continuation lines.
|
(word-wrap t) ; Wrap at word for continuation lines.
|
||||||
|
|
||||||
|
:config
|
||||||
|
(defvar my/current-marker-register 0
|
||||||
|
"An index to the current marker register.")
|
||||||
|
|
||||||
|
(defun my/sort-marker-register-elements (a b)
|
||||||
|
"Returns `t' if the file name is the same and A < B."
|
||||||
|
(and (string= (buffer-file-name (marker-buffer (cdr a)))
|
||||||
|
(buffer-file-name (marker-buffer (cdr b))))
|
||||||
|
(< (marker-position (cdr a))
|
||||||
|
(marker-position (cdr b)))))
|
||||||
|
|
||||||
|
(defun my/marker-registers ()
|
||||||
|
"Returns all registers which markers."
|
||||||
|
(let (result)
|
||||||
|
(dolist (item register-alist)
|
||||||
|
(when (markerp (cdr item))
|
||||||
|
(setq result (cons item result))))
|
||||||
|
(sort result 'my/sort-marker-register-elements)))
|
||||||
|
|
||||||
|
(defun my/next-register ()
|
||||||
|
"Jump to next register."
|
||||||
|
(interactive)
|
||||||
|
(setq my/current-marker-register (+ my/current-marker-register 1))
|
||||||
|
(when (>= my/current-marker-register (length (my/marker-registers)))
|
||||||
|
(setq my/current-marker-register 0))
|
||||||
|
(let (register-element register-name)
|
||||||
|
(setq register-element
|
||||||
|
(car (nthcdr my/current-marker-register (my/marker-registers))))
|
||||||
|
(setq register-name (car register-element))
|
||||||
|
(register-to-point register-name)))
|
||||||
|
|
||||||
|
(defun my/prev-register ()
|
||||||
|
"Jump to previous register."
|
||||||
|
(interactive)
|
||||||
|
(setq my/current-marker-register (- my/current-marker-register 1))
|
||||||
|
(when (< my/current-marker-register 0)
|
||||||
|
(setq my/current-marker-register (- (length (my/marker-registers)) 1)))
|
||||||
|
(let (register-element register-name)
|
||||||
|
(setq register-element
|
||||||
|
(car (nthcdr my/current-marker-register (my/marker-registers))))
|
||||||
|
(setq register-name (car register-element))
|
||||||
|
(register-to-point register-name)))
|
||||||
|
|
||||||
:bind
|
:bind
|
||||||
("C-r" . jump-to-register) ; Move point to location in register.
|
("C-r" . jump-to-register) ; Move point to location in register.
|
||||||
("C-S-r" . point-to-register) ; Store location of point in register.
|
("C-S-r" . point-to-register) ; Store location of point in register.
|
||||||
|
("C-<f5>" . my/prev-register) ; Jump to previous marker register.
|
||||||
|
("C-<f6>" . my/next-register) ; Jump to next marker register.
|
||||||
|
|
||||||
:hook
|
:hook
|
||||||
(text-mode . auto-fill-mode) ; Enable word-wrapping at fill-column.
|
(text-mode . auto-fill-mode) ; Enable word-wrapping at fill-column.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user