diff options
| author | Leo Liu | 2011-06-26 14:37:04 +0800 |
|---|---|---|
| committer | Leo Liu | 2011-06-26 14:37:04 +0800 |
| commit | 6302e0d3ceb59aa9c255d9706ce704543369b4bb (patch) | |
| tree | 0e77b9e68c786feb719fcd2c34e581cc9ca8fd9f | |
| parent | 2afef60a03c32cd6a9db697f12d6284b2b41415a (diff) | |
| download | emacs-6302e0d3ceb59aa9c255d9706ce704543369b4bb.tar.gz emacs-6302e0d3ceb59aa9c255d9706ce704543369b4bb.zip | |
Extend emacs register to accept value from registerv-make
A value object returned by `registerv-make' has slots to control
jump-to-register, describe-register-1 and insert-register.
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/register.el | 48 |
2 files changed, 53 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 81f0eaa723a..52cb69b7d66 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-06-26 Leo Liu <sdl.web@gmail.com> | ||
| 2 | |||
| 3 | * register.el (registerv): New struct. | ||
| 4 | (registerv-make): New function. | ||
| 5 | (jump-to-register, describe-register-1, insert-register): Support | ||
| 6 | the jump-func, print-func and insert-func slot of a registerv | ||
| 7 | struct. (Bug#8415) | ||
| 8 | |||
| 1 | 2011-06-26 Chong Yidong <cyd@stupidchicken.com> | 9 | 2011-06-26 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 10 | ||
| 3 | * vc/vc.el (vc-revert-show-diff): New defcustom. | 11 | * vc/vc.el (vc-revert-show-diff): New defcustom. |
diff --git a/lisp/register.el b/lisp/register.el index af1a421a0a2..82a0cf33c3e 100644 --- a/lisp/register.el +++ b/lisp/register.el | |||
| @@ -28,6 +28,8 @@ | |||
| 28 | ;; pieces of buffer state to named variables. The entry points are | 28 | ;; pieces of buffer state to named variables. The entry points are |
| 29 | ;; documented in the Emacs user's manual. | 29 | ;; documented in the Emacs user's manual. |
| 30 | 30 | ||
| 31 | (eval-when-compile (require 'cl)) | ||
| 32 | |||
| 31 | (declare-function semantic-insert-foreign-tag "semantic/tag" (foreign-tag)) | 33 | (declare-function semantic-insert-foreign-tag "semantic/tag" (foreign-tag)) |
| 32 | (declare-function semantic-tag-buffer "semantic/tag" (tag)) | 34 | (declare-function semantic-tag-buffer "semantic/tag" (tag)) |
| 33 | (declare-function semantic-tag-start "semantic/tag" (tag)) | 35 | (declare-function semantic-tag-start "semantic/tag" (tag)) |
| @@ -50,9 +52,36 @@ | |||
| 50 | 52 | ||
| 51 | ;;; Code: | 53 | ;;; Code: |
| 52 | 54 | ||
| 55 | (defstruct | ||
| 56 | (registerv (:constructor nil) | ||
| 57 | (:constructor registerv--make (&optional data print-func | ||
| 58 | jump-func insert-func)) | ||
| 59 | (:copier nil) | ||
| 60 | (:type vector) | ||
| 61 | :named) | ||
| 62 | (data nil :read-only t) | ||
| 63 | (print-func nil :read-only t) | ||
| 64 | (jump-func nil :read-only t) | ||
| 65 | (insert-func nil :read-only t)) | ||
| 66 | |||
| 67 | (defun* registerv-make (data &key print-func jump-func insert-func) | ||
| 68 | "Create a register value object. | ||
| 69 | |||
| 70 | DATA can be any value. | ||
| 71 | PRINT-FUNC if provided controls how `list-registers' and | ||
| 72 | `view-register' print the register. It should be a function | ||
| 73 | recieving one argument DATA and print text that completes | ||
| 74 | this sentence: | ||
| 75 | Register X contains [TEXT PRINTED BY PRINT-FUNC] | ||
| 76 | JUMP-FUNC if provided, controls how `jump-to-register' jumps to the register. | ||
| 77 | INSERT-FUNC if provided, controls how `insert-register' insert the register. | ||
| 78 | They both receive DATA as argument." | ||
| 79 | (registerv--make data print-func jump-func insert-func)) | ||
| 80 | |||
| 53 | (defvar register-alist nil | 81 | (defvar register-alist nil |
| 54 | "Alist of elements (NAME . CONTENTS), one for each Emacs register. | 82 | "Alist of elements (NAME . CONTENTS), one for each Emacs register. |
| 55 | NAME is a character (a number). CONTENTS is a string, number, marker or list. | 83 | NAME is a character (a number). CONTENTS is a string, number, marker, list |
| 84 | or a struct returned by `registerv-make'. | ||
| 56 | A list of strings represents a rectangle. | 85 | A list of strings represents a rectangle. |
| 57 | A list of the form (file . FILE-NAME) represents the file named FILE-NAME. | 86 | A list of the form (file . FILE-NAME) represents the file named FILE-NAME. |
| 58 | A list of the form (file-query FILE-NAME POSITION) represents | 87 | A list of the form (file-query FILE-NAME POSITION) represents |
| @@ -120,6 +149,11 @@ delete any existing frames that the frame configuration doesn't mention. | |||
| 120 | (interactive "cJump to register: \nP") | 149 | (interactive "cJump to register: \nP") |
| 121 | (let ((val (get-register register))) | 150 | (let ((val (get-register register))) |
| 122 | (cond | 151 | (cond |
| 152 | ((registerv-p val) | ||
| 153 | (assert (registerv-jump-func val) nil | ||
| 154 | "Don't know how to jump to register %s" | ||
| 155 | (single-key-description register)) | ||
| 156 | (funcall (registerv-jump-func val) (registerv-data val))) | ||
| 123 | ((and (consp val) (frame-configuration-p (car val))) | 157 | ((and (consp val) (frame-configuration-p (car val))) |
| 124 | (set-frame-configuration (car val) (not delete)) | 158 | (set-frame-configuration (car val) (not delete)) |
| 125 | (goto-char (cadr val))) | 159 | (goto-char (cadr val))) |
| @@ -209,6 +243,11 @@ The Lisp value REGISTER is a character." | |||
| 209 | (princ " contains ") | 243 | (princ " contains ") |
| 210 | (let ((val (get-register register))) | 244 | (let ((val (get-register register))) |
| 211 | (cond | 245 | (cond |
| 246 | ((registerv-p val) | ||
| 247 | (if (registerv-print-func val) | ||
| 248 | (funcall (registerv-print-func val) (registerv-data val)) | ||
| 249 | (princ "[UNPRINTABLE CONTENTS]."))) | ||
| 250 | |||
| 212 | ((numberp val) | 251 | ((numberp val) |
| 213 | (princ val)) | 252 | (princ val)) |
| 214 | 253 | ||
| @@ -285,8 +324,11 @@ Interactively, second arg is non-nil if prefix arg is supplied." | |||
| 285 | (push-mark) | 324 | (push-mark) |
| 286 | (let ((val (get-register register))) | 325 | (let ((val (get-register register))) |
| 287 | (cond | 326 | (cond |
| 288 | ((consp val) | 327 | ((registerv-p val) |
| 289 | (insert-rectangle val)) | 328 | (assert (registerv-insert-func val) nil |
| 329 | "Don't know how to insert register %s" | ||
| 330 | (single-key-description register)) | ||
| 331 | (funcall (registerv-insert-func val) (registerv-data val))) | ||
| 290 | ((stringp val) | 332 | ((stringp val) |
| 291 | (insert-for-yank val)) | 333 | (insert-for-yank val)) |
| 292 | ((numberp val) | 334 | ((numberp val) |