[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-nerd-commenter 8809dccfdb 223/235: user can customize
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-nerd-commenter 8809dccfdb 223/235: user can customize comment style |
Date: |
Thu, 6 Jan 2022 02:59:50 -0500 (EST) |
branch: elpa/evil-nerd-commenter
commit 8809dccfdbd7eb4cb34fa42794a80de5469e11d6
Author: Chen Bin <chenbin.sh@gmail.com>
Commit: Chen Bin <chenbin.sh@gmail.com>
user can customize comment style
---
README.org | 14 ++++++++++++++
evil-nerd-commenter-operator.el | 8 ++++----
evil-nerd-commenter.el | 35 +++++++++++++++++++++++++++++------
pkg.sh | 2 +-
4 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/README.org b/README.org
index 55f166b2d4..da9b7d50b7 100644
--- a/README.org
+++ b/README.org
@@ -282,6 +282,20 @@ Most popular programming languages are supported.
You can set up =evilnc-original-above-comment-when-copy-and-comment= to decide
which style to use when =evilnc-copy-and-comment-lines= or
=evilnc-copy-and-comment-operator=,
- Place the commented out text above original text
- Or place the original text above commented out text
+** Customize comment style
+Most commands call =evilnc-comment-or-uncomment-region-function=.
+
+You can modify this variable to customize the comment style.
+
+#+begin_src elisp
+(with-eval-after-load 'evil-nerd-commenter
+ (defun my-comment-or-uncomment-region (beg end)
+ (let* ((comment-start "aaa")
+ (comment-end "bbb"))
+ (evilnc-comment-or-uncomment-region-internal beg end)))
+ (setq evilnc-comment-or-uncomment-region-function
+ 'my-comment-or-uncomment-region))
+#+end_src
* Credits
- [[https://github.com/lalopmak][Lally Oppenheimer (AKA lalopmak)]] added the
support for text-object in Evil
- [[https://github.com/ryuslash][Tom Willemse (AKA ryuslash)]] provided the
fix to make Emacs 24.4 work
diff --git a/evil-nerd-commenter-operator.el b/evil-nerd-commenter-operator.el
index df5a0a71a4..65820bb3a2 100644
--- a/evil-nerd-commenter-operator.el
+++ b/evil-nerd-commenter-operator.el
@@ -145,7 +145,7 @@ Or expand the region to contain whole lines if it's not
comment and certain cond
(cond
((eq type 'block)
(let* ((newpos (evilnc-expand-to-whole-comment-or-line beg end) ))
- (evil-apply-on-block #'evilnc--comment-or-uncomment-region
+ (evil-apply-on-block #'evilnc-comment-or-uncomment-region
(car newpos)
(cdr newpos)
nil)))
@@ -156,11 +156,11 @@ Or expand the region to contain whole lines if it's not
comment and certain cond
(/= (char-before end) ?\n))
(/= beg (point-min))
(= (char-before beg) ?\n))
- (evilnc--comment-or-uncomment-region (1- beg) end))
+ (evilnc-comment-or-uncomment-region (1- beg) end))
((eq type 'line)
;; comment whole line, for now
- (evilnc--comment-or-uncomment-region beg
+ (evilnc-comment-or-uncomment-region beg
(save-excursion
(goto-char (1- end))
(line-end-position))))
@@ -168,7 +168,7 @@ Or expand the region to contain whole lines if it's not
comment and certain cond
(t
(when (and beg end)
(let* ((newpos (evilnc-expand-to-whole-comment-or-line beg end)))
- (evilnc--comment-or-uncomment-region (car newpos) (cdr newpos))))))
+ (evilnc-comment-or-uncomment-region (car newpos) (cdr newpos))))))
;; place cursor on beginning of line
(if (and (called-interactively-p 'any) (eq type 'line))
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index d3e19fad32..ac487410a6 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -3,7 +3,7 @@
;; Author: Chen Bin <chenbin DOT sh AT gmail.com>
;; URL: http://github.com/redguardtoo/evil-nerd-commenter
-;; Version: 3.5.1
+;; Version: 3.5.2
;; Package-Requires: ((emacs "24.4"))
;; Keywords: convenience evil
;;
@@ -111,6 +111,19 @@
;; (local-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines))
;; (add-hook 'matlab-mode-hook 'matlab-mode-hook-config)
;;
+;; Most commands call `evilnc-comment-or-uncomment-region-function'.
+;; You can modify this variable to customize the comment style,
+;;
+;; (with-eval-after-load 'evil-nerd-commenter
+;; (defun my-comment-or-uncomment-region (beg end)
+;; (let* ((comment-start "aaa")
+;; (comment-end "bbb"))
+;; (evilnc-comment-or-uncomment-region-internal beg end)))
+;; (setq evilnc-comment-or-uncomment-region-function
+;; 'my-comment-or-uncomment-region))
+;;
+;; See "Options Controlling Comments" in Emacs manual for comment options.
+;;
;; See https://github.com/redguardtoo/evil-nerd-commenter for detail.
;;
;;; Code:
@@ -130,6 +143,10 @@
"If t then invert region comment status line by line.
Please note it has NOT effect on evil text object!")
+(defvar evilnc-comment-or-uncomment-region-function
+ 'evilnc-comment-or-uncomment-region-internal
+ "Comment or uncomment region.")
+
(defvar evilnc-cpp-like-comment-syntax-modes
'(java-mode
javascript-mode
@@ -464,7 +481,8 @@ Code snippets embedded in Org-mode is identified and right
`major-mode' is used.
(goto-char end)
(web-mode-comment-or-uncomment))))
-(defun evilnc--comment-or-uncomment-region (beg end)
+;;;###autoload
+(defun evilnc-comment-or-uncomment-region-internal (beg end)
"Comment or uncomment region from BEG to END."
(cond
((eq major-mode 'web-mode)
@@ -476,6 +494,11 @@ Code snippets embedded in Org-mode is identified and right
`major-mode' is used.
(t
(evilnc--working-on-region beg end 'comment-or-uncomment-region))))
+;;;###autoload
+(defun evilnc-comment-or-uncomment-region (beg end)
+ "Comment or uncomment region from BEG to END."
+ (funcall evilnc-comment-or-uncomment-region-function beg end))
+
(defun evilnc--current-line-num ()
"Get current line number."
(save-restriction
@@ -551,7 +574,7 @@ Paragraphs are separated by empty lines."
(evilnc-do-paragraphs
(lambda (b e)
(evilnc--fix-buggy-major-modes)
- (evilnc--comment-or-uncomment-region b e))
+ (evilnc-comment-or-uncomment-region b e))
num))
;;;###autoload
@@ -568,7 +591,7 @@ Paragraphs are separated by empty lines."
(if (> (line-end-position) e)
(setq e (line-end-position)))
(evilnc--fix-buggy-major-modes)
- (evilnc--comment-or-uncomment-region b e)))))
+ (evilnc-comment-or-uncomment-region b e)))))
;;;###autoload
(defun evilnc-quick-comment-or-uncomment-to-the-line (&optional last-digits)
@@ -632,7 +655,7 @@ CORRECT comment syntax will be used for
C++/Java/Javascript."
(setq num (- 0 num)))
(evilnc--operation-on-lines-or-region '(lambda (b e)
(evilnc--fix-buggy-major-modes)
-
(evilnc--comment-or-uncomment-region b e))
+
(evilnc-comment-or-uncomment-region b e))
num))
(goto-char orig-pos)))))
@@ -737,7 +760,7 @@ Then we operate the expanded region. NUM is ignored."
(defun evilnc-version ()
"The version number."
(interactive)
- (message "3.5.1"))
+ (message "3.5.2"))
(defvar evil-normal-state-map)
(defvar evil-visual-state-map)
diff --git a/pkg.sh b/pkg.sh
index 028799e1b2..6950ef636a 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,6 +1,6 @@
#!/bin/bash
name=evil-nerd-commenter
-version=3.5.1
+version=3.5.2
pkg=$name-$version
mkdir $pkg
cp *.el $pkg
- [nongnu] elpa/evil-nerd-commenter c9fa23ee7e 206/235: evil operator try to comment on whole lines if possible, (continued)
- [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, 2022/01/06
- [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 <=
- [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
- [nongnu] elpa/evil-nerd-commenter ba535606b4 003/235: add a use case, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 188a475cfc 013/235: Merge branch 'master' of github.com:redguardtoo/evil-nerd-commenter, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 64ee33dac4 022/235: insert live demo link into README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 1cec61caac 038/235: Removed redundant double information, ELPA Syncer, 2022/01/06