I am a new user to emacs. I need to compare two files, one local file and another in a server.
I fireup emacs opening my local file. Now I split emacs into two using C-x 3. Now I opened up a shell in my second frame on the right. I opened a shell using M-x shell. Now ssh-ed into my server. I navigated to a deep location and I need to open a file from this location on my right buffer. I tried C-x C-f but its showing my location directory?
Is there a solution for this?
Edit:
I think I stressed my problem wrongly. I just want to see both files open in emacs and read them together. Not really a diff.
Use Tramp and ediff. Something like
M-x ediff-files RET
/local/path/to/file RET
/ssh:user#host:/remote/path/to/file RET
user and host are the arguments you need for ssh.
Related
I've spent a whole day on this now. Say I open emacs and press C-c p p to open projectile-switch-project then RET to select a project, emacs opens a new window horizontally (on top of the previous) with the current buffer.
What I need is for projectile to use the already existing window and not open a new one. I've gone through every single line of my config and can figure out what is causing it.
I'd have posted my config but it's split over multiple files which will make it impractical to link to here.
The related packages I can think of which I use are:
projectile,
ivy swiper counsel - trilogy
What I've tried so far is start emacs without loading (ivy swiper counsel) and also I've tried replacing all my projectile code with bare minimum:
(use-package projectile
:ensure t
:init
(projectile-mode +1)
:bind (:map projectile-mode-map
("s-p" . projectile-command-map)
("C-c p" . projectile-command-map)))
which didn't work either.
I'm not expecting any specifics since it's a hand crafted config however I'm hoping for general pointes as to where to look for the possible cause.
I'm researching more to see if i can find a better way for you, but this is what i have so far...
If you want to look around the customization options just type M-x customize. I found a ton of options you can browse through. Projectile was listed under "Convenience" and frames/windows were listed under "Environment". You can also search packages you might be interested in for more customization if you have MELPA installed.
Considering the way that buffers and windows work I don't think you can just replace the content inside the buffer with the content of another file. I think (or at least how I've been using Emacs) you will always open a new buffer to open a file and close old buffers if needed.
From what I was reading, buffers are like interfaces between Emacs and the file you're peering into. It sets up a connection, points to the file, and creates a name for the buffer (usually from the file name unless you change it). Something I find interesting is you can even have multiple buffers open to the same file and as you type on the screen in one buffer the text should show up in the other buffer in real time.
I was reading some documentation on it and I think the command you're looking for is C-x C-f or C-x d, which opens DiredMode. The first one opens your home directory and the second opens the current directory for the file in your selected buffer. This will open a mini-buffer to search through files and when you choose the file it should open the file in a new buffer on top of the buffer you were looking at initially.
Then you can use C-x b to list and move between other buffers that are already open.
Also, M-x projectile-find-file is a command you can use to search files and get the same outcome. I don't have that set to a key-binding so I don't know if there is a default, plus I'm using Spacemacs with evil-mode, so not everything is the same as original Emacs.
Also, maybe look into extension you can get from MELPA like Treemacs
When I try to use helm-projectile-grep while using Tramp mode in Emacs and then jump into a selected file, a path to this file is wrongly prepended with /ssh:username#host-address:. So, as a result a new file is created with the address /ssh:username#host-address:/ssh:username#host-address:/home/username/file. Notice, that /ssh:username#host-address: is repeated twice. Appreciate any information about overcoming the issue.
I use the following method to connect to a remote host via emacs TRAMP :
C-x C-f /remotehost:filename RET (or /method:user#remotehost:filename)
It works great, and remotehost can be one of my ssh aliases. However I still have to navigate the whole path for the filename, which can be quite long.
Is there a way to set up a default path (like a default cd) that would be pre-filled/proposed in the list (if existing for instance) when opening a new TRAMP/ssh connection to a particular host ?
Example :
C-x C-f /work-host:/
;; auto complete suggests some files, how do I suggest another file/path ?
Note : I am using Emacs prelude in case it matters
You might navigate to your complete path, open a dired buffer, then save that as a bookmark (C-x r m). The next time you want to go there, just use the bookmark (C-x r b).
The Tramp manual explains in its FAQ section several ways to shorten paths. It's not exactly what you have asked for, but maybe it gives you some imagination what could be done.
Eval (info "(tramp) Frequently Asked Questions")
I'm using Emacs on windows. My default folder is c:/home, but I want to edit my file in d:/ how to do it in ido mode ? I tried // but that put me in c:/.
Currently, I use C-f (change back to normal find file mode), but that defeat the purpose of using ido mode in first place....
As stated in a comment you just type "d:/" in the minibuffer while in ido-find-file. You don't need to be at the start of the string, it's intelligent enough to know what you're trying to do.
C-x C-f d:/ MyFile.txt
will point you at the file D:/MyFile.txt
So, i'm running emacs over a crappy ssh connection and I have it set up to use cscope. I can not use X because of this...hence I'm running emacs inside putty. However, when I search for something with cscope and it opens up the other buffer, I can not
follow the links where cscope tells me which file and line number the item is on. When I go t a line number and hit enter, emacs tells me 'buffer is read-only' (it is trying to actually put in a new line instead of following the link). anyone know how I can follow those links?
I don't know about cscope for sure - but you should be able to find out the appropriate key binding by doing a "Ctrl-h m" in the buffer with all the links. This should open another buffer showing you help/key bindings on all the active modes.
E.g. if you do the same thing in a grep result buffer it indicates the key binding "C-c C-c compile-goto-error" which is used to open file at the grep line number (so it may be the same keys for cscope).
As a workaround, I'm pressing <space> key on the cscope result line. It shows the code in the other frame, although it doesn't position the cursor there.
Changing this line in xcscope.el fixed the problem on my computer.
-(define-key cscope-list-entry-keymap [return] 'cscope-select-entry-other-window)
+(define-key cscope-list-entry-keymap (kbd "RET") 'cscope-select-entry-other-window)
Could you use cscope with Tramp mode? I'm not familiar with cscope, but I've had great results using tramp mode to read/write files remotely over an SSH connection.
I believe GNU find version 4.2 and above supports -L to follow symbolic links. Hence,
find -L . -name *.[ch] > cscope.files
cscope -b -R -q -i cscope.files
might work well
Another workaround. Just type 'o' to select what you want. It means cscope-select-entry-one-window :)