Does anyone know a package that can make helm faster when selecting buffer (helm-buffer-lists) or command (helm-M-x)?

For example:

  1. add number for helm-buffer-lists (just like original recentf-open-files ) ,I can use an alternative number selection for buffers.
  2. match commands for helm-M-x like this, open-config-file (as ocf), I think it can be an alternative selection when I type ocf. When select, place these selections at top (I think there are few additions than original matchs)

I find how to add number for helm-buffers-list,just redefine this function with two points (in codes with comments) for adding line numbers.

 (defun helm-highlight-buffers (buffers _source)
     "Transformer function to highlight BUFFERS list.
   Should be called after others transformers i.e (boring buffers)."

     (cl-loop for i in buffers
    ;;; **1. create number***************************************
         for number from 1 to (length buffers) 
         for (name size mode meta) = (if helm-buffer-details-flag
                         (helm-buffer--details i 'details)
                    (helm-buffer--details i))
           for truncbuf = (if (> (string-width name) helm-buffer-max-length)
                               name helm-buffer-max-length
                            (concat name
                     (- (+ helm-buffer-max-length
                                                (length helm-buffers-end-truncated-string))
                                             (string-width name)) ? )))

           for len = (length mode)
           when (> len helm-buffer-max-len-mode)
           do (setq helm-buffer-max-len-mode len)
           for fmode = (concat (make-string
                                (- (max helm-buffer-max-len-mode len) len) ? )

           for formatted-size = (and size (format "%7s" size))
           collect (cons (if helm-buffer-details-flag
;;; **** 2. concat number at first ****************************
                             (concat (int-to-string number) " " truncbuf "\t" formatted-size
                                     "  " fmode "  " meta)
            (get-buffer i))))

To select buffer like recentf-open-files, I define some keys for helm-map for selecting by alt+number.

       ;;; add alt+number to select nth line
       (require 'cl)
       (cl-loop for n from 1 to 9
           for key = (format "M-%d" n)
           for fn = `(lambda ()
               (helm-next-line ,(- n 1))
           do (progn
            (define-key helm-map (kbd key) fn)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.