-
-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
counsel.el: Add command counsel-ibuffer
#1467
Conversation
counsel.el
Outdated
@@ -4476,6 +4476,77 @@ replacements. " | |||
(when (fboundp 'advice-remove) | |||
(advice-remove #'describe-bindings #'counsel-descbinds)))) | |||
|
|||
;;** `counsel-ibuffer' | |||
(defvar counsel-ibuffer-buffer-name nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any merits/downsides to making this a defcustom
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internal variable and gets overwritten as soon as counsel-ibuffer
is called. The name of the ibuffer you want to use can be specified through the argument name
when calling counsel-ibuffer
.
I admit the doc string is misleading, I will also add an additional -
to the variable name to make it clear that it's meant for internal use only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabacino OK, thanks for clarifying, I was just curious.
counsel.el
Outdated
;; by comparing line numbers. | ||
(let ((prev-lineno 0) | ||
lineno) | ||
(while (> (setq lineno (line-number-at-pos)) prev-lineno) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be more efficient to just check (point)
instead of line number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I refactored the iteration to compare points.
counsel.el
Outdated
(when (buffer-live-p current-buf) | ||
(push | ||
(cons | ||
(substring-no-properties (thing-at-point 'line) 0 -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a.k.a. (buffer-substring-no-properties (line-beginning-position) (line-end-position))
?
The open vanilla ibuffer action fails here with make plain:
An easy fix: --- a/counsel.el
+++ b/counsel.el
@@ -4538,7 +4538,7 @@ NAME specifies the name of the buffer (defaults to \"*Ibuffer*\")."
"Switch to buffer of candidate X in other window."
(switch-to-buffer-other-window (cdr x)))
-(defun counsel-ibuffer-visit-vanilla-ibuffer ()
+(defun counsel-ibuffer-visit-vanilla-ibuffer (_)
"Switch to vanilla ibuffer."
(switch-to-buffer counsel-ibuffer-buffer-name))
|
Simple counsel version of `ibuffer`. Credit for the idea belongs to @joedicastro.
1799310
to
82da2c2
Compare
…ound Instead of comparing line numbers, we remember the point of the first entry and abort the iteration as soon as this point is encountered for the second time.
@basil-conto @mookid Thank you both for your suggestions. I've updated the PR accordingly. |
I get infloop with this setting in my config: (setq ibuffer-movement-cycle nil) |
Merged, thanks all. |
Simple counsel version of
ibuffer
.Credit for the idea belongs to @joedicastro.
Deprecates #943