Skip to content

Commit

Permalink
cleanup todos again.
Browse files Browse the repository at this point in the history
  • Loading branch information
JJPandari committed Aug 30, 2019
1 parent cdb2416 commit 7860707
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 50 deletions.
14 changes: 9 additions & 5 deletions modes/init-dired.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
(let ((gls (executable-find "gls")))
(when gls (setq insert-directory-program gls)))

(jester/with-major-leader 'Deer:name
"w" 'wdired-change-to-wdired-mode)
(jester/with-major-leader 'ranger-mode-map
"w" 'wdired-change-to-wdired-mode)

(jester/with-major-leader 'wdired-mode-map
"," 'wdired-finish-edit
"a" 'wdired-abort-changes)

(use-package ranger
;; TODO into deer by invoking dired not showing icons?
:init
;; NOTE: remap doesn't change when dired-* is called from code
(jester/with-leader
"f d" 'dired-jump)
:bind (([remap dired-jump] . deer)
Expand All @@ -18,9 +22,9 @@
:config
(ranger-override-dired-mode 1))

;; TODO icon showing?
(use-package all-the-icons-dired
:after (all-the-icons ranger)
:hook (dired-mode . all-the-icons-dired-mode))
:hook ((dired-mode . all-the-icons-dired-mode)
(ranger-mode . all-the-icons-dired-mode)))

(provide 'init-dired)
106 changes: 95 additions & 11 deletions modes/init-editing-utils.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
;; TODO auto `else' when use space after if{
;; }
;; TODO pad-operator
;;----------------------------------------------------------------------------
;; Some basic preferences
;;----------------------------------------------------------------------------
Expand All @@ -27,7 +24,6 @@
recentf-max-saved-items 1000)

(electric-indent-mode -1) ;; this is global
;; TODO undo: group to previous ops for evil
(use-package aggressive-indent
:custom (aggressive-indent-region-function 'evil-indent "also convert tab/space when indent")
:hook (after-init . aggressive-indent-global-mode))
Expand Down Expand Up @@ -83,6 +79,19 @@
"z" 'subword-backward)
:commands (subword-forward subword-backward))


(use-package electric-operator
:hook ((js2-mode . electric-operator-mode)
(css-mode . electric-operator-mode)
(sass-mode . electric-operator-mode)
(rust-mode . electric-operator-mode)
(java-mode . electric-operator-mode)
(python-mode . electric-operator-mode)
(sql-mode . electric-operator-mode)
(c-mode . electric-operator-mode)
(php-mode . electric-operator-mode)))


;;----------------------------------------------------------------------------
;; kill back to indentation
;;----------------------------------------------------------------------------
Expand Down Expand Up @@ -376,19 +385,18 @@ Threat is as function body when from endline before )"
(widen)
(save-excursion
(goto-char pos)
(+ 1 (current-line)))))
(+ 1 (count-lines (point-min) (line-beginning-position 1))))))

(defun narrow-to-region-indirect-buffer-maybe (start end use-indirect-buffer)
"Indirect buffer could multiple widen on same file."
(if (region-active-p) (deactivate-mark))
(if use-indirect-buffer
(with-current-buffer
(jester/eval-with-display-in-same-window
(clone-indirect-buffer
(generate-new-buffer-name
(format "%s-indirect-:%s-:%s"
(buffer-name) (line-number-at-position start) (line-number-at-position end)))
'display))
(clone-indirect-buffer
(generate-new-buffer-name
(format "%s-indirect-:%s-:%s"
(buffer-name) (line-number-at-position start) (line-number-at-position end)))
'display)
(narrow-to-region start end)
(goto-char (point-min)))
(narrow-to-region start end)))
Expand Down Expand Up @@ -424,5 +432,81 @@ If use-indirect-buffer is not nil, use `indirect-buffer' to hold the widen conte

(jester/with-leader "n n" 'narrow-or-widen-dwim)

;;----------------------------------------------------------------------------
;; insert lorem
;;----------------------------------------------------------------------------
(defun insert-lorem ()
(interactive)
(insert "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque sem mauris, aliquam vel interdum in, faucibus non libero. Asunt in anim uis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in anim id est laborum. Allamco laboris nisi ut aliquip ex ea commodo consequat."))

;;----------------------------------------------------------------------------
;; do something to a comma-delimitered sentence
;;----------------------------------------------------------------------------
(evil-define-text-object jester/evil-a-subsentence (count &optional beg end type)
"Select a subsentence(delimitered by comma)."
:extend-selection nil
(list (progn
(re-search-backward "[,.] ?")
(forward-char)
(when (eq (char-after (point)) ? ) (forward-char))
(point))
(re-search-forward "[,.] ?")))

(evil-define-text-object jester/evil-inner-subsentence (count &optional beg end type)
"Select a subsentence(delimitered by comma), without the punctuations."
:extend-selection nil
(list (progn
(re-search-backward "[,.] ?")
;; (re-search-backward "[,.] ?\\|( ?")
(forward-char)
(when (eq (char-after (point)) ? ) (forward-char))
(point))
(progn (re-search-forward "[,.] ?")
(backward-char)
(when (memq (char-before) (list ?. ?,)) (backward-char))
(point))))

(general-define-key
:keymaps 'evil-outer-text-objects-map
"S" 'jester/evil-a-subsentence)
(general-define-key
:keymaps 'evil-inner-text-objects-map
"S" 'jester/evil-inner-subsentence)

;;----------------------------------------------------------------------------
;; select an argument
;;----------------------------------------------------------------------------
(evil-define-text-object jester/evil-a-arg (count &optional beg end type)
"Select an argument."
:extend-selection nil
(let* (last-arg-p
(head (progn
(re-search-backward "[,(] ?")
(forward-char)
(when (eq (char-after (point)) ? ) (forward-char))
(point)))
(tail (progn (re-search-forward "[,] ?\\| ?)")
(setq last-arg-p (eq (char-before) ?\)))
(when (eq (char-before) ?\))
(while (memq (char-before) (list ? ?\))) (backward-char)))
(point))))
(when last-arg-p
(setq head (progn (goto-char head)
(while (memq (char-before) (list ?, ? )) (backward-char))
(point))))
(list head tail)))

(evil-define-text-object jester/evil-inner-arg (count &optional beg end type)
"Select an argument, without the punctuations."
:extend-selection nil
(list (progn
(re-search-backward "[,(] ?")
(forward-char)
(when (eq (char-after (point)) ? ) (forward-char))
(point))
(progn (re-search-forward "[,] ?\\| ?)")
(while (memq (char-before) (list ?, ? ?\))) (backward-char))
(point))))


(provide 'init-editing-utils)
2 changes: 2 additions & 0 deletions modes/init-evil.el
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"-" 'evil-numbers/dec-at-pt))


;; TODO support for lispyville & `general-key-dispatch'
(use-package evil-goggles
:after evil
:custom (evil-goggles-duration 0.1)
Expand Down Expand Up @@ -273,6 +274,7 @@
;; Set initial states for modes.
;;----------------------------------------------------------------------------
(evil-set-initial-state 'debugger-mode 'motion)
(evil-set-initial-state 'messages-buffer-mode 'motion)
;; special mode is for viewing info, e.g. "q" is bound to quit,
;; but it's normal state there so we lose the bindings. Use motion state.
(evil-set-initial-state 'special-mode 'motion)
Expand Down
1 change: 0 additions & 1 deletion modes/init-minibuffer.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
(setq enable-recursive-minibuffers t)
(minibuffer-depth-indicate-mode 1)
;; TODO press a key in minibuffer to continue in evil-command-window

(general-define-key
:keymaps '(minibuffer-local-map minibuffer-local-ns-map minibuffer-local-completion-map minibuffer-local-must-match-map minibuffer-local-isearch-map
Expand Down
10 changes: 7 additions & 3 deletions modes/init-mode-line.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
'("" "" "" "" "" "" "" "" "" "" ""))

(setq-default mode-line-format
;; setq mode-line-format ;; this is for debug
(list

"%1"
Expand All @@ -57,6 +56,12 @@
;; ;; evil state
;; '(:eval evil-mode-line-tag)

"%1"
'(:eval (when defining-kbd-macro
(format " %s%c "
(propertize "" 'face '((:family "FontAwesome")))
evil-this-macro)))

" %+"

;; anzu
Expand All @@ -83,7 +88,7 @@
"%1"
;; git info
'(:eval (when vc-mode
(s-replace "Git" (propertize "" 'face '(:family "github-octicons")) vc-mode)))
(s-replace "Git" (propertize "" 'face '((:family "github-octicons"))) vc-mode)))

;; minor modes
;; minor-mode-alist
Expand All @@ -110,6 +115,5 @@

mode-line-end-spaces))

;; TODO indicator for recording a macro

(provide 'init-mode-line)
48 changes: 23 additions & 25 deletions modes/init-web.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
(general-define-key
:keymaps 'evil-outer-text-objects-map
;; "t" 'jester/evil-a-tag-dwim
"t" 'evil-a-tag
"a" 'jester/evil-a-attribute)
(general-define-key
:keymaps 'evil-inner-text-objects-map
"a" 'jester/evil-inner-attribute)
"t" 'evil-a-tag)
(jester/with-major-leader 'web-mode-map
"r" 'web-mode-element-rename
"f" 'web-mode-fold-or-unfold)
Expand Down Expand Up @@ -59,26 +55,6 @@
:keymaps '(web-mode-map js2-mode-map)
"C-l" 'emmet-expand-yas))

;;----------------------------------------------------------------------------
;; include line feeds when tag occupy whole lines
;;----------------------------------------------------------------------------
;; TODO evil-this-operator
(evil-define-text-object jester/evil-a-tag-dwim (count &optional beg end type)
"Select a tag block's whole lines.
if the open tag is the first in its line and the close tag is the last in its,
mark the whole lines containing the this tag pair
else only mark the tag pair"
:extend-selection nil
(let* ((point-list (evil-select-xml-tag beg end type count t))
(tag-beg (car point-list))
(tag-end (cadr point-list))
(line-beg (progn (goto-char tag-beg) (line-beginning-position))))
(if (and (looking-back "^\s*")
(progn (goto-char tag-end) (looking-at "\s*$"))
(not (equal (progn (print (car command-history)) (car command-history)) '(evil-surround-delete 116))))
(evil-range line-beg (line-end-position) 'line)
point-list)))

;;----------------------------------------------------------------------------
;; evil text object for html attribute
;;----------------------------------------------------------------------------
Expand All @@ -87,10 +63,32 @@ else only mark the tag pair"
:extend-selection nil
(list (- (web-mode-attribute-beginning-position) 1)
(+ (web-mode-attribute-end-position) 1)))

(evil-define-text-object jester/evil-inner-attribute (count &optional beg end type)
"Select an attribute."
:extend-selection nil
(list (web-mode-attribute-beginning-position)
(+ (web-mode-attribute-end-position) 1)))

(evil-define-text-object jester/evil-a-arg-or-attribute (count &optional beg end type)
"Select an arg or attribute."
:extend-selection nil
(condition-case err
(cl-subseq (jester/evil-a-attribute) 0 2)
(error (cl-subseq (jester/evil-a-arg) 0 2))))

(evil-define-text-object jester/evil-inner-arg-or-attribute (count &optional beg end type)
"Select an arg or attribute."
:extend-selection nil
(condition-case err
(cl-subseq (jester/evil-inner-attribute) 0 2)
(error (cl-subseq (jester/evil-inner-arg) 0 2))))

(general-define-key
:keymaps 'evil-outer-text-objects-map
"a" 'jester/evil-a-arg-or-attribute)
(general-define-key
:keymaps 'evil-inner-text-objects-map
"a" 'jester/evil-inner-arg-or-attribute)

(provide 'init-web)
7 changes: 2 additions & 5 deletions modes/init-windows.el
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,10 @@
"*skewer-error*"
("^\\*.*build.*\\*$" :regexp t)
("^\\*evil-.+\\*$" :regexp t)
("-indirect-" :regexp t)
'Man-mode
'woman-mode
'snippet-mode
;; TODO not work
;; ('markdown-mode :custom (lambda (buffer)
;; (with-current-buffer buffer edit-server-edit-mode)))
)
'snippet-mode)
"cars for shackle rule, representing conditions using same-window rule")

(defvar jester-shackle-same-window-rule
Expand Down

0 comments on commit 7860707

Please sign in to comment.