Force neotree to stay at project root - emacs

I'm using neotree and projectile. I can open neotree at my project root using neotree-find-project-root, and it's beautiful.
When I open a file in a subfolder, it changes the neotree root to the folder that contains that file. This is less useful to me than if neotree view remained the project root.
Can I force neotree to always display the project root folder, and not automatically descend into subfolders?
(Toggling neotree off and on again using neotree-find-project-root will bring it back to the root, but it's a pain to do this manually. There must be a way to automatically do this?)

I don't see a way to configure neotree to do this. You could consider submitting an issue to the developers of neotree, as this seems like it would be a common feature request.
As a sort of hacky fix, you could try something like this.
(add-hook 'find-file-hook
(lambda ()
(let ((buffer (current-buffer)))
(neotree-find (projectile-project-root))
(set-buffer buffer))))
This hook is run every time a new file is opened. It changes the neotree directory to the projectile project root, then sets the current buffer to the original buffer you were working with.

Related

Find .emacs file on Windows bash

I would like to change few things in my .emacs configuration file. The problem is that I cannot find it.
Does anyone have any idea where it could be on Windows bash?
Is it even called .emacs on windows Bash? Do I have to create it myself?
Thanks in advance
After some researches, here is what I understood :
As Varro said in the commnent, .emacs file will not be created by default, since it will only contain cuztomizations you want. So you have to create it yourself. By the way, apparently it is a good practice to call it init.el. To find where to create it, type env in the terminal and look for the HOME variable. This value will show you the path considered as the home directory, where emacs created .emacs.d/ folder. You must create init.el file in this folder, and emacs will load it automatically.
This is not related to the question but it might help you :
I needed this file in order to change the cursor on emacs. At first, I thought that emacs was not loading the file correctly, because the cursor was not changing. I made some tests, and I was able to change background color, so it was not the problem. But, in fact, you can NOT change the cursor, since it is defined by the terminal itself, not emacs.

Getting browser-style tabs in emacs

Really new programming student here, and I'm trying to get tabs in emacs (browser style, like Aquamacs has).
So, how do you get tabs in emacs? A strip of labels showing me which buffers I have open, and clicking on one of them selects that buffer.
I have googled this extensively, but not being fluent in elisp makes it really hard to understand. I have installed the tabbar package, but I do not know where to go from here.
What do I want? Just tabs, and a command to open new tabs, for example C-t (or whatever is best).
I have installed the tabbar package, but I do not know where to go from here.
The tabbar library provides a global minor mode named tabbar-mode, so you will want to enable that in your init file. If it's installed somewhere in your load-path then the following will work:
(when (require 'tabbar nil t)
(tabbar-mode 1))
There is lots of documentation in the library's Commentary, which you can visit like so:
M-x find-library RET tabbar RET
Try this, it's called tabbar and should allow you to do what you're looking for.
As the other answers, tabbar is what you're looking for.
You need to copy it to wherever you keep your emacs files (if you don't have such a place - make one, tabbar will not be the last add-on you'll use :) ), load the file and start the tabbar-mode.
In the below code, the emacs files dir is .emacs.files and it is in my home dir.
(setq tabbar-file
(expand-file-name "tabbar.el"
(expand-file-name ".emacs.files" "~")))
(load-file tabbar-file)
(tabbar-mode 1)
(define-key global-map "\M-[" 'tabbar-backward)
(define-key global-map "\M-]" 'tabbar-forward)
In the above code, I also added binding of scrolling through the tabs to Alt-[ and Alt-].
As to opening new tabs - every time you'll open a new file, it will be opened in a new tab, so don't worry...

emacs neotree go to directory when using helm projectile

How can I make it such that whenever I do helm-projectile-find-file, neotree will jump to that directory?
you could add an advice to helm-projectile-find-file that it runs neotree-find once it's done.
Something like this:
(defadvice helm-projectile-find-file (after helm-projectile-find-file activate)
(neotree-dir default-directory))
Hope this helps

"Open Recent" in Emacs

Does Emacs have the capability to open recent files (e.g. a menu like File > Open Recent...)?
I know that Aquamacs, for OS X, has this feature. But is it common to all Emacs versions?
The most idiomatic method of providing this functionality that I know of is through the use of recentf-mode (more here). I enable it in my initialization file with:
(require 'recentf)
(recentf-mode 1)
It then provides an interactive function, recentf-open-files, which I bind to C-x f, which provides a numbered menu of recently opened files that spans sessions, i.e. even if you shut down emacs and restart it, it will retain your recently opened files. You can bind the function to an accelerator with another line in your initialization file, like:
(global-set-key "\C-xf" 'recentf-open-files)
(Optional)
If you make extensive use of Tramp, recentf will track those files too, and do it's periodic cleanup thing which can be a real mess since the files are remote. Prevent this by putting this in your startup file:
(setq recentf-auto-cleanup 'never)
Ordinary GNU Emacs doesn't have a menu showing recently open files. However, all Emacs commands have history, including find-file (C-x C-f). Selecting “File | Open” in the menu or opening a file with emacsclient also adds to this history. After you press C-x C-f, press up and down to navigate the history of opened files.
The history is saved between sessions if you enable session saving with the desktop package.
If you just want to save the minibuffer history between emacs invocations you can put the following in your .emacs:
(savehist-mode 1)
Unlike the desktop package that can save all your open buffers across invocations, this does just the minibuffer history (e.g. when opening a file you can use the up arrow to navigate the list of files you opened in a previous session).
GNU Emacs does include library recentf.el, since Emacs 22. Just do as indicated by R.P. Dillon.

how to disable copy file on drag-and-drop

According to a doc
Emacs supports “drag and drop”: dropping a file into an ordinary Emacs window visits the file using that window. As an exception, dropping a file into a window displaying a Dired buffer moves or copies the file into the displayed directory.
How can I disable move or copy of a file in a dired mode so that emacs would visit the file in any mode?
Set dired-dnd-protocol-alist to nil.
(setq dired-dnd-protocol-alist nil)
...or use M-x customize to do it.