From: Shiyuan <gshy2014@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: hideshow minor-mode
Date: Tue, 16 Oct 2012 09:40:40 -0500 [thread overview]
Message-ID: <CAOm4EMsqvoy0ud8z-2w0gR9iP3eQikMDtHROo0CNR5Mxp29pDg@mail.gmail.com> (raw)
In-Reply-To: <87mwznhu6f.fsf@web.de>
[-- Attachment #1: Type: text/plain, Size: 2137 bytes --]
Michael,
That works. Thank you very much for guiding me into the world of Lisp.
Shiyuan
On Tue, Oct 16, 2012 at 12:17 AM, Michael Heerdegen <
michael_heerdegen@web.de> wrote:
> Hi again,
>
> > Michael,
> > Thanks for the detailed reply. However, it doesn't work for me. I
> > guess I make a mistake somewhere. Here is mymode.el:
> >
> > http://paste.lisp.org/display/132611
>
> Yes, there are two little errors.
>
> First, you register your mode in `hs-special-modes-alist' after you
> enable hs-minor-mode. That's too late, because hideshow then has
> already initialized its stuff. Also, adding to `hs-special-modes-alist'
> has to be done only once, and not every time mymode is enabled.
>
> Second, you quoted mymode-forward-sexp-func in your quoted list:
>
> | '(mymode "\\[begin]" "\\[end]" "#" 'mymode-forward-sexp-func nil))
> ^
>
> That's not needed, remember, the quote before a list already prevents
> evaluation of its members (you want to specify a symbol).
>
> So, this should do the trick:
>
> --8<---------------cut here---------------start------------->8---
> (require 'hideshow)
>
> (defun mymode-forward-sexp-func (arg)
> "move over ARG balanced blocks; This is needed by hs-minor-mode"
> (dotimes (number arg)
> (let ((counter 0))
> (catch 'done
> (while t
> (search-forward-regexp "\\[begin]\\|\\[end]")
> (setq counter (+ counter (if (looking-back "\\[begin]") 1 -1)))
> (when (= counter 0) (throw 'done t)))))))
>
> (add-to-list 'hs-special-modes-alist '(mymode "\\[begin]" "\\[end]" "#"
> mymode-forward-sexp-func))
>
> (define-derived-mode mymode fundamental-mode
> "mymode is a major mode for fun."
> (setq mode-name "mymode")
> (setq comment-start "#")
> (setq comment-end "")
> (hs-minor-mode 1))
> --8<---------------cut here---------------end--------------->8---
>
> Of course, that's all just for playing. If mymode was a major-mode
> really to be used, you would leave it up to the user to call
> `hs-minor-mode' e.g. in `mymode-hook', and not call it in the mode
> definition.
>
>
> Michael.
>
>
[-- Attachment #2: Type: text/html, Size: 2990 bytes --]
next prev parent reply other threads:[~2012-10-16 14:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.11001.1350265231.855.help-gnu-emacs@gnu.org>
2012-10-15 18:04 ` hideshow minor-mode Michael Heerdegen
2012-10-15 23:30 ` Shiyuan
[not found] ` <mailman.11078.1350343816.855.help-gnu-emacs@gnu.org>
2012-10-16 1:03 ` Michael Heerdegen
2012-10-16 4:20 ` Shiyuan
[not found] ` <mailman.11086.1350361261.855.help-gnu-emacs@gnu.org>
2012-10-16 5:17 ` Michael Heerdegen
2012-10-16 14:40 ` Shiyuan [this message]
[not found] ` <mailman.11111.1350398455.855.help-gnu-emacs@gnu.org>
2012-10-16 18:09 ` Michael Heerdegen
2012-10-15 1:40 Shiyuan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOm4EMsqvoy0ud8z-2w0gR9iP3eQikMDtHROo0CNR5Mxp29pDg@mail.gmail.com \
--to=gshy2014@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.