-
Notifications
You must be signed in to change notification settings - Fork 6
Add option to choose whether the deleted region should be added to kill ring #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,12 @@ | |
:safe t | ||
) | ||
|
||
(defcustom smart-hungry-delete-add-kill-ring t | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I don't want to be annoying, but can we rename this to |
||
"If t, deleted region will be added to `kill ring`." | ||
:type '(boolean) | ||
:safe t | ||
) | ||
|
||
(defun smart-hungry-delete-looking-back-limit () | ||
"LIMIT for `looking-back`." | ||
(max 0 (- (point) smart-hungry-delete-max-lookback))) | ||
|
@@ -124,6 +130,14 @@ completely deleted." | |
(add-hook 'nxml-mode-hook 'smart-hungry-delete-default-sgml-mode-common-hook) | ||
(add-hook 'text-mode-hook 'smart-hungry-delete-default-text-mode-hook)) | ||
|
||
;;;###autoload | ||
(defun smart-hungry-delete-should-add-kill-ring (should-kill) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. common elisp convention is to postfix predicate functions with How about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, this isn't a predicate. Hmm. |
||
"Choose deleted region should be added to kill ring or not by `SHOULD-KILL`." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
(interactive) | ||
(setq smart-hungry-delete-add-kill-ring should-kill) | ||
(put #'smart-hungry-delete-backward-char 'delete-selection (if smart-hungry-delete-add-kill-ring 'kill nil)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you putting stuff into the fsymbol here? It's never used, is it? |
||
(put #'smart-hungry-delete-forward-char 'delete-selection (if smart-hungry-delete-add-kill-ring 'kill nil))) | ||
|
||
;;;###autoload | ||
(defun smart-hungry-delete-backward-char (arg) | ||
"If there is more than one char of whitespace between previous word and point, | ||
|
@@ -136,8 +150,6 @@ With prefix argument ARG, just delete a single char." | |
(prefix-command-preserve-state) | ||
(smart-hungry-delete-char arg t)) | ||
|
||
(put #'smart-hungry-delete-backward-char 'delete-selection 'kill) | ||
|
||
;;;###autoload | ||
(defun smart-hungry-delete-forward-char (arg) | ||
"If there is more than one char of whitespace between point and next word, | ||
|
@@ -150,8 +162,6 @@ With prefix argument ARG, just delete a single char." | |
(prefix-command-preserve-state) | ||
(smart-hungry-delete-char arg)) | ||
|
||
(put #'smart-hungry-delete-forward-char 'delete-selection 'kill) | ||
|
||
(defun smart-hungry-delete-char-trigger (to from) | ||
"Return t if the region (TO FROM) should be killed completely." | ||
(save-excursion | ||
|
@@ -204,7 +214,7 @@ With PREFIX just delete one char." | |
fallback 'delete-char) | ||
) | ||
(if (use-region-p) | ||
(kill-region nil nil t) | ||
(if smart-hungry-delete-add-kill-ring (kill-region nil nil t) (delete-region (region-beginning) (region-end))) | ||
(let ((kill-hungrily (funcall check smart-hungry-delete-char-kill-regexp))) | ||
(cond ((functionp kill-hungrily) | ||
(funcall-interactively kill-hungrily)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide these in a separate PR?