From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.help Subject: Re: how to deal with comment in a new lang mode Date: Sat, 01 Nov 2008 22:23:15 +0100 Organization: FH-Trier Message-ID: <1225574667.102383@arno.fh-trier.de> References: <78961dbc-b748-4a52-bd2d-b793b61d3212@d36g2000prf.googlegroups.com> <413a22e1-3685-4b1a-97d7-cda08401b838@v22g2000pro.googlegroups.com> <1225553160.28988@arno.fh-trier.de> <250e7a38-f6fa-4dcb-93c7-7fc9c1c40339@b31g2000prb.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1225575794 12521 80.91.229.12 (1 Nov 2008 21:43:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 1 Nov 2008 21:43:14 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 01 22:44:17 2008 connect(): Connection refused Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KwOGI-0007mQ-GB for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Nov 2008 22:44:03 +0100 Original-Received: from localhost ([127.0.0.1]:52266 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KwOFA-0006TZ-CT for geh-help-gnu-emacs@m.gmane.org; Sat, 01 Nov 2008 17:42:52 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-2.dfn.de!news-stu1.dfn.de!news.belwue.de!news.uni-kl.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 117 Original-NNTP-Posting-Host: 143-93-54-11.arno.fh-trier.de Original-X-Trace: news.uni-kl.de 1225574697 13858 143.93.54.11 (1 Nov 2008 21:24:57 GMT) Original-X-Complaints-To: usenet@news.uni-kl.de Original-NNTP-Posting-Date: Sat, 1 Nov 2008 21:24:57 +0000 (UTC) User-Agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018) In-Reply-To: <250e7a38-f6fa-4dcb-93c7-7fc9c1c40339@b31g2000prb.googlegroups.com> Cache-Post-Path: arno.fh-trier.de!unknown@dslb-088-069-055-165.pools.arcor-ip.net X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) Original-Xref: news.stanford.edu gnu.emacs.help:164009 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:59351 Archived-At: Xah wrote: > Xah wrote: >>> i suppose i or any could easily write up a command to compact ending >>> parens ... i wonder why it's not really done. I guess its because most >>> people type parens one by one (as opposed to pairs), so they never >>> ends up with hanging parens like above in the first place. > > Andreas Politz wrote: >> However, I would probablly use this baby : >> >> ,----[ C-h k M-^ ] >> | M-^ runs the command delete-indentation >> | which is an interactive compiled Lisp function in `simple.el'. >> | It is bound to M-^. >> | (delete-indentation &optional ARG) >> | >> | Join this line to previous and fix up whitespace at join. >> | If there is a fill prefix, delete it from the beginning of this line. >> | With argument, join this line to following line. >> `---- > > ah yes. That's the one i was looking for. > > Andreas wrote: >> I think your conclusion is true, but as for the proposition (people type >> parens one by one), I think most people simply don't end up with this pattern >> of parentheses when they code lisp. Where did the newline come from >> anyway, especially since it is not desired ? > > i always type paren in pairs (using a kbd shortcut), and i don't ever > manually delete sinle paren. They always move in pairs, so during my > elisp coding the nesting integrity is always maintained. > What I was trying to say is, that inserting parens in pairs does not insert newlines. I don't see the connection. Somehow you end up with newlines between your parentheses and then you need to remove them. Why insert them in the first place ? (rethorical question) -ap > So, i have: > (global-set-key (kbd "H-t") (lambda () (interactive) (insert "()") > (backward-char 1))) > > The “t” is the right hand's middle finger position on dvorak. > (qwerty's k) > The H is Hyper, which is the Windows key on my PC keyboard (used with > OSX). > > plus mark-sexp (Ctrl+Alt+Space). (mark-sexp is recently replaced by a > singe Alt+8 using Nikolaj Schumacher's implementation of extend- > selection recently discussed here, which effectively covers the > functionality of mark-sexp.) > > So, with inserting parens in pairs, mark-sexp, and copy/cut/paste, and > with ergo bindings for cursor moving shortcuts all under right hand, > these makes coding lisp a breeze. > > Note: other sexp navigation commands are used sometimes: > (global-set-key (kbd "M-") 'backward-up-list) > (global-set-key (kbd "M-") 'down-list) > (global-set-key (kbd "M-") 'backward-sexp) > (global-set-key (kbd "M-") 'forward-sexp) > (global-set-key (kbd "M-S-") 'backward-list) > (global-set-key (kbd "M-S-") 'forward-list) > > -------------------------------- > > ok, i just coded a compact-parens. Here it is. The code is not > formatted, so one can see the code shape resulted from a the method > lisp coding of maintaining nesting integrity. > > (defun compact-parens () > "Removing white spaces in ending parenthesises. > Removes white space from cursor point to end of code block (\n\n). > Or, act on a text selection." > (interactive) > (let (meat meatNew p1 p2) > > (setq myword > (if (and transient-mark-mode mark-active) > (progn (setq p1 (region-beginning) ) (setq p2 (region- > end) )) > (save-excursion > (setq p1 (point) ) > (search-forward-regexp "\n\n" nil t) > (setq p2 (- (point) 2)) > ) > )) > > (setq meat (buffer-substring-no-properties p1 p2)) > > (setq meatNew > (with-temp-buffer > (insert meat) > (goto-char (point-min)) > (while (search-forward-regexp "[ \t\n]+)[ \t\n]+" nil t) (replace- > match " )" t t)) > (buffer-string) > )) > > (delete-region p1 p2) > (insert meatNew) > ) > > > ) > > > code haven't been tested much but should work... > > Xah > ∑ http://xahlee.org/ > > ☄