I want to open manuals directly in Terminal to Emacs by
man man
I put the following code as an alias in .zshrc unsuccessfully
alias man=x
unalias man
man() { emacs ^x man }
How can you open manuals to emacs?
Perhaps this is what you mean:
function man() { emacs -eval "(progn (setq Man-notify-method 'bully) (man \"$1\"))" }
The setq is there just to make the manual page hide the *scratch* buffer; if you don't want that, it is enough to do
function man() { emacs -eval "(man \"$1\")" }
If you want to call Emacs functions from the command line, you must write the function call in elisp; you can't just give Emacs key sequences on the command line.
I'm not sure I completely understand your question, but you can open a man page in emacs by simply doing M-x man followed by the man page you want to view. If you want to do this directly from the command line I imagine it would not be too difficult to set up a script to do this.
alias man 'emacs -e man'
Check out this part of the info pages (and the following sections) for more information.
A few possibilities, depending on how you want the man pages formatted:
man man > /tmp/man
emacs /tmp/man
or
zcat `man -w man` | nroff > /tmp/man
emacs /tmp/man
or
emacs `man -w man`
Related
The org-mode manual states that org-mode will """...execute the command in a shell link""" but it does not show the syntax for such a link.
I would appreciate a simple complete working example of how such a shell-link could work. Perhaps for doing ls -l on a directory... e.g.:
[[see all my files][shell://cd ~/files; ls -larth]]
The literal text is [[shell:ls%20~][foo]].
If you use C-c C-l to insert links, org-mode will auto-escape spaces
and other things for you.
I have a symbolic link ~/c from my home directory to ~/a/b/c/. After
cd ~/c
I land in ~/a/b/c and then fire up emacs. In emacs I open a file using Ctrl-x Ctrl-f. The minibuffer shows ~/c/, not ~/a/b/c, and when I enter ../ I get a listing of my home directory, rather than a listing of ~/a/b.
I find that weird. Is there a way to prevent emacs from following symbolic links backwards? I have tried
(defun file-symlink-p (FILENAME) nil)
with no success. Interestingly, different shells handle symbolic links differently:
cat ~/c/../
expands to directory b for csh, but to ~/ in bash. So emacs seems to be closer to the bash behavior. I favor the csh approach really.
Any hints highly appreciated.
There are lots of places in UNIX where programs call out to the program in $PAGER (usually less or some similar command) to display some output. It's certainly true that many of the most common uses have an Emacs replacement (in the case of man, for example), but I'd still like a general way to use Emacs as my system-wide pager. Ideally this would mean that calls to PAGER end up in an Emacs temporary buffer similar to *Help*, a read-only buffer you can navigate around and dismiss by pressing "q".
I usually run a shell through M-x shell, so my envisioned use case is that typing a command like "man foo" in the *shell* window will bring up the man page in another window, more or less exactly like how the built-in *Help* system works.
For general use of $PAGER, you might be interested in e-sink.
For the specific case of man pages, it's better to use Emacs's built-in man mode as you note. I have this in my .bashrc:
man ()
{
if [ "$TERM" == "eterm-color" ]; then
emacsclient -e "(man \"$1\")";
else
command man "$#";
fi
}
Since you use shell-mode rather than ansi-term-mode like I do you will either have to make this use emacsclient all the time, or do something like (setenv "WITHIN_EMACS" "1") in your .emacs file so you can switch on $WITHIN_EMACS instead.
I want to search in all files from the current folder for macro CODE_INIT_PARAMETERS.
I can do Alt + X occur, Return CODE_INIT_PARAMETERS Return, but this shows only entries from open buffers.
Is there a way to search all files from current folder, from Emacs, without switching to M-x shell and then grep? I want to avoid grep, because for some commands (M-x occur) Emacs do jumps to offending code, and I want that too.
You can try M-x rgrep.
It will ask for:
the directory where you want to search recursively
a file pattern for the files you want to include in the search
the pattern you want to search
As an extra, it will exclude source control private directories from your search (like CVS, .svn or .git).
Emacs provides a built-in command:
M-x grep RET CODE_INIT_PARAMETERS *.c
(and 'grep-find to search sub directories)
Though I prefer the interface provided by an external package igrep (which provides the commands igrep and igrep-find).
If you open a folder in dired, and mark all of the files (with 'm') you can run 'dired-do-search ('A' in my bindings). This will search all marked files. To get to the next one, run tags-loop-continue (M-,)
I have set up several ELisp functions to mark various subsets of the files (.h files, .cpp files, etc.) and to create a recursive dired to search a whole tree...
This is an improvement on Trey Jackson's suggestion.
M-x grep
You will see the grep command, e.g. grep -nH -e
Add R to the first set of flags (for recursive), and put your search term after -e
grep -nHR -e CODE_INIT_PARAMETERS
Hit RET. The results will be understandable by Emacs -- you will be able to click or otherwise navigate to them, like M-x occur. You may need to put the search directory at the end of the command:
grep -nHR -e CODE_INIT_PARAMETERS /path/to/root/of/search
M-x find-grep-dired also works similarly as rgrep
In cases where
you may be searching repeatedly; and
etags will work
you might consider using etags and invoking either find-tag (bound to M-. by default) or tags-search (no default binding but can be continued with M-,).
There is as well ack-grep mode for Emacs which uses the ack-grep tool which is specifically designed for ''grepping'' programming languages and IMHO looks nicer than the output of M-x grep.
But as mentioned earlier etags should be the proper way!
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 :)