Emacs Is Ignoring My Path When It Runs a Compile Command

Emacs is ignoring my path when it runs a compile command

A small modification to the solution by sanityinc (couldn't find a way to enter it in the comments above -- is that just me?)

  • I use -l option to the shell to force a login shell (which reads .profile or .bash_profile), rather than an interactive shell (which only reads .bashrc).
  • I do some string trimming on the returned path (as inspection shows a newline sneaking in).

Modified code:

(defun set-exec-path-from-shell-PATH ()
(let ((path-from-shell
(replace-regexp-in-string "[[:space:]\n]*$" ""
(shell-command-to-string "$SHELL -l -c 'echo $PATH'"))))
(setenv "PATH" path-from-shell)
(setq exec-path (split-string path-from-shell path-separator))))
(when (equal system-type 'darwin) (set-exec-path-from-shell-PATH))

Emacs Unable to Find Python.exe When Exec-Path Loaded (Windows 8.1)

It's a bit odd, but it seems that explicitly setting the exec-path in this way was what was causing the problem. After a little bit of fiddling around with alternative means of setting the exec-path (to avoid the listp problem) I found that using:

(add-to-list 'load-path "~/folder/foo")
(add-to-list 'load-path "~/folder/foo")

instead of setq exec-path worked just fine in terms of letting me use my binaries and in letting me get to Python, too. Solution is posted in case anyone else has a similar issue (students and self-taught users like myself especially).

Note: I did not add the location of my Python executable to my .emacs file in any way, just the environmental variable Path in Windows. This was sufficient for Emacs to find the executable.

Byte compile emacs lisp file: Error: Cannot open load file

You need to put dired+.el in your load-path.

dired+.el explicitly does this:

(provide 'dired+)
(require 'dired+) ; Ensure loaded before compile this.

This is an Emacs-Lisp idiom that ensures that the library is loaded before compiling it. For Dired+ this is appropriate.

So do this:

(add-to-list 'load-path "/your/path/to/dired+/")

The relevant doc for the idiom used here is (elisp) Named Features. Here is a bit of it:

Although top-level calls to `require' are evaluated during byte
compilation, `provide' calls are not. Therefore, you can ensure that a
file of definitions is loaded before it is byte-compiled by including a
`provide' followed by a `require' for the same feature, as in the
following example.

(provide 'my-feature) ; Ignored by byte compiler,
; evaluated by `load'.
(require 'my-feature) ; Evaluated by byte compiler.

The compiler ignores the `provide', then processes the `require' by
loading the file in question. Loading the file does execute the
`provide' call, so the subsequent `require' call does nothing when the
file is loaded.

ansi-term won't find file under current directory?

Does the same thing happen when you start Emacs without your init file, i.e., emacs -Q? If so, that's the designed behavior or (especially if you use a development snapshot) perhaps an Emacs bug.

If not, then bisect your init file recursively to find out which part of it causes this behavior. To do that, use, e.g., command comment-region (see prefix arg in doc) to comment and uncomment a block of text. Comment out 1/2 of your init file, then 3/4, then 7/8,...,
each time testing whether the uncommented portion causes or removes the problematic behavior. You will very quickly identify what causes the behavior.

Run multi-string bash script from Emacs

Multiline commands are fine to provide as an argument to bash -c if you quote them as you would any other shell argument that might contain shell metacharacters, e.g.:

(setq my-command
(concat "IFS=: read -ra dirs <<<\"$PATH\"\n"
"for dir in ${dirs[@]}; do\n"
" echo got dir \"$dir\"\n"
"done\n"))

(shell-command (format "bash -c %s" (shell-quote-argument my-command)))

How to make Emacs pickup the correct python in Snow Leopard?

Edit /etc/path (as an administrator) and move the line /usr/local/bin to the top of the file.

compile package is not loaded in chez scheme

You have to buy the compile package. Instructions at www.scheme.com.

how to configure emacs to start in a directory (windows)

Create a Windows shortcut to the Emacs executable, and use that to start Emacs. Create the shortcut by right-clicking the file runemacs.exe in folder bin and choosing Create shortcut.

Then fill out the Properties in the Shortcut tab:

Field Target has the command for starting Emacs: the location and name of the binary (executable) followed by whatever options you want and any file or directory that you want to start editing.

Field Start in has the directory that I want Emacs to start in.

For example:

  • Target: D:\Emacs-25.1\bin\runemacs.exe --debug-init "d:\usr\some-user-name\some-directory"

  • Start in: d:\usr\some-user-name\some-directory

Then just double-click your shortcut to start Emacs. Or single-click it, if you pin it to the Task Bar.

You can create as many such shortcuts as you want, either to the same Emacs executable (e.g. with different options or startup directories) or to different executables (e.g. different Emacs releases).



Related Topics



Leave a reply



Submit