0

I need something like helm-register which lists all the registers and it can be searched through.

1

Latest version of counsel (version 20190522.2133 on MELPA) has counsel-register.

From the documentation:

counsel-register is an interactive, autoloaded function defined in
counsel.el.

Signature
(counsel-register)

Documentation
Interactively choose a register.

Key Bindings
This command is not in any keymaps.

References
counsel-register is unused in counsel.el.
0

How about this:

(defvar counsel-register-history nil
  "History for `counsel-register'.")

(defun counsel-register-action (s)
  "Default action for `counsel-register'.

Do what I mean for each type of register."
  (let* ((k (string-to-char s))
         (v (get-register k)))
    (if (or (stringp v) (numberp v))
        (insert (format "%s" v))
      (jump-to-register k))))

(defun counsel-register ()
  "Interactively choose a register and perform a default an action on it."
  (interactive)
  (ivy-read "Register: "
            (cl-loop for (k . v) in register-alist
                     collect (concat (key-description (list k))
                                     " => "
                                     (if (or (stringp v) (numberp v))
                                         (format "%s" v)
                                       (format "[%s] %s"
                                               (symbol-name (car v))
                                               (cdr v)))))
            :preselect 0
            :history 'counsel-register-history
            :action #'counsel-register-action))

Note that this solution does not search through bookmarks. But that would be easy to add. You just have to account for bookmarks-alist as well.

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.