[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-nerd-commenter 87734b9c7f 218/235: clean code
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-nerd-commenter 87734b9c7f 218/235: clean code |
Date: |
Thu, 6 Jan 2022 02:59:49 -0500 (EST) |
branch: elpa/evil-nerd-commenter
commit 87734b9c7fcd047f73a072b9d03ec05f786eeb03
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
clean code
---
evil-nerd-commenter-operator.el | 2 +-
evil-nerd-commenter-sdk.el | 5 +++++
evil-nerd-commenter.el | 8 +++-----
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/evil-nerd-commenter-operator.el b/evil-nerd-commenter-operator.el
index 3e37928480..067c5c6f20 100644
--- a/evil-nerd-commenter-operator.el
+++ b/evil-nerd-commenter-operator.el
@@ -220,7 +220,7 @@ Or expand the region to contain whole lines if it's not
comment and certain cond
;; so we need go back
(let* ((str (save-excursion
(goto-char e)
- (buffer-substring-no-properties (line-beginning-position)
e)))
+ (evilnc-sdk-cur-line e)))
(empty-line-p (string-match "^[ \t]*$" str)))
(if empty-line-p
;; empty line plus line feed
diff --git a/evil-nerd-commenter-sdk.el b/evil-nerd-commenter-sdk.el
index 696ea3c663..21b43998b2 100644
--- a/evil-nerd-commenter-sdk.el
+++ b/evil-nerd-commenter-sdk.el
@@ -92,6 +92,11 @@ or else we can't select multiple lines comment."
(and (<= (line-beginning-position) beg)
(<= end (line-end-position))))
+(defun evilnc-sdk-cur-line (&optional end)
+ "String from line beginning to END or line end."
+ (buffer-substring-no-properties (line-beginning-position)
+ (or end (line-end-position))))
+
(defun evilnc-sdk-expand-to-contain-whole-lines (beg end)
"Expand region between BEG and END so the region contain whole lines.
Return new range like '(region_begin . region_end)."
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index 9316e17a33..d160ac2953 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -622,7 +622,7 @@ CORRECT comment syntax will be used for
C++/Java/Javascript."
;; donot move the cursor
;; support negative number
(cond
- ((and (= 1 num) (string-match "^[ \t]*$" (buffer-substring-no-properties
(line-beginning-position) (line-end-position))))
+ ((and (= 1 num) (string-match "^[ \t]*$" (evilnc-sdk-cur-line)))
;; comment on current empty line
(comment-dwim nil))
(t
@@ -880,10 +880,8 @@ if NO-EMACS-KEYBINDINGS is t, we don't define keybindings
in EMACS mode."
"Html tag comment at position BEG?"
(save-excursion
(goto-char beg)
- (let* ((line (buffer-substring-no-properties (line-beginning-position)
- (line-end-position)))
- (re (concat "^[ \t]*" (regexp-quote (evilnc-html-comment-start)))))
- (string-match-p re line))))
+ (string-match-p (concat "^[ \t]*" (regexp-quote
(evilnc-html-comment-start)))
+ (evilnc-sdk-cur-line))))
;;;###autoload
(defun evilnc-comment-or-uncomment-html-tag ()
- [nongnu] elpa/evil-nerd-commenter 9c87ea30fa 199/235: wording, (continued)
- [nongnu] elpa/evil-nerd-commenter 9c87ea30fa 199/235: wording, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter ce3530406c 201/235: fixed CI, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter a5555ff02a 202/235: remove legacy code on old version of web-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter d664ad5af7 203/235: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter c9fa23ee7e 206/235: evil operator try to comment on whole lines if possible, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter fd2fba722e 205/235: clean keybinding setup code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 4a72fbd022 207/235: README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 76f07963c0 213/235: Update outdated link to emacswiki, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 747e346f11 212/235: Merge pull request #109 from hlissner/patch-1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 1bd2de5201 214/235: Merge pull request #111 from duchainer/patch-outdated-link-emacswiki, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 87734b9c7f 218/235: clean code,
ELPA Syncer <=
- [nongnu] elpa/evil-nerd-commenter 6ed6f9ea82 215/235: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter b670f69b64 221/235: add emacs27 to ci, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 2401d871ad 217/235: use GPL version 3, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 8809dccfdb 223/235: user can customize comment style, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 9e7e969719 226/235: try stay put when comment in evil visual line state, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 563cdc154b 222/235: fix typo and add unit test for web-mode, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 5535be5421 227/235: (line . column), ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter c0f49e4e87 228/235: fixed minor issue, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 118bebd02a 229/235: use github workflows instead of travis ci, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter c48a95c3ff 234/235: feat: support .tsx files, ELPA Syncer, 2022/01/06