Advertisement
pharmokan

emacs hydra wip

May 1st, 2020
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. (defun jump-forward-and-highlight-inside-quotes ()
  2. "highlight encounters in-between single and double quotes"
  3. (interactive)
  4. (deactivate-mark)
  5. (forward-char 2)
  6. (when (re-search-forward "'\\|\"" nil t)
  7. (er/expand-region 1)
  8. (exchange-point-and-mark)
  9. )
  10. )
  11.  
  12. (defun jump-backward-and-highlight-inside-quotes ()
  13. "highlight encounters in-between single and double quotes"
  14. (interactive)
  15. (deactivate-mark)
  16. (backward-char 2)
  17. (when (re-search-backward "'\\|\"" nil t)
  18. (er/expand-region 1)
  19. ;(exchange-point-and-mark)
  20. )
  21. )
  22.  
  23. (defun jump-forward-and-highlight-inside-pairs ()
  24. "Bounce from one paren to the matching paren."
  25. (interactive)
  26. (when (re-search-forward "\\[\\|\{\\|\(" nil t)
  27. (er/mark-inside-pairs)
  28. (exchange-point-and-mark)
  29. )
  30. )
  31.  
  32. (defun jump-backward-and-highlight-inside-pairs ()
  33. "Bounce from one paren to the matching paren."
  34. (interactive)
  35. (when (re-search-backward "\\]\\|\}\\|\)" nil t)
  36. (er/mark-inside-pairs)
  37. (exchange-point-and-mark)
  38. )
  39. )
  40.  
  41.  
  42. (defhydra hydra-zoom ()
  43. ("1" (do-what "b"))
  44. ("2" (do-what "f"))
  45. ("-" (do-what "b"))
  46. ("=" (do-what "f"))
  47. ("p" (do-what "b"))
  48. ("n" (do-what "f"))
  49. ("[" (do-what "b"))
  50. ("]" (do-what "f"))
  51. ("k" (do-what "b"))
  52. ("i" (do-what "f"))
  53. ("d" (do-what "b"))
  54. ("f" (do-what "f"))
  55. )
  56.  
  57.  
  58. ;;g->
  59. (defun dz-quote-bracket-highlight (arg)
  60. (interactive "P")
  61. (message nil)
  62. (setq r (format "%c" (read-key)))
  63. ;; (setq r (read-key))
  64. ;;(message ">%s<" r)
  65. (hydra-menu))
  66.  
  67. ;;hydra->
  68. (defun hydra-menu ()
  69. (interactive)
  70. (hydra-zoom/body)
  71. ;(message "%s" r)
  72. )
  73.  
  74. (defun dz-quote (direction)
  75. (interactive)
  76. (pcase direction
  77. ("b" (jump-backward-and-highlight-inside-quotes))
  78. ("f" (jump-forward-and-highlight-inside-quotes))
  79. (otherwise (message "bracket direction not specified correctly"))
  80. )
  81. )
  82.  
  83. (defun dz-bracket (direction)
  84. (interactive)
  85. (pcase direction
  86. ("b" (jump-backward-and-highlight-inside-pairs))
  87. ("f" (jump-forward-and-highlight-inside-pairs))
  88. (otherwise (message "bracket direction not specified correctly"))
  89. )
  90. )
  91.  
  92. (defun do-what (direction)
  93. (interactive)
  94. (pcase r
  95. ("b" (dz-bracket direction))
  96. ("q" (dz-quote direction))
  97. (otherwise nil))
  98. )
  99.  
  100. (global-set-key (kbd "<C-f1>") 'hydra-menu)
  101. (global-set-key (kbd "<C-f2>") 'dz-quote-bracket-highlight)
  102. (global-set-key (kbd "<C-f3>") 'eval-buffer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement