[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-nerd-commenter dfdaae43e9 106/235: Don't byte-compile
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-nerd-commenter dfdaae43e9 106/235: Don't byte-compile the evil bits |
Date: |
Thu, 6 Jan 2022 02:59:39 -0500 (EST) |
branch: elpa/evil-nerd-commenter
commit dfdaae43e9157dab23b483e59a60f7d97327f907
Author: Tom Willemse <tom@ryuslash.org>
Commit: Tom Willemse <tom@ryuslash.org>
Don't byte-compile the evil bits
Separate the parts that require evil to function. This way the evil code
can fail to byte compile while letting the rest go ahead. It also keeps
the code from breaking when evil is unavailable during compile time.
---
evil-nerd-commenter-operator.el | 77 +++++++++++++++++++++++++++++++++++++++++
evil-nerd-commenter.el | 42 +---------------------
2 files changed, 78 insertions(+), 41 deletions(-)
diff --git a/evil-nerd-commenter-operator.el b/evil-nerd-commenter-operator.el
new file mode 100644
index 0000000000..ee0bc0d36f
--- /dev/null
+++ b/evil-nerd-commenter-operator.el
@@ -0,0 +1,77 @@
+;;; evil-nerd-commenter-operator --- Provides an evil operator for
evil-nerd-commenter
+
+;; Copyright (C) 2013 Chen Bin
+
+;; Author: Chen Bin <chenbin.sh@gmail.com>
+;; URL: http://github.com/redguardtoo/evil-nerd-commenter
+;; Version: 1.5.9
+;; Keywords: commenter vim line evil
+;;
+;; This file is not part of GNU Emacs.
+
+;;; License:
+
+;; This file is part of evil-nerd-commenter
+;;
+;; evil-nerd-commenter is free software: you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as published
+;; by the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; evil-nerd-commenter is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; Provides an operator for evil-mode.
+
+;;; Code:
+
+(require 'evil)
+
+(evil-define-operator evilnc-comment-operator (beg end type register
yank-handler)
+ "Comments text from BEG to END with TYPE.
+Save in REGISTER or in the kill-ring with YANK-HANDLER."
+ (interactive "<R><x><y>")
+ (unless register
+ (let ((text (filter-buffer-substring beg end)))
+ (unless (string-match-p "\n" text)
+ ;; set the small delete register
+ (evil-set-register ?- text))))
+ (evil-yank beg end type register yank-handler)
+ (cond
+ ((eq type 'block)
+ (let ((newpos (evilnc--extend-to-whole-comment beg end) ))
+ (evil-apply-on-block #'evilnc--comment-or-uncomment-region (nth 0
newpos) (nth 1 newpos) nil)
+ )
+ )
+ ((and (eq type 'line)
+ (= end (point-max))
+ (or (= beg end)
+ (/= (char-before end) ?\n))
+ (/= beg (point-min))
+ (= (char-before beg) ?\n))
+ (evilnc--comment-or-uncomment-region (1- beg) end))
+ ((eq type 'line)
+ (evilnc--comment-or-uncomment-region beg end))
+ (t
+ (let ((newpos (evilnc--extend-to-whole-comment beg end) ))
+ (evilnc--comment-or-uncomment-region (nth 0 newpos) (nth 1 newpos))
+ )
+ ))
+ ;; place cursor on beginning of line
+ (when (and (evil-called-interactively-p)
+ (eq type 'line))
+ (evil-first-non-blank)))
+
+(define-key evil-normal-state-map evilnc-hotkey-comment-operator
'evilnc-comment-operator)
+(define-key evil-visual-state-map evilnc-hotkey-comment-operator
'evilnc-comment-operator)
+
+(provide 'evil-nerd-commenter-operator)
+
+;;; evil-nerd-commenter-operator.el ends here
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index c013ef1fc2..e13cff45e8 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -90,9 +90,6 @@
;;; Code:
-(eval-when-compile
- (require 'evil nil :noerror))
-
;; Example, press ",,a{" will change C code:
;; {printf("hello");} => /* {printf("hello");}*/
;; google "vim text object for more syntax"
@@ -537,44 +534,7 @@ or 'C-u 3 M-x
evilnc-quick-comment-or-uncomment-to-the-line' to comment to the l
;; Attempt to define the operator on first load.
;; Will only work if evil has been loaded
(eval-after-load 'evil
- '(progn
- (evil-define-operator evilnc-comment-operator (beg end type register
yank-handler)
- "Comments text from BEG to END with TYPE.
-Save in REGISTER or in the kill-ring with YANK-HANDLER."
- (interactive "<R><x><y>")
- (unless register
- (let ((text (filter-buffer-substring beg end)))
- (unless (string-match-p "\n" text)
- ;; set the small delete register
- (evil-set-register ?- text))))
- (evil-yank beg end type register yank-handler)
- (cond
- ((eq type 'block)
- (let ((newpos (evilnc--extend-to-whole-comment beg end) ))
- (evil-apply-on-block #'evilnc--comment-or-uncomment-region (nth 0
newpos) (nth 1 newpos) nil)
- )
- )
- ((and (eq type 'line)
- (= end (point-max))
- (or (= beg end)
- (/= (char-before end) ?\n))
- (/= beg (point-min))
- (= (char-before beg) ?\n))
- (evilnc--comment-or-uncomment-region (1- beg) end))
- ((eq type 'line)
- (evilnc--comment-or-uncomment-region beg end))
- (t
- (let ((newpos (evilnc--extend-to-whole-comment beg end) ))
- (evilnc--comment-or-uncomment-region (nth 0 newpos) (nth 1 newpos))
- )
- ))
- ;; place cursor on beginning of line
- (when (and (evil-called-interactively-p)
- (eq type 'line))
- (evil-first-non-blank)))
- (define-key evil-normal-state-map evilnc-hotkey-comment-operator
'evilnc-comment-operator)
- (define-key evil-visual-state-map evilnc-hotkey-comment-operator
'evilnc-comment-operator)
- ))
+ '(require 'evil-nerd-commenter-operator))
(provide 'evil-nerd-commenter)
- [nongnu] elpa/evil-nerd-commenter 336ce1ab67 083/235: readme on using evil-leader, (continued)
- [nongnu] elpa/evil-nerd-commenter 336ce1ab67 083/235: readme on using evil-leader, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 7ec8564adc 082/235: optimize code a little bit, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 1cff8e027d 084/235: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 20a242a085 087/235: tweak README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 10dd7f8f1d 090/235: Merge branch 'tuhdo-master', ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter c2d8cd947e 089/235: remove some interacitve hint and fixed some bug, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter b9e34fe377 088/235: Prompt user for input and fix evilnc-kill-to-line, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter f9bdfa9a70 096/235: sample setup for evil-leader users v1.5.5, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 23e4d4d1e1 097/235: updated doc, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter a88146b600 099/235: fixed: minor bug comment to the line v1.5.7, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter dfdaae43e9 106/235: Don't byte-compile the evil bits,
ELPA Syncer <=
- [nongnu] elpa/evil-nerd-commenter ac03a92ae6 107/235: updated README v1.5.10, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter ff0344ed82 110/235: updated README v1.5.12, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 1dd577ca35 113/235: clean README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 06ac3b1680 115/235: README updated, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter f12142e033 118/235: Update evil-nerd-commenter-operator.el, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 0529e7c78e 119/235: clean code on kill-ring, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter ab27df65e6 120/235: clean doc v1.5.15, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 2d04ea603a 124/235: add melpa badge, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 82069b7643 121/235: comment region restricted in one line #50, v2.0, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter cb96ce729f 125/235: complete doc. make `M-x checkdoc' happy, ELPA Syncer, 2022/01/06