Emacs - how to install and use dired+? - emacs

I'm using GNU Emacs 24.2.1 on Windows 7.
I want to use the dired+ features, but I am not able to load them appropriately.
The file dired+.el exists in my lisp path.
I added the line (require 'dired+) in my configuration file which is loaded during Emacs' startup.
But when I type C-x d, it seems to me that the "normal" dired is loaded, not dired+.
How can I tell if I'm using dired+ or dired?
it looks like that:
I can use commands that start with diredp- however, so it seems that dired+ is somehow loaded, but e. g. I do not see the additional commands in the context menu available by right-clicking with the mouse which should allow me to open a directory in Windows explorer e. g. (like described here in the dired+ wiki: http://www.emacswiki.org/emacs/DiredPlus )
What am I doing wrong?

Judging by the comments in the header of dired+.el, dired+ does not augment the usual dired-mode display, instead you have to use dired+ specific entry points to enter the dired+ buffer.
;; Additional suggested key bindings:
;;
;; (define-key ctl-x-map "d" 'diredp-dired-files)
;; (define-key ctl-x-4-map "d" 'diredp-dired-files-other-window)
So you are overriding the usual C-x d key binding (dired) with one for diredp-dired-files.

Related

Why doesn't modifying the .emacs file change the behavior of GNU Emacs?

I'm running GNU Emacs 24.3.1 on Windows 7. As mentioned in this manual page, I can type
C-x d ~/ RET
to determine the location of my home directory. In my case, Emacs returns:
e:/EmacsDocs
which, according to Windows Explorer, indeed contains a file .emacs. When I open .emacs with Emacs, the file appears to be empty.
Now, I want to set Emacs so that it is in overwrite mode by default. According to this page, that can be done by adding the following to .emacs:
(setq-default overwrite-mode t)
But when I make this change to .emacs and close and reopen Emacs, Emacs does not overwrite when I select text and start typing. (Rather, it still operates in insertion mode, with new characters inserted before the cursor.)
I also tried, for example, adding this command to .emacs, which according to this page will disable cursor blinking:
(blink-cursor-mode 0)
but again, there is no change when I restart Emacs.
How can I tell if Emacs is actually reading the .emacs in the home directory (upon restarting Emacs)?
You are confusing what Emacs calls overwrite-mode with the requested behavior "overwrite when I select text and start typing".
In Emacs, the latter behavior is called delete-selection-mode, and overwrite-mode means that when you type text (without selecting anything), any existing text that follows the cursor is overwritten by what you type.
Most Emacs users do not turn on overwrite-mode by default, and they just hit the insert key (typically to the left of the home key) to toggle `overwrite-mode on/off when they need/want to.
One way to turn on delete-selection-mode by default is to put one of the following in your init file (.emacs):
(setq delete-selection-mode t)
or
(delete-selection-mode)
Another way is to customize the option delete-selection-mode using M-x customize-option RET delete-selection-mode RET and save the customized value.
Instead of editing the file outside of Emacs, just type
C-x C-f ~/.emacs
and add your configurations there. Save with
C-x C-s
and restart. This should work, since ~ in Emacs defaults to the home directory.

How do I find org-mode files with completion in Emacs?

I have a growing set of org files stored in org-directory. How can I navigate between them, preferably with interactive filtering and completion?
I thought there was a way to get org-mode to produce a list of known org files for quick navigation, but I can't seem to find it. If org-mode does not have this feature, how can I make a simple command that launches something like helm or icicles to find them?
The question is not very clear to me. But if your Org-mode files all have a certain file-name pattern (e.g. *.org) and all are in the same directory (org-directory) then you can use several methods Emacs method to access them:
C-x C-f *.org RETURN in org-directory opens them all (the buffers are visiting them but only the last one is shown).
C-x C-f *.org TAB in org-directory, to show them using completion, then pick whichever one you want (or pick more than one, using a glob pattern, as in #1).
The same as #2, using Icicles or Helm. In Icicles, at least, you can also match using regexps and in other ways.
Open Dired for just those files: C-x d *.org.
There are really any number of ways to do what you've described. But I'm guessing that you have not really described your request/problem/question well enough, and when you do you will get a narrower set of answers.
UPDATE after your comments:
Here's one way: Open Dired on all of your Org files in and under org-directory.
(defun foo ()
"Open Dired for (only) the Org files in and under `org-directory`."
(interactive)
(cd org-directory)
(dired "*.org" "-lRF"))
Test it with M-x foo. Put this in your init file:
(foo)
And here's another way: M-x bar or bind bar to a key.
(defun bar ()
"Open an Org file in or under `org-directory`."
(interactive)
(let ((default-directory org-directory)
(icicle-file-match-regexp ".*\\.org"))
(icicle-locate-file-of-content)))
I have a package that does just that: plain-org-wiki.
It's nothing too elaborate: I just dump all of my 45 org files into a single directory and get completion for them.
How about org-iswitchb, which is provided by org already?
Switch between Org buffers.
With one prefix argument, restrict available buffers to files.
With two prefix arguments, restrict available buffers to agenda files.
Add this to your startup file after org is loaded:
(global-set-key "\C-cb" 'org-iswitchb)
My favorite solution to this is helm-mode which is activated with the helm package from MELPA. Here's a demo:
It really makes for a great environment for searching ones files quickly. In addition, one can enable fuzzy completion! Here's a minimal configuration (after installing the helm package):
(require 'helm-config)
(helm-mode 1)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
You can also run grep on the files if you'd like to search their content. Take a look at this amazing guide if you'd like to learn more.

emacs command-t behavior

I'm a total emacs newbie. I watched a video which shows ido in emacs working similar to command-t in textmate:
(video is: http://vimeo.com/1013263)
The issue is I don't get this behavior when I'm in emacs with ido mode. Here is my init.el:
(require 'ido)
(ido-mode t)
(setq ido-enable-flex-matching t)
I have no idea what t means, this is just what I found online.
When I search for a file (C-x C-f) it doesn't find files in sub directories. So if I have a file test/core.clj and I search for tc (for test core) it has no match.
On thing I notice is that he has 'Project file:' in the screenshot, where I get 'Find file:'. I installed 'find-file-in-project' to see if that was the missing behavior but it doesn't work either. It only does matching on the filename, not the directories containing the file.
ido 'learns' what files you've visited and maintains a history cache. I believe that's what you're seeing in the screenshot above.(sometimes you'll want to clear the cache with ido-wash-history).
Usually once you've been in a project for a while it'll work in the way you're expecting.
If you're new to emacs, customize is the best way to experiment with the various features. e.g. you can M-x customize-group <RET> ido <RET> and see all the options for ido
There are other options, like find-file-in-project, are you sure you're actually invoking it? Just installing it isn't enough, that won't re-bind C-x C-f for you.
Try M-x find-file-in-project and see if that's the behaviour you desire.
There's also find-file-in-repository if you always work in source controlled dir.
('t' means true btw).
I would take a look at find-file-in-project.el.
http://www.emacswiki.org/cgi-bin/wiki/FindFileInProject
It will search for all files within the .git tree. I have this mapped to C-c f.
the "t" just means non-nil or true. You could use "a", "w", or "t" and it would mean the same thing. People just use t by convention.
Enabling
If you want to enable something you would have in your .emacs (ido-mode t)
Disabling
If you want to disable something you would have in your .emacs (ido-mode nil)

How to make speedbar list the C functions + Unable to use sr-speedbar+macro+command history

I am new to Emacs on Windows XP and have multiple queries which I could not find/understand after a lot of search.
I understand that speedbar will support showing of C functions list. As mentioned in http://stackoverflow.com/questions/259364/how-do-i-configure-emacs-speedbar-for-c-sharp-mode, I added the code in .emacs as
(speedbar 1)
(add-to-list 'speedbar-fetch-etags-parse-list
'("\\.c" . speedbar-parse-c-or-c++tag))
I see the speedbar startup but it never shows the functions. Maybe I need to install etags but cannot find it. I also found gtags but could never find a binary
I copied sr-speedbar.el in ~/emacs.d/ directory. I added (require 'sr-speedbar) in .emacs, commented out speedbar related code, reloaded M-x ~/.emacs but did not find any sr-speedbar. If I uncomment speedbar code and comment sr-speedbar, it shows the speedbar on loading. Emacs is able to find sr-speedbar.el in ~/emacs.d/ directory since if I change filename, it shows an error: unable to find sr-speedbar.
I wanted to make a keyboard macro for logging using tramp and ssh. However, when I record a macro, I have to delete multiple characters to provide the path from the beginnig i.e. emacs automatically shows the last path and so I have to delete all the characeters and then start again with ssh://. The keyboard macro records all backspaces and returns error if the backspaces are more than the length of the current path. Is there a way to avoid it
I configured linum package. I want it to start at the beginning of emacs session automatically with typing M-x linum. How can I do that?
Is there way to retrieve command history (not shell commands) and then replay some command
Thanks again for patience on reading until the point :-)
For C, C++, and other languages, supported by CEDET/Semantic, the Speedbar is able to show functions & other objects. But you need to setup Semantic correctly, for example, you can use my article in CEDET.
As I understand, to enable linum-mode globally, you need to put (global-linum-mode 1) into your ~/.emacs
For 3, there are two options:
just type "/ssh:blabla" at the end of the pre-inserted directory (this directory will be ignored as witnessed by it becoming grey).
do C-a C-k to erase the content of the minibuffer.
For 5, there is repeat-complex-command bound to C-x ESC ESC and there is repeat bound to C-x z.

How do I list all yanks in emacs?

Is there a way to list all the yanked text in Emacs? You can do it on Textmate with SPLAT+V.
Edit: I meant recently killed items, items that can be yanked.
The list of kills (i.e., the list of things you can yank) is called kill ring and stored in the variable kill-ring, so you can view it (in a not very nice way) with C-h v kill-ring RET.
The kill ring also appears in the menu, under “Edit / Paste from kill menu”. If you use a text mode Emacs or have turned the menu bar off, you can access the menu with M-x tmm-menubar (bound to M-`): type M-` e p followed by the first letter of the item you want to paste (if it's a letter and it's unique, otherwise whatever character is indicated). If you don't want to paste anything, type M-` e p C-g; the kills remain in the *Completions* buffer. The kill texts are displayed truncated to yank-menu-length characters.
To my knowledge, emacs doesn't support that feature out of the box.
If you're using a Debian or Ubuntu Linux distribution, you can install the emacs-goodies-el package, which contains a browse-kill-ring feature (bound to M-y by default).
Alternatively, you can use the browse-kill-ring ELisp package available here.
See also here for a nice article about this problem and other alternate solutions.
EmacsWiki has a satisfying list of solutions. A portable and intuitive solution uses the built-in popup.el to display a vertical list to choose from:
(global-set-key (kbd "C-c y") '(lambda ()
(interactive)
(popup-menu 'yank-menu)))
In Icicles you can see all of your kill-ring, and yank any entries in it using completion. By default, C-y is bound in Icicle mode to icicle-yank-maybe-completing.
That's the same as yank, unless you give it a negative prefix arg (e.g., C--). In that case, it lets you complete against the kill-ring. Completion can be prefix, apropos (substring, regexp), or fuzzy.
http://www.emacswiki.org/emacs/Icicles_-_Multi-Commands
councel-yank-pop wors well for me
especially with the binding suggested in
http://pragmaticemacs.com/emacs/counsel-yank-pop-with-a-tweak/
(use-package counsel
:bind
(("M-y" . counsel-yank-pop)
:map ivy-minibuffer-map
("M-y" . ivy-next-line)))
if you use helm, you may call the helm-show-kill-ring function.