emacs-elpa-diffs
[Top][All Lists]
Advanced

[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)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]