From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: zeek Newsgroups: gmane.emacs.help Subject: Re: Macros in dired - Is it possible? Date: Sat, 18 Jul 2009 10:19:03 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <7b577771-72b5-4d61-ad90-430bb2e81d49@m3g2000pri.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1247938874 25678 80.91.229.12 (18 Jul 2009 17:41:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 Jul 2009 17:41: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 Jul 18 19:41:08 2009 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 1MSDuE-0004od-Dc for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Jul 2009 19:41:06 +0200 Original-Received: from localhost ([127.0.0.1]:46916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MSDuD-0002qd-Vc for geh-help-gnu-emacs@m.gmane.org; Sat, 18 Jul 2009 13:41:05 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!q40g2000prh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 101 Original-NNTP-Posting-Host: 98.210.185.123 Original-X-Trace: posting.google.com 1247937543 21977 127.0.0.1 (18 Jul 2009 17:19:03 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 18 Jul 2009 17:19:03 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q40g2000prh.googlegroups.com; posting-host=98.210.185.123; posting-account=7iT16wkAAACqcLLRnV0zYFnujvXLMqOo User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.11) Gecko/2009061212 Firefox/3.0.9,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:171015 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:66204 Archived-At: > can you give description in terms of what you watn to do exactly? > e.g. > which files you want to process? are they all html files? files with > certain line? etc? First, thank you for replying. Sorry for the confusion, simplified it too much. Let me try again 60% of all the files are just plain text files 40% are html files I have 2 macros: one for plain text files and another for html files a) The macro for the plain text files looks for certain individual words, and then tries to delete the paragraph that contains that word (actually, it just deletes the line that contains the words and the line above and the line below it (as you astutely surmised). I would like it to delete paragraphs, but this is the best I could do. b) The macro for the html files looks for the same certain words, and then deletes everything between these two tags: and Then, I manually save the file so that I can read the text and html versions later on in the day. Generally, for the text files, the size gets reduced by about 20-50%. Why am I doing this? Over the years I have learned that certain individuals take for ever to get to the point, and that when these individuals use certain words or phrases, the entire paragraph containing those words/phrases is just bla, bla, bla. So the macro just deletes them for me before I read them. Do the paragraphs that get deleted contain information that I am interested in knowing about? Yes, but very rarely. So far it has never been a problem. So I do the following for every file from these certain individuals: Open the file in a buffer Type C-u 0 M-x macro.name RET Manually save the file. Kill the buffer Now, do the exact same thing for the next file, and the next, and the next, etc What would be nice is to just do this one time. So I was thinking would it be possible to mark all the text files in dired and run the macro on all the marked files? The macros run ok, but I have to manually save the file and manually kill the buffer before moving on to the next file. I could never get the macros to save and the kill the buffer for me, so that is why I am saving and killing the buffer manually. Both macros (the one for the text files and the one for the html files) are saved in Lisp code in my .emacs file. > > what do you want to do to each file? delete certain lines, then save? > what text pattern does the line needs to match? etc. > For text files, delete every paragraph that contains those certain words and save the file For html files, delete everything between the two tags: and save the file Example of word searched for: "vacation" Example of phrase searched for "when I was" These are not the actual words/phrases that I search for, but does get the point across. I search for 6 words and 1 phrase. > kbd macros are typically one session use only. they are not meant to > be edited, and they are pretty unreadable. They simply are record of > keystrokes. In your case, of calling kbd macros on kbd macros, is > probably much simpler having a elisp function. > Oh, I see, that is why you are asking for the pattern to match. Never thought of a function. Don't know how to do that yet. Not there yet in the Emacs Lisp tutorial. Snippet of html macro via M-x edit-named-kbd-macro -------------------------------- 3* ;; beginning-of-buffer C-s ;; isearch-forward v ;; self-insert-command a ;; self-insert-command c ;; self-insert-command a ;; self-insert-command t ;; self-insert-command i ;; self-insert-command o ;; self-insert-command n ;; self-insert-command RET ;; org-return C-c C-b ;; outline-backward-same-level C-SPC ;; set-mark-command C-c C-f ;; outline-forward-same-level C-w ;; kill-region C-d ;; delete-char C-a ;; org-beginning-of-line -------------------------------- Cheers