From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pierre.techoueyres@free.fr Newsgroups: gmane.emacs.help Subject: What's the right way to define a custom info path. Date: Wed, 25 Nov 2015 16:45:07 +0100 (CET) Message-ID: <1603934532.294950108.1448466307513.JavaMail.root@spooler5n-g27.priv.proxad.net> References: <1139248550.294947690.1448466260727.JavaMail.root@spooler5n-g27.priv.proxad.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1448470190 15240 80.91.229.3 (25 Nov 2015 16:49:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Nov 2015 16:49:50 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 25 17:49:48 2015 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 1a1dGL-00019U-5g for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Nov 2015 17:49:45 +0100 Original-Received: from localhost ([::1]:46411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1dGM-0002fs-OS for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Nov 2015 11:49:46 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1cFs-0004HL-JP for help-gnu-emacs@gnu.org; Wed, 25 Nov 2015 10:45:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1cFp-0005Fo-LG for help-gnu-emacs@gnu.org; Wed, 25 Nov 2015 10:45:12 -0500 Original-Received: from smtp6-g21.free.fr ([2a01:e0c:1:1599::15]:43318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1cFp-0005E7-C6 for help-gnu-emacs@gnu.org; Wed, 25 Nov 2015 10:45:09 -0500 Original-Received: from spooler5n-g27.priv.proxad.net (unknown [172.20.243.237]) by smtp6-g21.free.fr (Postfix) with ESMTP id 4653582257 for ; Wed, 25 Nov 2015 16:44:45 +0100 (CET) In-Reply-To: <1139248550.294947690.1448466260727.JavaMail.root@spooler5n-g27.priv.proxad.net> X-Originating-IP: [90.83.102.195] X-Mailer: Zimbra 7.2.0-GA2598 (ZimbraWebClient - FF3.0 (Win)/7.2.0-GA2598) X-Authenticated-User: pierre.techoueyres@free.fr X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:e0c:1:1599::15 X-Mailman-Approved-At: Wed, 25 Nov 2015 11:49:08 -0500 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:108215 Archived-At: ** The context - I'm working on Windows 7 (but I think the Windows version is not important) with Emacs 24.5.1. - My Emacs is installed on c:/programmes/emacs (c:/programmes is a custom directory, not the standard Program Files which contains spaces). - I installed some packages with package.el : - org-plus-contrib - ecb - I extracted some packages from git versions on ~/.emacs.d/site-lisp : - tramp - cedet All packages have info files. ** My attempts I tried to setup everything properly to have Info display the right version of all manuals : - tramp in c:/programmes/emacs/share/emacs/24.5.50/lisp/net/ is superseded by the one in ~/.emacs.d/site-lisp/emacs-tramp an the info manual retrieved is the right one. - cedet in ~/.emacs.d/site-lisp/cedet is loaded before the one in c:/programmes/emacs an so on for the info manual - packages cedet superseded the one in emacs-core and Info display the latest manual ** what I've in my init.el First I've disabled autoexec of package initialize with `(setq package-enable-at-startup nil)' (this is needed to allow loading of custom cedet). Then I've added tramp's install dir to my load-path. Then defined a custom-file to ~/.emacs.d/custom.el Then add to my load-path cedet install dir and load the cedet-devel-load file which initialize everything. Then call package-initialize, and *after* load my custom-file. ** My problems First I tried to setup the Info-path with the custom variable `Info-default-directory-list' but that doesn't work, because of package-activate-1 which call info-initialize so the customization of Info-default-directory-list is done too late. And worse it's not correctly initialized !!! Next I try using `Info-directory-list' but to do so I must require info and call info-initialize in my init.el and I prefer to avoid that. Then I looked at `Info-additional-directory-list' which has the same problem as `Info-default-directory-list'. ** What I think should be done. 1) `Info-default-directory-list' should be correctly initialized for the emacs w32. 1) To do that env.el should provide an `w32-substitute-env-vars' to allow replacement of %var% strings with the corresponding env vars. 2) The defcustom of Info-default-directory-list should call (substitute-env-vars configure-info-directory) instead of configure-info-directory directly. 2) `package-activate-1' should not require info nor use `info-initialize'. Instead it should add info paths on `Info-default-directory-list' or `Info-additional-directory-list' (maybe the later). ** My questions Have I do something wrong with my config ? Should I set an INFOPATH env var with absolutes paths ? If the answer of the previous questions is : No, should I open bugs ? Sorry for the really long message and the poor english. ** Some patches #+BEGIN_SRC ediff 3 files changed, 46 insertions(+), 5 deletions(-) lisp/emacs-lisp/package.el | 9 +++++---- lisp/info.el | 2 +- lisp/w32-fns.el | 40 ++++++++++++++++++++++++++++++++++++++++ modified lisp/emacs-lisp/package.el @@ -690,10 +690,11 @@ package-activate-1 loaded-files-list)))) ;; Add info node. (when (file-exists-p (expand-file-name "dir" pkg-dir)) - ;; FIXME: not the friendliest, but simple. - (require 'info) - (info-initialize) - (push pkg-dir Info-directory-list)) + (unless (member pkg-dir Info-default-directory-list) + (push pkg-dir Info-default-directory-list)) + (when (and (bound-and-true-p Info-directory-list) + (not (member pkg-dir Info-directory-list))) + (push pkg-dir Info-directory-list))) (push name package-activated-list) ;; Don't return nil. t)) modified lisp/info.el @@ -186,7 +186,7 @@ Info-default-directory-list (or (and (featurep 'ns) (let ((dir (expand-file-name "../info" data-directory))) (if (file-directory-p dir) dir))) - configure-info-directory))) + (substitute-env-vars configure-info-directory)))) (prefixes ;; Directory trees in which to look for info subdirectories (prune-directory-list '("/usr/local/" "/usr/" "/opt/" "/"))) modified lisp/w32-fns.el @@ -340,4 +340,44 @@ w32-append-code-lines (delete-matching-lines "^$\\|^;") (save-buffers-kill-emacs t)) + +;;;; Support for environment variables +(defconst w32-env--substitute-vars-regexp + "%\\(?:\\(?1:[[:alnum:]_\-]+\\)%\\|%\\)") + +(defun w32-substitute-env-vars (string &optional when-undefined) + "Substitute environment variables referred to in STRING. +`%FOO%' where FOO is an environment variable name means to substitute +the value of that variable. The variable name should be terminated +with a character not a letter, digit or underscore; otherwise, enclose +the entire variable name in braces. For instance, in `ab%cd-x%', +`%cd-x%' is treated as an environment variable. + +If WHEN-DEFINED is nil, references to undefined environment variables +are replaced by the empty string; if it is a function, the function is called +with the variable name as argument and should return the text with which +to replace it or nil to leave it unchanged. +If it is non-nil and not a function, references to undefined variables are +left unchanged. + +Use `%%' to insert a single percent sign." + (let ((start 0)) + (while (string-match w32-env--substitute-vars-regexp string start) + (cond ((match-beginning 1) + (let* ((var (match-string 1 string)) + (value (getenv var))) + (if (and (null value) + (if (functionp when-undefined) + (null (setq value (funcall when-undefined var))) + when-undefined)) + (setq start (match-end 0)) + (setq string (replace-match (or value "") t t string) + start (+ (match-beginning 0) (length value)))))) + (t + (setq string (replace-match "%" t t string) + start (+ (match-beginning 0) 1))))) + string)) + +(defalias 'substitute-env-vars 'w32-substitute-env-vars)) + ;;; w32-fns.el ends here #+END_SRC