[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil-nerd-commenter d3581dcf64 014/235: workaround autocon
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil-nerd-commenter d3581dcf64 014/235: workaround autoconf.el comment bug |
Date: |
Thu, 6 Jan 2022 02:59:31 -0500 (EST) |
branch: elpa/evil-nerd-commenter
commit d3581dcf64faf2182d12ca85abe9519e88c511ab
Author: chen bin <chenbin.sh@gmail.com>
Commit: chen bin <chenbin.sh@gmail.com>
workaround autoconf.el comment bug
---
README.org | 9 ++++++---
evil-nerd-commenter-pkg.el | 2 +-
evil-nerd-commenter.el | 30 ++++++++++++++++++++++++++----
pkg.sh | 2 +-
4 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/README.org b/README.org
index f8beccc135..99b2a8f0f5 100644
--- a/README.org
+++ b/README.org
@@ -1,15 +1,18 @@
-* evil-nerd-commenter (current version 0.0.3)
+* evil-nerd-commenter (current version 0.0.4)
As a developer, I often need comment/uncomment lines for debugging or adding
some short comment in the code block.
As I know, the [[http://www.vim.org/scripts/script.php?script_id=1218][Nerd
Commenter]] for Vim is the most efficient way to doing this thing.
Unfortunately, there is no similar plugin in Emacs.
That's why I develop this Nerd Commenter simulator for Emacs people.
-* Why evil-nerd-commenter is better? Show me a simple use case!
+* Why evil-nerd-commenter is better?
+** A simple use case on the efficiency
Say you want to comment out nine lines. Instead pressing "C-space M-9 C-n
M-;", now you can press "M-9 M-;" or ",9ci".
The key point is you need NOT mark any text to comment line(s)!
-So you strike less keys to comment code than the origial "M-x comment-dwim".
+So you strike less keys to comment code than the original "M-x comment-dwim".
+** The commenter will ALWAYS work even the official Emacs has some bug
+I'll provide long-term support for this plugin for *ANY language* in the
future. Here is a example how I work around
[[https://github.com/redguardtoo/evil-nerd-commenter/issues/3][a bug in
autoconf.el]].
* Install
evil-nerd-commenter is already uploaded to [[http://marmalade-repo.org/]]. So
the best way to install it is using Emacs' package manager.
* Set up
diff --git a/evil-nerd-commenter-pkg.el b/evil-nerd-commenter-pkg.el
index 6ca316b37a..774e64af0e 100644
--- a/evil-nerd-commenter-pkg.el
+++ b/evil-nerd-commenter-pkg.el
@@ -1,2 +1,2 @@
-(define-package "evil-nerd-commenter" "0.0.3"
+(define-package "evil-nerd-commenter" "0.0.4"
"Comment/uncomment lines efficiently. Like Nerd Commenter in
Vim")
diff --git a/evil-nerd-commenter.el b/evil-nerd-commenter.el
index 82e79ad413..93ee158a3f 100644
--- a/evil-nerd-commenter.el
+++ b/evil-nerd-commenter.el
@@ -4,7 +4,7 @@
;; Author: Chen Bin <chenbin DOT sh AT gmail>
;; URL: http://github.com/redguardtoo/evil-nerd-commenter
;; Keywords: commenter vim line evil
-;; Version: 0.0.3
+;; Version: 0.0.4
;; This file is not part of GNU Emacs.
@@ -21,7 +21,7 @@
;;; Code:
;; shamelessly copied from goto-line
-(defun evilnc-goto-line (line)
+(defun evilnc--goto-line (line)
(save-restriction
(widen)
(goto-char (point-min))
@@ -30,6 +30,25 @@
(forward-line (1- line))))
)
+(defun evilnc--fix-buggy-major-modes ()
+ "fix major modes whose comment regex is buggy.
+@see http://lists.gnu.org/archive/html/bug-gnu-emacs/2013-03/msg00891.html"
+ (when (string= major-mode "autoconf-mode")
+ ;; since comment-use-syntax is nil in autoconf.el, the comment-start-skip
need
+ ;; make sure the its first parenthesized expression match the string
exactly before
+ ;; the "dnl", check the comment-start-skip in lisp-mode may give you some
hint.
+ ;; See code in (defun comment-search-forward) from emacs 24.2.1:
+ ;; (if (not comment-use-syntax)
+ ;; (if (re-search-forward comment-start-skip limit noerror)
+ ;; (or (match-end 1) (match-beginning 0))
+ ;; My regex make sure (match-end 1) return the position of comment starter
+ (when (and (boundp 'comment-use-syntax) (not comment-use-syntax))
+ ;; Maybe autoconf.el will (setq comment-use-syntax t) in the future?
+ (setq comment-start-skip "^\\(\\s*\\)\\(dnl\\|#\\) +")
+ )
+ )
+ )
+
;;;###autoload
(defun evilnc-comment-or-uncomment-to-the-line (&optional LINENUM)
"Comment or uncomment from the current line to the LINENUM line"
@@ -38,15 +57,16 @@
(let ((b (line-beginning-position))
(e (line-end-position)))
(save-excursion
- (evilnc-goto-line LINENUM)
+ (evilnc--goto-line LINENUM)
(if (< (line-beginning-position) b)
(setq b (line-beginning-position)))
(if (> (line-end-position) e)
(setq e (line-end-position)))
+ (evilnc--fix-buggy-major-modes)
(comment-or-uncomment-region b e)
)
)
- ))
+ ))
;;;###autoload
(defun evilnc-toggle-comment-empty-lines ()
@@ -74,6 +94,7 @@
(save-excursion
(forward-line (- NUM 1))
(setq e (line-end-position))
+ (evilnc--fix-buggy-major-modes)
(comment-or-uncomment-region b e)
)
)
@@ -86,6 +107,7 @@
(setq b (line-beginning-position))
(goto-char e)
(setq e (line-end-position))
+ (evilnc--fix-buggy-major-modes)
(comment-or-uncomment-region b e)))
))
diff --git a/pkg.sh b/pkg.sh
index 6e9d0020e7..0deb2a7a5a 100755
--- a/pkg.sh
+++ b/pkg.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-pkg=evil-nerd-commenter-0.0.3
+pkg=evil-nerd-commenter-0.0.4
mkdir $pkg
cp README.org $pkg
cp *.el $pkg
- [nongnu] elpa/evil-nerd-commenter aa34d89797 185/235: add unit test and CI, (continued)
- [nongnu] elpa/evil-nerd-commenter aa34d89797 185/235: add unit test and CI, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter f7b082d5b2 186/235: add build status into README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 00840b3da4 198/235: Merge pull request #103 from mamapanda/master, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter fa40dab8d2 208/235: know the text object before operate on it, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 4387407615 209/235: fixed key binding setup, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 60b8862864 210/235: clean code, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter b7fc023492 220/235: fixed: `add-to-list’ can’t use lexical var `cands’, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter b8ac35fe01 225/235: add evilnc-yank-and-comment-operator, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter b8a2601117 006/235: some tip, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter ef643d604d 007/235: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter d3581dcf64 014/235: workaround autoconf.el comment bug,
ELPA Syncer <=
- [nongnu] elpa/evil-nerd-commenter 72965eab13 019/235: remove warning when installing package, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter a074fed790 033/235: Added check for evil-define-operator, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 71995b8ac3 034/235: Updated readme, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 0e24866151 048/235: updated README, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter f3d4f7ef29 070/235: better integration with org-mode v1.3.0, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 1edf652fc6 086/235: explain how NOT to use comma as leader key, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter befd4da216 117/235: Comment operator should not be filling registers and kill-ring, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 9220e93853 128/235: Merge pull request #56 from syohex/correct-package-headers, ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 7a441580ae 141/235: Save position in org-mode src blocks., ELPA Syncer, 2022/01/06
- [nongnu] elpa/evil-nerd-commenter 80f503be1e 161/235: typo in doc, ELPA Syncer, 2022/01/06