[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
What's the right way to define a custom info path.
From: |
pierre . techoueyres |
Subject: |
What's the right way to define a custom info path. |
Date: |
Wed, 25 Nov 2015 16:45:07 +0100 (CET) |
** 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
- What's the right way to define a custom info path.,
pierre . techoueyres <=