|
|
||
|
hi,
here is some code for .emacs. Although looks kind of discusting, it
works on my machine(GNU Emacs 22).
Hope it would be useful for you :-)
;;; code starts
(require 'lua-mode)
(add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-mode))
; for hs-minor-mode
(defvar lua-sexp-alist '(("then" . "end")
("function" . "end")
("do" . "end")))
(defun lua-forward-sexp (&optional arg)
"Forward to block end"
(save-match-data
(let ((stackheight 0)
(regexp ""))
(setq regexp (concat "\\(" (mapconcat 'car lua-sexp-alist "\\|")
"\\|end\\)"))
(re-search-forward regexp nil t arg)
(setq stackheight 1)
(while (> stackheight 0)
(re-search-forward regexp nil t arg)
(if (string= "end" (match-string 1))
(setq stackheight (- stackheight 1))
(setq stackheight (+ stackheight 1)))))))
(add-to-list 'hs-special-modes-alist
`(lua-mode ,(concat "\\(?:" (mapconcat 'car
lua-sexp-alist "\\|") "\\)")
,(concat "\\(?:" (mapconcat 'cdr lua-sexp-alist "\\|") "\\)")
"--" ; comment prefix
lua-forward-sexp))
(defun my-lua-hook()
(interactive)
(hs-minor-mode 1)
; key bindings
(local-set-key [?\C-,] 'hs-hide-block)
(local-set-key [?\C-.] 'hs-show-block)
)
(add-hook 'lua-mode-hook 'my-lua-hook)
;;; code ends
I appreciate the help from Ye WinBin
2006/9/25, Jürgen Hötzel <juergen@hoetzel.info>:
There is no support for hideshow in lua-mode yet. Jürgen On Sun, Sep 24, 2006 at 04:10:05PM +0800, tsong chong wrote: > Hi, > > I'm using emacs lua-mode, and wondering how to fold code blocks > > I've tried M-x hs-minor-mode, and select Hide Block in the Hide/Show menu. > But nothing happened. > > > Thanks and best regards, > > Tsong Chong