[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Proposed patch - Better choice of default for gtags-visit-rootdir
From: |
Earl Chew |
Subject: |
Proposed patch - Better choice of default for gtags-visit-rootdir |
Date: |
Sat, 26 Sep 2015 13:56:18 -0700 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
When in a file buffer that resides in what will be the gtags
root directory (because the GTAGS et al have not yet been created),
invoking gtags-visit-rootdir and pressing RETURN to accept the
default results in the file being chosen rather than the
(displayed) directory.
This is because read-file-name is using the absolute file name
of the file:
> If both default and initial are nil and the buffer is visiting
> a file, read-file-name uses the absolute file name of that
> file as default.
--- gtags.el 2015-09-14 19:48:17.000000000 -0700
+++ ../share/gtags/gtags.el 2015-09-26 13:22:52.490185835 -0700
@@ -515,13 +515,17 @@
(defun gtags-visit-rootdir ()
"Tell tags commands the root directory of source tree."
(interactive)
- (let (path input)
+ (let (path input default-path)
(setq path gtags-rootdir)
(if (not path)
(setq path (gtags-get-rootpath)))
(if (not path)
(setq insert-default-directory (if (string-match
gtags-tramp-path-regexp default-directory) nil t)))
- (setq input (read-file-name "Visit root directory: " path path t))
+ (setq default-path
+ (if (and insert-default-directory (not path))
+ default-directory
+ path))
+ (setq input (read-file-name "Visit root directory: " path
default-path t))
(if (equal "" input) nil
(if (not (file-directory-p input))
(message "%s is not directory." input)
- Proposed patch - Better choice of default for gtags-visit-rootdir,
Earl Chew <=