From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bob Proulx Newsgroups: gmane.emacs.help Subject: Re: Emacs Book Vs Emacs Manuals Date: Fri, 26 Jun 2015 23:02:13 -0600 Message-ID: <20150626221204690538460@bob.proulx.com> References: <55561B9E.4070101@arlsoft.com> <87y4kpfvct.fsf@debian.uxu> <87mvzmv7ef.fsf@nl106-137-147.student.uu.se> <871tgycjae.fsf@mbork.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1435381361 17189 80.91.229.3 (27 Jun 2015 05:02:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 27 Jun 2015 05:02:41 +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 Jun 27 07:02:35 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z8iG5-0003cL-Q1 for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Jun 2015 07:02:30 +0200 Original-Received: from localhost ([::1]:34479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8iG4-0005Ui-Al for geh-help-gnu-emacs@m.gmane.org; Sat, 27 Jun 2015 01:02:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8iFv-0005Ua-9p for help-gnu-emacs@gnu.org; Sat, 27 Jun 2015 01:02:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z8iFs-0004Bi-45 for help-gnu-emacs@gnu.org; Sat, 27 Jun 2015 01:02:19 -0400 Original-Received: from joseki.proulx.com ([216.17.153.58]:36500) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8iFr-0004Ba-S2 for help-gnu-emacs@gnu.org; Sat, 27 Jun 2015 01:02:16 -0400 Original-Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 2E7C72185D for ; Fri, 26 Jun 2015 23:02:14 -0600 (MDT) Original-Received: by hysteria.proulx.com (Postfix, from userid 1000) id 071302DC4D; Fri, 26 Jun 2015 23:02:13 -0600 (MDT) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 216.17.153.58 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:105215 Archived-At: Rusi wrote: > Emanuel Berg wrote: > > %% (replace-regexp "^\\(.*&.*&\\).*&\\(.*\\)" "\\1\\2") > > 51 chars (ignoring that things like ^& are shift chords) > > F3 > C-s & RET C-SPC C-s C-s RET C-w C-a C-n > F4 > > 16 keystrokes counting each chord as 1 1/2 keys I don't think keyboard golf is the best justification for something. It helps. But for me keyboard macros are simply more interactive. They are a way to quickly multiply one keystroke into many. But the above does make me realize that I often use keyboard macros when the "shape" of the text is a factor in the editing of it. Such as when I need to make edits around something both above and below it. I might need to move a chunk of text up or down or otherwise mutate it in unusual ways while editing. During the keyboard macro I can search for something, then search for something different, perhaps several times to land on the right starting point. Then I can move up or down spatially to be where I want to be. That is much harder to do with regular expression. I grew up with regular expressions and use them all of the time. But I use different tools at different times. Here is a contrived example. Split the buffer into two windows. C-x 4 C-f /tmp/outfile RET C-x o Then set up this quick keyboard macro. C-s ;; isearch-forward-regexp \ ;; self-insert-command ^ ;; self-insert-command C-p ;; previous-line C-SPC ;; set-mark-command C-b ;; backward-char M-w ;; kill-ring-save C-n ;; next-line C-e ;; move-end-of-line C-x o ;; other-window C-y ;; yank C-x o ;; other-window Run that on this following, C-x e, e, e, e, e, repeatedly executing the macro and decode the (not so) secret message. the quick brown fox jumps over a lazy dog ^ the quick brown fox jumps over a lazy dog ^ the quick brown fox jumps over a lazy dog ^ the quick brown fox jumps over a lazy dog ^ the quick brown fox jumps over a lazy dog ^ the quick brown fox jumps over a lazy dog ^ the quick brown fox jumps over a lazy dog ^ the quick brown fox jumps over a lazy dog ^ the quick brown fox jumps over a lazy dog ^ the quick brown fox jumps over a lazy dog ^ the quick brown fox jumps over a lazy dog ^ Regular expressions are awesome. But keyboard macros are awesome too. Bob