emacs projectile: override vcs mode - emacs

GNU Emacs 24.3.1 + projectile 0.11.0 (installed using melpa)
When I try to find a file (C-c p f) in an svn project (https) it takes ages before the completion comes up. Additionally I require a secure VPN connection which is not always active.
From the debug stacktrace (see below) I suspect it's due to the svn list (which is also very slow when I run it on command line).
Projectile is automatically selecting the svn mode because it recognized this project as an svn project however that's not strictly required for me. I'd be fine if projectile would just do a local find (projectile-generic-command)
My questions:
Does projectile allow me to configure/override the vcs mode somehow (e.g. through .projectile file)?
I know I can switch to native indexing mode, however I don't want to do that globally. How would I set that up for this project only?
Any other solutions?
Stacktrace from the debug-on-quit:
Debugger entered--Lisp error: (quit)
call-process("/bin/bash" nil t nil "-c" "svn list -R . | grep -v '$/' | tr '\\n' '\\0'")
apply(call-process "/bin/bash" nil t nil ("-c" "svn list -R . | grep -v '$/' | tr '\\n' '\\0'"))
process-file("/bin/bash" nil t nil "-c" "svn list -R . | grep -v '$/' | tr '\\n' '\\0'")
shell-command-to-string("svn list -R . | grep -v '$/' | tr '\\n' '\\0'")
projectile-files-via-ext-command("svn list -R . | grep -v '$/' | tr '\\n' '\\0'")
projectile-get-repo-files()
projectile-dir-files-external("<svn_path>" "<svn_path>")
projectile-dir-files("<svn_path>")
#[(it) "^H !\207" [fn it] 2]("<svn_path>")
mapcar(#[(it) "^H !\207" [fn it] 2] ("<svn_path>"))
-mapcat(projectile-dir-files ("<svn_path>"))
projectile-current-project-files()
projectile-find-file(nil)
call-interactively(projectile-find-file nil nil)

Related

Why "-n" is commonly used for dry-run?

Well known commands like make, rsync, and, git use -n option for dry-run.
What does -n stand for in this context?
My guess is that it's because dry-run contains the letter n and because d and r are already used:
$ make --help | grep '^ *-[dr]'
-d Print lots of debugging information.
-r, --no-builtin-rules Disable the built-in implicit rules.
$ rsync --help | grep '^ *-[dr]'
-r, --recursive recurse into directories
-d, --dirs transfer directories without recursing

How do I fuzzy find all files containing specific text using ripgrep and fzf and open it VSCode

I have the following command to fuzzy find files in the command line and to open the selected file in VSCode.:
fzf --print0 -e | xargs -0 -r code
Now I want to be able to search also file contents for a string. I am able to find the searched string in the command line:
rg . | fzf --print0 -e
but now it does not work anymore to open the file in VSCode using this command:
rg . | fzf --print0 -e | xargs -0 -r code
because to VSCode is passed a file name which contains the file name itself and the search string which is of course an empty file.
How can I combine to two above commands to pass the file name to VSCode which contains the searched string?
The --vimgrep option to rg returns just what the doctor ordered. That's what I used in the vscode extension issue request you put in:
https://github.com/rlivings39/vscode-fzf-quick-open/commit/101a6d8e44b707d11e661ca10aaf37102373c644
It returns data like:
$ rg --vimgrep
extension.ts:5:5:let fzfTerminal: vscode.Terminal | undefined = undefined;
extension.ts:6:5:let fzfTerminalPwd: vscode.Terminal | undefined = undefined;
Then you can cut out the first 3 fields and pass them to code -g:
rg --vimgrep --color ansi | fzf --ansi --print0 | cut -z -d : -f 1-3 | xargs -0 -r code -g

How can I get this bash sub shell to work in Fish?

I'm trying to get this command line working in Fish.
git show $(git log --pretty=oneline | fzf | cut -d ' ' -f1)
What is supposed to happen is git log --pretty=oneline | fzf | cut -d ' ' -f1 lets you select a commit interactively from git log and then returns the commit hash which is passed to git show.
I thought Fish uses parentheses for "subcommands" but this doesn't work.
git show (git log --pretty=oneline | fzf | cut -d ' ' -f1)
It goes straight to the default output of git show which is the HEAD commit.
I suspect my idea of how the shell works is incorrect. Any help appreciated.
UPDATE
This is the output from the pipeline
$ git log --pretty=oneline | fzf | cut -d ' ' -f1
3eb7a8fa09ac94cf4a76109b896f7ba58959f5a8
UPDATE 2
As answered by #faho, this is a bug in Fish.
You can workaround for now by using a tempfile
git log --pretty=oneline | fzf | cut -d ' ' -f1 > $TMPDIR/fzf.result; and git show (cat $TMPDIR/fzf.result)`
Or, more succinctly using xargs
git log --pretty=oneline | fzf | cut -d ' ' -f1 | xargs -o git show
This is fish issue #1362, which is also mentioned in fzf's readme.
There's an easy workaround: Instead of a command substitution, use read, like
git log --pretty=oneline | fzf | cut -d ' ' -f 1 | read -l answer
git show $answer
(fzf currently uses a tempfile in its fish bindings, but I'm working on rectifying that)

How to copy Zsh aliases to Eshell

I'm trying to copy using the command provided in here. That is,
alias | sed -E "s/^alias ([^=]+)='(.*)'$/alias \1 \2 \$*/g; s/'\\\''/'/g;" >~/.emacs.d/eshell/alias
This worked with Bash, I was using Emacs-Starter-Kit; but not working with Zsh -- not working means it copied things but to no effect.
[As a side note]
It seems like, I don't have few Eshell default variables i.e. eshell-read-aliases-list, and eshell-aliases-file. So, I even don't know where should my Eshell alias file reside.
Got it working after setting
(setq eshell-directory-name (expand-file-name "./" (expand-file-name "eshell" prelude-personal-dir)))
in post.el (my personal .el file for post-processing) under prelude/personal
... and modified the given bash command to
alias | awk '{print "alias "$0}' | sed -E "s/^alias ([^=]+)='(.*)'$/alias \1 \2 \$*/g; s/'\\\''/'/g;" > ~/.emacs.d/personal/eshell/alias
... and appended that to .zshrc.
Found that alias command, in zsh, prints aliases without prefix alias<space>, unlike bash. Therefore this part
| awk '{print "alias "$0}'

Why emacsclient can't find socket after executing 'emacs --daemon'

It is so confusing that emacsclient said it can't find socket just after executing emacs --daemon in bash:
$ ps aux | grep emacs
shiangro 1744 0.0 0.0 2432784 604 s000 S+ 1:03下午 0:00.00 grep emacs
$ /usr/local/bin/emacs --daemon
("emacs")
Starting Emacs daemon.
Restarting server
$ /usr/local/bin/emacsclient -t
emacsclient: can't find socket; have you started the server?
To start the server in Emacs, type "M-x server-start".
emacsclient: No socket or alternate editor. Please use:
--socket-name
--server-file (or environment variable EMACS_SERVER_FILE)
--alternate-editor (or environment variable ALTERNATE_EDITOR)
I have this settings in my .emacs:
(server-start)
(setq server-socket-dir "~/.emacs.d/server")
and it works,the server file ~/.emacs.d/server/server was just there,but emacsclient say it can't find socket,so annoying that I have to tell him the socket file using the -s option.
I find this thorny problem while I want let emacs runing as a daemon after everytime rebooting(start) systerm by using crontab's ◎reboot special strings.
In this case ,cron successfully started the emacs server and the server file ~/.emacs.d/server/server was also there, but later when I started a terminal and tried to emacsclient -t ,it failed and complained can't find socket file!
Although I can bypass this problem by using -s ~/.emacs.d/server/server everytime I excute emacsclient,or alias emacsclient as emacsclient -s ~/.emacs.d/server/server ,but is ther a better way to comfort my heart?
Backgroud:
system: Mac OS X 10.9.2
emacs: GNU Emacs 24.3.1 installed by homebrew
Finding the server socket file is the tricky bit, you can use lsof to find it, and then a bit of grep-ing to extract the socket path/filename.
lsof -c emacs | grep server | grep -E -o '[^[:blank:]]*$'
Or on OSX when you expect to be running /Application/Emacs you'd change the command name lsof is looking for with -c Emacs. ie.
lsof -c Emacs | grep server | grep -E -o '[^[:blank:]]*$'
You could use cut instead of the messy filtering grep (searching for non-blanks until the line end [^[:blank:]]*$)
lsof -c Emacs | grep server | cut -c70-
Better yet, squish the interspacing and use cut's field chopping.
lsof -c Emacs | grep server | tr -s " " | cut -d' ' -f8
Now that you have the socket (or it's empty) you can do a conditional start on emacsclient, ie.
#!/bin/bash
socket_file=$(lsof -c Emacs | grep server | tr -s " " | cut -d' ' -f8)
if [[ $socket_file == "" ]]; then
# Just run Emacs (with any arguments passed to the script)
# It would be a good idea to parse the arguments and clean/remove
# anything emacsclient specific.
# (ie. -e should be --eval for emacs)
# note that emacsclient doesn't fix these args for you either
# when using -a / --alternate-editor
emacs $# &
# or on OSX
/Application/Emacs.app/Contents/MacOS/Emacs $# &
else
emacsclient $# -n -s $socket_file
fi
Since you've done:
/usr/local/bin/emacs --daemon
the server is already started. So, you don't actually need the:
(server-start)
(setq server-socket-dir "~/.emacs.d/server")
in your .emacs. When you follow that approach, the server is placed in /tmp/emacs502 (or maybe some other number). On linux, emacsclient doesn't seem to have trouble finding it there (in that case I'm seeing /tmp/emacs1920), and so "emacsclient -nw" works. I'm trying it on OSX using HomeBrew, as you are, and I find I have to connect using:
emacsclient -nw -s /tmp/emacs502/server
(If you used --deamon=name, then you would use "name" instead of "server" in that last line.)
emacsclient only finds the emacs server if I run emacs from the command line. If I run emacs from the Ubuntu launcher then emacsclient fails to connect to the server.
If you want to use the Emacs daemon instead of the server, define the two environment variables
export ALTERNATE_EDITOR=""
export EDITOR=emacsclient
You can add these environment variables in either ~/.bashrc or ~/.profile.
If the ALTERNATE_EDITOR environment variable is empty, then Emacs will run its daemon and connect to it.
I think emacsclient can look for special file server in standard path only, e.g. in /tmp/emacs1000. If you change this parameter server-socket-dir, then you should tell about it to emacsclient by key -s.