From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.bugs Subject: bug#8415: 23.3.50; Extensible Emacs Registers Date: Thu, 23 Jun 2011 16:11:27 +0800 Message-ID: References: <4D9A45CD.4030808@gmail.com> <4D9A7537.5030005@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1308816753 25778 80.91.229.12 (23 Jun 2011 08:12:33 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 23 Jun 2011 08:12:33 +0000 (UTC) Cc: 8415@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 23 10:12:27 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QZf1V-0005Ep-8Z for geb-bug-gnu-emacs@m.gmane.org; Thu, 23 Jun 2011 10:12:25 +0200 Original-Received: from localhost ([::1]:51891 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZf1T-0007CK-V0 for geb-bug-gnu-emacs@m.gmane.org; Thu, 23 Jun 2011 04:12:24 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:38977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZf1A-0007Be-K7 for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2011 04:12:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QZf19-0001TA-36 for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2011 04:12:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40924) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZf18-0001T6-T0 for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2011 04:12:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QZf18-0000CQ-9B; Thu, 23 Jun 2011 04:12:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Leo Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Jun 2011 08:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8415 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1308816718757 (code B ref -1); Thu, 23 Jun 2011 08:12:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 23 Jun 2011 08:11:58 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QZf14-0000C9-DB for submit@debbugs.gnu.org; Thu, 23 Jun 2011 04:11:58 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QZf12-0000Bx-CI for submit@debbugs.gnu.org; Thu, 23 Jun 2011 04:11:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QZf0v-0001SD-LN for submit@debbugs.gnu.org; Thu, 23 Jun 2011 04:11:50 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:58273) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZf0v-0001S7-CV for submit@debbugs.gnu.org; Thu, 23 Jun 2011 04:11:49 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:38935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZf0t-00079Y-Mp for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2011 04:11:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QZf0r-0001Rd-5L for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2011 04:11:47 -0400 Original-Received: from mail-iw0-f169.google.com ([209.85.214.169]:37501) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZf0q-0001RR-Pn for bug-gnu-emacs@gnu.org; Thu, 23 Jun 2011 04:11:45 -0400 Original-Received: by iwn8 with SMTP id 8so1803810iwn.0 for ; Thu, 23 Jun 2011 01:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=2cO7yN4yaNhR8IsBEdmeEzi9vXuQM10WI9gppXn+pSE=; b=bX7wyyEvlymgw2pgvXdOtWEfhQ3RPWSASbsa2r5H1hDWdmQtKF6Ch7NYhP9tzzgh8c YEVreBBvLJKq9LVyUano4Dm5uO/ld9l+FTiCUaS2FpsXxHvNhst5S3d9Jeur6wBKu5dM iPsbd/uILWQkaYgeOClXjphbzC4DyRmeHQ/C4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=hsSS4oEQp4QzFVkzfCsHSrUTOJvBBTfROtzWcXyXDwer1RBWR6nvs6alMTsAjqthQb yIlGAqIdQFnvFV0+ep1+Ls7ZDMopQXGd+foXWS/jx9ZV4eVaDMr7MH5XJjOTS0/6GR8b d9amI0PRFL3QVoHBihcqKuIDKUaZVBTEuaWeg= Original-Received: by 10.42.168.2 with SMTP id u2mr1836282icy.317.1308816703699; Thu, 23 Jun 2011 01:11:43 -0700 (PDT) Original-Received: from localhost ([114.247.10.75]) by mx.google.com with ESMTPS id vn4sm1403942icb.7.2011.06.23.01.11.36 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 23 Jun 2011 01:11:42 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Fri, 08 Apr 2011 22:25:02 -0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 23 Jun 2011 04:12:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:47417 Archived-At: --=-=-= Content-Type: text/plain Hello Stefan, Is this patch OK? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=reg.diff Content-Description: reg.diff === 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 + + * 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 * 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) --=-=-= Content-Type: text/plain Leo --=-=-=--