joestar

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit a8953f015990e523dbddd28af1bcf4938766ad9e
parent 7e6584abdf18bca7583184efc630c1627dd1dd5a
Author: Ryan Jeffrey <pwishie@gmail.com>
Date:   Thu, 30 May 2019 19:49:02 -0700

most of search

Diffstat:
MREADME.org | 16+++++-----------
Mjoestar.el | 47++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/README.org b/README.org @@ -3,17 +3,12 @@ Joestar is a minor mode for emacs that seeks to emulate [[https://github.com/jha * Known Issues The keyboard shortcut to insert a shell command currently does not work properly. In order to insert shell output call the joe-insertcmd function directly. -* Joestar and undo-tree -Joestar depends on undo-tree, which uses C-x for several of its keybindings, which conflicts with Joestar's usage of C-x. -In order to fix this, Joestar remaps the three following functions: -#+BEGIN_SRC emacs-lisp +* TODO Goals for Next Major Version +- [ ] Find function +- [ ] Regions +- [ ] Keyboard Macros -(define-key map (kbd "s-x u") 'undo-tree-visualize) -(define-key map (kbd "s-x r u") 'undo-tree-save-state-to-register) -(define-key map (kbd "s-x r U") 'undo-tree-restore-state-from-register) - -#+END_SRC -* Tutorial +* Basic Tutorial ** A note on Control key sequences Because of the way that Joe works *C-k C-e* is the same as *C-k e*. However, Emacs considers these to be different key sequences. @@ -48,4 +43,3 @@ To line number. Up one screen. - *C-v* Down one screen. - diff --git a/joestar.el b/joestar.el @@ -55,6 +55,8 @@ (defvar joe-marklist nil "List of the currently used marks.") +(defvar joe-prev-search nil "The last searched-for item.") + (make-variable-buffer-local 'joe-mark-0) (make-variable-buffer-local 'joe-mark-1) (make-variable-buffer-local 'joe-mark-2) @@ -69,6 +71,21 @@ (make-variable-buffer-local 'joe-lastmark) (make-variable-buffer-local 'joe-nextmark) +(make-variable-buffer-local 'joe-prev-search) + +;; non-interactive helper functions + +; TODO lambda-ize +(defun joe-get-findstr () + "Get the string to search for." + (if (null joe-prev-search) + (read-string "Find: ") + (read-string (format "Find [%s]: " joe-prev-search)))) + +(defun joe-get-find-action () + "Prompt the user for an action." + (read-string "(I)gnore (R)eplace (B)ackwards Bloc(K): ")) + (defun joe-todo-func () "TODO func." (interactive)) @@ -134,6 +151,7 @@ (interactive) (call-interactively 'undo-tree-undo)) +; TODO (defun joe-reloadall () "Revert all unmodified buffers." (interactive)) @@ -318,7 +336,7 @@ (goto-char joe-nextmark)))) ; TODO fix bug where this only works if called from mb -(defun joe-insertcmd (com) +(defun joe-run (com) "Append the output of shell command COM to current buffer." (interactive "sProgram to run: ") (let* ((joe-cur-mark (point-marker))) @@ -326,6 +344,23 @@ (insert (shell-command-to-string com)) (goto-char joe-cur-mark))) +(defun joe-ffirst (str action) + "Find next STR, perform ACTION." + (interactive (list (joe-get-findstr) (joe-get-find-action))) + (setq joe-prev-search str) + (cond ((string= action "R") + (progn + (message "TODO"))) + ((string= action "B") + (search-backward str)) + ((string= action "K") + (progn + (call-interactively 'narrow-to-region) + (goto-char (point-min)) + (search-forward str) + (widen))) + ((search-forward str)))) + (defalias 'joe-nbuf 'next-buffer) (defalias 'joe-pbuf 'previous-buffer) (defalias 'joe-reload 'revert-buffer) @@ -373,7 +408,7 @@ (define-key joe-map (kbd "C-k C-l") 'joe-line) (define-key joe-map (kbd "C-k l") (kbd "C-k C-l")) (define-key joe-map (kbd "C-g") 'joe-todo-func) ; TODO - + ;; misc (define-key joe-map (kbd "C-k C-j") 'joe-todo-func) (define-key joe-map (kbd "C-k j") (kbd "C-k C-j")) @@ -418,10 +453,8 @@ (define-key joe-map (kbd "C-c") 'joe-tw0) ;; search - (define-key joe-map (kbd "C-k C-f") '(lambda () - "Joe-style find function." - (interactive))) ; TODO - (define-key joe-map (kbd "C-k C-f") (kbd "C-k C-f")) + (define-key joe-map (kbd "C-k C-f") 'joe-ffirst) + (define-key joe-map (kbd "C-k f") (kbd "C-k C-f")) ;; help TODO (define-key joe-map (kbd "C-k C-h") '(lambda () @@ -473,7 +506,7 @@ ;; shell TODO ;; in joe, the cursor does not change when the comand is appended. - (define-key joe-map (kbd "<escape> !") 'joe-insertcmd) + (define-key joe-map (kbd "<escape> !") 'joe-run) (define-key joe-map (kbd "C-k C-z") 'suspend-emacs) (define-key joe-map (kbd "C-k z") (kbd "C-k C-z"))