[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/jade-mode 0eb59822bf 081/128: Merge pull request #35 from
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/jade-mode 0eb59822bf 081/128: Merge pull request #35 from tjefferson08/add_new_comment_syntax |
Date: |
Sat, 29 Jan 2022 08:24:49 -0500 (EST) |
branch: elpa/jade-mode
commit 0eb59822bf4d8d827d5d6c5f5e99bd9d47ec0041
Merge: e621d186c1 d8324d4820
Author: Travis Jefferson <tjefferson@signpost.com>
Commit: Travis Jefferson <tjefferson@signpost.com>
Merge pull request #35 from tjefferson08/add_new_comment_syntax
Improve comment line/region function
---
example.jade | 2 ++
jade-mode.el | 40 ++++++++++++++++++++++++++++++----------
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/example.jade b/example.jade
index 95ebbf300d..f7e0482632 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 d6f8e14891..42b9f5957e 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
@@ -73,7 +93,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 literal content following tag/class/id
;; e.g. tag Inner text
@@ -261,8 +281,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 63f6e54b85 013/128: define backtab for ubuntu, (continued)
- [nongnu] elpa/jade-mode 63f6e54b85 013/128: define backtab for ubuntu, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode c6623ac6a6 021/128: added a basic stylus-mode, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 039b637cee 016/128: new blank line + single tab = full indent, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode b8778ae525 015/128: use builtin for moving point to beginning of text, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode de66308323 004/128: reboot, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode a22d4acd31 001/128: initial commit, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode a7c85da4df 048/128: Added single quoted strings support to stylus mode., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 3db33f4642 050/128: Fixed sws-indent-line not detecting the use of tab indent, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode eea90de1df 038/128: Add support for keywords syntax coloring., ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode dd7becb0fb 062/128: Merge pull request #25 from gavinpc/patch-1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/jade-mode 0eb59822bf 081/128: Merge pull request #35 from tjefferson08/add_new_comment_syntax,
ELPA Syncer <=
- [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