Browse Source

hyrda: Start moving hydras to their own directory

master
Peter J. Jones 3 months ago
parent
commit
ceaad10626
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
7 changed files with 107 additions and 37 deletions
  1. 1
    1
      default.nix
  2. 59
    0
      hydras/dired.el
  3. 26
    0
      hydras/haskell-mode.el
  4. 8
    11
      lisp/interactive.el
  5. 2
    0
      lisp/keys.el
  6. 11
    0
      lisp/modes.el
  7. 0
    25
      modes/haskell-mode-conf.el

+ 1
- 1
default.nix View File

@@ -38,7 +38,7 @@ pkgs.stdenv.mkDerivation rec {
export emacspath="${emacsAndPackages}/bin"

substituteAll ${src}/dot.emacs.el "$out/dot.emacs.el"
cp -r ${src}/lisp ${src}/modes "$out/emacs.d/"
cp -r ${src}/lisp ${src}/modes ${src}/hydras "$out/emacs.d/"
chmod u+w "$out"/emacs.d/*

for f in ${src}/bin/*; do

+ 59
- 0
hydras/dired.el View File

@@ -0,0 +1,59 @@
;;; dired.el --- Hydras for `dired-mode'.

;;; Commentary:
;;
;; My hydras for dired-mode.

;;; Code:
(require 'dired)
(require 'dired-aux)
(require 'dired-filter)
(require 'dired-narrow)
(require 'dired-x)
(require 'hydra)
(require 'noccur)

;; External functions:
(declare-function pjones:dired-mark-all-files "../modes/dired-conf.el")

(defhydra pjones:hydras:dired-mode (:hint nil) "
^Narrowing^ ^Marking^ ^Operations^
-----------------------------------------------------------
_/ n_: name _M n_: name _o_: noccur marked
_/ r_: regexp _M r_: regexp _q_: query replace
_/ ._: ext _M ._: ext _C_: copy
_/ f_: files _M f_: files _d_: delete
_/ d_: dirs _M d_: dirs _R_: rename
_/ s_: symlinks _M s_: symlinks _T_: touch
_/ m_: mode _M m_: mode _S_: symlink
_/ p_: pop one _M u_: none _F_: find
_/ /_: pop all _M a_: all
"
("/ n" dired-filter-by-name)
("/ r" dired-filter-by-regexp)
("/ ." dired-filter-by-extension)
("/ f" dired-filter-by-file)
("/ d" dired-filter-by-directory)
("/ s" dired-filter-by-symlink)
("/ m" dired-filter-by-mode)
("/ p" dired-filter-pop)
("/ /" dired-filter-pop-all)
("M n" dired-filter-mark-by-name)
("M r" dired-filter-mark-by-regexp)
("M ." dired-filter-mark-by-extension)
("M f" dired-filter-mark-by-file)
("M d" dired-filter-mark-by-directory)
("M s" dired-filter-mark-by-symlink)
("M m" dired-filter-mark-by-mode)
("M u" dired-unmark-all-marks)
("M a" pjones:dired-mark-all-files)
("o" noccur-dired)
("q" dired-do-query-replace-regexp)
("C" dired-do-copy)
("d" dired-flag-file-deletion)
("R" dired-do-rename)
("T" dired-do-touch)
("S" dired-do-relsymlink)
("F" find-dired))

;;; dired.el ends here

+ 26
- 0
hydras/haskell-mode.el View File

@@ -0,0 +1,26 @@
;;; haskell-mode.el ;; Hydras for haskell-mode

;;; Commentary:

;;; Code:
(require 'hydra)

(defhydra pjones:hydras:haskell-mode (:hint nil)
"
^Imports^ ^GHCi^ ^Insert/Edit^ ^Run
^^^^^^^^^-------------------------------------------------------------------------
_C-c C-i_: jump _C-c C-;_: info _C-c C-0_: cost center _C-c c_: compile
_C-c C-l_: return _C-c C-r_: reload _C-c C-n_: kill module
_C-c C-s_: sort _C-c C-t_: type _C-c C-e_: edit cabal
"
("C-c C-;" dante-info)
("C-c C-0" haskell-mode-toggle-scc-at-point :color blue)
("C-c C-e" pjones:haskell-edit-cabal-file :color blue)
("C-c C-i" haskell-navigate-imports)
("C-c C-l" haskell-navigate-imports-return :color blue)
("C-c C-n" pjones:haskell-module-name-to-kill-ring :color blue)
("C-c C-r" dante-restart)
("C-c C-s" pjones:haskell-sort-imports)
("C-c C-t" dante-type-at :color blue))

;;; haskell-mode ends here

+ 8
- 11
lisp/interactive.el View File

@@ -35,17 +35,6 @@ placing it in the kill ring)."
(delete-region (point) (progn (funcall forward (- arg))
(point))))))

(defun pjones:exchange-point-and-mark (&optional arg)
"Exchange point and mark without changing if the region is active.

If the region is active, keep it active. If the region is
inactive, keep it inactive. When ARG is non-nil, negate this
behavior."
(interactive "P")
(exchange-point-and-mark
(if (region-active-p) arg
(not arg))))

(defun pjones:switch-to-previous-buffer ()
"Switch back to the last buffer shown in this window."
(interactive)
@@ -202,6 +191,14 @@ current buffer after point."
(let ((switch-window-threshold 1))
(switch-window-then-delete)))

(defun pjones:show-hydra-for-mode ()
"Show a hydra for the current mode."
(interactive)
(let ((func (intern (format "pjones:hydras:%s/body" major-mode))))
(if (fboundp func)
(call-interactively func)
(message "no hydra for %s" major-mode))))

;; Local Variables:
;; byte-compile-warnings: (not noruntime)
;; End:

+ 2
- 0
lisp/keys.el View File

@@ -19,8 +19,10 @@
(declare-function pjones:start-mail "./interactive.el")
(declare-function pjones:start-term "./interactive.el")
(declare-function pjones:switch-window-then-delete "./interactive.el")
(declare-function pjones:show-hydra-for-mode "./interactive.el")

;; Overriding default key bindings
(global-set-key (kbd "<f1>") #'pjones:show-hydra-for-mode)
(global-set-key (kbd "C-h M-m") #'describe-mode)
(global-set-key (kbd "C-r") #'isearch-backward-regexp)
(global-set-key (kbd "C-s") #'isearch-forward-regexp)

+ 11
- 0
lisp/modes.el View File

@@ -7,6 +7,10 @@
(concat (file-name-directory (directory-file-name (file-name-directory load-file-name))) "modes/")
"The directory where I keep mode-specific configuration files.")

(defvar pjones:hydras-dir
(concat (file-name-directory (directory-file-name pjones:modes-dir)) "hydras/")
"The directory where I keep mode-specific hydras.")

;; Automatically load my per-mode configuration files
(dolist (file (directory-files pjones:modes-dir t))
(let ((basename (file-name-nondirectory file)))
@@ -14,6 +18,13 @@
(eval-after-load (intern (replace-match "" t t basename))
`(load ,file)))))

;; Automatically load my per-mode hydras:
(dolist (file (directory-files pjones:hydras-dir t))
(let ((basename (file-name-nondirectory file)))
(when (string-match "\\(\\.elc\\)$" basename)
(eval-after-load (intern (replace-match "" t t basename))
`(load ,file)))))

(defun pjones:maybe-start-edit-server ()
"Start `edit-server' if this is the main Emacs instance."
(if (string= "server" server-name)

+ 0
- 25
modes/haskell-mode-conf.el View File

@@ -151,31 +151,6 @@ Otherwise go totally crazy."
(sort-regexp-fields
nil "^import +\\(qualified \\)?\\(.+\\)$" "\\2" b e)))

;; TODO:
;; * Remove whitespace at end of line while typing?
;;
;; close frames when using q (think *grep* or *compilation*)

(defhydra hydra-haskell (:hint nil)
"
^Imports^ ^GHCi^ ^Insert/Edit^ ^Run
^^^^^^^^^-------------------------------------------------------------------------
_C-c C-i_: jump _C-c C-;_: info _C-c C-0_: cost center _C-c C-c_: compile
_C-c C-l_: return _C-c C-r_: reload _C-c C-p_: new module
_C-c C-s_: sort _C-c C-t_: type _C-c C-n_: kill module
^ ^ ^ ^ _C-c C-e_: edit cabal
"
("C-c C-;" dante-info)
("C-c C-0" haskell-mode-toggle-scc-at-point :color blue)
("C-c C-c" pjones:haskell-compile :color blue)
("C-c C-e" pjones:haskell-edit-cabal-file :color blue)
("C-c C-i" haskell-navigate-imports)
("C-c C-l" haskell-navigate-imports-return :color blue)
("C-c C-n" pjones:haskell-module-name-to-kill-ring :color blue)
("C-c C-p" pjones:haskell-new-module :color blue)
("C-c C-r" dante-restart)
("C-c C-s" pjones:haskell-sort-imports)
("C-c C-t" dante-type-at :color blue))

(defun pjones-haskell-process-wrapper-function (argv)
"Run Haskell tools through nix-shell by modifying ARGV.

Loading…
Cancel
Save