all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Rami A'" <rami.ammari@gmail.com>, <help-gnu-emacs@gnu.org>
Subject: RE: Cycling through favored buffers
Date: Thu, 25 Apr 2013 15:14:04 -0700	[thread overview]
Message-ID: <36E143CB907A42B3B88E5D479610252B@us.oracle.com> (raw)
In-Reply-To: <c5dd21e3-8536-4bdd-8808-4a8d339ef4a4@googlegroups.com>

> not sure how to incorporate your suggestion in my code.
> 
> So in the code that I have crs-hated-buffers, which are the 
> buffers to ignore:
> (defvar crs-hated-buffers
>   '("KILL" "*Compile-Log*" "*Buffer List*" "*Messages*"
>     "*compilation*" "TAGS" "*scratch*" "source" "headers")) 
> 
> How do I add the cl-remove-if to this variable so it would 
> include all dired type buffers?

You don't add it to that variable.  You treat your removal of those buffers as
one way to filter `buffer-list' and checking (derived-mode-p 'dired-mode) as
another way to filter.  IOW filter another way what you've already filtered one
way.  (Or typically better, filter both at the same time, so you traverse
`buffer-list' only once.)

> secondly, the code that I have cycles through all buffers 
> "except" the ignored ones mentioned above.
> So after I construct cl-remove-if-not that includes the 
> directories I want to only cycle through, how to apply that 
> on my code? or maybe I need a totally new function that would 
> do the trick?

Not sure what you really are trying to do.  You mentioned having two different
commands, one to remove hated stuff and dirs and the other keep only dir buffers
"headers" and "source".

But if you instead want a single command that removes (a) your hated buffers and
(b) buffers that are directories except "headers" and "source", then do just
that.

Your `crs-bury-buffer' uses a list of buffers.  Right now, you construct that
list by removing some (hated) buffers from `buffer-list'.  Conceptually, you can
do this: after you have removed those buffers, remove also the other ones you
want to remove.  And add back any others you want to keep.

But it is better to just use a single predicate (lambda (buf)...) that filters
`buffer-list' only once, in all of the ways you want, whatever they might be:
remove if this-or-that but not if such-and-such.

(let ((my-buflist
       (cl-remove-if (lambda (bf)
                       (and (or it-is-a-hated-buffer
                                it-is-a-directory)
                            (not it-is-headers-or-source)))
                     (buffer-list))))
  (switch-to-buffer...)

                     




      reply	other threads:[~2013-04-25 22:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-24 22:59 Cycling through favored buffers Rami A
2013-04-25 21:32 ` Drew Adams
     [not found] ` <mailman.24641.1366925547.855.help-gnu-emacs@gnu.org>
2013-04-25 21:38   ` Rami A
2013-04-25 22:14     ` Drew Adams [this message]

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

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

  git send-email \
    --in-reply-to=36E143CB907A42B3B88E5D479610252B@us.oracle.com \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=rami.ammari@gmail.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.