From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: yzhh Newsgroups: gmane.emacs.devel Subject: record-lisp.el - current status Date: Thu, 22 Nov 2007 00:57:01 +0800 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: ger.gmane.org 1195665034 27854 80.91.229.12 (21 Nov 2007 17:10:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Nov 2007 17:10:34 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Nov 21 18:10:38 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Iut5n-00016s-Lu for ged-emacs-devel@m.gmane.org; Wed, 21 Nov 2007 18:10:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iut5Y-00036C-W6 for ged-emacs-devel@m.gmane.org; Wed, 21 Nov 2007 12:10:13 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Iut4e-0001lL-99 for emacs-devel@gnu.org; Wed, 21 Nov 2007 12:09:16 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Iut4b-0001hC-DL for emacs-devel@gnu.org; Wed, 21 Nov 2007 12:09:15 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iut4b-0001gg-5j for emacs-devel@gnu.org; Wed, 21 Nov 2007 12:09:13 -0500 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Iut4a-0006Mi-6J for emacs-devel@gnu.org; Wed, 21 Nov 2007 12:09:12 -0500 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Iusz5-0003QC-SS for emacs-devel@gnu.org; Wed, 21 Nov 2007 17:03:31 +0000 Original-Received: from 211.90.238.185 ([211.90.238.185]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 21 Nov 2007 17:03:31 +0000 Original-Received: from yezonghui by 211.90.238.185 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 21 Nov 2007 17:03:31 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 128 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 211.90.238.185 User-Agent: KNode/0.10.5 X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:83792 Archived-At: Hi, I've been quiet for some time. But I kept do some coding every day. The more code I write, the more I find myself unfamiliar with emacs and lisp. Well, record-lisp.el (if you remember) has now progressed. The following is the code it generated after recording some of my operations. (defun recorded-commands (var2) "List of latest recorded commands." (interactive) (let (var3 var4 var7 (case-fold case-fold-search)) (setq case-fold-search t) ;;; (setq var1 (point-marker)) ; (set-mark-command nil) (search-forward (concat "is" var2)) (search-forward (concat "is" var2)) (setq var3 (point-marker)) ; (set-mark-command nil) (forward-word 1) (forward-word nil) (setq var4 (buffer-substring-no-properties var3 (point))) ; (cua-copy-region nil) ;;; (setq var5 (point-marker)) ; (set-mark-command nil) (end-of-buffer nil) ;;; (setq var6 (point-marker)) ; (set-mark-command nil) (insert var4) ; (yank nil) (setq var7 (point-marker)) ; (set-mark-command nil) (backward-char 2) ;;; (setq var8 (buffer-substring-no-properties var7 (point))) ; (cua-copy-region nil) (forward-char 1) (setq case-fold-search case-fold))) What I did is copy some string, start recording, start isearch, type 'is', yank what I previously copied string into search string, search again, copy the word after cursor, move to end of buffer, yank, copy another char, and stop recording. You can notice that yank something that is not copied(killed) during the recording resulted in a argument 'var2' in the defun. And there are other variables standing for the mark and copied strings. They are used to avoid changing mark and kill-ring which is not encouraged in emacs lisp code. Vars that's not used has corresponding code commented. These are the most commonly needed behaviour, I think. To further explain how customization of the generated code, please see the following internal data I used. The first is a vector of global options regarding the use of variables -their name, constant values (recorded), and usage (as var, arg or const), regarding defun name and doc string. All these can be changed, to get a diffenret version of generated code. The other is a list of 'code template', they represent the recorded commands and references the variables in global options. Generated code come out of this list. (setq reclisp-global-options [(("var8" . ["var8" as-unused "h"]) ("var7" . ["var7" as-var nil]) ("var6" . ["var6" as-unused nil]) ("var5" . ["var5" as-unused nil]) ("var4" . ["var4" as-var "ch"]) ("var3" . ["var3" as-var nil]) ("var2" . ["var2" as-arg "ear"]) ("var1" . ["var1" as-unused nil])) "recorded-commands" "List of latest recorded commands."]) (setq reclisp-code-template (((isearch-forward nil 1)) ((isearch-printing-char)) ((isearch-printing-char)) ((isearch-yank-kill)) ((isearch-repeat-forward)) ((isearch-other-control-char nil)) ((setq (reclisp-want-var-name "var1") (point-marker)) (write-var . "var1") (orig-cmd set-mark-command nil)) ((search-forward (concat "is" (reclisp-want-var-name-or-value "var2"))) (read-var . "var2")) ((search-forward (concat "is" (reclisp-want-var-name-or-value "var2"))) (read-var . "var2")) ((setq (reclisp-want-var-name "var3") (point-marker)) (write-var . "var3") (orig-cmd set-mark-command nil)) ((forward-word 1)) ((forward-word nil)) ((setq (reclisp-want-var-name "var4") (buffer-substring-no-properties (reclisp-want-var-name "var3") (point))) (write-var . "var4") (read-var . "var3") (orig-cmd cua-copy-region nil)) ((setq (reclisp-want-var-name "var5") (point-marker)) (write-var . "var5") (orig-cmd set-mark-command nil)) ((end-of-buffer nil)) ((setq (reclisp-want-var-name "var6") (point-marker)) (write-var . "var6") (orig-cmd set-mark-command nil)) ((insert (reclisp-want-var-name-or-value "var4")) (read-var . "var4") (orig-cmd yank nil)) ((setq (reclisp-want-var-name "var7") (point-marker)) (write-var . "var7") (orig-cmd set-mark-command nil)) ((backward-char 2)) ((setq (reclisp-want-var-name "var8") (buffer-substring-no-properties (reclisp-want-var-name "var7") (point))) (write-var . "var8") (read-var . "var7") (orig-cmd cua-copy-region nil)) ((forward-char 1)))) I have not implemented a customization user interface yet, and I want suggestions. Actually the recording is also incomplete - what's missing include yank-in-minibuffer recording. -- regards, yzhh