From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/27292 Path: news.gmane.org!not-for-mail From: Sanjoy Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: emacs lisp for context in AucTeX Date: Thu, 20 Apr 2006 11:15:52 -0400 Message-ID: References: <97a06f070604200523h37a656ceh990b2565db50a85f@mail.gmail.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" X-Trace: sea.gmane.org 1145548589 3450 80.91.229.2 (20 Apr 2006 15:56:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 20 Apr 2006 15:56:29 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Thu Apr 20 17:56:28 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1FWbVu-0001dT-US for gctc-ntg-context-518@m.gmane.org; Thu, 20 Apr 2006 17:56:15 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 94175127A3; Thu, 20 Apr 2006 17:56:14 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 16609-04-2; Thu, 20 Apr 2006 17:56:09 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id A52C61279F; Thu, 20 Apr 2006 17:56:09 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id A5DC01279D for ; Thu, 20 Apr 2006 17:56:07 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 16609-04 for ; Thu, 20 Apr 2006 17:56:05 +0200 (CEST) Original-Received: from smtpauth08.mail.atl.earthlink.net (smtpauth08.mail.atl.earthlink.net [209.86.89.68]) by ronja.ntg.nl (Postfix) with SMTP id CCDC3127A9 for ; Thu, 20 Apr 2006 17:16:47 +0200 (CEST) Original-Received: from [24.41.6.91] (helo=approximate.corpus.cam.ac.uk) by smtpauth08.mail.atl.earthlink.net with asmtp (TLSv1:AES256-SHA:256) (Exim 4.34) id 1FWata-0005zE-OF; Thu, 20 Apr 2006 11:16:38 -0400 Original-Received: from sanjoy by approximate.corpus.cam.ac.uk with local (Exim 4.60) (envelope-from ) id 1FWasr-0006nS-3W; Thu, 20 Apr 2006 11:15:53 -0400 Original-To: johan.sandblom@ki.se, mailing list for ConTeXt users In-Reply-To: Your message of "Thu, 20 Apr 2006 14:23:41 +0200." <97a06f070604200523h37a656ceh990b2565db50a85f@mail.gmail.com> X-Mailer: MH-E 7.93; nmh 1.1; GNU Emacs 21.4.1 Content-ID: <26128.1145546152.0@localhost> X-ELNK-Trace: dcd19350f30646cc26f3bd1b5f75c9f474bf435c0eb9d4789de090ecffd5a975ba1520107e6aaeb84c7f582b2a7a7501350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 24.41.6.91 X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:27292 Archived-At: ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26128.1145546152.1@localhost> Great. Mojca suggested that I wikify my Emacs lisp. It's now at . Following that method ('a method is a trick I use twice.' --Polya), I've put your elisp there too -- hope that's okay. I removed the (local-set-key "$" 'start-context-math) so that your code can stand alone (in case people want one or the other). I had to change a few things at the end (some maybe because I'm using GNU Emacs rather than XEmacs, not sure). Below is the diff and I've attached the resulting version. Most of the trouble was in the keybindings: (local-set-key "\C-c\C-fc" 'context-insert-FLOW-cells) doesn't work because C-c C-f is already defined as TeX-font, so it can't be a prefix as well. So I chose "\C-cnF". Also the function name needed an "s" at the end. These two: (local-set-key "\C-cnn" 'context-insert-nattab) (local-set-key "\C-cnr" 'context-insert-nattab-row) have a related problem, in that "\C-cn" is not a prefix yet, so "\C-cnn" and "\C-cnr" are not valid sequences. So I changed the first use of "\C-cn" as a prefix to use define-key(), which seems to make a prefix-map automatically as I eventually learnt by inspecting tex.el. So: (define-key (current-local-map) "\C-cnF" 'context-insert-FLOW-cells) Then the following local-set-key's work. As I say, this is on Emacs 21.4, and the tricks may be different on XEmacs. -Sanjoy --- a/tables.el 2006-04-20 10:46:16.000000000 -0400 +++ b/tables.el 2006-04-20 10:43:41.000000000 -0400 @@ -1,5 +1,5 @@ (defun context-insert-nattab (rows columns) - ;; Johan Sandblom 060128 + ;; Johan Sandblom 2006-01-28 "Insert a TABLE skeleton" (interactive "nNumber of rows: \nnNumber of columns: \n") (newline) @@ -44,8 +44,8 @@ (newline) (backward-char 5)) -(defun context-insert-FLOW-cell (n) - ;; Johan Sandblom 060128 +(defun context-insert-FLOW-cells (n) + ;; Johan Sandblom 2006-01-28 "Insert a FLOWchart cell" (interactive "nNumber of cells: \n") (newline) @@ -62,8 +62,7 @@ (add-hook 'ConTeXt-mode-hook '(lambda () - (local-set-key "\C-c\C-fc" 'context-insert-FLOW-cells) + (define-key (current-local-map) "\C-cnF" 'context-insert-FLOW-cells) (local-set-key "\C-cnr" 'context-insert-nattab-row) (local-set-key "\C-cnc" 'context-insert-nattab-column) - (local-set-key "\C-cnn" 'context-insert-nattab) - (local-set-key "$" 'start-context-math))) + (local-set-key "\C-cnn" 'context-insert-nattab))) ------- =_aaaaaaaaaa0 Content-Type: text/plain; name="natural-tables.el"; charset="us-ascii" Content-ID: <26128.1145546152.2@localhost> Content-Description: revised natural tables elisp (defun context-insert-nattab (rows columns) ;; Johan Sandblom 2006-01-28 "Insert a TABLE skeleton" (interactive "nNumber of rows: \nnNumber of columns: \n") (newline) (insert "\\bTABLE\n\\setupTABLE\[\]\n") ;; First a TABLE header (insert "\\bTABLEhead\n\\bTR\\bTH \\eTH\n") (let ((column 1)) (while (< column (- columns 1)) (insert " \\bTH \\eTH\n") (setq column (1+ column)))) (insert " \\bTH \\eTH\\eTR\n\\eTABLEhead\n\\bTABLEbody\n") ;; The rows and columns (let ((row 1)) (while (<= row rows) (insert "\\bTR\\bTD \\eTD\n") ;; The let expression makes sure that each loop starts at the ;; right place (let ((column 1)) (while (< column (- columns 1)) (insert " \\bTD \\eTD\n") (setq column (1+ column))) (insert " \\bTD \\eTD\\eTR\n") (setq row (1+ row)))) (insert "\\eTABLEbody\n\\eTABLE\n"))) (defun context-insert-nattab-row (columns) "Insert a row in a TABLE" (interactive "nNumber of columns: \n") (newline) (insert "\\bTR\\bTD \\eTD\n") (let ((column 1)) (while (< column (- columns 1)) (insert " \\bTD \\eTD\n") (setq column (1+ column))) (insert " \\bTD \\eTD\\eTR\n"))) (defun context-insert-nattab-column (&optional arg) "Insert a column in a TABLE" (interactive "P") (insert "\\bTD \\eTD") (indent-for-tab-command) (newline) (backward-char 5)) (defun context-insert-FLOW-cells (n) ;; Johan Sandblom 2006-01-28 "Insert a FLOWchart cell" (interactive "nNumber of cells: \n") (newline) (let ((x 1)) (while (<= x n) (insert "\\startFLOWcell\n") (insert " \\name {}\n") (insert " \\location {}\n") (insert " \\shape {action}\n") (insert " \\text {}\n") (insert " \\connection[rl]{}\n") (insert "\\stopFLOWcell\n") (setq x (1+ x))))) (add-hook 'ConTeXt-mode-hook '(lambda () (define-key (current-local-map) "\C-cnF" 'context-insert-FLOW-cells) (local-set-key "\C-cnr" 'context-insert-nattab-row) (local-set-key "\C-cnc" 'context-insert-nattab-column) (local-set-key "\C-cnn" 'context-insert-nattab))) ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context ------- =_aaaaaaaaaa0--