From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#37527: [PATCH] Install C source code for for debugging help Date: Thu, 26 Sep 2019 13:07:52 -0700 Message-ID: <20190926200752.12563-1-eggert@cs.ucla.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="31338"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Paul Eggert To: 37527@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 26 22:09:15 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iDa4g-0007wQ-KN for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Sep 2019 22:09:14 +0200 Original-Received: from localhost ([::1]:44104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDa4f-0000Ig-5m for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Sep 2019 16:09:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60355) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDa4W-0000IR-4L for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2019 16:09:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDa4U-0001cY-Ev for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2019 16:09:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36498) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iDa4U-0001cQ-Bi for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2019 16:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iDa4U-0007Yx-5B for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2019 16:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Sep 2019 20:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 37527 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.156952849728998 (code B ref -1); Thu, 26 Sep 2019 20:09:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Sep 2019 20:08:17 +0000 Original-Received: from localhost ([127.0.0.1]:45319 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iDa3k-0007Xd-DY for submit@debbugs.gnu.org; Thu, 26 Sep 2019 16:08:16 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:38943) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iDa3i-0007XU-EN for submit@debbugs.gnu.org; Thu, 26 Sep 2019 16:08:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60215) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDa3e-0000DD-Hd for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2019 16:08:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDa3a-0000kl-L5 for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2019 16:08:10 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:38742) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iDa3a-0000fG-D0 for bug-gnu-emacs@gnu.org; Thu, 26 Sep 2019 16:08:06 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 96BD316027C for ; Thu, 26 Sep 2019 13:08:02 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id OO2elc61FcdN; Thu, 26 Sep 2019 13:07:58 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E1B5916027B; Thu, 26 Sep 2019 13:07:58 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id mTj2yEvtnuJ1; Thu, 26 Sep 2019 13:07:58 -0700 (PDT) Original-Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id BC129160265; Thu, 26 Sep 2019 13:07:58 -0700 (PDT) X-Mailer: git-send-email 2.21.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:167330 Archived-At: Without this change, on typical GNU/Linux distributions like Debian, the first button of =E2=80=98C-h f car RET=E2=80=99 does not work because the source code for =E2=80=98car=E2=80=99 is not installed. Fix this by installing the (compressed) C source code along with the (compressed) Lisp source code that is already installed. This adds about 3 MB (about 2%) to the size of the installed files on my platform. * Makefile.in (install_srcdir, enable_install_srcdir): New macros. (epaths-force): Substitute PATH_SOURCE too. (exp_sourcesrcdir): Install copy of C source code if enable_install_srcdir says to. * configure.ac (install_srcdir): New var. Add support for --disable-install-srcdir (to disable installation of source) and for --enable-install-srcdir=3D'.' (to have Emacs refer to its source dir). * lisp/emacs-lisp/find-func.el (find-function-C-source): Also look for gzipped source files. * src/emacs.c (init_cmdargs): Set source-directory to be the same as installation-directory when running with an uninstalled Emacs. * src/epaths.in (PATH_SOURCE): New macro. * src/lread.c (syms_of_lread): When initializing source-directory, use PATH_SOURCE as-is if it is absolute; otherwise, use it relative to PATH_DUMPLOADSEARCH/.. as before. --- Makefile.in | 25 +++++++++++++++++++++++++ configure.ac | 19 +++++++++++++++++++ etc/NEWS | 6 ++++++ lisp/emacs-lisp/find-func.el | 5 ++++- src/emacs.c | 2 ++ src/epaths.in | 3 +++ src/lread.c | 8 ++++++-- 7 files changed, 65 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index aa11e6b0b7..6ffb8eb747 100644 --- a/Makefile.in +++ b/Makefile.in @@ -266,6 +266,10 @@ etcdir=3D # once. archlibdir=3D@archlibdir@ =20 +# Where to put installed source code, and whether to install it at all. +install_srcdir=3D@install_srcdir@ +enable_install_srcdir=3D@enable_install_srcdir@ + # Where to put the etc/DOC file. etcdocdir=3D@etcdocdir@ =20 @@ -374,6 +378,7 @@ epaths-force: -e 's;\(#.*PATH_BITMAPS\).*$$;\1 "${bitmapdir}";' \ -e 's;\(#.*PATH_X_DEFAULTS\).*$$;\1 "${x_default_search_path}";' \ -e 's;\(#.*PATH_GAME\).*$$;\1 $(PATH_GAME);' \ + -e 's;\(#.*PATH_SOURCE\).*$$;\1 "${install_srcdir}";' \ -e 's;\(#.*PATH_DOC\).*$$;\1 "${etcdocdir}";') && \ ${srcdir}/build-aux/move-if-change epaths.h.$$$$ src/epaths.h =20 @@ -624,6 +629,26 @@ install-arch-indep: done; \ ${GZIP_PROG} -9n "../etc/publicsuffix.txt"; \ } +ifneq ($(enable_install_srcdir),no) + -unset CDPATH; \ + umask 022; $(MKDIR_P) "$(DESTDIR)$(install_srcdir)/src" && \ + exp_sourcesrcdir=3D`cd "$(DESTDIR)$(install_srcdir)/src" && /bin/pwd` &= & \ + [ "`cd $(srcdir)/src && /bin/pwd`" =3D "$$exp_sourcesrcdir" ] || { \ + $(set_installuser); \ + printf 'Copying compressed C sources to %s ...\n' \ + "$(DESTDIR)$(install_srcdir)/src"; \ + for file in `cd $(srcdir) && echo src/*.[cm]`; do \ + installed_file=3D"$(DESTDIR)$(install_srcdir)/$$file" && \ + $(INSTALL_DATA) "$$file" "$$installed_file" && \ + [ -z "$(GZIP_PROG)" ] || { \ + rm -f "$$installed_file.gz" && \ + $(GZIP_PROG) -9n "$$installed_file" && \ + installed_file=3D$$installed_file.gz; \ + } || exit; \ + chown $$installuser "$$installed_file" || true; \ + done; \ + } +endif -chmod -R a+r "$(DESTDIR)${datadir}/emacs/${version}" ${COPYDESTS} =20 ## The above chmods are needed because "umask 022; tar ..." is not diff --git a/configure.ac b/configure.ac index 7435f2e8da..ac50e6e297 100644 --- a/configure.ac +++ b/configure.ac @@ -194,6 +194,7 @@ lisppath=3D'${locallisppath}:${standardlisppath}' etcdir=3D'${datadir}/emacs/${version}/etc' archlibdir=3D'${libexecdir}/emacs/${version}/${configuration}' +install_srcdir=3D'${datadir}/emacs/${version}' etcdocdir=3D'${datadir}/emacs/${version}/etc' gamedir=3D'${localstatedir}/games/emacs' =20 @@ -540,6 +541,21 @@ AC_DEFUN locallisppath=3D${enableval} locallisppathset=3Dyes fi) =20 +AC_ARG_ENABLE([install-srcdir], + [AS_HELP_STRING([--disable-install-srcdir], + [do not install low-level Emacs source code useful for debugging. + Use '--enable-install-srcdir=3D.' to have Emacs refer to the + source directory it was configured from.])], + [], + [enable_install_srcdir=3Dyes]) +case $enable_install_srcdir in + yes | no) ;; + .) install_srcdir=3D`cd "$srcdir" && /bin/pwd` || + AC_MSG_ERROR([cannot get srcdir name]) + enable_install_srcdir=3Dno;; + *) AC_MSG_ERROR([invalid install-srcdir]);; +esac + AC_ARG_ENABLE(checking, [AS_HELP_STRING([--enable-checking@<:@=3DLIST@:>@], [enable expensive checks. With LIST, @@ -2061,6 +2077,7 @@ AC_DEFUN dnl This one isn't really used, only archlibdir is. libexecdir=3D"\${ns_appbindir}/libexec" archlibdir=3D"\${ns_appbindir}/libexec" + install_srcdir=3D"\${ns_appresdir}" etcdocdir=3D"\${ns_appresdir}/etc" etcdir=3D"\${ns_appresdir}/etc" dnl FIXME maybe set datarootdir instead. @@ -5211,6 +5228,8 @@ AC_DEFUN AC_SUBST(x_default_search_path) AC_SUBST(etcdir) AC_SUBST(archlibdir) +AC_SUBST([enable_install_srcdir]) +AC_SUBST([install_srcdir]) AC_SUBST(etcdocdir) AC_SUBST(bitmapdir) AC_SUBST(gamedir) diff --git a/etc/NEWS b/etc/NEWS index 0a4ada3cc6..7643905256 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -125,6 +125,12 @@ removed configure options.) ** The distribution tarball now has test cases; 'make check' runs them. This is intended mostly to help developers. =20 +--- +** Emacs now installs a copy of its C source code, used for debugging he= lp. +For example, pressing the first button in the *Help* buffer generated +by 'C-h f car RET' now takes you to a copy of the C-language +implementation of the function 'car'. + --- ** Emacs now requires GTK 2.24 and GTK 3.10 for the GTK 2 and GTK 3 builds respectively. diff --git a/lisp/emacs-lisp/find-func.el b/lisp/emacs-lisp/find-func.el index 142c99edd4..2812ae6f22 100644 --- a/lisp/emacs-lisp/find-func.el +++ b/lisp/emacs-lisp/find-func.el @@ -245,7 +245,10 @@ find-function-C-source (let ((dir (or find-function-C-source-directory (read-directory-name "Emacs C source dir: " nil nil t))= )) (setq file (expand-file-name file dir)) - (if (file-readable-p file) + (if (or (file-readable-p file) + (let ((file-gz (concat file ".gz"))) + (and (file-readable-p file-gz) + (setq file file-gz)))) (if (null find-function-C-source-directory) (setq find-function-C-source-directory dir)) (error "The C source file %s is not available" diff --git a/src/emacs.c b/src/emacs.c index 21a05d337e..fa547b59f5 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -522,6 +522,7 @@ init_cmdargs (int argc, char **argv, int skip_args, c= har const *original_pwd) if (!NILP (etc_exists)) { Vinstallation_directory =3D Ffile_name_as_directory (d= ir); + Vsource_directory =3D Vinstallation_directory; break; } } @@ -547,6 +548,7 @@ init_cmdargs (int argc, char **argv, int skip_args, c= har const *original_pwd) { tem =3D Fexpand_file_name (build_string (".."), dir); Vinstallation_directory =3D Ffile_name_as_directory (t= em); + Vsource_directory =3D Vinstallation_directory; break; } } diff --git a/src/epaths.in b/src/epaths.in index 5fe35b64c8..4e15c3a3d6 100644 --- a/src/epaths.in +++ b/src/epaths.in @@ -73,5 +73,8 @@ along with GNU Emacs. If not, see . */ /* Where Emacs should store game score files. */ #define PATH_GAME "/usr/local/var/games/emacs" =20 +/* Where Emacs should look for installed sources. */ +#define PATH_SOURCE "/usr/local/share/emacs" + /* Where Emacs should look for the application default file. */ #define PATH_X_DEFAULTS "/usr/lib/X11/%L/%T/%N%C%S:/usr/lib/X11/%l/%T/%N= %C%S:/usr/lib/X11/%T/%N%C%S:/usr/lib/X11/%L/%T/%N%S:/usr/lib/X11/%l/%T/%N= %S:/usr/lib/X11/%T/%N%S" diff --git a/src/lread.c b/src/lread.c index 5000b38a01..849632a7ec 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4979,9 +4979,13 @@ syms_of_lread (void) DEFVAR_LISP ("source-directory", Vsource_directory, doc: /* Directory in which Emacs sources were found when Emacs w= as built. You cannot count on them to still be there! */); + char const *path_source =3D PATH_SOURCE; Vsource_directory - =3D Fexpand_file_name (build_string ("../"), - Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH, 0))); + =3D (file_name_absolute_p (path_source) + ? build_string (path_source) + : Fexpand_file_name (build_string ("../" PATH_SOURCE), + Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH, + false)))); =20 DEFVAR_LISP ("preloaded-file-list", Vpreloaded_file_list, doc: /* List of files that were preloaded (when dumping Emacs). = */); --=20 2.21.0