GNU bug report logs -
#8415
23.3.50; Extensible Emacs Registers
Previous Next
Reported by: Leo <sdl.web <at> gmail.com>
Date: Sun, 3 Apr 2011 12:30:03 UTC
Severity: wishlist
Tags: patch
Found in version 23.3.50
Fixed in version 24.1
Done: Glenn Morris <rgm <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #55 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello Stefan,
Is this patch OK?
[reg.diff (text/x-diff, inline)]
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog 2011-06-23 03:35:05 +0000
+++ lisp/ChangeLog 2011-06-23 07:46:05 +0000
@@ -1,3 +1,11 @@
+2011-06-23 Leo Liu <sdl.web <at> gmail.com>
+
+ * register.el (registerv): New struct.
+ (registerv-make): New function.
+ (jump-to-register, describe-register-1, insert-register): Support
+ the jump-func, print-func and insert-func slot of a registerv
+ struct.
+
2011-06-22 Leo Liu <sdl.web <at> gmail.com>
* minibuffer.el (completing-read-function)
=== modified file 'lisp/register.el'
--- lisp/register.el 2011-04-19 13:44:55 +0000
+++ lisp/register.el 2011-06-23 05:07:49 +0000
@@ -28,6 +28,8 @@
;; pieces of buffer state to named variables. The entry points are
;; documented in the Emacs user's manual.
+(eval-when-compile (require 'cl))
+
(declare-function semantic-insert-foreign-tag "semantic/tag" (foreign-tag))
(declare-function semantic-tag-buffer "semantic/tag" (tag))
(declare-function semantic-tag-start "semantic/tag" (tag))
@@ -50,9 +52,36 @@
;;; Code:
+(defstruct
+ (registerv (:constructor nil)
+ (:constructor registerv--make (&optional data print-func
+ jump-func insert-func))
+ (:copier nil)
+ (:type list)
+ :named)
+ (data nil :read-only t)
+ (print-func nil :read-only t)
+ (jump-func nil :read-only t)
+ (insert-func nil :read-only t))
+
+(defun* registerv-make (data &key print-func jump-func insert-func)
+ "Create a register value object.
+
+DATA can be any value.
+PRINT-FUNC if provided controls how `list-registers' and
+`view-register' print the register. It should be a function
+recieving one argument DATA and print text that completes
+this sentence:
+ Register X contains [TEXT PRINTED BY PRINT-FUNC]
+JUMP-FUNC if provided, controls how `jump-to-register' jumps to the register.
+INSERT-FUNC if provided, controls how `insert-register' insert the register.
+They both receive DATA as argument."
+ (registerv--make data print-func jump-func insert-func))
+
(defvar register-alist nil
"Alist of elements (NAME . CONTENTS), one for each Emacs register.
-NAME is a character (a number). CONTENTS is a string, number, marker or list.
+NAME is a character (a number). CONTENTS is a string, number, marker, list
+or a struct returned by `registerv-make'.
A list of strings represents a rectangle.
A list of the form (file . FILE-NAME) represents the file named FILE-NAME.
A list of the form (file-query FILE-NAME POSITION) represents
@@ -118,8 +147,10 @@
delete any existing frames that the frame configuration doesn't mention.
\(Otherwise, these frames are iconified.)"
(interactive "cJump to register: \nP")
- (let ((val (get-register register)))
+ (let* ((val (get-register register))
+ (jump-func (and (registerv-p val) (registerv-jump-func val))))
(cond
+ (jump-func (funcall jump-func (registerv-data val)))
((and (consp val) (frame-configuration-p (car val)))
(set-frame-configuration (car val) (not delete))
(goto-char (cadr val)))
@@ -207,8 +238,11 @@
(princ "Register ")
(princ (single-key-description register))
(princ " contains ")
- (let ((val (get-register register)))
+ (let* ((val (get-register register))
+ (print-func (and (registerv-p val) (registerv-print-func val))))
(cond
+ (print-func (funcall print-func (registerv-data val)))
+
((numberp val)
(princ val))
@@ -283,8 +317,10 @@
Interactively, second arg is non-nil if prefix arg is supplied."
(interactive "*cInsert register: \nP")
(push-mark)
- (let ((val (get-register register)))
+ (let* ((val (get-register register))
+ (insert-func (and (registerv-p val) (registerv-insert-func val))))
(cond
+ (insert-func (funcall insert-func (registerv-data val)))
((consp val)
(insert-rectangle val))
((stringp val)
[Message part 3 (text/plain, inline)]
Leo
This bug report was last modified 13 years and 323 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.