unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: zeek <zp1zp11@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Macros in dired - Is it possible?
Date: Sat, 18 Jul 2009 10:19:03 -0700 (PDT)	[thread overview]
Message-ID: <aba643e6-1a9f-4179-9110-3a071453de47@q40g2000prh.googlegroups.com> (raw)
In-Reply-To: 7b577771-72b5-4d61-ad90-430bb2e81d49@m3g2000pri.googlegroups.com

> 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: <file> and </file>

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: <file> </file>
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*<C-home>		;; 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




  reply	other threads:[~2009-07-18 17:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2744.1247896840.2239.help-gnu-emacs@gnu.org>
2009-07-18  9:14 ` Macros in dired - Is it possible? Xah Lee
2009-07-18 17:19   ` zeek [this message]
2009-07-18 21:10     ` Anselm Helbig
2009-07-18 21:02 ` muede
2009-07-18 21:08 ` Anselm Helbig
2009-07-19  2:29   ` zeek
2009-07-19 16:04     ` Xah Lee
2009-07-17 18:41 zeek peters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aba643e6-1a9f-4179-9110-3a071453de47@q40g2000prh.googlegroups.com \
    --to=zp1zp11@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).