|
7 | 7 | ;; Description: Automatically truncate lines for markup languages.
|
8 | 8 | ;; Keyword: automatic truncate visual lines
|
9 | 9 | ;; Version: 0.1.3
|
10 |
| -;; Package-Requires: ((emacs "24.3") (auto-rename-tag "0.2.9")) |
| 10 | +;; Package-Requires: ((emacs "24.3")) |
11 | 11 | ;; URL: https://github.com/jcs-elpa/atl-markup
|
12 | 12 |
|
13 | 13 | ;; This file is NOT part of GNU Emacs.
|
|
32 | 32 |
|
33 | 33 | ;;; Code:
|
34 | 34 |
|
35 |
| -(require 'auto-rename-tag) |
36 |
| - |
37 | 35 | (defgroup atl-markup nil
|
38 | 36 | "Automatically truncate lines for markup languages."
|
39 | 37 | :prefix "atl-markup-"
|
|
47 | 45 |
|
48 | 46 | ;;; Util
|
49 | 47 |
|
50 |
| -(defun atl-markup--get-current-char-string () |
51 |
| - "Get the current character as the 'string'." |
52 |
| - (if (char-before) (string (char-before)) "")) |
53 |
| - |
54 |
| -(defun atl-markup--current-char-string-match-p (c) |
55 |
| - "Check the current character string match to C." |
56 |
| - (string-match-p c (atl-markup--get-current-char-string))) |
57 |
| - |
58 | 48 | (defun atl-markup--inside-comment-block-p ()
|
59 | 49 | "Check if current cursor point inside the comment block."
|
60 | 50 | (nth 4 (syntax-ppss)))
|
61 | 51 |
|
| 52 | +(defun atl-markup--inside-tag-p () |
| 53 | + "Check if current point inside the tag." |
| 54 | + (let ((backward-less (save-excursion (search-backward "<" nil t))) |
| 55 | + (backward-greater (save-excursion (search-backward ">" nil t))) |
| 56 | + (forward-less (save-excursion (search-forward "<" nil t))) |
| 57 | + (forward-greater (save-excursion (search-forward ">" nil t)))) |
| 58 | + (unless backward-less (setq backward-less -1)) |
| 59 | + (unless backward-greater (setq backward-greater -1)) |
| 60 | + (unless forward-less (setq forward-less -1)) |
| 61 | + (unless forward-greater (setq forward-greater -1)) |
| 62 | + (and (not (= -1 backward-less)) |
| 63 | + (not (= -1 forward-greater)) |
| 64 | + (< backward-greater backward-less) |
| 65 | + (or (< forward-greater forward-less) |
| 66 | + (= -1 forward-less))))) |
| 67 | + |
62 | 68 | ;;; Core
|
63 | 69 |
|
64 | 70 | (defun atl-markup--web-truncate-lines-by-face ()
|
65 | 71 | "Enable/Disable the truncate lines mode depends on the face cursor currently on."
|
66 | 72 | (when (and (not (= (point) (point-min))) (not (= (point) (point-max)))
|
67 |
| - (not (atl-markup--current-char-string-match-p |
68 |
| - atl-markup-ignore-regex)) |
| 73 | + (not (save-excursion |
| 74 | + (backward-char 1) |
| 75 | + (looking-at-p atl-markup-ignore-regex))) |
69 | 76 | (not (atl-markup--inside-comment-block-p))
|
70 | 77 | (not (eolp)))
|
71 | 78 | (let ((message-log-max nil) (inhibit-message t))
|
72 |
| - (if (auto-rename-tag--inside-tag-p) |
| 79 | + (if (atl-markup--inside-tag-p) |
73 | 80 | (toggle-truncate-lines 1)
|
74 | 81 | (toggle-truncate-lines -1)))))
|
75 | 82 |
|
|
0 commit comments