44 lines
1.2 KiB
EmacsLisp
44 lines
1.2 KiB
EmacsLisp
;;; module-piper.el -- piping functions for emacs
|
|
;;;
|
|
;;; Commentary:
|
|
;;; Convenient piping functions for emacs.
|
|
;;;
|
|
;;; Code:
|
|
|
|
(require 'module-magit)
|
|
|
|
(defvar piper-mode-map
|
|
(let ((map (make-sparse-keymap)))
|
|
(define-key map (kbd "<SPC>") 'scroll-up-command)
|
|
(define-key map (kbd "<DEL>") 'scroll-down-command)
|
|
(define-key map (kbd "C-|") 'piper-popup)
|
|
map)
|
|
"Keymap for `piper-mode'.")
|
|
|
|
(define-minor-mode piper-mode
|
|
"Toggle Filtering mode."
|
|
;; The initial value.
|
|
:init-value nil
|
|
;; The indicator for the mode line.
|
|
:lighter " |"
|
|
;; The minor mode bindings.
|
|
:keymap piper-mode-map
|
|
:group 'piper)
|
|
|
|
(add-to-list 'emulation-mode-map-alists `((piper-mode . ,piper-mode-map)))
|
|
|
|
(with-eval-after-load 'magit-popup
|
|
(magit-define-popup piper-popup
|
|
"Show popup buffer featuring shell-like piper commands."
|
|
'piper-commands
|
|
:actions '((?f "Flush" flush-lines)
|
|
(?k "Keep" keep-lines)
|
|
(?c "Cut Columns" columns-lines)
|
|
(?s "Sort" sort-lines)
|
|
(?u "Unique Lines" uniquify-lines)
|
|
(?! "Next Pipe" pipe))
|
|
:default-action 'pipe))
|
|
|
|
(provide 'module-piper)
|
|
;;; module-piper.el ends here.
|