Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

merge #70

Open
wants to merge 28 commits into
base: rewrite
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
05f554b
UPDATE DOC
DogLooksGood Feb 14, 2018
be5d7da
remove duplicate definition of parinfer-delete-indentation
ahrjarrett Feb 27, 2018
5bfc915
Merge pull request #61 from ahrjarrett/master
DogLooksGood Feb 27, 2018
f08de41
remove dependency on package.el
richardsonpaul Jun 28, 2018
33b2996
Print error message and line number when indent mode fails
Jul 11, 2018
42c6df2
Merge pull request #65 from telotortium/indent-error
DogLooksGood Jul 12, 2018
04dd27a
Merge pull request #64 from richardsonpaul/lispy-package-installed
DogLooksGood Jul 18, 2018
306e0b1
extension fboundp lispy -> lispy-mode
yqrashawn Jul 31, 2018
e557411
Merge pull request #66 from yqrashawn/lispy
DogLooksGood Aug 1, 2018
fe1182d
make parinfer evil more reactive
yqrashawn Aug 7, 2018
6e83167
add evil support for smart-yank and smart-tab
yqrashawn Aug 7, 2018
15da365
yank prblem
yqrashawn Aug 7, 2018
daec246
add evil shift line
yqrashawn Aug 9, 2018
c8ddee6
add evil normal state
yqrashawn Aug 9, 2018
554cb70
add evil-exit-visual-state
yqrashawn Aug 9, 2018
129c06b
add comment line
yqrashawn Aug 12, 2018
253252e
fix evil forward backward char
yqrashawn Aug 12, 2018
53beb44
lispy parins
yqrashawn Aug 22, 2018
24e8b5d
add lispy tab
yqrashawn Aug 22, 2018
2dd0f9f
disable lispy-parins, need better solution
yqrashawn Aug 28, 2018
96759d0
evil forward backward char don't invoke reindent
yqrashawn Aug 30, 2018
422b0f3
fix parinfer lispy parens
yqrashawn Sep 4, 2018
0d4558d
cleanup
yqrashawn Sep 4, 2018
371a441
delay on evil shift
yqrashawn Sep 4, 2018
be939a9
cleanup
yqrashawn Sep 4, 2018
2466b76
bugfix
yqrashawn Sep 4, 2018
6347269
doc
yqrashawn Sep 4, 2018
a7c0414
Merge pull request #67 from yqrashawn/master
DogLooksGood Sep 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[[file:images/logo.png]]

* About Smart Mode
Currently this project is rewriting for providing smart mode on branch `v3`.
Currently this project is rewriting for providing smart mode on branch `smart`.
* Demo
[[file:images/demo.gif]]

Expand Down
58 changes: 29 additions & 29 deletions parinfer-ext.el
Original file line number Diff line number Diff line change
Expand Up @@ -186,28 +186,29 @@ Use rainbow-delimiters for Paren Mode, and dim-style parens for Indent Mode."
(parinfer-lispy:paren-char-p ca)
(parinfer-lispy:paren-char-p cb))))

(defun parinfer-lispy:parens ()
(interactive)
(if (region-active-p)
(defun parinfer-lispy:parens (arg)
(interactive "P")
(if (or (region-active-p) arg)
(call-interactively 'lispy-parens)
(call-interactively 'self-insert-command)))

(defun parinfer-lispy:brackets ()
(interactive)
(if (region-active-p)
(defun parinfer-lispy:brackets (arg)
(interactive "P")
(if (or (region-active-p) arg)
(call-interactively 'lispy-brackets)
(call-interactively 'self-insert-command)))

(defun parinfer-lispy:braces ()
(interactive)
(if (region-active-p)
(defun parinfer-lispy:braces (arg)
(interactive "P")
(if (or (region-active-p) arg)
(call-interactively 'lispy-braces)
(call-interactively 'self-insert-command)))

(defun parinfer-lispy:init ()
(if (package-installed-p 'lispy)
(if (fboundp 'lispy-mode)
(progn
(require 'lispy)
(mapc (lambda (x) (lispy-define-key parinfer-mode-map (format "%d" x) 'digit-argument))
(number-sequence 0 9))
(define-key parinfer-mode-map (kbd "(") 'parinfer-lispy:parens)
(define-key parinfer-mode-map (kbd "{") 'parinfer-lispy:braces)
(define-key parinfer-mode-map (kbd "[") 'parinfer-lispy:brackets)
Expand All @@ -230,24 +231,27 @@ Use rainbow-delimiters for Paren Mode, and dim-style parens for Indent Mode."
(define-key parinfer-mode-map (kbd "M-m") 'lispy-mark-symbol)
(define-key parinfer-mode-map (kbd "b") 'special-lispy-back)
(define-key parinfer-mode-map (kbd "f") 'special-lispy-flow)
(define-key parinfer-mode-map (kbd "f") 'special-lispy-flow)
(define-key parinfer-mode-map (kbd "e") 'special-lispy-eval)
(define-key parinfer-mode-map (kbd "o") 'special-lispy-other-mode)
(define-key parinfer-mode-map (kbd "O") 'special-lispy-oneline)
(define-key parinfer-mode-map (kbd "M") 'special-lispy-alt-multiline)
(define-key parinfer-mode-map (kbd "y") 'special-lispy-occur)
(define-key parinfer-mode-map (kbd "i") 'special-lispy-tab)
(define-key parinfer-mode-map (kbd "r") 'special-lispy-raise)
(define-key parinfer-mode-map (kbd "C-a") 'lispy-move-beginning-of-line)
(define-key parinfer-mode-map (kbd "g") 'special-lispy-goto)
(define-key parinfer-mode-map (kbd ">") 'special-lispy-slurp)
(define-key parinfer-mode-map (kbd "<") 'special-lispy-barf)
(define-key parinfer-mode-map (kbd "n") 'special-lispy-new-copy)
(define-key parinfer-mode-map (kbd "SPC" )'parinfer-lispy:space))
(define-key parinfer-mode-map (kbd "t") 'special-lispy-teleport)
(define-key parinfer-mode-map (kbd "H") 'special-lispy-ace-symbol-replace)
(define-key parinfer-mode-map (kbd "p") 'special-lispy-paste)
(define-key parinfer-mode-map (kbd "/") 'special-lispy-splice)
(define-key parinfer-mode-map (kbd "SPC") 'parinfer-lispy:space))
(message "Parinfer extension lispy: It seems Lispy is not installed!")))

(parinfer-define-extension lispy
"Integration with Lispy."

:mount
(require 'eldoc)
(eldoc-add-command-completions "lispy-" "parinfer-")
Expand All @@ -268,12 +272,13 @@ Use rainbow-delimiters for Paren Mode, and dim-style parens for Indent Mode."
"Integration with Evil."
:mount
(parinfer-strategy-add 'default
'evil-delete-char)
'(evil-delete-char evil-shift-left evil-shift-right evil-shift-right-line
evil-shift-left-line))
(parinfer-strategy-add 'instantly
'(evil-delete evil-change evil-change-line evil-paste-before evil-paste-after
evil-delete-line evil-delete-char evil-delete-backward-char evil-substitute
evil-change-whole-line evil-force-normal-state evil-normal-state
evil-shift-left evil-shift-right))
evil-exit-visual-state))
(parinfer-strategy-add 'skip
'(evil-previous-line evil-forward-char evil-backward-char evil-next-line
evil-forward-word evil-forward-word-begin evil-backward-word-begin
Expand Down Expand Up @@ -355,7 +360,7 @@ Use rainbow-delimiters for Paren Mode, and dim-style parens for Indent Mode."
(save-excursion
(end-of-line)
(while (eq (char-before) 32)
(backward-delete-char 1)))
(backward-delete-char 1)))
(save-excursion
(parinfer--goto-line parinfer-smart-tab:indicator-line)
(when (parinfer--empty-line-p)
Expand Down Expand Up @@ -486,7 +491,7 @@ Use rainbow-delimiters for Paren Mode, and dim-style parens for Indent Mode."
(delete-indentation)
(backward-char))
(end-of-line)
(while (eq 32 (char-before))
(while (eq 32 (char-before))
(backward-delete-char 1))
(-distinct pos-list))))))

Expand Down Expand Up @@ -665,7 +670,10 @@ Use rainbow-delimiters for Paren Mode, and dim-style parens for Indent Mode."
(define-key parinfer-mode-map [remap backward-char] 'parinfer-smart-tab:backward-char)
(define-key parinfer-region-mode-map [remap parinfer-shift-right] 'parinfer-smart-tab:shift-right)
(define-key parinfer-region-mode-map [remap parinfer-shift-left] 'parinfer-smart-tab:shift-left)

(if (fboundp 'evil-define-key)
(progn (evil-define-key 'insert parinfer-region-mode-map [remap evil-shift-right-line] 'parinfer-smart-tab:shift-right)
(evil-define-key 'insert parinfer-region-mode-map [remap evil-shift-left-line] 'parinfer-smart-tab:shift-left)))

:unmount
(remove-hook 'post-command-hook 'parinfer-smart-tab:clean-indicator t)
(remove-hook 'pre-command-hook 'parinfer-smart-tab:clean-indicator-pre t))
Expand Down Expand Up @@ -757,7 +765,7 @@ Use rainbow-delimiters for Paren Mode, and dim-style parens for Indent Mode."
(forward-sexp)
(insert (parinfer-one:get-close-paren key)))
(parinfer-one:paren)))

((-contains-p parinfer-one:indent-trigger-keys key)
(progn
(parinfer--invoke-parinfer-when-necessary)))
Expand Down Expand Up @@ -831,15 +839,7 @@ Use rainbow-delimiters for Paren Mode, and dim-style parens for Indent Mode."
:unmount
(remove-hook 'post-command-hook 'parinfer-one:invoke-when-necessary-auto t)
(remove-hook 'pre-command-hook 'parinfer-one:update-context t))


(provide 'parinfer-ext)
;;; parinfer-ext.el ends here








32 changes: 20 additions & 12 deletions parinfer.el
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ close-parens after it.")

(defvar parinfer-strategy
'((default
self-insert-command delete-indentation kill-line
comment-dwim kill-word delete-char newline kill-region comment-or-uncomment-region newline-and-indent)
self-insert-command delete-indentation kill-line comment-line
comment-dwim kill-word delete-char newline kill-region comment-or-uncomment-region newline-and-indent)
(instantly
delete-region newline)
(skip))
Expand Down Expand Up @@ -858,11 +858,18 @@ If There's no change, switch to Indent Mode."
(text (buffer-substring-no-properties (point-min) (point-max)))
(result (parinferlib-indent-mode text opts))
(success (plist-get result :success))
(err (plist-get result :error))
(error-message (plist-get err :message))
(error-line-no (plist-get err :line-no))
(changed-lines (plist-get result :changed-lines)))
(if (not success)
(progn
(message (concat "Parinfer: Pairs unmatched, switch to Paren mode. "
"When pair fixed, You can switch to indent mode."))
(message (concat "Parinfer: Error%s: \"%s\" - switch to Paren mode. "
"When error fixed, you can switch to indent mode.")
(if (null error-line-no)
""
(format " on line %d" error-line-no))
error-message)
nil)
(if (and changed-lines
(not (string= text (plist-get result :text))))
Expand All @@ -886,11 +893,18 @@ If there's any change, display a confirm message in minibuffer."
(text (buffer-substring-no-properties (point-min) (point-max)))
(result (parinferlib-indent-mode text opts))
(success (plist-get result :success))
(err (plist-get result :error))
(error-message (plist-get err :message))
(error-line-no (plist-get err :line-no))
(changed-lines (plist-get result :changed-lines)))
(if (not success)
(progn
(message (concat "Pairs unmatched, switch to Paren mode. "
"When pair fixed, You can switch to indent mode."))
(message (concat "Parinfer: Error%s: \"%s\" - switch to Paren mode. "
"When error fixed, you can switch to indent mode.")
(if (null error-line-no)
""
(format " on line %d" error-line-no))
error-message)
nil)
(if (and changed-lines
(not (string= text (plist-get result :text))))
Expand Down Expand Up @@ -1032,12 +1046,6 @@ invoke parinfer after every semicolon input."
(parinfer--invoke-parinfer))))
(call-interactively 'self-insert-command)))

(defun parinfer-delete-indentation ()
"Replacement in 'parinfer-mode' for 'delete-indentation' command."
(interactive)
(parinfer-paren-run
(call-interactively 'delete-indentation)))

(defun parinfer-toggle-mode ()
"Switch parinfer mode between Indent Mode and Paren Mode."
(interactive)
Expand Down