unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Eric Brown <eric.c.brown@mac.com>, help-gnu-emacs@gnu.org
Subject: RE: Quickly Viewing Files in a File List, and then Quickly Closing
Date: Fri, 18 Oct 2013 09:55:27 -0700 (PDT)	[thread overview]
Message-ID: <d8b9571c-e7ee-4871-acb7-dcc9a33f9d7e@default> (raw)
In-Reply-To: <70b8bb7d-6e1a-418d-af12-c122119094e5@default>

> If you hold down `Control' while doing that (i.e., `C-down') then
> you act on each file in turn.  (You can use `C-RET' to act on a file
> that you have cycled to using just `up' or `down'.)
...
> You could easily define a command that would do that, say putting
> the `kill-buffer' action on a timer or associating it with an event
> (e.g. visiting the next file).

Here is a quick command definition that does that.  It lets you use
the Icicles alternate action keys, `C-S-RET', `C-S-down', etc., which
are analogous to the main action keys, `C-RET', `C-down', etc. (which
visit the candidate), to visit the candidate in `view-mode' and at
the same time kill the buffer of the last such visited candidate.

(defun my-find-file ()
  "Like `icicle-find-file', but alt action views file temporarily.
Alternate action keys such as `C-S-down' visit the candidate file in
`view-mode' and kill the buffer of the last such viewed candidate."
  (interactive)
  (let ((icicle-candidate-alt-action-fn
         (lambda (file)
           (when (and my-last-viewed
                      (get-file-buffer my-last-viewed))
             (kill-buffer (get-file-buffer my-last-viewed)))
           (setq my-last-viewed  (abbreviate-file-name file))
           (view-file file)
           (select-frame-set-input-focus
	      (window-frame (active-minibuffer-window))))))
    (icicle-find-file-of-content)))

(defvar my-last-viewed nil
  "Last file viewed by alternate action of `my-find-file'.")

So you would:

1. Use `M-x my-find-file' (or bind it to a key - e.g., `C-x C-f').
2. Optionally type part of a file name, to limit the matching names.
3. Optionally use `down' or `up' to cycle among file names.
4. Use `C-S-down' to visit the next file in order.
5. Repeat #4 to see other files in order.
6. Repeat #2 or #3 to see other sets of files.
7. End with `RET' to choose a file to visit or `C-g' to cancel.

Each file buffer you visited with `C-S-down' was killed when you
viewed the next one.  You can also mix in `C-down' or `C-RET' to
also visit files whose buffers you do not want to kill
automatically.  (Change `view-file' to `find-file' if you don't
want to visit in `view-mode', which is read-only.)

[By default, the alternate action for `icicle-find-file' is
`icicle-alt-act-fn-for-type', which prompts you for a file-
appropriate action to use on the particular candidate chosen for
the action.  Command `my-find-file' just substitutes a different
alternate action function (for all candidates you choose).]



  reply	other threads:[~2013-10-18 16:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18  5:55 Quickly Viewing Files in a File List, and then Quickly Closing Eric Brown
2013-10-18  7:46 ` Thorsten Jolitz
2013-10-18  8:38 ` Eric Abrahamsen
2013-10-18 11:32 ` Alan Schmitt
2013-10-18 14:23 ` Drew Adams
2013-10-18 16:55   ` Drew Adams [this message]
2013-10-19  7:13 ` Vagn Johansen
2013-10-28 11:45 ` escherdragon

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=d8b9571c-e7ee-4871-acb7-dcc9a33f9d7e@default \
    --to=drew.adams@oracle.com \
    --cc=eric.c.brown@mac.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).