bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32731: 26.1.50; Ibuffer filter by mode: Handle >1 mode names


From: Noam Postavsky
Subject: bug#32731: 26.1.50; Ibuffer filter by mode: Handle >1 mode names
Date: Sat, 22 Sep 2018 09:00:10 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Tino Calancha <address@hidden> writes:

> commit 72e332c986304775e91020c88ded1ba9d7226023
> Author: Tino Calancha <address@hidden>
> Date:   Fri Sep 21 17:32:57 2018 +0900
>
>     Ibuffer filter by modes: Accept several mode names
>     
>     Extend all mode filters so that they handle >1 mode.
>     For instance, if the user wants to filter all buffers in
>     C or C++ mode, then s?he can call the filter interactively

If you'll pardon another nit, I suggest using "they" instead of "s?he"
which has the advantage of being a pronounceable English word.

> +      (let ((,filter (cons ',name qualifier))
> +            (,qualifier-str qualifier))
> +        ,(when accept-list
> +           `(progn
> +              (unless (listp qualifier) (setq qualifier (list qualifier)))
> +              ;; Reject equivalent filters: (or f1 f2) is same as (or f2 f1).
> +              (setq qualifier (sort (delete-dups qualifier) #'string-lessp))
> +              (setq ,filter (cons ',name (car qualifier)))
> +              (setq ,qualifier-str
> +                    (mapconcat (lambda (m) (if (symbolp m) (symbol-name m) 
> m))
> +                               qualifier ","))
> +              (when (cdr qualifier) ; Compose individual filters with `or'.
> +                (setq ,filter `(or ,@(mapcar (lambda (m) (cons ',name m)) 
> qualifier))))))
> +        (if (null (ibuffer-push-filter ,filter))
> +            (message ,(format "Filter by %s already applied:  %%s" 
> description)
> +                     ,qualifier-str)
> +          (message ,(format "Filter by %s added:  %%s" description)
> +                   ,qualifier-str)
> +          (ibuffer-update nil t))))

Since I'm here nitting anyway, I would tweak this code a bit:

    (let ((,filter (cons ',name qualifier))
          (,qualifier-desc qualifier))
      ,(when accept-list
         `(when (listp qualifier)
            (setq ,qualifier-desc
                  (mapconcat (lambda (m) (if (symbolp m) (symbol-name m) m))
                             qualifier ","))
            (if (null (cdr qualifier))
                (setf (cdr ,filter) (car qualifier)) ; Singleton list.
              ;; Reject equivalent filters: (or f1 f2) is same as (or f2 f1).
              (setq qualifier (delete-consecutive-dups
                               (sort qualifier #'string-lessp)))
              ;; Compose individual filters with `or'.
              (setq ,filter `(or ,@(mapcar (lambda (m) (cons ',name m))
                                           qualifier))))))
      (if (null (ibuffer-push-filter ,filter))
          (message ,(format "Filter by %s already applied:  %%s" description)
                   ,qualifier-desc)
        (message ,(format "Filter by %s added:  %%s" description)
                 ,qualifier-desc)
        (ibuffer-update nil t)))

>         (push (list ',name ,description
>                  (lambda (buf qualifier)
> -                     (condition-case nil
> -                         (progn ,@body)
> -                       (error (ibuffer-pop-filter)
> -                              (when (eq ',name 'predicate)
> -                                (error "Wrong filter predicate: %S"
> -                                       qualifier))))))
> +                  (condition-case nil
> +                      (progn ,@body)
> +                    (error (ibuffer-pop-filter)
> +                           (when (eq ',name 'predicate)
> +                             (error "Wrong filter predicate: %S"
> +                                    qualifier))))))
>            ibuffer-filtering-alist)
>         :autoload-end)))

I think this hunk is just changing spaces to tabs (shouldn't .dir-locals
be setting indent-tabs-mode to nil though?).






reply via email to

[Prev in Thread] Current Thread [Next in Thread]