From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Davis Herring" Newsgroups: gmane.emacs.devel Subject: Re: More conventient move beginning/end of line Date: Mon, 24 Sep 2007 09:30:08 -0700 (PDT) Message-ID: <46324.128.165.123.18.1190651408.squirrel@webmail.lanl.gov> References: <46F469D2.5070007@gmail.com> Reply-To: herring@lanl.gov NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1190651433 718 80.91.229.12 (24 Sep 2007 16:30:33 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 24 Sep 2007 16:30:33 +0000 (UTC) Cc: Emacs Devel To: "Lennart Borgman (gmail)" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 24 18:30:28 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 1IZqpH-0006ia-IS for ged-emacs-devel@m.gmane.org; Mon, 24 Sep 2007 18:30:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IZqpE-0005LC-R2 for ged-emacs-devel@m.gmane.org; Mon, 24 Sep 2007 12:30:24 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IZqpA-0005Gt-HF for emacs-devel@gnu.org; Mon, 24 Sep 2007 12:30:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IZqp7-0005BQ-4y for emacs-devel@gnu.org; Mon, 24 Sep 2007 12:30:19 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IZqp6-0005B4-Ul for emacs-devel@gnu.org; Mon, 24 Sep 2007 12:30:16 -0400 Original-Received: from mailwasher.lanl.gov ([204.121.3.2]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IZqp6-0000v8-F8 for emacs-devel@gnu.org; Mon, 24 Sep 2007 12:30:16 -0400 Original-Received: from mailrelay2.lanl.gov (mailrelay2.lanl.gov [128.165.4.103]) by mailwasher.lanl.gov (8.13.8/8.13.6/(ccn-5)) with ESMTP id l8OGUC4E025178; Mon, 24 Sep 2007 10:30:12 -0600 Original-Received: from webmail1.lanl.gov (webmail1.lanl.gov [128.165.4.106]) by mailrelay2.lanl.gov (8.13.8/8.13.8/(ccn-5)) with ESMTP id l8OGU8kh018157; Mon, 24 Sep 2007 10:30:08 -0600 Original-Received: from webmail1.lanl.gov (localhost.localdomain [127.0.0.1]) by webmail1.lanl.gov (8.12.11.20060308/8.12.11) with ESMTP id l8OGU8Mj028761; Mon, 24 Sep 2007 10:30:08 -0600 Original-Received: (from apache@localhost) by webmail1.lanl.gov (8.12.11.20060308/8.12.11/Submit) id l8OGU8Lx028759; Mon, 24 Sep 2007 09:30:08 -0700 X-Authentication-Warning: webmail1.lanl.gov: apache set sender to herring@lanl.gov using -f Original-Received: from 128.165.123.18 (SquirrelMail authenticated user 196434) by webmail.lanl.gov with HTTP; Mon, 24 Sep 2007 09:30:08 -0700 (PDT) In-Reply-To: <46F469D2.5070007@gmail.com> User-Agent: SquirrelMail/1.4.8-6.el3.2lanl X-Priority: 3 (Normal) Importance: Normal X-CTN-5-MailScanner-Information: Please see http://network.lanl.gov/email/virus-scan.php X-CTN-5-MailScanner: Found to be clean X-CTN-5-MailScanner-From: herring@lanl.gov X-Detected-Kernel: Linux 2.4-2.6 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:79707 Archived-At: > Some editor I used long ago had some behaviour similar to the functions > below. One press on HOME moved to the beginning of line, next to the > start of the text on that line. It would be nice to have this in Emacs > (maybe the ARG part should be skipped): I use these very similar functions. They use the prefix arg to force the normal behavior (although I just use C-a and C-e, which I don't rebind, when I want to avoid these). They also have "bad" docstrings, of course. The important difference is that the end-of-line replacement moves back before up to one comment and whitespace if repeated. (defun maybe-beginning-of-line (ARG) "Move point to beginning of current line, or to beginning of text after indentation if already there. With ARG non-nil, acts as `move-beginning-of-line'." (interactive "P") (if (and (bolp) (null ARG)) (back-to-indentation) (move-beginning-of-line ARG))) (defun maybe-end-of-line (ARG) "Move point to end of current line, or to end of text before any comment if already there. With ARG non-nil, acts as `move-end-of-line'." (interactive "P") (if (and (eolp) (null ARG)) (let* ((opoint (point)) (bpoint (line-beginning-position))) ;; `forward-char' is dumb, but not all modes use ?< syntax. (while (< (point-after (forward-comment 1)) opoint) (skip-syntax-forward " ") (forward-char)) (skip-syntax-backward " " bpoint) ;; If there's nothing but a comment, move back to its start. (when (bolp) (skip-syntax-forward " " opoint))) (move-end-of-line ARG))) Davis -- This product is sold by volume, not by mass. If it appears too dense or too sparse, it is because mass-energy conversion has occurred during shipping.