From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: display just defuns and doc-strings of elisp Date: Mon, 12 May 2014 07:16:05 +0200 Message-ID: <87siofvap6.fsf@zigzag.favinet> References: <20140511144013.517b5ccd@gauss> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1399871535 21763 80.91.229.3 (12 May 2014 05:12:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 12 May 2014 05:12:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon May 12 07:12:08 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WjiX0-0006lf-Df for geh-help-gnu-emacs@m.gmane.org; Mon, 12 May 2014 07:12:06 +0200 Original-Received: from localhost ([::1]:35327 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjiWz-00081Q-Vt for geh-help-gnu-emacs@m.gmane.org; Mon, 12 May 2014 01:12:05 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjiWi-00081J-TT for help-gnu-emacs@gnu.org; Mon, 12 May 2014 01:11:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WjiWY-0006HF-A2 for help-gnu-emacs@gnu.org; Mon, 12 May 2014 01:11:48 -0400 Original-Received: from smtp208.alice.it ([82.57.200.104]:2581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WjiWX-0006Gy-Um for help-gnu-emacs@gnu.org; Mon, 12 May 2014 01:11:38 -0400 Original-Received: from zigzag.favinet (79.51.120.119) by smtp208.alice.it (8.6.060.28) id 52443B822AD016BA for help-gnu-emacs@gnu.org; Mon, 12 May 2014 07:11:36 +0200 Original-Received: from ttn by zigzag.favinet with local (Exim 4.80) (envelope-from ) id 1Wjib3-0007w3-6C for help-gnu-emacs@gnu.org; Mon, 12 May 2014 07:16:17 +0200 Mail-Followup-To: help-gnu-emacs@gnu.org In-Reply-To: <20140511144013.517b5ccd@gauss> (Joe Riel's message of "Sun, 11 May 2014 14:40:13 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.57.200.104 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:97608 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable () Joe Riel () Sun, 11 May 2014 14:40:13 -0700 Is there an existing elisp function that displays just the defs [first line] and doc-strings in an elisp source buffer? I don't think so. However, you can use hideshow like so: (defun display-docstring-and-code-line-counts (ov) (when (eq 'code (overlay-get ov 'hs)) (let ((beg (overlay-start ov)) (end (overlay-end ov))) (save-excursion (goto-char (overlay-start ov)) (forward-line 1) (when (looking-at "\\s-*\"") (forward-sexp 1) (cond ((eolp) ;; purposeful (forward-line 1) (skip-chars-forward "[:space:]") (move-overlay ov (setq beg (point)) end)) (t=20 ;; unbearable lightness (delete-overlay ov) (setq ov nil))))) (when ov (overlay-put ov 'display (propertize=20 (format " ... / %d" (count-lines beg end)) 'face 'font-lock-warning-face)))))) =20 (setq hs-set-up-overlay 'display-docstring-and-code-line-counts) =20 The line-count stuff is because this code is dervived from the example given in `C-h v hs-set-up-overlay'. The important part is the call to =E2=80=98move-overlay=E2=80=99. Readers of source code (src/bu= ffer.c) will note that =E2=80=98delete-overlay=E2=80=99 returns nil, but that is not documented. Had it been, i would have reversed the sense of the innermost COND and used IF: (if (not (eolp)) ;; unbearable lightness (setq ov (delete-overlay ov)) ;; purposeful (forward-line 1) (skip-chars-forward "[:space:]") (move-overlay ov (setq beg (point)) end)) But that's just a question of style. Mogrify at will, YMMV, etc... =20 =2D-=20 Thien-Thi Nguyen GPG key: 4C807502 (if you're human and you know it) read my lisp: (responsep (questions 'technical) (not (via 'mailing-list))) =3D> nil --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlNwWRkACgkQZwMiJEyAdQLsSwCfb3dWGhcb2apQY0DqQjQiBLYE WQYAoMgM2/XKCEmEx3ZaIbZpyJNn/u1T =9rFo -----END PGP SIGNATURE----- --=-=-=--