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
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@

// * Buffer local variables
// Local Variables:
// eval: (verilog-ext-hierarchy-outshine-nav-mode)
// eval: (verilog-ext-hierarchy-outline-nav-mode)
// End:
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

// * Buffer local variables
// Local Variables:
// eval: (verilog-ext-hierarchy-outshine-nav-mode)
// eval: (verilog-ext-hierarchy-outline-nav-mode)
// End:
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@

// * Buffer local variables
// Local Variables:
// eval: (verilog-ext-hierarchy-outshine-nav-mode)
// eval: (verilog-ext-hierarchy-outline-nav-mode)
// End:
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@

// * Buffer local variables
// Local Variables:
// eval: (verilog-ext-hierarchy-outshine-nav-mode)
// eval: (verilog-ext-hierarchy-outline-nav-mode)
// End:
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Hierarchy generated by `verilog-ext'

// * instances
// ** test_if_params
// ** test_if_params_array
// ** block0
// ** block1
// ** block2
// ** block3
// ** block_gen
// ** block_ws_0
// ** block_ws_1
// ** test_if
// ** test_if_params
// ** test_if_params_array
// ** test_if_params_empty
// ** block_ws_0
// ** block_ws_1


// * Buffer local variables
// Local Variables:
// eval: (verilog-ext-hierarchy-outshine-nav-mode)
// eval: (verilog-ext-hierarchy-outline-nav-mode)
// End:
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

// * Buffer local variables
// Local Variables:
// eval: (verilog-ext-hierarchy-outshine-nav-mode)
// eval: (verilog-ext-hierarchy-outline-nav-mode)
// End:
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Hierarchy generated by `verilog-ext'

// * instances
// ** test_if_params
// ** test_if_params_array
// ** block0
// ** block1
// ** block2
// ** block3
// ** block_gen
// ** test_if
// ** test_if_params
// ** test_if_params_array
// ** test_if_params_empty
// ** block_ws_0
// ** block_ws_1
// ** test_if
// ** test_if_params_empty


// * Buffer local variables
// Local Variables:
// eval: (verilog-ext-hierarchy-outshine-nav-mode)
// eval: (verilog-ext-hierarchy-outline-nav-mode)
// End:
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@

// * Buffer local variables
// Local Variables:
// eval: (verilog-ext-hierarchy-outshine-nav-mode)
// eval: (verilog-ext-hierarchy-outline-nav-mode)
// End:
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@

// * Buffer local variables
// Local Variables:
// eval: (verilog-ext-hierarchy-outshine-nav-mode)
// eval: (verilog-ext-hierarchy-outline-nav-mode)
// End:
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@

// * Buffer local variables
// Local Variables:
// eval: (verilog-ext-hierarchy-outshine-nav-mode)
// eval: (verilog-ext-hierarchy-outline-nav-mode)
// End:
100 changes: 50 additions & 50 deletions test/src/verilog-ext-test-hierarchy.el

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/src/verilog-ext-test-setup-package.el
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
(setq verilog-date-scientific-format t)
(setq verilog-case-fold nil) ; Regexps should NOT ignore case
(setq verilog-align-ifelse nil)
(setq verilog-indent-ignore-regexp "// \\*") ; Ignore outshine headings
(setq verilog-indent-ignore-regexp "// \\*") ; Ignore outline/outshine headings
;; Verilog AUTO
(setq verilog-auto-delete-trailing-whitespace t) ; ‘delete-trailing-whitespace’ in ‘verilog-auto’.
(setq verilog-auto-indent-on-newline t) ; Self-explaining
Expand Down
2 changes: 1 addition & 1 deletion test/src/verilog-ext-test-setup-straight.el
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
(setq verilog-date-scientific-format t)
(setq verilog-case-fold nil) ; Regexps should NOT ignore case
(setq verilog-align-ifelse nil)
(setq verilog-indent-ignore-regexp "// \\*") ; Ignore outshine headings
(setq verilog-indent-ignore-regexp "// \\*") ; Ignore outline/outshine headings
;; Verilog AUTO
(setq verilog-auto-delete-trailing-whitespace t) ; ‘delete-trailing-whitespace’ in ‘verilog-auto’.
(setq verilog-auto-indent-on-newline t) ; Self-explaining
Expand Down
86 changes: 35 additions & 51 deletions verilog-ext-hierarchy.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

;;; Code:

(require 'outshine)
(require 'outline)
(require 'hierarchy)
(require 'tree-widget)
(require 'async)
Expand All @@ -45,7 +45,7 @@

(defcustom verilog-ext-hierarchy-frontend 'hierarchy
"Verilog-ext hierarchy display and navigation frontend."
:type '(choice (const :tag "Outshine" outshine)
:type '(choice (const :tag "Outline" outline)
(const :tag "Hierarchy" hierarchy))
:group 'verilog-ext-hierarchy)

Expand Down Expand Up @@ -164,7 +164,7 @@ Return populated `hierarchy' struct."
(defun verilog-ext-hierarchy--convert-struct-to-string (hierarchy-struct)
"Convert HIERARCHY-STRUCT to a string.
Used to convert hierarchy formats for displaying on different frontends."
(let ((offset-blank-spaces 2) ; Intended to be used by outshine, which assumes that...
(let ((offset-blank-spaces 2) ; Intended to be used by outline, which assumes that...
(unicode-spc 32) ; ... vhier output adds two offset indent spaces
(debug nil))
(unless (hierarchy-p hierarchy-struct)
Expand All @@ -184,7 +184,7 @@ Used to convert hierarchy formats for displaying on different frontends."
"Convert HIERARCHY-STRING to an alist.
Used to convert hierarchy formats for displaying on different frontends.
Alist will be of the form (module instance1:NAME1 instance2:NAME2 ...)."
(let ((offset-blank-spaces 2) ; Intended to be used by outshine, which assumes that...
(let ((offset-blank-spaces 2) ; Intended to be used by outline, which assumes that...
(debug nil) ; ... vhier output adds two offset indent spaces
flat-hierarchy current-line parent current-indent cell hierarchy-alist)
(unless (stringp hierarchy-string)
Expand Down Expand Up @@ -518,73 +518,57 @@ Show only module name, discard instance name after colon (mod:INST)."
(when verilog-ext-hierarchy-twidget-init-expand
(verilog-ext-hierarchy-twidget-nav-init-expand)))

;;;;; outshine
(defmacro verilog-ext-hierarchy-outshine-nav (verilog-ext-func outshine-func)
"Define function VERILOG-EXT-FUNC to call OUTSHINE-FUNC.
Called in a buffer with `verilog-ext-hierarchy-outshine-nav-mode' enabled.
Move through headings and point at the beginning of the tag."
(declare (indent 0) (debug t))
`(defun ,verilog-ext-func ()
(interactive)
(beginning-of-line) ; Required for `outline-hide-sublevels'
(call-interactively ,outshine-func)
(skip-chars-forward (car (car outshine-promotion-headings)))))

(verilog-ext-hierarchy-outshine-nav verilog-ext-hierarchy-outshine-nav-previous-visible-heading #'outline-previous-visible-heading)
(verilog-ext-hierarchy-outshine-nav verilog-ext-hierarchy-outshine-nav-next-visible-heading #'outline-next-visible-heading)
(verilog-ext-hierarchy-outshine-nav verilog-ext-hierarchy-outshine-nav-up-heading #'outline-up-heading)
(verilog-ext-hierarchy-outshine-nav verilog-ext-hierarchy-outshine-nav-forward-same-level #'outline-forward-same-level)
(verilog-ext-hierarchy-outshine-nav verilog-ext-hierarchy-outshine-nav-backward-same-level #'outline-backward-same-level)
(verilog-ext-hierarchy-outshine-nav verilog-ext-hierarchy-outshine-nav-hide-sublevels #'outline-hide-sublevels)

(defun verilog-ext-hierarchy-outshine-jump-to-file (&optional other-window)
;;;;; outline
(defun verilog-ext-hierarchy-outline-jump-to-file (&optional other-window)
"Jump to module definition at point on navigation hierarchy file.
If OTHER-WINDOW is non-nil, open definition in other window."
(interactive)
(if other-window
(xref-find-definitions-other-window (thing-at-point 'symbol t))
(xref-find-definitions (thing-at-point 'symbol t))))

(defun verilog-ext-hierarchy-outshine-jump-to-file-other-window ()
(defun verilog-ext-hierarchy-outline-jump-to-file-other-window ()
"Jump to module definition at point on navigation hierarchy file."
(interactive)
(verilog-ext-hierarchy-outshine-jump-to-file :other-window))
(verilog-ext-hierarchy-outline-jump-to-file :other-window))

(define-minor-mode verilog-ext-hierarchy-outshine-nav-mode
"Instance navigation frontend with `outshine'.
Makes use of processed output under `outline-minor-mode' and `outshine'."
(define-minor-mode verilog-ext-hierarchy-outline-nav-mode
"Instance navigation frontend with `outline'.
Makes use of processed output under `outline-minor-mode'."
:lighter " vH"
:keymap
'(;; Hide/Show
("a" . outline-show-all)
("i" . outline-show-children)
("h" . outline-show-children)
("l" . verilog-ext-hierarchy-outshine-nav-hide-sublevels)
("l" . outline-hide-sublevels)
("I" . outline-show-branches)
(";" . outline-hide-other)
;; Movement
("u" . verilog-ext-hierarchy-outshine-nav-up-heading)
("C-c C-u" . verilog-ext-hierarchy-outshine-nav-up-heading)
("n" . verilog-ext-hierarchy-outshine-nav-next-visible-heading)
("j" . verilog-ext-hierarchy-outshine-nav-next-visible-heading)
("p" . verilog-ext-hierarchy-outshine-nav-previous-visible-heading)
("k" . verilog-ext-hierarchy-outshine-nav-previous-visible-heading)
("C-c C-n" . verilog-ext-hierarchy-outshine-nav-forward-same-level)
("C-c C-p" . verilog-ext-hierarchy-outshine-nav-backward-same-level)
("u" . outline-up-heading)
("C-c C-u" . outline-up-heading)
("n" . outline-next-visible-heading)
("j" . outline-next-visible-heading)
("p" . outline-previous-visible-heading)
("k" . outline-previous-visible-heading)
("C-c C-n" . outline-forward-same-level)
("C-c C-p" . outline-backward-same-level)
;; Jump
("o" . verilog-ext-hierarchy-outshine-jump-to-file-other-window)
("C-o" . verilog-ext-hierarchy-outshine-jump-to-file-other-window)
("RET" . verilog-ext-hierarchy-outshine-jump-to-file)
("C-j" . verilog-ext-hierarchy-outshine-jump-to-file))
("o" . verilog-ext-hierarchy-outline-jump-to-file-other-window)
("C-o" . verilog-ext-hierarchy-outline-jump-to-file-other-window)
("RET" . verilog-ext-hierarchy-outline-jump-to-file)
("C-j" . verilog-ext-hierarchy-outline-jump-to-file))
;; Minor-mode code
(outshine-mode 1)
(setq outline-regexp "// [\\*]+ ")
(setq outline-minor-mode-highlight 'override)
(outline-minor-mode 1)
(setq buffer-read-only t)
(view-mode -1))

(defun verilog-ext-hierarchy-outshine-display (hierarchy)
"Display HIERARCHY using `outshine'.
(defun verilog-ext-hierarchy-outline-display (hierarchy)
"Display HIERARCHY using `outline'.
Expects HIERARCHY to be a indented string."
(let ((buf "*Verilog-outshine*"))
(let ((buf "*Verilog-outline*"))
(with-current-buffer (get-buffer-create buf)
(setq buffer-read-only nil)
(erase-buffer)
Expand All @@ -606,14 +590,14 @@ Expects HIERARCHY to be a indented string."
;; Insert local variables at the end of the file
(goto-char (point-max))
(newline 1)
(insert "\n// * Buffer local variables\n// Local Variables:\n// eval: (verilog-ext-hierarchy-outshine-nav-mode)\n// End:\n")
(insert "\n// * Buffer local variables\n// Local Variables:\n// eval: (verilog-ext-hierarchy-outline-nav-mode)\n// End:\n")
;; Insert header to get some info of the file
(goto-char (point-min))
(open-line 1)
(insert "// Hierarchy generated by `verilog-ext'\n")
(verilog-ext-with-no-hooks
(verilog-mode))
(verilog-ext-hierarchy-outshine-nav-mode))
(verilog-ext-hierarchy-outline-nav-mode))
(pop-to-buffer buf)))

;;;; Core
Expand Down Expand Up @@ -678,11 +662,11 @@ frontend.
E.g.: If extracted with vhier and displayed with hierarchy it is needed to
convert between an indented string and a populated hierarchy struct."
(let ((display-hierarchy hierarchy))
(cond (;; Outshine
(eq verilog-ext-hierarchy-frontend 'outshine)
(cond (;; Outline
(eq verilog-ext-hierarchy-frontend 'outline)
(when (hierarchy-p hierarchy)
(setq display-hierarchy (verilog-ext-hierarchy--convert-struct-to-string hierarchy)))
(verilog-ext-hierarchy-outshine-display display-hierarchy))
(verilog-ext-hierarchy-outline-display display-hierarchy))
;; Hierarchy
((eq verilog-ext-hierarchy-frontend 'hierarchy)
(setq display-hierarchy hierarchy)
Expand Down
2 changes: 1 addition & 1 deletion verilog-ext-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ Pass the args START, END and optional COLUMN to `indent-region'."
(defun verilog-ext-tab (&optional arg)
"Run corresponding TAB function depending on `major-mode'.

If on an outline header, fold/unfold current section (`outshine' compatibility).
If on an outline header, fold/unfold current section (`outline' compatibility).

If on a `verilog-mode' buffer, run `electric-verilog-tab' with original
`verilog-mode' syntax table. Prevents indentation issues with compiler
Expand Down
2 changes: 1 addition & 1 deletion verilog-ext.el
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
;; URL: https://github.com/gmlarumbe/verilog-ext
;; Version: 0.6.2
;; Keywords: Verilog, IDE, Tools
;; Package-Requires: ((emacs "29.1") (verilog-mode "2024.3.1.121933719") (verilog-ts-mode "0.3.0") (lsp-mode "8.0.0") (ag "0.48") (ripgrep "0.4.0") (hydra "0.15.0") (apheleia "3.1") (yasnippet "0.14.0") (flycheck "32") (outshine "3.0.1") (async "1.9.7"))
;; Package-Requires: ((emacs "29.1") (verilog-mode "2024.3.1.121933719") (verilog-ts-mode "0.3.0") (lsp-mode "8.0.0") (ag "0.48") (ripgrep "0.4.0") (hydra "0.15.0") (apheleia "3.1") (yasnippet "0.14.0") (flycheck "32") (async "1.9.7"))

;; 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
Expand Down