6

My crystal ball tells me that you want (require 'seq) and then ... (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.


3

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 ...


2

Recursion for the win. (defun json-filter-paths (json paths) (mapcar (lambda (elt) (if (consp elt) (cons (car elt) (json-filter-paths (cdr (assoc (car elt) json)) (cdr elt))) (cons elt (cdr (assoc elt json))))) paths)) (json-filter-paths'((owner (login . "octocat") (avatar . "blah")...


2

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)


2

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.


2

Here's a command that finds all duplicate lines in the buffer and deletes the rest: (defun keep-duplicate-lines () (interactive) (let (lines dups) (save-excursion (goto-char (point-max)) (when (/= (char-after (1- (point-max))) ?\n) (newline)) (goto-char (point-min)) (while (not (eobp)) (forward-line 1) ...


2

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" "...


1

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 "/": (setq directory-abbrev-alist '(("/home/realraptor/Work/Project/subjproject/submodule/foo/baa" ...


1

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 ...


Only top voted, non community-wiki answers of a minimum length are eligible