My crystal ball tells me that you want
... (seq-filter ...) ...
The seq package is built-in, even though you have to say explicitly when you want to use it. Of course it's still not called filter, you may say, so you additionally need
(defalias 'filter #'seq-filter)
tho I'd advise against doing that.
You can always make the *grep* buffer writable with C-x C-q and delete lines the normal way (e.g. with C-a C-k C-k). When you are done, press C-x C-q again to make it read-only if you wish and use TAB and ENTER to navigate and visit files in the list.
Use remq or delq to remove nil elements from a list (to remove more complex structures, consider remove and delete, too).
(remq nil (mapcar (lambda (x)
(when (< x 3) (+ x 5)))
'(1 2 3 4 5 6)))
The first example can be also simplified using flatten-tree as it will remove empty lists, i.e. nils.
(flatten-tree (mapcar (...
You're essentially saying you want to match any of a list of patterns.
regexp-opt takes a list of strings and produces a single regexp which matches any of them.
(regexp-opt '("no" "nix"))
Note that the individual strings in the input list are not regexps -- the end result will be analogous to ...
(lambda (x) (and (not (string-match-p (regexp-quote "no") x))
(not (string-match-p (regexp-quote "nix") x))))
Or use cl-remove-if-not. Or use seq-filter or cl-remove-if-not twice, instead of and. And so on.
You should simply use synchronous processes whenever possible, because it is simple, easy to use and reliable, for example,
(cl-loop with output = (shell-command-to-string "ceedling version")
for line in (split-string output "\n")
when (string-match-p "::" line)
collect (split-string line "::" nil " +"))
;; (("Ceedling" "...
Does it need to be "named filter"?
As @Stefan mentions, seq-filter is available in Emacs 25.1.
Earlier releases, going back to almost forever, have functions remove-if and remove-if-not, in library cl.el. Recent releases provide the same functions under the names cl-remove-if and cl-remove-if-not, in library cl-seq.el (so you need not load library cl.el at ...
Emacs 25 will include the seq.el library, which will provide default functions to manipulate sequences. Right now you can download it from GNU ELPA for Emacs 24. The functions you are looking for are:
(seq-filter (lambda (x) (/= 0 (% x 2))) '(1 2 3 4 5)) ; => (1 3 5)
(seq-remove (lambda (x) (/= 0 (% x 2))) '(1 2 3 4 5)) ; => (2 4)
Okay remove-if-not makes a copy of the list it operates on. So this is the equivalent to collect-if above.
From my perspective remove-if-not is a really tricky name for something like collect-if or sub-list (not with the meaning of cl-sublis but with the meaning of sub-list). There should be an alias saying more directly what that function does.
I can think of three ways of handling this.
One would be to add a new column type to ibuffer.
A second (which would be system-wide) would be to define a directory alias in directory-mode-alist. Playing with this, the alias needs to start with "/":
The answer to any "Is it possible" question is almost always yes (there is a theorem by Turing which tells us the limit of what is computable, but in practice people rarely come up against that limit). It is better to rephrase this type of question to ask how to do something, rather than merely if it is possible, since that's usually what most people mean by ...
Just to add to what @NickD said, which is what I too recommend:
After making buffer *grep* writable, use commands flush-lines and keep-lines to quickly remove lines you're uninterested in.
M-x flush-lines - Remove all lines after point that match a regexp you provide.
M-x keep-lines - Remove all lines after point that do not match a regexp you provide.
Is there a function that applies a transformation to a sequence and returns only the non-nil values?
Since Emacs 26, you can use mapcan:
(mapcan (lambda (n)
(and (< n 3) (list (+ n 5))))
(number-sequence 1 6))
Alternatively, there's the age-old mapcar+delq approach like in choroba's answer (delq is more commonly used than remq, since ...
"Entry" is used ambiguously in the documentation:
an Org mode entry consists of a headline, scheduling information, optional drawers and the body of entry (text, possibly followed by subentries).
an agenda entry consists of some agenda information (the category, scheduling information, possibly some other things controlled by the variable org-...
/ n (M-x package-menu-filter-by-name) does exactly what you want, it filters only the package name, e.g., / n lsp-mode gets only the lsp-mode package.
/ n runs the command package-menu-filter-by-name (found in
package-menu-mode-map), which is an interactive compiled Lisp function
It is bound to / n, .
Try C-h P (M-x describe-package), it allows you filter by package names through the minibuffer. If you use helm-mode, it looks like
And in the *Packages* buffer, use Isearch and/or Occur, for example, to search packages start with lsp, use
M-s o ^ +lsp
M-s o is M-x occur.
I think the way to go is to write a custom agenda view. You would need to modify the variable org-agenda-custom-commands in your init file to add your custom agenda view. Something like this (untested - I'll try to do some testing and fix any problems, but please be forewarned):
(setq meeting1-custom-agenda-view '("M" tags "TAG1|TAG2|TAG3"))
You can create an overlay that hides lines with (make-overlay (line-beginning-position) (1+ (line-end-position))) and (overlay-put ol 'invisible t).
The following Elisp Org formula hides the line with the element 21 in its first column.
It just shows the principle and has much room for improvement. E.g., multiple evaluation of the org formula results in ...
The answer is given in the doc string of isearch-forward:
If this function is called non-interactively with a nil NO-RECURSIVE-EDIT,
it does not return to the calling function until the search is done.
See the function isearch-mode for more information.
In your first form
(let ((isearch-filter-predicate (lambda (a b) nil)))
Magit does not support this currently. You should open a feature request. I probably won't implement this any time soon, but an issue would help me to not forget about this completely.
Edit: I am longer considering to implement this. My recommendation is to set remote.<name>.fetch so that the boring branches don't even make it into your local ...