From: Emanuel Berg <moasen@zoho.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to get the bounds of the current defun?
Date: Sun, 08 Oct 2017 23:00:51 +0200 [thread overview]
Message-ID: <86efqdqrr0.fsf@zoho.com> (raw)
In-Reply-To: 87efqd9yfm.fsf@web.de
Michael Heerdegen wrote:
> I need a function that for any elisp mode
> buffer receives a position as argument and
> returns non-nil if inside a defun (i.e.
> when there is a top-level expression covering
> POS). If this is the case, the return value
> is a cons (BEG . END) where BEG and END are
> the beginning and end positions of this
> toplevel sexp.
(defun is-defun ()
(interactive)
(save-excursion
(let ((pos (point))
(start (progn (beginning-of-defun) (point)))
(end (progn (end-of-defun) (point))) )
(when (and (<= start pos)
(<= pos end) )
(cons start end) ))))
Hm, it seems `end-of-defun' is a bit too
generous - perhaps that can be replaced...
--
underground experts united
http://user.it.uu.se/~embe8573
next prev parent reply other threads:[~2017-10-08 21:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-08 20:28 How to get the bounds of the current defun? Michael Heerdegen
2017-10-08 21:00 ` Emanuel Berg [this message]
2017-10-08 22:21 ` Michael Heerdegen
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=86efqdqrr0.fsf@zoho.com \
--to=moasen@zoho.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.