Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using buffer-name causes potential errors #15

Closed
terlar opened this issue May 17, 2019 · 0 comments · Fixed by #16
Closed

Using buffer-name causes potential errors #15

terlar opened this issue May 17, 2019 · 0 comments · Fixed by #16

Comments

@terlar
Copy link
Contributor

terlar commented May 17, 2019

buffer-name does not always return the actual file-name. If you have multiple buffers with the same conflicting name it could be renamed, as well as personally I have custom code displaying different buffer-name based on project.

E.g.

(defun +projectile-relative-buf-name ()
  (when (buffer-file-name)
    (let ((buffer-name (if (projectile-project-p)
                           (concat (projectile-project-name) "/" (file-relative-name (buffer-file-name) (projectile-project-root)))
                         (abbreviate-file-name (buffer-file-name)))))
      (rename-buffer buffer-name t))))
(add-hook 'find-file-hook #'+projectile-relative-buf-name)

In those cases you will get, since the buffer-name is passed as --stdin-filename:

Error: ENOENT: no such file or directory, scandir '/path/to/src/code'

One work-around is to instead use buffer-file-name which will give the absolute path to the file.

terlar added a commit to terlar/flymake-eslint that referenced this issue May 17, 2019
Use buffer-file-name which will return the full path file name which
should be compatible with --stdin-filename

Fixes orzechowskid#15
orzechowskid pushed a commit that referenced this issue May 17, 2019
* use buffer-file-name instead of buffer-name

Use buffer-file-name which will return the full path file name which
should be compatible with --stdin-filename

Fixes #15

* update contributor header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant