[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 407ce2c 051/272: counsel.el (counsel-list-processes): New
From: |
Oleh Krehel |
Subject: |
[elpa] master 407ce2c 051/272: counsel.el (counsel-list-processes): New command |
Date: |
Mon, 25 Apr 2016 10:13:16 +0000 |
branch: master
commit 407ce2c3e31ae264b88ee319faed1f82e2684fe6
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-list-processes): New command
* counsel.el (counsel-list-processes-action-delete): New defun.
(counsel-list-processes-action-switch): New defun.
* ivy.el: re-indent.
Fixes #357
---
counsel.el | 25 +++++++++++++++++++++++++
ivy.el | 57 +++++++++++++++++++++++++++++----------------------------
2 files changed, 54 insertions(+), 28 deletions(-)
diff --git a/counsel.el b/counsel.el
index 4a6e68f..b6ac36a 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1412,6 +1412,31 @@ Describe the selected candidate."
'(("d" counsel-descbinds-action-find "definition")
("i" counsel-descbinds-action-info "info")))
+(defun counsel-list-processes-action-delete (x)
+ (delete-process x)
+ (setf (ivy-state-collection ivy-last)
+ (setq ivy--all-candidates
+ (delete x ivy--all-candidates))))
+
+(defun counsel-list-processes-action-switch (x)
+ (if (get-buffer x)
+ (switch-to-buffer x)
+ (message "Process %s doesn't have a buffer" x)))
+
+;;;###autoload
+(defun counsel-list-processes ()
+ "Offer completion for `process-list'
+The default action deletes the selected process.
+An extra action allows to switch to the process buffer."
+ (interactive)
+ (list-processes--refresh)
+ (ivy-read "Process: " (mapcar #'process-name (process-list))
+ :require-match t
+ :action
+ '(1
+ ("o" counsel-list-processes-action-delete "kill")
+ ("s" counsel-list-processes-action-switch "switch"))))
+
(provide 'counsel)
;;; counsel.el ends here
diff --git a/ivy.el b/ivy.el
index bb2aa99..2240e9e 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1061,9 +1061,10 @@ the restoring themselves.")
;;** Entry Point
(cl-defun ivy-read (prompt collection
- &key predicate require-match initial-input
- history preselect keymap update-fn sort
- action unwind re-builder matcher dynamic-collection
caller)
+ &key
+ predicate require-match initial-input
+ history preselect keymap update-fn sort
+ action unwind re-builder matcher dynamic-collection
caller)
"Read a string in the minibuffer, with completion.
PROMPT is a format string, normally ending in a colon and a
@@ -1135,30 +1136,30 @@ customizations apply to the current completion session."
(ivy--reset-state ivy-last)
(prog1
(unwind-protect
- (minibuffer-with-setup-hook
- #'ivy--minibuffer-setup
- (let* ((hist (or history 'ivy-history))
- (minibuffer-completion-table collection)
- (minibuffer-completion-predicate predicate)
- (resize-mini-windows (cond
- ((display-graphic-p) nil)
- ((null resize-mini-windows)
'grow-only)
- (t resize-mini-windows))))
- (read-from-minibuffer
- prompt
- (ivy-state-initial-input ivy-last)
- (make-composed-keymap keymap ivy-minibuffer-map)
- nil
- hist)
- (when (eq ivy-exit 'done)
- (let ((item (if ivy--directory
- ivy--current
- ivy-text)))
- (unless (equal item "")
- (set hist (cons (propertize item 'ivy-index ivy--index)
- (delete item
- (cdr (symbol-value hist))))))))
- ivy--current))
+ (minibuffer-with-setup-hook
+ #'ivy--minibuffer-setup
+ (let* ((hist (or history 'ivy-history))
+ (minibuffer-completion-table collection)
+ (minibuffer-completion-predicate predicate)
+ (resize-mini-windows (cond
+ ((display-graphic-p) nil)
+ ((null resize-mini-windows)
'grow-only)
+ (t resize-mini-windows))))
+ (read-from-minibuffer
+ prompt
+ (ivy-state-initial-input ivy-last)
+ (make-composed-keymap keymap ivy-minibuffer-map)
+ nil
+ hist)
+ (when (eq ivy-exit 'done)
+ (let ((item (if ivy--directory
+ ivy--current
+ ivy-text)))
+ (unless (equal item "")
+ (set hist (cons (propertize item 'ivy-index ivy--index)
+ (delete item
+ (cdr (symbol-value hist))))))))
+ ivy--current))
(remove-hook 'post-command-hook #'ivy--exhibit)
(when (setq unwind (ivy-state-unwind ivy-last))
(funcall unwind))
@@ -1624,7 +1625,7 @@ Insert .* between each char."
"Update the prompt according to `ivy--prompt'."
(when ivy--prompt
(unless (memq this-command '(ivy-done ivy-alt-done ivy-partial-or-done
- counsel-find-symbol))
+ counsel-find-symbol))
(setq ivy--prompt-extra ""))
(let (head tail)
(if (string-match "\\(.*\\): \\'" ivy--prompt)
- [elpa] master bc4d4a8 043/272: swiper.el (swiper-font-lock-exclude): Add sauron-mode, (continued)
- [elpa] master bc4d4a8 043/272: swiper.el (swiper-font-lock-exclude): Add sauron-mode, Oleh Krehel, 2016/04/25
- [elpa] master 93d1adc 026/272: Properly support matching ignoring order, Oleh Krehel, 2016/04/25
- [elpa] master 9a6b5fd 042/272: Add rcirc-mode to swiper-font-lock-ensure-exclude, Oleh Krehel, 2016/04/25
- [elpa] master ec7da3f 075/272: ivy.el (ivy-help-file): Improve location, Oleh Krehel, 2016/04/25
- [elpa] master c76c005 045/272: Add feedback for sole ivy completion., Oleh Krehel, 2016/04/25
- [elpa] master 59c5f16 044/272: Special case empty ivy-count-format completion., Oleh Krehel, 2016/04/25
- [elpa] master 569c11e 017/272: ivy.el (ivy-completion-in-region): Use compact ivy-count-format, Oleh Krehel, 2016/04/25
- [elpa] master d996215 038/272: Add counsel-descbinds, Oleh Krehel, 2016/04/25
- [elpa] master 9ef344d 062/272: use imenu API to jump to position. required by org-mode, Oleh Krehel, 2016/04/25
- [elpa] master 0a9780b 046/272: ivy.el (ivy--recompute-index): Update cl-position logic, Oleh Krehel, 2016/04/25
- [elpa] master 407ce2c 051/272: counsel.el (counsel-list-processes): New command,
Oleh Krehel <=
- [elpa] master e3e1f51 052/272: ivy.el (ivy-ffap-url-functions): Customize "C-x C-f M-n", Oleh Krehel, 2016/04/25
- [elpa] master b39f409 056/272: counsel.el (counsel-unicode-char): Display hex codes in left column, Oleh Krehel, 2016/04/25
- [elpa] master eab714f 054/272: counsel.el (counsel-at-git-issue-p): New defun, Oleh Krehel, 2016/04/25
- [elpa] master 4696b89 057/272: ivy.el (ivy-switch-buffer-other-window): New command, Oleh Krehel, 2016/04/25
- [elpa] master 763d42b 048/272: Initialize `ivy-last` to empty state., Oleh Krehel, 2016/04/25
- [elpa] master c0c0f63 060/272: ivy.el (ivy-read): Fix extra actions for completing-read, Oleh Krehel, 2016/04/25
- [elpa] master 5f4bc14 058/272: counsel.el (counsel-rhythmbox-current-song): Preselect the current song, Oleh Krehel, 2016/04/25
- [elpa] master 2877ae1 063/272: ivy.el (ivy-ignore-buffers): New defcustom, Oleh Krehel, 2016/04/25
- [elpa] master 480cc85 071/272: README.md: Update, Oleh Krehel, 2016/04/25
- [elpa] master 7b08db8 094/272: ivy.el (ivy-next-history-element): Use "\\_<" instead of "\\b", Oleh Krehel, 2016/04/25