From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: How to get the bounds of the current defun? Date: Sun, 08 Oct 2017 22:28:29 +0200 Message-ID: <87efqd9yfm.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1507494548 20852 195.159.176.226 (8 Oct 2017 20:29:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 8 Oct 2017 20:29:08 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.60 (gnu/linux) To: Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 08 22:29:00 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e1IC2-000409-NT for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Oct 2017 22:28:58 +0200 Original-Received: from localhost ([::1]:55027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1IC8-0001f2-Gb for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Oct 2017 16:29:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1IBh-0001ew-ED for help-gnu-emacs@gnu.org; Sun, 08 Oct 2017 16:28:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1IBd-0003rM-GA for help-gnu-emacs@gnu.org; Sun, 08 Oct 2017 16:28:37 -0400 Original-Received: from mout.web.de ([212.227.15.3]:58070) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e1IBd-0003r3-6o for help-gnu-emacs@gnu.org; Sun, 08 Oct 2017 16:28:33 -0400 Original-Received: from drachen.dragon ([92.74.174.244]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LjrYH-1dQ1cl2Osb-00boV4; Sun, 08 Oct 2017 22:28:30 +0200 X-Provags-ID: V03:K0:MlrSFa3LLHzkAgGs+0kWWAxYZwG75ffamnThhkAQ+UVczrj+BYa LQLr1ZrTxQTuaHFYXHqRHTRnt3+6P+yApuhAVg6YnLSxlRdA45ldrFLIKuyrisWHWEcPLcK S0JmWQLCzcna/PLiwkKyAl0IK3PqpwvZ6eAiSntrQGG4uw0BARdjqZ1/bp9pYjbFLw49tB2 66d3U39uwUzEprU8FLX4A== X-UI-Out-Filterresults: notjunk:1;V01:K0:VXcHttllb3Y=:LrszB0RrHsdP5Z6FQoXmUr GIMSzKSTQNXGBKSkH6nwC32ZnxqySqDfm+bc1R1HOWaf5hxelFdsIO32Cy0BwEyFOzUDRlLTJ IjnB0iPmqMprXBSLIM+Hg1d7D9Vx07sk+JZnGEkXh+r+WZ4t1oSHLk7E+8jI3m9GU2w93F6yJ Xzru8zeN4o3EcuFgLv1LWbW5lYK1G9A0wpR+uNOhVXzFpLIiasthmmO2tkhkjkQczcpqz6GaT AsrI1J7jOTymIHm8VmtPQH30Ja1UMo8nNlTn74Gawo7UrNVEiog3hPk5vBs+uaVxRNQNBDTk2 z66vlp6SH71tj/v2CTgFnNwqQaq5Btfrl85J6Zn75WJLHJ2jX3saClMse4IuQDu9BinkCkglq HatkqgqmseV3lzwMsDXcwaOKsLd3BjLsyHakAF9xGyxEX9QA/LIxqDAmK4Mldf2kdtbEmtD9s k3hlOfYaFrNheTwF4zBtXauEgSeu50VdbP1aQbksh4yE/zbn3IEi5+E3kIZsETOkNujNLPcAP iMmxhdV6NrPHMiHH349Ut3lRACv2gmZJ4p7EpvGw0SuL2uQRETFHD8WGC4Cb/ZMpMYc2joGHT 3hUDeqMWNK0b0v6c2kjJi4gTeHU+LNaoYjm6rjkuYzXLGfVu3xKmJmzU1X6GhdHCujcEMKk8Y yP5o7aZfxwByGu0OBsyODJE2PTOz2rpmsaiHu/MyFBdFjK/6gLR9CbjB3JXmZ0lS8wievZi42 Vd+Aztz8OvQREysSxVGBLOUpM4sq7LGzmx8wq4KzSW89c0+kSlC9Ee9IAEus3p4XOdSkkDfO X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.15.3 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114522 Archived-At: Hi, 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. This seems surprisingly hard, I can only think of solutions that are really complicated. The most complicated part is actually to find out whether the value is non-nil or nil. Not every toplevel expression needs to be a list! If POS is not inside a level of parens, I think I could use the second element ("character address of start of last complete sexp terminated") of `syntax-ppss' but that's still a bit of way from a result. There are really strange cases like the positions of space characters in symbol\ with\ spaces. I want to know if anyone knows some elegant solution I fail to see. TIA, Michael.