diff --git a/doc/emacs/programs.texi b/doc/emacs/programs.texi index f42f40fa28f..12bde32be05 100644 --- a/doc/emacs/programs.texi +++ b/doc/emacs/programs.texi @@ -1735,7 +1735,7 @@ Hide all blocks @var{n} levels below this block @vindex hs-indicator-maximum-buffer-size @vindex hs-isearch-open @vindex hs-hide-block-behavior -@vindex hs-special-modes-alist +@vindex hs-modes-alist These variables can be used to customize Hideshow mode: @table @code @@ -1782,6 +1782,9 @@ code blocks and comments), or @code{nil} (unhide neither code blocks nor comments). The default value is @code{code}. @end table +All necessary settings for each mode can be found in the variable +@code{hs-modes-alist}. + @node Symbol Completion @section Completion for Symbol Names @cindex completion (symbol names) diff --git a/etc/NEWS b/etc/NEWS index d3eff6991dd..81117951302 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1100,6 +1100,12 @@ should hide a block. If set to 'after-bol', hide the innermost block to which the current line belongs. If set to 'after-cursor', hide the block after cursor position. By default this is set to 'after-bol'. ++++ +*** The variable 'hs-special-modes-alist' is now obsolete. +Use the new variable 'hs-modes-alist' instead, which supports mode +hierarchy for each value. + + ** C-ts mode +++ diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index 96626600d55..c3158069dcd 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el @@ -930,7 +930,7 @@ allowed. This minor issue currently only affects \"(/\" and \"/)\".") "block" "critical") t) "\\_>") "Regexp matching the end of an F90 \"block\", from the line start. -Used in the F90 entry in `hs-special-modes-alist'.") +Used in the F90 entry in `hs-modes-alist'.") ;; Ignore the fact that FUNCTION, SUBROUTINE, WHERE, FORALL have a ;; following "(". DO, CASE, IF can have labels. @@ -966,12 +966,12 @@ Used in the F90 entry in `hs-special-modes-alist'.") "Regexp matching the start of an F90 \"block\", from the line start. A simple regexp cannot do this in fully correct fashion, so this tries to strike a compromise between complexity and flexibility. -Used in the F90 entry in `hs-special-modes-alist'.") +Used in the F90 entry in `hs-modes-alist'.") -;; hs-special-modes-alist is autoloaded. -(add-to-list 'hs-special-modes-alist - `(f90-mode ,f90-start-block-re ,f90-end-block-re - "!" f90-end-of-block nil)) +;; hs-modes-alist is autoloaded. +(add-to-list 'hs-modes-alist + `(f90-mode (start . ,f90-start-block-re) (end . ,f90-end-block-re) + (c-start . "!") (forward-fn . f90-end-of-block))) ;; Imenu support. diff --git a/lisp/progmodes/fortran.el b/lisp/progmodes/fortran.el index d1f14fdf8fe..6eb75af01a3 100644 --- a/lisp/progmodes/fortran.el +++ b/lisp/progmodes/fortran.el @@ -549,7 +549,7 @@ than ENDDO.") "\\|!\\|$\\)") "Regexp matching the end of a Fortran \"block\", from the line start. Note that only ENDDO is handled for the end of a DO-loop. Used -in the Fortran entry in `hs-special-modes-alist'.") +in the Fortran entry in `hs-modes-alist'.") (defconst fortran-start-block-re (concat @@ -582,11 +582,11 @@ in the Fortran entry in `hs-special-modes-alist'.") "Regexp matching the start of a Fortran \"block\", from the line start. A simple regexp cannot do this in fully correct fashion, so this tries to strike a compromise between complexity and flexibility. -Used in the Fortran entry in `hs-special-modes-alist'.") +Used in the Fortran entry in `hs-modes-alist'.") -(add-to-list 'hs-special-modes-alist - `(fortran-mode ,fortran-start-block-re ,fortran-end-block-re - "^[cC*!]" fortran-end-of-block nil)) +(add-to-list 'hs-modes-alist + `(fortran-mode (start . ,fortran-start-block-re) (end . ,fortran-end-block-re) + (c-start . "^[cC*!]") (forward-fn . fortran-end-of-block))) (defvar fortran-mode-syntax-table @@ -1247,7 +1247,7 @@ Directive lines are treated as comments." (goto-char i) (= (line-beginning-position) p))))) -;; Used in hs-special-modes-alist. +;; Used in hs-modes-alist. (defun fortran-end-of-block (&optional num) "Move point forward to the end of the current code block. With optional argument NUM, go forward that many balanced blocks. diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el index 6158253ee53..13ec1bf65c9 100644 --- a/lisp/progmodes/hideshow.el +++ b/lisp/progmodes/hideshow.el @@ -370,30 +370,48 @@ This is only used if `hs-indicator-type' is set to `margin' or nil." :version "31.1") ;;;###autoload -(defvar hs-special-modes-alist - ;; FIXME: Currently the check is made via - ;; (assoc major-mode hs-special-modes-alist) so it doesn't pay attention - ;; to the mode hierarchy. - '((c-mode "{" "}" "/[*/]" nil nil) - (c-ts-mode "{" "}" "/[*/]" nil nil) - (c++-mode "{" "}" "/[*/]" nil nil) - (c++-ts-mode "{" "}" "/[*/]" nil nil) - (bibtex-mode ("@\\S(*\\(\\s(\\)" 1)) - (java-mode "{" "}" "/[*/]" nil nil) - (java-ts-mode "{" "}" "/[*/]" nil nil) - (js-mode "{" "}" "/[*/]" nil) - (js-ts-mode "{" "}" "/[*/]" nil) - (mhtml-mode "{\\|<[^/>]*?" "}\\|]*[^/]>" "