branch: elpa/adoc-mode commit 6ccb9d6de5bb05dcc46aafac2d00f9783deb5b2b Author: Florian Kaufmann <sensor...@gmail.com> Commit: Florian Kaufmann <sensor...@gmail.com>
intermediate checkin - to be removed --- TAGS | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ adoc-mode-test.el | 17 ++++++-- adoc-mode.el | 115 ++++++++++++++++++++++++-------------------------- 3 files changed, 192 insertions(+), 64 deletions(-) diff --git a/TAGS b/TAGS new file mode 100644 index 0000000000..c81d7fa062 --- /dev/null +++ b/TAGS @@ -0,0 +1,124 @@ + +adoc-mode.el,5334 +(defconst adoc-mode-version 113,4643 +(defgroup adoc 117,4796 +(defcustom adoc-script-raise 121,4866 +(defcustom adoc-insert-replacement 133,5368 +(defcustom adoc-unichar-name-resolver 147,5898 +(defcustom adoc-two-line-title-del 167,6780 +(defcustom adoc-delimited-block-del180,7251 +(defcustom adoc-default-title-type 248,9581 +(defcustom adoc-default-title-sub-type 253,9725 +(defcustom adoc-enable-two-line-title 257,9842 +(define-obsolete-face-alias 'adoc-orig-default adoc-orig-default275,10537 +(defface adoc-align276,10604 +(define-obsolete-face-alias 'adoc-generic adoc-generic291,11076 +(define-obsolete-face-alias 'adoc-monospace adoc-monospace292,11143 +(define-obsolete-face-alias 'adoc-strong adoc-strong293,11219 +(define-obsolete-face-alias 'adoc-emphasis adoc-emphasis294,11288 +(define-obsolete-face-alias 'adoc-superscript adoc-superscript295,11361 +(define-obsolete-face-alias 'adoc-subscript adoc-subscript296,11440 +(define-obsolete-face-alias 'adoc-secondary-text adoc-secondary-text297,11515 +(define-obsolete-face-alias 'adoc-replacement adoc-replacement298,11600 +(define-obsolete-face-alias 'adoc-complex-replacement adoc-complex-replacement299,11679 +(define-obsolete-face-alias 'adoc-list-item adoc-list-item300,11774 +(define-obsolete-face-alias 'adoc-table-del adoc-table-del301,11844 +(define-obsolete-face-alias 'adoc-reference adoc-reference302,11915 +(define-obsolete-face-alias 'adoc-delimiter adoc-delimiter303,11990 +(define-obsolete-face-alias 'adoc-hide-delimiter adoc-hide-delimiter304,12060 +(define-obsolete-face-alias 'adoc-anchor adoc-anchor305,12145 +(define-obsolete-face-alias 'adoc-comment adoc-comment306,12214 +(define-obsolete-face-alias 'adoc-warning adoc-warning307,12285 +(define-obsolete-face-alias 'adoc-preprocessor adoc-preprocessor308,12354 +(defvar adoc-align 314,12696 +(defvar adoc-generic 315,12728 +(defvar adoc-monospace 316,12767 +(defvar adoc-strong 317,12815 +(defvar adoc-emphasis 318,12856 +(defvar adoc-superscript 319,12901 +(defvar adoc-subscript 320,12952 +(defvar adoc-replacement 321,12999 +(defvar adoc-complex-replacement 322,13050 +(defvar adoc-list-item 323,13117 +(defvar adoc-table-del 324,13159 +(defvar adoc-reference 325,13202 +(defvar adoc-secondary-text 326,13249 +(defvar adoc-delimiter 327,13306 +(defvar adoc-hide-delimiter 328,13348 +(defvar adoc-anchor 329,13400 +(defvar adoc-comment 330,13441 +(defvar adoc-warning 331,13484 +(defvar adoc-preprocessor 332,13525 +(defconst adoc-title-max-level 334,13579 +(defconst adoc-uolist-max-level 337,13657 +(defconst adoc-summarize-re-uolisti 342,13913 +(defconst adoc-summarize-re-olisti 346,14113 +(defconst adoc-summarize-re-llisti 349,14216 +(defvar adoc-unichar-alist 352,14319 +(defvar adoc-mode-hook 355,14421 +(defvar adoc-mode-abbrev-table 358,14500 +(defvar adoc-font-lock-keywords 361,14583 +(defvar adoc-replacement-failed 364,14666 +(define-abbrev-table 'adoc-mode-abbrev-table adoc-mode-abbrev-table366,14705 +(defun adoc-re-attribute-entry 372,14865 +(defun adoc-re-one-line-title 377,15031 +(defun adoc-make-one-line-title 394,15657 +(defun adoc-re-two-line-title 401,15987 +(defun adoc-make-two-line-title 420,16705 +(defun adoc-re-oulisti 433,17254 +(defun adoc-make-uolisti 491,20083 +(defun adoc-re-llisti 508,20940 +(defun adoc-re-delimited-block-line 528,21624 +(defun adoc-re-delimited-block 537,21801 +(defun adoc-re-verbatim-paragraph-sequence 547,22132 +(defun adoc-re-precond 569,22965 +(defun adoc-re-quote-precondition 581,23314 +(defun adoc-re-unconstrained-quote 608,24257 +(defun adoc-re-constrained-quote 627,24977 +(defun adoc-re-quote 649,25778 +(defun adoc-re-paragraph-separate 659,26068 +(defun adoc-re-paragraph-start 684,26561 +(defun adoc-re-aor(713,27183 +(defun adoc-re-ror(717,27311 +(defun adoc-re-cell-specifier 722,27566 +(defun adoc-kwf-std 728,27828 +(defun adoc-facespec-subscript 752,28763 +(defun adoc-facespec-superscript 755,28867 +(defvar adoc-lex-face-1 760,29092 +(defvar adoc-lex-face-2 761,29128 +(defvar adoc-lex-face-3 762,29164 +(defvar adoc-lex-face-4 763,29200 +(defvar adoc-lex-face-5 764,29236 +(defvar adoc-lex-face-6 765,29272 +(defvar adoc-lexems 767,29309 +(defun adoc-lexxer 811,32067 +(defun adoc-kw-one-line-title 846,33688 +(defun adoc-kw-two-line-title 860,34315 +(defmacro adoc-kw-oulisti 875,34984 +(defmacro adoc-kw-llisti 889,35540 +(defun adoc-kw-delimited-block 903,36084 +(defun adoc-kw-delimtier-line-fallback 917,36805 +(defmacro adoc-kw-admonition-paragraph 928,37306 +(defmacro adoc-kw-verbatim-paragraph-sequence 939,37796 +(defun adoc-kw-quote 949,38234 +(defmacro adoc-kw-replacement 969,39279 +(defun adoc-unfontify-region-function 1007,41052 +(defun adoc-font-lock-mark-block-function 1012,41213 +(defun adoc-get-font-lock-keywords 1016,41306 +(defun adoc-show-version 1506,64936 +(defun adoc-goto-ref-label 1511,65083 +(defun adoc-title-descriptor(1529,65663 +(defun adoc-make-title(1571,67181 +(defun adoc-modify-title 1580,67511 +(defun adoc-promote-title 1658,71133 +(defun adoc-denote-title 1667,71440 +(defun adoc-adjust-title-del 1680,71750 +(defun adoc-toggle-title-type 1688,71993 +(defun adoc-make-unichar-alist(1698,72289 +(defun adoc-unichar-by-name 1711,72729 +(defun adoc-entity-to-string 1715,72864 +(defun adoc-calc 1739,73793 +(define-derived-mode adoc-mode 1760,74537 + +adoc-mode-test.el,34 +(defun adoctest-make-buffer 7,88 diff --git a/adoc-mode-test.el b/adoc-mode-test.el index f6e28688d5..f051ef2665 100644 --- a/adoc-mode-test.el +++ b/adoc-mode-test.el @@ -98,6 +98,13 @@ "open block line 1\nopen block line 2" nil "\n" nil "--" markup-meta-hide-face "\n" nil "\n" nil + + "Lorem " nil "*" markup-meta-hide-face "ipsum" markup-strong-face "*" markup-meta-hide-face " dolor\n" nil + "Lorem " nil "**" markup-meta-hide-face "ipsum" markup-strong-face "**" markup-meta-hide-face " dolor\n" nil + "Lorem " nil "``" markup-replacement-face "ipsum" nil "''" markup-replacement-face " dolor\n" nil + "Lorem " nil "'" markup-meta-hide-face "ipsum" markup-emphasis-face "'" markup-meta-hide-face " dolor\n" nil + "Lorem " nil "`" markup-replacement-face "ipsum" nil "'" markup-replacement-face " dolor\n" nil + "Lorem " nil "++" markup-meta-hide-face "ipsum" nil "++" markup-meta-hide-face " dolor\n" nil ) (goto-char (point-min)) @@ -106,10 +113,12 @@ (let* ((tmp (get-text-property (point) 'adoctest)) (tmp2 (get-text-property (point) 'face))) (when tmp - (ert-should (equal tmp2 tmp)))) - (if (< (point) (point-max)) - (forward-char 1) - (setq not-done nil))))) + (if (listp tmp2) + (ert-should (member tmp tmp2)) + (ert-should (equal tmp tmp2)))) + (if (< (point) (point-max)) + (forward-char 1) + (setq not-done nil)))))) (ert-run-tests-interactively "^adoctest-") diff --git a/adoc-mode.el b/adoc-mode.el index 6193a843e2..c2dc8985f1 100644 --- a/adoc-mode.el +++ b/adoc-mode.el @@ -734,18 +734,20 @@ MUST-FREE-GROUPS a list of regexp group numbers which may not match text that has an adoc-reserved text-property with a non-nil value." (let ((found t) (prevented t) saved-point) - (while (and found prevented) + (while (and found prevented (<= (point) end) (not (eobp))) (setq saved-point (point)) (setq found (re-search-forward regexp end t)) - (setq prevented ; prevented is only meaningfull wenn found is non-nil - (or (not found) ; the following is only needed when found - (some (lambda(x) - (and (match-beginning x) - (text-property-not-all (match-beginning 1) - (match-end 1) - 'adoc-reserved nil))) - must-free-groups))) - (when (and found prevented) + ;; it is prevented if some/any of the must free groups contain text which + ;; has a non-nil adoc-reserved text property + (setq prevented + (and found + (some (lambda(x) + (and (match-beginning x) + (text-property-not-all (match-beginning x) + (match-end x) + 'adoc-reserved nil))) + must-free-groups))) + (when (and found prevented (<= (point) end)) (goto-char (1+ saved-point)))) (and found (not prevented)))) @@ -907,7 +909,7 @@ Concerning TYPE, LEVEL and SUB-TYPE see `adoc-re-llisti'." '(0 '(face nil font-lock-multiline t) t) '(1 '(face markup-meta-hide-face adoc-reserved t) t) (if (not inhibit-text-reserved) - `(2 '(face ,text-face adoc-reserved t) t) + `(2 '(face ,text-face face markup-verbatim-face adoc-reserved t) t) `(2 ,text-face t)) '(3 '(face markup-meta-hide-face adoc-reserved t) t))) @@ -946,37 +948,20 @@ Concerning TYPE, LEVEL and SUB-TYPE see `adoc-re-llisti'." ;; highlighers '(1 '(face adoc-monospace adoc-reserved t font-lock-multiline t)))) -(defmacro adoc-kw-quote (type ldel text-face &optional del-face rdel literal-p) - "Creates a keyword which highlights (un)constrained quotes. +(defun adoc-kw-quote (type ldel text-face-spec &optional del-face rdel literal-p) + "Return a keyword which highlights (un)constrained quotes. When LITERAL-P is non-nil, the contained text is literal text." - `(list - ;; matcher function - (lambda (end) - (let ((found t) (prevented t) saved-point) - (while (and found prevented) - (setq saved-point (point)) - (setq found - (re-search-forward ,(adoc-re-quote type ldel rdel) end t)) - (setq prevented ; prevented is only meaningfull wenn found is non-nil - (or - (not found) ; the following is only needed when found - (and (match-beginning 1) - (text-property-not-all (match-beginning 1) (match-end 1) 'adoc-reserved nil)) - (text-property-not-all (match-beginning 2) (match-end 2) 'adoc-reserved nil) - (text-property-not-all (match-beginning 4) (match-end 4) 'adoc-reserved nil))) - (when (and found prevented) - (goto-char (+ saved-point 1)))) - (and found (not prevented)))) - ;; highlighers - ;; there two facespec for subexpression 3 (text), because text-face can evaluate to - ;; a facespec being a list - '(1 '(face adoc-delimiter adoc-reserved t) t t) ; attribute list - '(2 '(face ,(or del-face adoc-hide-delimiter) adoc-reserved t) t) ; open del - '(3 ,text-face append) ; text 1) - ,(if literal-p - '(list 3 ''(face nil adoc-reserved t)) - '(list 3 nil)) - '(4 '(face ,(or del-face adoc-hide-delimiter) adoc-reserved t) t))); close del + (list + ;; matcher function + `(lambda (end) (adoc-kwf-std end ,(adoc-re-quote type ldel rdel) 1 2 4)) + ;; highlighers + '(1 '(face markup-meta-face adoc-reserved t) t t) ; attribute list + `(2 '(face ,(or del-face markup-meta-hide-face) adoc-reserved t) t) ; open del + `(3 ,text-face-spec append) ; text + (if literal-p + `(3 '(face ,markup-verbatim-face adoc-reserved t) append) + '(3 nil)) ; grumbl, I dont know how to get rid of it + `(4 '(face ,(or del-face markup-meta-hide-face) adoc-reserved t) t))); close del ;; bug: escapes are not handled yet ;; todo: give the inserted character a specific face. But I fear that is not @@ -1163,7 +1148,7 @@ When LITERAL-P is non-nil, the contained text is literal text." (adoc-kw-delimited-block 3 markup-verbatim-face) ; literal (adoc-kw-delimited-block 4 nil t) ; quote (adoc-kw-delimited-block 5 nil t) ; example - (adoc-kw-delimited-block 6 adoc-secondary-text) ; sidebar + (adoc-kw-delimited-block 6 adoc-secondary-text t) ; sidebar (adoc-kw-delimited-block 7 nil t) ; open block (adoc-kw-delimtier-line-fallback) @@ -1263,31 +1248,41 @@ When LITERAL-P is non-nil, the contained text is literal text." ;; todo. look in asciidoc source how exactly asciidoc does it ;; 1) BUG: actually only ifdef::no-inline-literal[] ;; 2) TODO: in asciidod.conf (but not yet here) also in inline macro section - (adoc-kw-quote adoc-constrained "`" adoc-monospace nil nil t) ;1) - (adoc-kw-quote adoc-unconstrained "+++" adoc-monospace nil nil t) ;2) - (adoc-kw-quote adoc-unconstrained "$$" adoc-monospace nil nil t) ;2) + + ;; AsciiDoc Manual: constitutes an inline literal passthrough. The enclosed + ;; text is rendered in a monospaced font and is only subject to special + ;; character substitution. + (adoc-kw-quote 'adoc-constrained "`" markup-typewriter-face nil nil t) ;1) + ;; AsciiDoc Manual: The triple-plus passthrough is functionally identical to + ;; the pass macro but you don’t have to escape ] characters and you can + ;; prefix with quoted attributes in the inline version + (adoc-kw-quote 'adoc-unconstrained "+++" markup-typewriter-face nil nil t) ;2) + ;;The double-dollar passthrough is functionally identical to the triple-plus + ;;passthrough with one exception: special characters are escaped. + (adoc-kw-quote 'adoc-unconstrained "$$" markup-typewriter-face nil nil t) ;2) ;; special characters ;; ------------------ ;; no highlighting for them - ;; quotes. unconstrained and constrained. order given by asciidoc.conf + ;; quotes: unconstrained and constrained + ;; order given by asciidoc.conf ;; ------------------------------ - (adoc-kw-quote adoc-unconstrained "**" adoc-strong) - (adoc-kw-quote adoc-constrained "*" adoc-strong) - (adoc-kw-quote adoc-constrained "``" nil adoc-replacement "''") - (adoc-kw-quote adoc-constrained "'" adoc-emphasis) - (adoc-kw-quote adoc-constrained "`" nil adoc-replacement "'") - ;; `...` , +++...+++, $$...$$ are moved to passthrough stuff above - (adoc-kw-quote adoc-unconstrained "++" adoc-monospace) - (adoc-kw-quote adoc-constrained "+" adoc-monospace) - (adoc-kw-quote adoc-unconstrained "__" adoc-emphasis) - (adoc-kw-quote adoc-constrained "_" adoc-emphasis) - (adoc-kw-quote adoc-unconstrained "##" adoc-generic) ; unquoted - (adoc-kw-quote adoc-constrained "#" adoc-generic) ; unquoted - (adoc-kw-quote adoc-unconstrained "~" (adoc-facespec-subscript)) - (adoc-kw-quote adoc-unconstrained"^" (adoc-facespec-superscript)) + (adoc-kw-quote 'adoc-unconstrained "**" markup-strong-face) + (adoc-kw-quote 'adoc-constrained "*" markup-strong-face) + (adoc-kw-quote 'adoc-constrained "``" nil adoc-replacement "''") ; double quoted text + (adoc-kw-quote 'adoc-constrained "'" markup-emphasis-face) ; single quoted text + (adoc-kw-quote 'adoc-constrained "`" nil adoc-replacement "'") + ;; `...` , +++...+++, $$...$$ are within passthrough stuff above + (adoc-kw-quote 'adoc-unconstrained "++" markup-typewriter-face) ; AsciiDoc manual: really onl '..are rendered in a monospaced font.' + (adoc-kw-quote 'adoc-constrained "+" markup-typewriter-face) + (adoc-kw-quote 'adoc-unconstrained "__" markup-emphasis-face) + (adoc-kw-quote 'adoc-constrained "_" markup-emphasis-face) + (adoc-kw-quote 'adoc-unconstrained "##" markup-gen-face) ; unquoted text + (adoc-kw-quote 'adoc-constrained "#" markup-gen-face) ; unquoted text + (adoc-kw-quote 'adoc-unconstrained "~" (adoc-facespec-subscript)) ; subscript + (adoc-kw-quote 'adoc-unconstrained "^" (adoc-facespec-superscript)) ; superscript ;; special words