[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/jade-mode d8324d4820 078/128: Improve comment line/region
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/jade-mode d8324d4820 078/128: Improve comment line/region function |
Date: |
Sat, 29 Jan 2022 08:24:48 -0500 (EST) |
branch: elpa/jade-mode
commit d8324d482052a31a356f9d092ff0324871edc025
Author: Travis Jefferson <tjefferson@signpost.com>
Commit: Travis Jefferson <tjefferson@signpost.com>
Improve comment line/region function
- change default comment token to -//
- higlight -// blocks in comment face
- improve comment line/region functionality
---
example.jade | 2 ++
jade-mode.el | 40 ++++++++++++++++++++++++++++++----------
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/example.jade b/example.jade
index ba438263e6..8554312eee 100644
--- a/example.jade
+++ b/example.jade
@@ -1,5 +1,6 @@
!!!
html(lang="en")
+ -// consult http://jade-lang.com for a full language reference
head
title My page
body.bp
@@ -11,6 +12,7 @@ html(lang="en")
li
#content
// here is a real comment
+ -// here is another real comment, this is probably a better default
a(href = 'http://www.google.com') http://www.google.com
- if (youAreUsingJade)
p You are amazing
diff --git a/jade-mode.el b/jade-mode.el
index d1ab4ea46d..828fd9ece1 100644
--- a/jade-mode.el
+++ b/jade-mode.el
@@ -21,16 +21,36 @@
"Returns t when line contains only whitespace chars, nil otherwise."
(string-match-p "^\\s-*$" (jade-line-as-string)))
-;; command to comment/uncomment text
(defun jade-comment-dwim (arg)
- "Comment or uncomment current line or region in a smart way.
-For detail, see `comment-dwim'."
+ "Comment or uncomment current line or region in a smart way."
(interactive "*P")
(require 'newcomment)
- (let (
- (comment-start "//") (comment-end "")
- )
- (comment-dwim arg)))
+ (let ((start (if (region-active-p)
+
+ ;; when region is active, use beginning of line at
+ ;; beginning of region (this way we don't start
+ ;; commenting in the middle of a line)
+ (progn
+ (save-excursion
+ (goto-char (region-beginning))
+ (point-at-bol)))
+
+ ;; without a region, just use beginning of current line
+ (point-at-bol)))
+
+ ;; same logic applies for end of line/region
+ (end (if (region-active-p)
+ (progn
+ (save-excursion
+ (goto-char (region-end))
+ (point-at-eol)))
+ (point-at-eol))))
+
+ ;; once we pick good values for start/end of region, simply use
+ ;; `comment-or-uncomment-region' from `newcomment' lib, and skip
+ ;; to next line for convenience
+ (comment-or-uncomment-region start end)
+ (forward-line)))
(defconst jade-keywords
(eval-when-compile
@@ -64,7 +84,7 @@ For detail, see `comment-dwim'."
(,"\\(?:^[ {2,}]*\\(?:[a-z0-9_:\\-]*\\)\\)?\\(#[A-Za-z0-9\-\_]*[^ ]\\)" 1
font-lock-variable-name-face) ;; id
(,"\\(?:^[ {2,}]*\\(?:[a-z0-9_:\\-]*\\)\\)?\\(\\.[A-Za-z0-9\-\_]*\\)" 1
font-lock-type-face) ;; class name
(,"^[ {2,}]*[a-z0-9_:\\-]*" 0 font-lock-function-name-face) ;; tag name
- (,"^\\s-*\\(//.*\\)" 1 font-lock-comment-face t) ;; jade block comments
+ (,"^\\s-*\\(-?//.*\\)" 1 font-lock-comment-face t) ;; jade block comments
;; remove highlighting from lines opening with a pipe `|'
;; e.g. | keywords like for should not be highlighted here
@@ -233,8 +253,8 @@ Follows indentation behavior of `indent-rigidly'."
(setq major-mode 'jade-mode)
;; comment syntax
- (set (make-local-variable 'comment-start) "// ")
- (set (make-local-variable 'comment-start-skip) "//\\s-*")
+ (set (make-local-variable 'comment-start) "-// ")
+ (set (make-local-variable 'comment-start-skip) "-//\\s-*")
(setq-default jade-tab-width 2)
(setq-local indent-line-function 'jade-indent-line)
- [nongnu] elpa/jade-mode 2e75549657 058/128: Merge pull request #18 from abutcher/comment-syntax, (continued)
- [nongnu] elpa/jade-mode 2e75549657 058/128: Merge pull request #18 from abutcher/comment-syntax, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 555c0863bc 009/128: bound S-tab to unindent line, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 523ac5b79f 022/128: Merge pull request #3 from mmichelli/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode e27e785ae7 003/128: added more code samples to example, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode e8e2964ef4 008/128: made tab cycle after hitting end, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 5552c5eaed 011/128: updated readme, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 871ec8a9b2 033/128: Change tag name's facename to font-lock-function-name-face., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 18dfef2623 043/128: Merge pull request #9 from jkpl/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode fd8a4f3a09 028/128: Merge pull request #7 from purcell/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode c0b9cfc755 034/128: Modify mather for doctype., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode d8324d4820 078/128: Improve comment line/region function,
ELPA Syncer <=
- [nongnu] elpa/jade-mode 7f63cc296c 054/128: Merge pull request #14 from jkpl/master, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 2d8a3013c4 063/128: Create LICENSE.txt, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 544be1a87d 079/128: match full tag decl. and un-hl subsequent content, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode ae579601b8 070/128: Merge pull request #30 from tjefferson08/fix_indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode c8532a66f6 037/128: Support comment-dwim for single line comment syntax., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode a8d77823a7 087/128: Merge pull request #40 from tjefferson08/39_highlight_js, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 1b86926046 061/128: Refined and extended syntax highlighting, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 36fbf629a8 049/128: Improved sws-mode indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 216d1f5148 109/128: use mc's mixin regex to highlight mixin syntax, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode efb86f6a36 101/128: Merge pull request #51 from tjefferson08/fix_compile_warnings, ELPA Syncer, 2022/01/29