[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Set the default-directory dynamically according to the buffer-file-name.
From: |
Hongyi Zhao |
Subject: |
Set the default-directory dynamically according to the buffer-file-name. |
Date: |
Wed, 29 Sep 2021 22:31:20 +0800 |
I wrote the following function to set the default-directory
dynamically according to the buffer-file-name:
(defun my/default-directory ()
(let ((file (buffer-file-name)))
(if (not file)
(message "no file name here.")
(setq default-directory (file-name-directory (buffer-file-name))))))
Then I apply this function to specific hooks, say, python-mode-hook.
This will make it easier for me to invoke files using the relative
path of each project. I want to know if this is a good practice.
Regards
--
Assoc. Prof. Hongyi Zhao <hongyi.zhao@gmail.com>
Theory and Simulation of Materials
Hebei Vocational University of Technology and Engineering
No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province
- Set the default-directory dynamically according to the buffer-file-name.,
Hongyi Zhao <=
- Re: Set the default-directory dynamically according to the buffer-file-name., Hongyi Zhao, 2021/09/29
- Re: Set the default-directory dynamically according to the buffer-file-name., Tassilo Horn, 2021/09/29
- Re: Set the default-directory dynamically according to the buffer-file-name., Hongyi Zhao, 2021/09/29
- Re: Set the default-directory dynamically according to the buffer-file-name., Emanuel Berg, 2021/09/29
- Re: Set the default-directory dynamically according to the buffer-file-name., Hongyi Zhao, 2021/09/30
- Re: Set the default-directory dynamically according to the buffer-file-name., Emanuel Berg, 2021/09/30
- Re: Set the default-directory dynamically according to the buffer-file-name., Hongyi Zhao, 2021/09/30
- Re: Set the default-directory dynamically according to the buffer-file-name., Emanuel Berg, 2021/09/30
RE: [External] : Set the default-directory dynamically according to the buffer-file-name., Drew Adams, 2021/09/29