Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### Changes

- `adoc-goto-ref-label` (`C-c C-a`) now completes over the anchors defined in the buffer instead of asking you to type the id blind. It stays permissive, so an id that isn't defined yet can still be entered, and the cross-reference at point is still offered as the default.
- The compilation error matcher now also recognises modern `asciidoctor:` diagnostics, not just the legacy AsciiDoc.py `asciidoc:` format, so jumping to warnings and errors works with current Asciidoctor output.
- `[source,ocaml]` code blocks now fontify with `neocaml-mode` when it is available, falling back to `tuareg-mode` and then `caml-mode`. To support this, a value in `adoc-code-lang-modes` may now be either a single major mode or a list of candidate modes tried in order (the first defined one wins).

Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Here are some of the main features of `adoc-mode`:
- heading navigation modelled on `markdown-mode` / `org-mode`: next / previous heading (`C-c C-n` / `C-c C-p`), forward / backward at the same level (`C-c C-f` / `C-c C-b`), and up to the parent heading (`C-c C-u`)
- title management: promote / demote (`M-left` / `M-right`), toggle between one-line and two-line styles, adjust underline length
- list editing: `M-left` / `M-right` nest the list item at point deeper or shallower, `M-RET` inserts a sibling item (incrementing the number for explicitly-numbered lists), `M-up` / `M-down` move an item (with its sub-items) past its siblings, and `M-x adoc-renumber-list` renumbers an explicitly-numbered list
- navigate to anchors (`C-c C-a`) and follow URLs, `link:` and `include::` macros, and xrefs at point (`C-c C-o` / `M-.`), or by clicking them with the mouse
- navigate to anchors with completion over the buffer's anchors (`C-c C-a`), and follow URLs, `link:` and `include::` macros, and xrefs at point (`C-c C-o` / `M-.`), or by clicking them with the mouse
- an `xref` backend over anchors: `M-?` lists every cross-reference to the anchor at point, with the usual xref marker stack and completion UI
- context-aware completion via `completion-at-point`: cross-reference ids inside `<<` / `xref:`, attribute names inside `{`, file paths after `include::`, and source-block languages inside `[source,`
- nested `imenu` index with hierarchical heading structure
Expand Down
7 changes: 5 additions & 2 deletions adoc-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -2909,9 +2909,12 @@ for multiline constructs to be matched."
(interactive (let* ((default (adoc-xref-id-at-point))
(default-str (if default (concat "(default " default ")") "")))
(list
(read-string
;; Offer the buffer's anchors as candidates, but stay
;; permissive (require-match nil) so a not-yet-defined id can
;; still be entered.
(completing-read
(concat "Goto anchor of reference/label " default-str ": ")
nil nil default))))
(adoc--collect-anchor-ids) nil nil nil nil default))))
(let ((pos (save-excursion
(goto-char (point-min))
(re-search-forward (adoc-re-anchor nil id) nil t))))
Expand Down
16 changes: 16 additions & 0 deletions test/adoc-mode-navigation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,22 @@
(adoc-goto-ref-label "bar")
(expect (line-number-at-pos) :to-equal 3)))

(it "offers the buffer's anchors when read interactively"
(with-temp-buffer
(adoc-mode)
(insert "[[alpha]]\n[[beta]]\nbody\n")
(goto-char (point-max))
(let (candidates)
(spy-on 'completing-read :and-call-fake
(lambda (_prompt collection &rest _)
(setq candidates (all-completions "" collection))
"alpha"))
(call-interactively #'adoc-goto-ref-label)
;; the buffer's anchors were offered as candidates
(expect (sort candidates #'string<) :to-equal '("alpha" "beta"))
;; and the chosen one was jumped to
(expect (line-number-at-pos) :to-equal 1))))

(it "follows the block id shorthand, including the style#id form"
(with-temp-buffer
(adoc-mode)
Expand Down