A formatted input file (*.alm
) often contains a large section of columned data. To fold this and improve navigation, I've tried to implement a hs-special-mode-alist
entry from hideshow.el
.
(setq hs-special-modes-alist
'((alamo-mode "begin_data" "end_data" "#" alamo-forward-sexp nil)))
After executing the the bare bones mode in the footer and opening `test.alm',
# Name: test.alm
# Long comments
# Like this will fold
BEGIN_DATA # This will not fold
1 2 3
1 2 3
1 2 3
END_DATA
running M-x hs-hide-all
results in:
# Name: test.alm...
begin_data # This will not fold
1 2 3
1 2 3
1 2 3
end_data
Despite my list declaration including a begin_data
/ end_data
pairing, the block is ignored. I expected the buffer to look like:
# Name: test.alm...
begin_data ... end_data
Is there a reason why hideshow.el
doesn't recognize and hide the begin_data
/ end_data
block or am I missing something in my usage or declarations?
To fold test.alm
load the following file:
;;; Demo code
(defun alamo-forward-sexp (&optional arg)
"Search forward to the next alamo option or begin/end of a data block.
ARG defines the forward or backwards count for the search."
(interactive "p")
(or arg (setq arg 1))
(re-search-forward "\\<\\(\\(begin\\|end\\)_data\\)\\>" nil nil arg))
(setq hs-special-modes-alist
'((alamo-mode "begin_data" "end_data" "#" alamo-forward-sexp nil)))
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.alm\\'" . alamo-mode))
;;;###autoload
(define-derived-mode alamo-mode prog-mode "ALAMO"
"A major mode for editing ALAMO input files. (*.alm)"
(setq-local comment-start "#") ; required for hs-minor-mode
(hs-minor-mode 1))
(provide 'alamo-mode)