start-up – La variable emacs command-line-default-directory no está configurada correctamente

Pregunta:

Estoy usando Emacs en Windows.

También tengo una VM VirtualBox a la que me conecto usando plink.

Pero luego, cuando uso el eshell, y hago cd <some folder> , me dice que No such directory found via CDPATH environment variable aunque inicié el eshell desde un búfer directo y escribí directamente la cd folder .

Creo que la clave es hacer que esta variable command-line-default-directory siga el directorio donde se abre el búfer.

Solo para reiterar mi pregunta, suponga que estoy en C://plink:<username>@<ip>:/home/asti/folder , quiero poder escribir cd foldername C://plink:<username>@<ip>:/home/asti/folder y no obtener el error No such directory found via CDPATH environment variable .

Respuesta:

Resolví esto con la siguiente función sobrecargada:

(defun cd (dir)
  "Make DIR become the current buffer's default directory.
If your environment includes a `CDPATH' variable, try each one of
that list of directories (separated by occurrences of
`path-separator') when resolving a relative directory name.
The path separator is colon in GNU and GNU-like systems."
  (interactive
   (list
    ;; FIXME: There's a subtle bug in the completion below.  Seems linked
    ;; to a fundamental difficulty of implementing `predicate' correctly.
    ;; The manifestation is that TAB may list non-directories in the case where
    ;; those files also correspond to valid directories (if your cd-path is (A/
    ;; B/) and you have A/a a file and B/a a directory, then both `a' and `a/'
    ;; will be listed as valid completions).
    ;; This is because `a' (listed because of A/a) is indeed a valid choice
    ;; (which will lead to the use of B/a).
    (minibuffer-with-setup-hook
        (lambda ()
          (setq minibuffer-completion-table
                (apply-partially #'locate-file-completion-table
                                 cd-path nil))
          (setq minibuffer-completion-predicate
                (lambda (dir)
                  (locate-file dir cd-path nil
                               (lambda (f) (and (file-directory-p f) 'dir-ok))))))
      (unless cd-path
        (setq cd-path (or (parse-colon-path (getenv "CDPATH"))
                          (list "./"))))
      (read-directory-name "Change default directory: "
                           default-directory default-directory
                           t))))
  (unless cd-path
    (setq cd-path (or (parse-colon-path (getenv "CDPATH"))
                      (list "./"))))
  (cd-absolute
   (or (locate-file dir (cons default-directory cd-path) nil
                    (lambda (f) (and (file-directory-p f) 'dir-ok)))
       (error "No such directory found via CDPATH environment variable"))))

Esto antepone, en la tercera desde la última línea, default-directory a cdpath (predeterminado ("./") ), que soluciona lo que parece ser un error con Windows Emacs locate-file-internal . ¡Puede tener efectos secundarios imprevistos!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

web tasarım