From: Leo <sdl.web@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 8415@debbugs.gnu.org
Subject: bug#8415: 23.3.50; Extensible Emacs Registers
Date: Thu, 23 Jun 2011 16:11:27 +0800 [thread overview]
Message-ID: <m1wrgdezm8.fsf@gmail.com> (raw)
In-Reply-To: <jwvwrj49q2q.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 08 Apr 2011 22:25:02 -0300")
[-- Attachment #1: Type: text/plain, Size: 34 bytes --]
Hello Stefan,
Is this patch OK?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: reg.diff --]
[-- Type: text/x-diff, Size: 3844 bytes --]
=== 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@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@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)
[-- Attachment #3: Type: text/plain, Size: 5 bytes --]
Leo
next prev parent reply other threads:[~2011-06-23 8:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-03 12:29 bug#8415: 23.3.50; Extensible Emacs Registers Leo
2011-04-03 17:21 ` Daniel Colascione
2011-04-04 1:29 ` Leo
2011-04-04 14:29 ` Stefan Monnier
2011-04-04 17:37 ` Leo
2011-04-04 22:19 ` Stefan Monnier
2011-04-04 22:27 ` Daniel Colascione
2011-04-05 1:41 ` Stefan Monnier
2011-04-05 1:49 ` Daniel Colascione
2011-04-05 3:07 ` Stefan Monnier
2011-04-05 5:42 ` Leo
2011-04-05 13:50 ` Stefan Monnier
2011-04-06 5:00 ` Leo
2011-04-06 15:38 ` Stefan Monnier
2011-04-07 3:13 ` Leo
2011-04-09 1:25 ` Stefan Monnier
2011-06-23 8:11 ` Leo [this message]
2011-06-25 13:19 ` Stefan Monnier
2011-06-26 6:42 ` Leo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1wrgdezm8.fsf@gmail.com \
--to=sdl.web@gmail.com \
--cc=8415@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.