From 2682662c96b784bf6355b33ee94c6d9c05031c5c Mon Sep 17 00:00:00 2001 From: Luke San Antonio Date: Sun, 3 Jul 2016 04:56:46 -0400 Subject: [PATCH 01/90] Use mode-* to set var require-final-newline --- adoc-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adoc-mode.el b/adoc-mode.el index 87e9650..ba160e3 100644 --- a/adoc-mode.el +++ b/adoc-mode.el @@ -3016,7 +3016,7 @@ Turning on Adoc mode runs the normal hook `adoc-mode-hook'." ;; misc (set (make-local-variable 'page-delimiter) "^<<<+$") - (set (make-local-variable 'require-final-newline) t) + (set (make-local-variable 'require-final-newline) mode-require-final-newline) (set (make-local-variable 'parse-sexp-lookup-properties) t) ;; it's the user's decision whether he wants to set imenu-sort-function to From 411eb48ce97ee4cd645d4b759f1de6b44b4d2f6c Mon Sep 17 00:00:00 2001 From: TobiasZawada Date: Sun, 29 May 2022 02:22:11 +0200 Subject: [PATCH 02/90] Sensorflo/pr35 (#3) * edit to remove some of the warnings from flycheck * Re-formulate first comment line of adoctest-trans. Additionally delete some trailing spaces. Co-authored-by: phelanm Co-authored-by: Tobias Zawada --- Cask | 7 ++++ adoc-mode-test.el | 100 ++++++++++++++++++++++++---------------------- 2 files changed, 60 insertions(+), 47 deletions(-) create mode 100644 Cask diff --git a/Cask b/Cask new file mode 100644 index 0000000..c33321b --- /dev/null +++ b/Cask @@ -0,0 +1,7 @@ +(source marmalade) + +(package "adoc-mode" "0.6.2" "a major-mode for editing AsciiDoc files in Emacs") + +(development + (depends-on "adoc-mode") +) diff --git a/adoc-mode-test.el b/adoc-mode-test.el index 51d7590..1e48b32 100644 --- a/adoc-mode-test.el +++ b/adoc-mode-test.el @@ -1,11 +1,11 @@ ;;; adoc-mode-test.el --- test suite for adoc-mode.el -;;; +;;; ;;; Commentary: -;; +;; ;; Call adoc-test-run to run the test suite -;; +;; ;;; Todo: -;; - test for font lock multiline property +;; - test for font lock multiline property ;; - test for presence of adoc-reserved (we do white-box testing here) ;; - test also with multiple versions of (X)Emacs ;; - compare adoc-mode fontification with actuall output from AsciiDoc, being @@ -22,6 +22,7 @@ ;; - beginning/end of paragraph ;; - side-to-side yes/no with next same construct (defun adoctest-faces (name &rest args) + "Todo document adoctest-faces NAME ARGS." (let ((not-done t) (font-lock-support-mode)) (with-temp-buffer @@ -52,13 +53,13 @@ (setq not-done nil))))))) (defun adoctest-trans (original-text expected-text transform) - "Calling TRANSFORM on EXPECTED-TEXT, ORIGINAL-TEXT `should' result. + "Calling TRANSFORM on ORIGINAL-TEXT `should' result in EXPECTED-TEXT. ORIGINAL-TEXT is put in an temporary buffer and TRANSFORM is -evaluated using `eval'. The resulting buffer content is compared +evaluated using `eval'. The resulting buffer content is compared to EXPECTED-TEXT. ORIGINAL-TEXT optionaly may contain the following special -charachters. Escaping them is not (yet) supported. They are +charachters. Escaping them is not (yet) supported. They are removed before TRANSFORM is evaluated. ! Position of point before TRANSFORM is evaluated @@ -86,7 +87,7 @@ removed before TRANSFORM is evaluated. (setq pos (1+ pos)) (setq pos-old pos)) (setq new-original-text (concat new-original-text (substring original-text pos-old pos))) - ;; run adoctest-trans-inner for each remembered pos + ;; run adoctest-trans-inner for each remembered pos (while pos-new-list (adoctest-trans-inner new-original-text expected-text transform (car pos-new-list)) (setq pos-new-list (cdr pos-new-list)))) @@ -94,6 +95,7 @@ removed before TRANSFORM is evaluated. (adoctest-trans-inner original-text expected-text transform))) (defun adoctest-trans-inner (original-text expected-text transform &optional pos) + "Todo document adoctest-trans-inner ORIGINAL-TEXT EXPECTED-TEXT TRANSFORM POS." (let ((not-done t) (font-lock-support-mode)) (with-temp-buffer @@ -105,7 +107,7 @@ removed before TRANSFORM is evaluated. (goto-char (1+ (car pos))) (set-mark (1+ (cdr pos)))) (pos - (goto-char (1+ pos)))) + (goto-char (1+ pos)))) ;; exercise (eval transform) ;; verify @@ -240,7 +242,7 @@ removed before TRANSFORM is evaluated. (ert-deftest adoctest-test-comments () (adoctest-faces "comments" - ;; as block macro + ;; as block macro "// lorem ipsum\n" markup-comment-face "\n" nil ;; as inline macro @@ -364,19 +366,19 @@ removed before TRANSFORM is evaluated. (adoctest-faces "images" ;; block macros ;; empty arglist - "image" markup-complex-replacement-face "::" markup-meta-face + "image" markup-complex-replacement-face "::" markup-meta-face "./foo/bar.png" markup-internal-reference-face "[]" markup-meta-face "\n" nil - ;; pos attribute 0 = alternate text - "image" markup-complex-replacement-face "::" markup-meta-face + ;; pos attribute 0 = alternate text + "image" markup-complex-replacement-face "::" markup-meta-face "./foo/bar.png" markup-internal-reference-face "[" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "\n" nil ;; keyword title - "image" markup-complex-replacement-face "::" markup-meta-face + "image" markup-complex-replacement-face "::" markup-meta-face "./foo/bar.png" markup-internal-reference-face "[" markup-meta-face "alt" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "\n" nil ;; keyword alt and title - "image" markup-complex-replacement-face "::" markup-meta-face + "image" markup-complex-replacement-face "::" markup-meta-face "./foo/bar.png" markup-internal-reference-face "[" markup-meta-face "alt" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "," markup-meta-face "title" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "\n" nil @@ -389,19 +391,19 @@ removed before TRANSFORM is evaluated. "lorem\nipsum\nsit" markup-secondary-text-face "]" markup-meta-face "\n" nil ;; no everything again with inline macros - "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face + "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face "./foo/bar.png" markup-internal-reference-face "[]" markup-meta-face "bar" 'no-face "\n" nil - "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face + "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face "./foo/bar.png" markup-internal-reference-face "[" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "bar" 'no-face "\n" nil - "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face + "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face "./foo/bar.png" markup-internal-reference-face "[" markup-meta-face "alt" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "bar" 'no-face "\n" nil - "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face + "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face "./foo/bar.png" markup-internal-reference-face "[" markup-meta-face "alt" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "," markup-meta-face "title" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "bar" 'no-face "\n" nil @@ -415,15 +417,15 @@ removed before TRANSFORM is evaluated. (ert-deftest adoctest-test-attribute-list () (adoctest-faces "attribute-list" - ;; positional attribute - "[" markup-meta-face "hello" markup-value-face "]" markup-meta-face "\n" nil + ;; positional attribute + "[" markup-meta-face "hello" markup-value-face "]" markup-meta-face "\n" nil ;; positional attribute containing spaces - "[" markup-meta-face "hello world" markup-value-face "]" markup-meta-face "\n" nil + "[" markup-meta-face "hello world" markup-value-face "]" markup-meta-face "\n" nil ;; positional attribute as string - "[\"" markup-meta-face "hello world" markup-value-face "\"]" markup-meta-face "\n" nil + "[\"" markup-meta-face "hello world" markup-value-face "\"]" markup-meta-face "\n" nil ;; multiple positional attributes - "[" markup-meta-face "hello" markup-value-face "," markup-meta-face "world" markup-value-face "]" markup-meta-face "\n" nil + "[" markup-meta-face "hello" markup-value-face "," markup-meta-face "world" markup-value-face "]" markup-meta-face "\n" nil ;; multiple positional attributes, however one or both are empty (really empty or only one space) "[" markup-meta-face "hello" markup-value-face ",]" markup-meta-face "\n" nil @@ -440,19 +442,19 @@ removed before TRANSFORM is evaluated. "[" markup-meta-face " " markup-value-face "]" markup-meta-face "\n" nil ;; keyword attribute - "[" markup-meta-face "salute" markup-attribute-face "=" markup-meta-face "hello" markup-value-face "]" markup-meta-face "\n" nil + "[" markup-meta-face "salute" markup-attribute-face "=" markup-meta-face "hello" markup-value-face "]" markup-meta-face "\n" nil ;; keyword attribute where value is a string - "[" markup-meta-face "salute" markup-attribute-face "=\"" markup-meta-face "hello world" markup-value-face "\"]" markup-meta-face "\n" nil + "[" markup-meta-face "salute" markup-attribute-face "=\"" markup-meta-face "hello world" markup-value-face "\"]" markup-meta-face "\n" nil ;; multiple positional attributes, multiple keyword attributes "[" markup-meta-face "lorem" markup-value-face "," markup-meta-face "ipsum" markup-value-face "," markup-meta-face "dolor" markup-attribute-face "=" markup-meta-face "sit" markup-value-face "," markup-meta-face - "dolor" markup-attribute-face "=" markup-meta-face "sit" markup-value-face "]" markup-meta-face "\n" nil + "dolor" markup-attribute-face "=" markup-meta-face "sit" markup-value-face "]" markup-meta-face "\n" nil ;; is , within strings really part of the string and not mistaken as element separator - "[\"" markup-meta-face "lorem,ipsum=dolor" markup-value-face "\"]" markup-meta-face "\n" nil + "[\"" markup-meta-face "lorem,ipsum=dolor" markup-value-face "\"]" markup-meta-face "\n" nil ;; does escaping " in strings work - "[\"" markup-meta-face "lorem \\\"ipsum\\\" dolor" markup-value-face "\"]" markup-meta-face + "[\"" markup-meta-face "lorem \\\"ipsum\\\" dolor" markup-value-face "\"]" markup-meta-face )) (ert-deftest adoctest-test-block-macro () @@ -593,7 +595,7 @@ removed before TRANSFORM is evaluated. ;; 1) test that meta characters always only have a single meta and don't get ;; markup-bold/-emphasis/... face just because they are within a ;; strongh/emphasis/... construct. - ;; 2) test that nested quotes really apply the faces of both quotes to the inner text + ;; 2) test that nested quotes really apply the faces of both quotes to the inner text (adoctest-faces "meta-face-cleanup-1" "*" markup-meta-hide-face "lorem " markup-strong-face "_" markup-meta-hide-face "ipsum" '(markup-strong-face markup-emphasis-face) "_" markup-meta-hide-face @@ -611,7 +613,7 @@ removed before TRANSFORM is evaluated. (ert-deftest adoctest-test-url () (adoctest-faces "url" - ;; url inline macro with attriblist + ;; url inline macro with attriblist "foo " nil "http://www.lorem.com/ipsum.html" markup-internal-reference-face "[" markup-meta-face "sit amet" markup-reference-face "]" markup-meta-face @@ -622,7 +624,7 @@ removed before TRANSFORM is evaluated. "sit,\namet,\nconsectetur" markup-reference-face "]" markup-meta-face " bar \n" nil - ;; url inline macro withOUT attriblist + ;; url inline macro withOUT attriblist "http://www.lorem.com/ipsum.html" markup-reference-face "[]" markup-meta-face " bar \n" nil @@ -632,7 +634,7 @@ removed before TRANSFORM is evaluated. (ert-deftest adoctest-test-url-enclosing-quote () (adoctest-faces "url-enclosing-quote" - ;; spaces between __ and url seem really to be needed also in asciidoc + ;; spaces between __ and url seem really to be needed also in asciidoc "foo " nil "__" markup-meta-hide-face " " nil "http://www.lorem.com/ipsum.html" '(markup-emphasis-face markup-reference-face) " " nil "__" markup-meta-hide-face @@ -647,9 +649,9 @@ removed before TRANSFORM is evaluated. (ert-deftest adoctest-test-inline-subst-boundaries () (adoctest-faces "inline-subst-boundaries" - ;; 1) don't cross title boundaries. + ;; 1) don't cross title boundaries. ;; 2) don't cross paragraph boundaries. - ;; 3) verify that the (un)constrained quotes would work however + ;; 3) verify that the (un)constrained quotes would work however "== " markup-meta-hide-face "chapter ** 1" markup-title-1-face "\n" nil "lorem ** ipsum\n" 'no-face "\n" nil @@ -686,7 +688,7 @@ removed before TRANSFORM is evaluated. "-" markup-list-face " " nil "dolor ** sit\n" 'no-face ;; test that a quote within the list element works "-" markup-list-face " " nil "dolor " 'no-face "**" markup-meta-hide-face " sit " markup-strong-face "**" markup-meta-hide-face "\n" nil - ;; dont mistake '**' list elements for quote starters/enders + ;; dont mistake '**' list elements for quote starters/enders "**" markup-list-face " " nil "lorem ** ipsum\n" 'no-face "**" markup-list-face " " nil "dolor ** sit\n" 'no-face "**" markup-list-face " " nil "dolor ** sit\n" 'no-face @@ -731,7 +733,7 @@ removed before TRANSFORM is evaluated. (ert-deftest adoctest-test-xref-at-point-1 () (unwind-protect (progn - (set-buffer (get-buffer-create "adoc-test")) + (set-buffer (get-buffer-create "adoc-test")) (insert "lorem xref:bogous1[] ipsum xref:foo[bla\nbli] dolor xref:bogous2[]") (re-search-backward "bli") ; move point within ref (should (equal (adoc-xref-id-at-point) "foo"))) @@ -740,7 +742,7 @@ removed before TRANSFORM is evaluated. (ert-deftest adoctest-test-xref-at-point-2 () (unwind-protect (progn - (set-buffer (get-buffer-create "adoc-test")) + (set-buffer (get-buffer-create "adoc-test")) (insert "lorem <> ipsum <> dolor <>") (re-search-backward "bli") ; move point within ref (should (equal (adoc-xref-id-at-point) "foo"))) @@ -749,7 +751,7 @@ removed before TRANSFORM is evaluated. (ert-deftest adoctest-test-goto-ref-label () (unwind-protect (progn - (set-buffer (get-buffer-create "adoc-test")) + (set-buffer (get-buffer-create "adoc-test")) (insert "[[foo]]\n" ;1 "lorem ipsum\n" ;2 "[[bar]]\n" ;3 @@ -764,11 +766,12 @@ removed before TRANSFORM is evaluated. (kill-buffer "adoc-test"))) (defun adoctest-template (template expected) + "Todo document adoctest-template TEMPLATE EXPECTED." (let ((buf-name (concat "adoctest-" (symbol-name template)))) (unwind-protect (progn ;; setup - (set-buffer (get-buffer-create buf-name)) + (set-buffer (get-buffer-create buf-name)) (delete-region (point-min) (point-max)) (funcall template) (should (equal (buffer-substring-no-properties (point-min) (point-max)) expected))) @@ -776,6 +779,7 @@ removed before TRANSFORM is evaluated. (kill-buffer buf-name)))) (defun adoctest-quotes (start-del end-del transform) + "Todo document adoctest-quotes START-DEL END-DEL TRANSFORM." (adoctest-trans "lorem ! ipsum" (concat "lorem " start-del end-del " ipsum") transform) (adoctest-trans "lorem dolor" @@ -840,6 +844,7 @@ removed before TRANSFORM is evaluated. (adoctest-trans "lorem" "lorem\nTIP: ipsum" '(tempo-template-adoc-paragraph-tip))) (defun adoctest-delimited-block (del transform) + "Todo document adoctest-delimited-block DEL TRANSFORM." (let ((del-line (if (integerp del) (make-string 50 del) del))) (adoctest-trans "" (concat del-line "\n\n" del-line) transform) @@ -954,6 +959,7 @@ removed before TRANSFORM is evaluated. ;; ;; todo: also test for warnings (defun adoctest-save-compile-load () + "Todo document adoctest-save-compile-load." (unwind-protect (progn (let ((buf-adoc-mode (find-buffer-visiting "adoc-mode.el")) @@ -963,17 +969,17 @@ removed before TRANSFORM is evaluated. (cond ((null buf-adoc-mode)) ;nop ((bufferp buf-adoc-mode) (save-buffer buf-adoc-mode)) - (t (error "Multiple buffer are visiting adoc-mode.el. Save them first"))) - (or (byte-compile-file (locate-library "adoc-mode.el" t)) (error "compile error")) - (or (load "adoc-mode.el" nil nil t) (error "load error")) + (t (error "Multiple buffer are visiting adoc-mode.el. Save them first"))) + (or (byte-compile-file (locate-library "adoc-mode.el" t)) (error "Compile error")) + (or (load "adoc-mode.el" nil nil t) (error "Load error")) ;; adoc-mode-test (cond ((null buf-adoc-mode-test)) ;nop ((bufferp buf-adoc-mode-test) (save-buffer buf-adoc-mode-test)) - (t (error "Multiple buffer are visiting adoc-mode-test.el. Save them first"))) - (or (byte-compile-file (locate-library "adoc-mode-test.el" t)) (error "compile error")) - (or (load "adoc-mode-test.el" nil nil t) (error "load error")))) + (t (error "Multiple buffer are visiting adoc-mode-test.el. Save them first"))) + (or (byte-compile-file (locate-library "adoc-mode-test.el" t)) (error "Compile error")) + (or (load "adoc-mode-test.el" nil nil t) (error "Load error")))) (when (file-exists-p "adoc-mode.elc") (delete-file "adoc-mode.elc")) @@ -985,7 +991,7 @@ removed before TRANSFORM is evaluated. ;; ensure that a failed test can be re-run (when (get-buffer "*ert*") - (kill-buffer "*ert*")) + (kill-buffer "*ert*")) ;; ensure no no-longer test defuns exist, which would otherwise be executed (mapatoms From 414e920433c5b5eccee9a223980b09a6229a7b28 Mon Sep 17 00:00:00 2001 From: Tobias Zawada Date: Sun, 29 May 2022 03:02:23 +0200 Subject: [PATCH 03/90] Avoid some compilation warnings. --- adoc-mode.el | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/adoc-mode.el b/adoc-mode.el index ba160e3..90c02d7 100644 --- a/adoc-mode.el +++ b/adoc-mode.el @@ -174,7 +174,7 @@ ;;; Variables: (require 'markup-faces) ; https://github.com/sensorflo/markup-faces -(require 'cl) ; I know, I should remove it, I will, eventually +(require 'cl-lib) ;; tempo or tempo-snippet is required later below @@ -333,12 +333,14 @@ AsciiDoc config file would the probably be '^[<>]-{4,}$'" ;; todo: limit value range to 1 or 2 (defcustom adoc-default-title-type 1 "Default title type, see `adoc-title-descriptor'." + :type 'integer :group 'adoc) ;; todo: limit value range to 1 or 2 (defcustom adoc-default-title-sub-type 1 "Default title sub type, see `adoc-title-descriptor'." - :group 'adoc ) + :type 'integer + :group 'adoc) (defcustom adoc-enable-two-line-title t "Wether or not two line titles shall be fontified. @@ -1329,17 +1331,17 @@ text having adoc-reserved set to 'block-del." (setq prevented (and found (or - (some (lambda(x) - (and (match-beginning x) - (text-property-not-all (match-beginning x) - (match-end x) - 'adoc-reserved nil))) - must-free-groups) - (some (lambda(x) - (and (match-beginning x)) - (text-property-any (match-beginning x) - (match-end x) - 'adoc-reserved 'block-del)) + (cl-some (lambda(x) + (and (match-beginning x) + (text-property-not-all (match-beginning x) + (match-end x) + 'adoc-reserved nil))) + must-free-groups) + (cl-some (lambda(x) + (and (match-beginning x)) + (text-property-any (match-beginning x) + (match-end x) + 'adoc-reserved 'block-del)) no-block-del-groups)))) (when (and found prevented (<= (point) end)) (goto-char (1+ saved-point)))) @@ -2267,7 +2269,8 @@ new customization demands." (setq adoc-font-lock-keywords (adoc-get-font-lock-keywords)) (when (and font-lock-mode (eq major-mode 'adoc-mode)) - (font-lock-fontify-buffer)) + (font-lock-flush) + (font-lock-ensure)) (adoc-easy-menu-define)) @@ -2766,9 +2769,6 @@ NEW-LEVEL-ABS defines the new level absolutely. When both NEW-LEVEL-REL and NEW-LEVEL-ABS are non-nil, NEW-LEVEL-REL takes precedence. When both are nil, level is not affected. -When ARG is nil, it defaults to 1. When ARG is negative, level is -demoted that many levels. If ARG is 0, see `adoc-adjust-title-del'. - When NEW-TYPE is nil, the title type is unaffected. If NEW-TYPE is t, the type is toggled. If it's 1 or 2, the new type is one line title or two line title respectively. @@ -2809,13 +2809,13 @@ and title's text are not preserved, afterwards its always one space." (error "Invalid title sub-type")) ((eq new-sub-type nil) sub-type) ((eq new-sub-type t) (if (eq sub-type 1) 2 1)) - (t (error "NEW-SUB-TYPE has invalid value")))) + (t (error "NEW-SUB-TYPE has invalid value")))) (level (nth 2 descriptor)) (new-level (cond ((or (null new-level-rel) (eq new-level-rel 0)) level) ((not (null new-level-rel)) - (let ((x (% (+ level arg) (+ adoc-title-max-level 1)))) + (let ((x (% (+ level new-level-rel) (+ adoc-title-max-level 1)))) (if (< x 0) (+ x adoc-title-max-level 1) x))) @@ -2826,7 +2826,7 @@ and title's text are not preserved, afterwards its always one space." (start (nth 4 descriptor)) (end (nth 5 descriptor)) (saved-col (current-column))) - + ;; set new title descriptor (setcar (nthcdr 0 descriptor) new-type-val) (setcar (nthcdr 1 descriptor) new-sub-type-val) @@ -2849,10 +2849,11 @@ and title's text are not preserved, afterwards its always one space." (forward-line -1)) (move-to-column saved-col)))) +(defvar unicode-character-list) ;; From unichars.el + (defun adoc-make-unichar-alist() "Creates `adoc-unichar-alist' from `unicode-character-list'" - (unless (boundp 'unicode-character-list) - (load-library "unichars.el")) + (require 'unichars nil t) (let ((i unicode-character-list)) (setq adoc-unichar-alist nil) (while i From 2ab9e1463b753c4ece53a9af8d8d0c33203527e8 Mon Sep 17 00:00:00 2001 From: Tobias Zawada Date: Sun, 29 May 2022 03:09:48 +0200 Subject: [PATCH 04/90] unichars.el is not a regular package. --- adoc-mode.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adoc-mode.el b/adoc-mode.el index 90c02d7..767b2a2 100644 --- a/adoc-mode.el +++ b/adoc-mode.el @@ -2853,7 +2853,8 @@ and title's text are not preserved, afterwards its always one space." (defun adoc-make-unichar-alist() "Creates `adoc-unichar-alist' from `unicode-character-list'" - (require 'unichars nil t) + (unless (boundp 'unicode-character-list) + (load "unichars")) (let ((i unicode-character-list)) (setq adoc-unichar-alist nil) (while i From 141af8c56aa3efc572c04767c25ba946341a6c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 15 Nov 2021 12:03:32 +0200 Subject: [PATCH 05/90] Associate with .adoc and .asciidoc --- adoc-mode.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/adoc-mode.el b/adoc-mode.el index 767b2a2..2343505 100644 --- a/adoc-mode.el +++ b/adoc-mode.el @@ -99,10 +99,12 @@ ;; ;; Each of the following is optional ;; -;; * According to AsciiDoc manual, .txt is the standard file extension of +;; * According to an old AsciiDoc manual, .txt is the standard file extension of ;; AsciiDoc files. Add the following to your initialization file to open all ;; .txt files with adoc-mode as major mode automatically: `(add-to-list -;; 'auto-mode-alist (cons "\\.txt\\'" 'adoc-mode))` +;; 'auto-mode-alist (cons "\\.txt\\'" 'adoc-mode))`. +;; More recent conventions for AsciiDoc file extensions include `.adoc` and +;; `.asciidoc`, these are associated automatically. ;; ;; * If your default face is a fixed pitch (monospace) face, but in AsciiDoc ;; files you liked to have normal text with a variable pitch face, @@ -3038,6 +3040,9 @@ Turning on Adoc mode runs the normal hook `adoc-mode-hook'." (easy-menu-add adoc-mode-menu)) +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.a\\(?:scii\\)?doc\\'" . adoc-mode)) + ;;;; non-definitions evaluated during load (adoc-calc) From 02f53a301b8e5b6e4934b47ab326892f70719c32 Mon Sep 17 00:00:00 2001 From: TobiasZawada Date: Wed, 4 May 2022 07:12:54 +0200 Subject: [PATCH 06/90] Fix #43. Add missing quote before adoc-reserved in adoc-kw-verbatim-paragraph-sequence --- adoc-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adoc-mode.el b/adoc-mode.el index 2343505..07deba2 100644 --- a/adoc-mode.el +++ b/adoc-mode.el @@ -1528,7 +1528,7 @@ Concerning TYPE, LEVEL and SUB-TYPE see `adoc-re-llisti'." ;; matcher function `(lambda (end) (and (re-search-forward ,(adoc-re-verbatim-paragraph-sequence) end t) - (not (text-property-not-all (match-beginning 0) (match-end 0) adoc-reserved nil)))) + (not (text-property-not-all (match-beginning 0) (match-end 0) 'adoc-reserved nil)))) ;; highlighers '(1 '(face adoc-monospace adoc-reserved t font-lock-multiline t)))) From 944ae37076702541d6aea230a2cb300b0873aea3 Mon Sep 17 00:00:00 2001 From: TobiasZawada Date: Mon, 30 May 2022 09:38:07 +0200 Subject: [PATCH 07/90] Create README.md --- README.md | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..dd85ebf --- /dev/null +++ b/README.md @@ -0,0 +1,111 @@ +# adoc-mode +## Introduction + +[AsciiDoc](http://www.methods.co.nz/asciidoc/) is a text document format for +writing short documents, articles, books and UNIX man pages. AsciiDoc files +can be translated to HTML and DocBook markups. + +adoc-mode is an Emacs major mode for editing AsciiDoc files. It emphasizes on +the idea that the document is highlighted so it pretty much looks like the +final output. What must be bold is bold, what must be italic is italic etc. +Meta characters are naturally still visible, but in a faint way, so they can +be easily ignored. + + +## Download + +The raw file (adoc-mode.el) can be found +[here](https://raw.github.com/sensorflo/adoc-mode/master/adoc-mode.el). +Optionally you can get the sources from the [git +repository](https://github.com/sensorflo/adoc-mode). + +You will also need to download the library +[markup-faces](https://github.com/sensorflo/markup-faces). If you install +adoc-mode via Emacs Lisp Packages, see below, markup-faces is installed +automatically if you don't have it yet. + + +## Installation + +Installation is as usual, so if you are proficient with Emacs you don't need +to read this. + +### Install the traditional way + +1. Copy the file adoc-mode.el to a directory in your load-path, e.g. + \~/.emacs.d. To add a specific directory to the load path, add this to our + initialization file (probably ~/.emacs): `(add-to-list 'load-path + "mypath")` + +2. Add either of the two following lines to your initialization file. The + first only loads adoc mode when necessary, the 2nd always during startup + of Emacs. + + * `(autoload 'adoc-mode "adoc-mode" nil t)` + + * `(require 'adoc-mode)` + +3. Optionally byte compile adoc-mode.el for faster startup: `M-x + byte-compile` + +4. To use adoc mode, call adoc-mode after you opened an AsciiDoc file: `M-x + adoc-mode` + + +### Install via Emacs Lisp Packages (on Marmalade) + +For this way you either need packages.el from +[here](https://github.com/technomancy/package.el) and or Emacs 24, where the +packages library is already included. adoc-mode is on the +[Marmalade](http://marmalade-repo.org/) package archive. + +* Type `M-x package-install RET adoc-mode RET`. + + +### Possible steps after installation + +Each of the following is optional + +* According to an old AsciiDoc manual, .txt is the standard file extension of + AsciiDoc files. Add the following to your initialization file to open all + .txt files with adoc-mode as major mode automatically: `(add-to-list + 'auto-mode-alist (cons "\\.txt\\'" 'adoc-mode))`. + More recent conventions for AsciiDoc file extensions include `.adoc` and + `.asciidoc`, these are associated automatically. + +* If your default face is a fixed pitch (monospace) face, but in AsciiDoc + files you liked to have normal text with a variable pitch face, + buffer-face-mode is for you: `(add-hook 'adoc-mode-hook (lambda() + (buffer-face-mode t)))` + + +## Features + +- sophisticated highlighting + +- promote / demote title + +- toggle title type between one line title and two line title + +- adjust underline length of a two line title to match title text's length + +- goto anchor defining a given id, default reading from xref at point + +- support for outline (however only with the one-line title style) + + +### Coming features + +The next features I plan to implement + +- Demote / promote for list items +- Outline support also for two line titles +- Correctly highlighting backslash escapes + + +## Screenshot + +The highlighting emphasizes on how the output will look like. _All_ +characters are visible, however meta characters are displayed in a faint way. + +![screenshot](http://dl.dropbox.com/u/75789984/adoc-mode.png) From 474b8f0878b004d348da09072fc278f798f5c022 Mon Sep 17 00:00:00 2001 From: TobiasZawada Date: Mon, 30 May 2022 09:41:52 +0200 Subject: [PATCH 08/90] Correct links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dd85ebf..184f878 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,10 @@ be easily ignored. The raw file (adoc-mode.el) can be found [here](https://raw.github.com/sensorflo/adoc-mode/master/adoc-mode.el). Optionally you can get the sources from the [git -repository](https://github.com/sensorflo/adoc-mode). +repository](https://github.com/emacsorphanage/adoc-mode). You will also need to download the library -[markup-faces](https://github.com/sensorflo/markup-faces). If you install +[markup-faces](https://github.com/emacsorphanage/markup-faces). If you install adoc-mode via Emacs Lisp Packages, see below, markup-faces is installed automatically if you don't have it yet. From cacd4e8f6773da85ebe17b733eb5e74f2f7c379c Mon Sep 17 00:00:00 2001 From: Tobias Zawada Date: Mon, 30 May 2022 10:04:56 +0200 Subject: [PATCH 09/90] Correct links. Avoid some warnings for adoc-mode-test.el --- README.md | 4 ++-- adoc-mode-test.el | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 184f878..26739f7 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ be easily ignored. ## Download The raw file (adoc-mode.el) can be found -[here](https://raw.github.com/sensorflo/adoc-mode/master/adoc-mode.el). +[here](https://raw.github.com/emacsorphanage/adoc-mode/master/adoc-mode.el). Optionally you can get the sources from the [git repository](https://github.com/emacsorphanage/adoc-mode). You will also need to download the library -[markup-faces](https://github.com/emacsorphanage/markup-faces). If you install +[markup-faces](https://github.com/sensorflo/markup-faces). If you install adoc-mode via Emacs Lisp Packages, see below, markup-faces is installed automatically if you don't have it yet. diff --git a/adoc-mode-test.el b/adoc-mode-test.el index 1e48b32..b1115b6 100644 --- a/adoc-mode-test.el +++ b/adoc-mode-test.el @@ -21,8 +21,17 @@ ;; - beginning/end of buffer ;; - beginning/end of paragraph ;; - side-to-side yes/no with next same construct +;; checkdoc-params: (NAME ARGS) (defun adoctest-faces (name &rest args) - "Todo document adoctest-faces NAME ARGS." + "Test font-lock on concatenation of STRING1 ... STRINGn. + +The k-th string STRINGk with k=1,...,n `should' be fontified +with FACEk. +STRING1, FACE1, ..., STRINGn, FACEn are free. + +NAME is just for identifying the test. + +\(fn NAME STRING1 FACE1 ... STRINGn FACEn)" (let ((not-done t) (font-lock-support-mode)) (with-temp-buffer @@ -33,7 +42,7 @@ ;; exercise (adoc-mode) - (font-lock-fontify-buffer) + (font-lock-fontify-region (point-min) (point-max)) ;; verify (goto-char (point-min)) From db6c51c8e7eff66ef6044b5caf054e4378cc6d44 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 19 Jul 2022 22:30:48 +0300 Subject: [PATCH 10/90] Restructure the README --- README.md | 82 ++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 26739f7..b518506 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,47 @@ +[![MELPA][melpa-badge]][melpa-package] +[![MELPA Stable][melpa-stable-badge]][melpa-stable-package] + # adoc-mode + ## Introduction -[AsciiDoc](http://www.methods.co.nz/asciidoc/) is a text document format for +[AsciiDoc](https://asciidoc.org/) is a text document format for writing short documents, articles, books and UNIX man pages. AsciiDoc files can be translated to HTML and DocBook markups. -adoc-mode is an Emacs major mode for editing AsciiDoc files. It emphasizes on +`adoc-mode` is an Emacs major mode for editing AsciiDoc files. It emphasizes on the idea that the document is highlighted so it pretty much looks like the final output. What must be bold is bold, what must be italic is italic etc. Meta characters are naturally still visible, but in a faint way, so they can be easily ignored. - -## Download - -The raw file (adoc-mode.el) can be found -[here](https://raw.github.com/emacsorphanage/adoc-mode/master/adoc-mode.el). -Optionally you can get the sources from the [git -repository](https://github.com/emacsorphanage/adoc-mode). - -You will also need to download the library -[markup-faces](https://github.com/sensorflo/markup-faces). If you install -adoc-mode via Emacs Lisp Packages, see below, markup-faces is installed -automatically if you don't have it yet. - - ## Installation -Installation is as usual, so if you are proficient with Emacs you don't need -to read this. - -### Install the traditional way - -1. Copy the file adoc-mode.el to a directory in your load-path, e.g. - \~/.emacs.d. To add a specific directory to the load path, add this to our - initialization file (probably ~/.emacs): `(add-to-list 'load-path - "mypath")` +`adoc-mode` is available on the community-maintained +[MELPA Stable][] and [MELPA][] repos. -2. Add either of the two following lines to your initialization file. The - first only loads adoc mode when necessary, the 2nd always during startup - of Emacs. +NonGNU ELPA and MELPA Stable are recommended as they have the latest stable version. +MELPA has a development snapshot for users who don't mind breakage but +don't want to run `adoc-mode` from a git checkout. - * `(autoload 'adoc-mode "adoc-mode" nil t)` +You can install `adoc-mode` using the following command: - * `(require 'adoc-mode)` +M-x package-install [RET] adoc-mode [RET] -3. Optionally byte compile adoc-mode.el for faster startup: `M-x - byte-compile` +or if you'd rather keep it in your Emacs config: -4. To use adoc mode, call adoc-mode after you opened an AsciiDoc file: `M-x - adoc-mode` +```emacs-lisp +(unless (package-installed-p 'adoc-mode) + (package-refresh-contents) + (package-install 'adoc-mode)) +``` +If the installation doesn't work try refreshing the package list: -### Install via Emacs Lisp Packages (on Marmalade) +M-x package-refresh-contents -For this way you either need packages.el from -[here](https://github.com/technomancy/package.el) and or Emacs 24, where the -packages library is already included. adoc-mode is on the -[Marmalade](http://marmalade-repo.org/) package archive. -* Type `M-x package-install RET adoc-mode RET`. - - -### Possible steps after installation - -Each of the following is optional +## Configuration * According to an old AsciiDoc manual, .txt is the standard file extension of AsciiDoc files. Add the following to your initialization file to open all @@ -93,7 +70,6 @@ Each of the following is optional - support for outline (however only with the one-line title style) - ### Coming features The next features I plan to implement @@ -102,10 +78,22 @@ The next features I plan to implement - Outline support also for two line titles - Correctly highlighting backslash escapes - ## Screenshot The highlighting emphasizes on how the output will look like. _All_ characters are visible, however meta characters are displayed in a faint way. ![screenshot](http://dl.dropbox.com/u/75789984/adoc-mode.png) + +## License + +Copyright © 2010-2013 Florian Kaufmann + +Distributed under the GNU General Public License; type C-h C-c to view it. + +[melpa-badge]: http://melpa.org/packages/adoc-mode-badge.svg +[melpa-stable-badge]: http://stable.melpa.org/packages/adoc-mode-badge.svg +[melpa-package]: http://melpa.org/#/adoc-mode +[melpa-stable-package]: http://stable.melpa.org/#/adoc-mode +[melpa]: http://melpa.org +[melpa stable]: http://stable.melpa.org From 46e8ea4126ef047c0cc78b394742963c41944142 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 19 Jul 2022 22:45:47 +0300 Subject: [PATCH 11/90] Add Eldev and a GHA workflow based on it I've also added a bunch of hacking guidelines for potential contributors. --- .github/workflows/test.yml | 34 ++++++++++++++++++++ .gitignore | 1 + Eldev | 1 + README.md | 66 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 Eldev diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2767f98 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + paths-ignore: ['**.md', '**.adoc'] + pull_request: + paths-ignore: ['**.md', '**.adoc'] + +jobs: + test: + runs-on: ubuntu-latest + continue-on-error: ${{matrix.emacs_version == 'snapshot'}} + + strategy: + matrix: + # Earliest supported + latest in each stable branch + snapshot. + emacs_version: ['25.1', '25.3', '26.3', '27.1', '28.1', 'snapshot'] + + steps: + - name: Set up Emacs + uses: purcell/setup-emacs@master + with: + version: ${{matrix.emacs_version}} + + - name: Install Eldev + run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh + + - name: Check out the source code + uses: actions/checkout@v2 + + - name: Test the project + run: | + eldev -p -dtT -C test --expect 100 + eldev -dtT -C compile --warnings-as-errors diff --git a/.gitignore b/.gitignore index d27fb03..3e4ada4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.elc #*# TAGS +.eldev diff --git a/Eldev b/Eldev new file mode 100644 index 0000000..c51ddaa --- /dev/null +++ b/Eldev @@ -0,0 +1 @@ +(eldev-use-package-archive 'melpa) diff --git a/README.md b/README.md index b518506..82e650c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Build Status](https://github.com/emacsorphanage/adoc-mode/workflows/CI/badge.svg)](https://github.com/emacsorphanage/adoc-mode/actions?query=workflow%3ACI) [![MELPA][melpa-badge]][melpa-package] [![MELPA Stable][melpa-stable-badge]][melpa-stable-package] @@ -85,6 +86,71 @@ characters are visible, however meta characters are displayed in a faint way. ![screenshot](http://dl.dropbox.com/u/75789984/adoc-mode.png) +## Hacking + +adoc-mode uses [Eldev](https://github.com/doublep/eldev) for development, so +you should install the tool first. + +The easiest and "purest" way to run adoc-mode is to execute: + + $ eldev emacs + +This will start a separate Emacs process with adoc-mode and its +dependencies available, but _without_ your normal packages installed. +However, you can use `Eldev-local` to add some packages with +`(eldev-add-extra-dependencies 'emacs ...)` forms. See Eldev +documentation for details. + +Alternatively, if you want to load adoc-mode from source code in the Emacs +you use for editing: + +- Generate autoloads file (that's done automatically when installing +via `package.el` but you'll have to do it manually in this case): + +``` shellsession +$ eldev build :autoloads +``` + +- Add to your `.emacs`: + +``` emacs-lisp +;; load adoc-mode from its source code +(add-to-list 'load-path "~/projects/adoc-mode") +(load "adoc-mode-autoloads" t t) +``` + +### Changing the code + +It's perfectly fine to load adoc-mode from `package.el` and then to start making +experiments by changing existing code and adding new code. + +A very good workflow is to just open the source code you've cloned and start +evaluating the code you've altered/added with commands like `C-M-x`, +`eval-buffer` and so on. + +Once you've evaluated the new code, you can invoke some interactive command that +uses it internally or open a Emacs Lisp REPL and experiment with it there. You +can open an Emacs Lisp REPL with `M-x ielm`. + +You can also quickly evaluate some Emacs Lisp code in the minibuffer with `M-:`. + +### Running the tests + +Run all tests with: + + $ eldev test + +NOTE: Tests may not run correctly inside Emacs' `shell-mode` buffers. Running +them in a terminal is recommended. + +You can also check for compliance with a variety of coding standards in batch mode (including docstrings): + + $ eldev lint + +To check for byte-compilation warnings you can just compile the project with Eldev: + + $ eldev compile + ## License Copyright © 2010-2013 Florian Kaufmann From 66cd5645a00b1f90e9d73e82550a187e296e98cb Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 19 Jul 2022 23:15:09 +0300 Subject: [PATCH 12/90] Clean up the front-matter Basically the whole README was repeated there, which is quite wasteful. I've also killed all the trailing whitespace. --- adoc-mode.el | 394 +++++++++++++++++---------------------------------- 1 file changed, 131 insertions(+), 263 deletions(-) diff --git a/adoc-mode.el b/adoc-mode.el index 07deba2..f83f4e5 100644 --- a/adoc-mode.el +++ b/adoc-mode.el @@ -1,16 +1,17 @@ ;;; adoc-mode.el --- a major-mode for editing AsciiDoc files in Emacs ;; -;; Copyright 2010-2013 Florian Kaufmann +;; Copyright 2009-2014 Florian Kaufmann +;; Copyright 2022 adoc-mode contributors ;; ;; Author: Florian Kaufmann -;; URL: https://github.com/sensorflo/adoc-mode/wiki +;; URL: https://github.com/emacsorphanage/adoc-mode ;; Created: 2009 ;; Version: 0.6.6 ;; Package-Requires: ((markup-faces "1.0.0")) ;; Keywords: wp AsciiDoc -;; +;; ;; This file is not part of GNU Emacs. -;; +;; ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) @@ -25,153 +26,21 @@ ;; along with this program; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth ;; Floor, Boston, MA 02110-1301, USA. -;; -;; -;; The syntax of the following commentary section is Markdown, so the same text -;; can be used for the wiki page on GitHub. Also, each paragraph, including list -;; items, are separated by blank lines, so it also looks good on Marmalade. + ;;; Commentary: -;; -;; # Introduction -;; -;; [AsciiDoc](http://www.methods.co.nz/asciidoc/) is a text document format for + +;; AsciiDoc is a text document format for ;; writing short documents, articles, books and UNIX man pages. AsciiDoc files ;; can be translated to HTML and DocBook markups. -;; +;; ;; adoc-mode is an Emacs major mode for editing AsciiDoc files. It emphasizes on ;; the idea that the document is highlighted so it pretty much looks like the ;; final output. What must be bold is bold, what must be italic is italic etc. ;; Meta characters are naturally still visible, but in a faint way, so they can ;; be easily ignored. -;; -;; -;; # Download -;; -;; The raw file (adoc-mode.el) can be found -;; [here](https://raw.github.com/sensorflo/adoc-mode/master/adoc-mode.el). -;; Optionally you can get the sources from the [git -;; repository](https://github.com/sensorflo/adoc-mode). -;; -;; You will also need to download the library -;; [markup-faces](https://github.com/sensorflo/markup-faces). If you install -;; adoc-mode via Emacs Lisp Packages, see below, markup-faces is installed -;; automatically if you don't have it yet. -;; -;; -;; # Installation -;; -;; Installation is as usual, so if you are proficient with Emacs you don't need -;; to read this. -;; -;; ## Install the traditional way -;; -;; 1. Copy the file adoc-mode.el to a directory in your load-path, e.g. -;; \~/.emacs.d. To add a specific directory to the load path, add this to our -;; initialization file (probably ~/.emacs): `(add-to-list 'load-path -;; "mypath")` -;; -;; 2. Add either of the two following lines to your initialization file. The -;; first only loads adoc mode when necessary, the 2nd always during startup -;; of Emacs. -;; -;; * `(autoload 'adoc-mode "adoc-mode" nil t)` -;; -;; * `(require 'adoc-mode)` -;; -;; 3. Optionally byte compile adoc-mode.el for faster startup: `M-x -;; byte-compile` -;; -;; 4. To use adoc mode, call adoc-mode after you opened an AsciiDoc file: `M-x -;; adoc-mode` -;; -;; -;; ## Install via Emacs Lisp Packages (on Marmalade) -;; -;; For this way you either need packages.el from -;; [here](https://github.com/technomancy/package.el) and or Emacs 24, where the -;; packages library is already included. adoc-mode is on the -;; [Marmalade](http://marmalade-repo.org/) package archive. -;; -;; * Type `M-x package-install RET adoc-mode RET`. -;; -;; -;; ## Possible steps after installation -;; -;; Each of the following is optional -;; -;; * According to an old AsciiDoc manual, .txt is the standard file extension of -;; AsciiDoc files. Add the following to your initialization file to open all -;; .txt files with adoc-mode as major mode automatically: `(add-to-list -;; 'auto-mode-alist (cons "\\.txt\\'" 'adoc-mode))`. -;; More recent conventions for AsciiDoc file extensions include `.adoc` and -;; `.asciidoc`, these are associated automatically. -;; -;; * If your default face is a fixed pitch (monospace) face, but in AsciiDoc -;; files you liked to have normal text with a variable pitch face, -;; buffer-face-mode is for you: `(add-hook 'adoc-mode-hook (lambda() -;; (buffer-face-mode t)))` -;; -;; -;; # Features -;; -;; - sophisticated highlighting -;; -;; - promote / demote title -;; -;; - toggle title type between one line title and two line title -;; -;; - adjust underline length of a two line title to match title text's length -;; -;; - goto anchor defining a given id, default reading from xref at point -;; -;; - support for outline (however only with the one-line title style) -;; -;; -;; ## Coming features -;; -;; The next features I plan to implement -;; -;; - Demote / promote for list items -;; - Outline support also for two line titles -;; - Correctly highlighting backslash escapes -;; -;; -;; # Screenshot -;; -;; The highlighting emphasizes on how the output will look like. _All_ -;; characters are visible, however meta characters are displayed in a faint way. -;; -;; ![screenshot](http://dl.dropbox.com/u/75789984/adoc-mode.png) -;; -;; -;;; Todo: -;; - Fontlock -;; - make font-lock regexps based upon AsciiDoc configuration file, or make -;; them configurable in a way similar to that configuration file -;; - respect font-lock-maximum-decoration -;; - delimited blocks are supported, but not well at all -;; - Most regexps for highlighting can spawn at most over two lines. -;; - font-lock's multi line capabilities are not used well enough. At least 2 -;; line spawns should be covered - replace all .*? by .*?\\(?:\n.*?\\)?? -;; - backslash escapes are seldom highlighted correctly -;; - Other common Emacs functionality/features -;; - demote/promote/create/delete titles/list-items. Also put emphasis on a -;; convenient simple user interface. -;; - hideshow -;; - outline mode shall support two line titles -;; - tags tables for anchors, indixes, bibliography items, titles, ... -;; - spell check shall ignore meta characters -;; - supply a regexp for magic-mode-alist -;; - Is there something that would remove hard newlines within a paragraph, -;; but just for display, so the paragraph uses the whole buffer length. -;; - are there generic base packages to handle lists / tables? -;; - a read only view mode where commands for navigation are on short key -;; bindings like alphanum letters -;; - study what other markup modes like rst offer -;; - AsciiDoc related features -;; - Two (or gradually fading) display modes: one emphasises to see the -;; AsciiDoc source text, the other emphasises to see how the output will -;; look like. Or even hide meta characters all together + +;;; Code: + ;;; Variables: @@ -187,7 +56,7 @@ Based upon AsciiDoc version 8.5.2. I.e. regexeps and rules are taken from that version's asciidoc.conf / manual.") -;;;; customization +;;;; customization (defgroup adoc nil "Major-mode for editing AsciiDoc files in Emacs. @@ -258,10 +127,10 @@ Each string must be exactly 2 characters long. Corresponds to the underlines element in the titles section of the asciidoc configuration file." :type '(list - (string :tag "level 0") - (string :tag "level 1") - (string :tag "level 2") - (string :tag "level 3") + (string :tag "level 0") + (string :tag "level 1") + (string :tag "level 2") + (string :tag "level 3") (string :tag "level 4") ) :group 'adoc) @@ -378,7 +247,7 @@ See for example `tempo-template-adoc-title-1'." :group 'adoc) -;;;; faces / font lock +;;;; faces / font lock (define-obsolete-face-alias 'adoc-orig-default 'adoc-align "23.3") (defface adoc-align '((t (:inherit (markup-meta-face)))) @@ -434,7 +303,7 @@ aligned. (defvar adoc-preprocessor 'markup-preprocessor-face) -;;;; misc +;;;; misc (defconst adoc-title-max-level 4 "Max title level, counting starts at 0.") @@ -700,7 +569,7 @@ When LEVEL is nil, a one line title of any level is matched. match-data has these sub groups: 1 leading delimiter inclusive whites between delimiter and title text 2 title's text exclusive leading/trailing whites -3 trailing delimiter with all whites +3 trailing delimiter with all whites 4 trailing delimiter only inclusive whites between title text and delimiter 0 only chars that belong to the title block element @@ -721,7 +590,7 @@ match-data has these sub groups: (defun adoc-make-one-line-title (sub-type level text) "Returns a one line title of LEVEL and SUB-TYPE containing the given text." (let ((del (make-string (+ level 1) ?=))) - (concat del " " text (when (eq sub-type 2) (concat " " del))))) + (concat del " " text (when (eq sub-type 2) (concat " " del))))) ;; AsciiDoc handles that by source code, there is no regexp in AsciiDoc. See ;; also adoc-re-one-line-title. @@ -739,10 +608,10 @@ a two line title underline, see also `adoc-re-two-line-title'." (lambda(x) (concat "\\(?:" - "\\(?:" (regexp-quote x) "\\)+" + "\\(?:" (regexp-quote x) "\\)+" (regexp-quote (substring x 0 1)) "?" "\\)")) - (if del (list del) adoc-two-line-title-del) "\\|") + (if del (list del) adoc-two-line-title-del) "\\|") ;; adoc-re-two-line-title shall have same behaviour als one line, thus ;; also here use \n instead $ "\\)[ \t]*\\(?:\n\\|\\'\\)")) @@ -778,7 +647,7 @@ match-data has these sub groups: "Returns a two line title of given LEVEL containing given TEXT. LEVEL starts at 1." (concat text "\n" (adoc-make-two-line-title-underline level (length text)))) - + (defun adoc-make-two-line-title-underline (level &optional length) "Returns a two line title underline. LEVEL is the level of the title, starting at 1. LENGTH is the @@ -807,11 +676,11 @@ match-data his this sub groups: WARNING: See warning about list item nesting level in `adoc-list-descriptor'." (cond - ;; ^\s*- +(?P.+)$ normal 0 + ;; ^\s*- +(?P.+)$ normal 0 ;; ^\s*\* +(?P.+)$ normal 1 ;; ... ... ;; ^\s*\*{5} +(?P.+)$ normal 5 - ;; ^\+ +(?P.+)$ bibliograpy(DEPRECATED) + ;; ^\+ +(?P.+)$ bibliograpy(DEPRECATED) ((eq type 'adoc-unordered) (cond ((or (eq sub-type 'adoc-normal) (null sub-type)) @@ -839,7 +708,7 @@ WARNING: See warning about list item nesting level in `adoc-list-descriptor'." ;; ^\s*\. +(?P.+)$ normal 0 ;; ^\s*\.{2} +(?P.+)$ normal 1 ;; ... etc until 5 ... - ((eq type 'adoc-implicitly-numbered) + ((eq type 'adoc-implicitly-numbered) (let ((r (cond ((numberp level) (number-to-string (+ level 1))) ((or (null level) (eq level 'adoc-all-levels)) "1,5") (t (error "adoc-implicitly-numbered: invalid level"))))) @@ -852,7 +721,7 @@ WARNING: See warning about list item nesting level in `adoc-list-descriptor'." ;; invalid (t (error "invalid (un)ordered list type")))) - + (defun adoc-make-uolisti (level is-1st-line) "Returns a regexp matching a unordered list item." (let* ((del (if (eq level 0) "-" (make-string level ?\*))) @@ -890,7 +759,7 @@ Subgroups: "\\(\\(" del "\\)\\(?:[ \t]+\\|$\\)\\)"))) ; 3 & 4 ;; glossary (DEPRECATED) - ;; ^(?P