counsel-etags icon indicating copy to clipboard operation
counsel-etags copied to clipboard

fail to find ctags

Open Ynjxsjmh opened this issue 4 years ago • 3 comments

In your code you just simply tranverse c d etc. driver to find target program under cygwin bin.

(defun counsel-etags-win-path (executable-name drive)
  "Guess EXECUTABLE-NAME's full path in Cygwin on DRIVE."
  (let* ((path (concat drive ":\\\\cygwin64\\\\bin\\\\" executable-name ".exe")))
    (if (file-exists-p path) path)))

;;;###autoload
(defun counsel-etags-guess-program (executable-name)
  "Guess path from its EXECUTABLE-NAME on Windows.
Return nil if it's not found."
  (cond
   ((file-remote-p default-directory)
    ;; Assume remote server has already added EXE into $PATH!
    executable-name)
   ((eq system-type 'windows-nt)
    (or (counsel-etags-win-path executable-name "c")
        (counsel-etags-win-path executable-name "d")
        (counsel-etags-win-path executable-name "e")
        (counsel-etags-win-path executable-name "f")
        (counsel-etags-win-path executable-name "g")
        (counsel-etags-win-path executable-name "h")))
   (t
    (if (executable-find executable-name) (executable-find executable-name)))))

However, my cygwin bin dir is D:\SoftWare\cygwin64\bin which is added to $PATH$, so this program fails to detect my ctags.exe.

Though I can set counsel-etags-tags-program, why not also find cygwin path in $PATH$?

Ynjxsjmh avatar Apr 11 '20 13:04 Ynjxsjmh

(setq cygpath (car (cl-member "cygwin" exec-path :test #'string-match-p))) can get the cygwin path in PATH or cygpath is set to nil.

https://emacs.stackexchange.com/questions/28684 for reference.

Ynjxsjmh avatar Apr 11 '20 19:04 Ynjxsjmh

65298d8 windows setup (Chen Bin)

redguardtoo avatar Apr 13 '20 02:04 redguardtoo

Adding executable-name to that or block will keep it always true, the error message will change to something like below if someone didn't add cygwin path to PATH and his cygwin path is not directively under cde.. driver.

Scan at e:/sourcecode/morerssplz/
Failed to create tags file.
error=exited abnormally with code 255

command=find . \( -iwholename "*/.git" -or -iwholename "*/.svn" -or -iwholename "*/.cvs" -or -iwholename "*/.bzr" -or -iwholename "*/.hg" -or -iwholename "*/bin" -or -iwholename "*/fonts" -or -iwholename "*/images" -or -iwholename "*/.DS_Store" -or -iwholename "*/.npm" -or -iwholename "*/.tmp" -or -iwholename "*/.sass-cache" -or -iwholename "*/.idea" -or -iwholename "*/node_modules" -or -iwholename "*/bower_components" -or -iwholename "*/.tox" -or -iwholename "*/.vscode" -or -iwholename "*/.cask" \) -prune -o -type f -not -size +512k -not -name "*.log" -not -name "rusty-tags.vim" -not -name "rusty-tags.emacs" -not -name "tags" -not -name "TAGS" -not -name "*.tgz" -not -name "*.gz" -not -name "*.xz" -not -name "*.zip" -not -name "*.tar" -not -name "*.rar" -not -name "GTAGS" -not -name "GPATH" -not -name "GRTAGS" -not -name "cscope.files" -not -name "*bundle.js" -not -name "*min.js" -not -name "*min.css" -not -name "*.png" -not -name "*.jpg" -not -name "*.jpeg" -not -name "*.gif" -not -name "*.bmp" -not -name "*.tiff" -not -name "*.ico" -not -name "*.doc" -not -name "*.docx" -not -name "*.xls" -not -name "*.ppt" -not -name "*.pdf" -not -name "*.odt" -not -name ".clang-format" -not -name "*.obj" -not -name "*.so" -not -name "*.o" -not -name "*.a" -not -name "*.ifso" -not -name "*.tbd" -not -name "*.dylib" -not -name "*.lib" -not -name "*.d" -not -name "*.dll" -not -name "*.exe" -not -name ".metadata*" -not -name "*.class" -not -name "*.war" -not -name "*.jar" -not -name "*flymake" -not -name "#*#" -not -name ".#*" -not -name "*.swp" -not -name "*~" -not -name "*.elc" -not -name "*.pyc" -print | ctags -e  -L -

Not adding executable-name error message is more clear

You need install Ctags at first.  Universal Ctags is highly recommended.
if: Please install Ctags before running this program!

Ynjxsjmh avatar Apr 13 '20 14:04 Ynjxsjmh