Example of creating a shell script link in org-mode - org-mode

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.

Related

emacs org mod with math expression

I am using org-mod to take note of some of my work, I have recently switched from sublime where I was used to writing some mathjax snippet.
What would be the correct and easiest way of having this snippet rendered correctly (either in the buffer or if not possible, via C-c C-c or C-c C-e).
\hat{y} = \hat{\beta}_{0}+\hat{\beta}_{1}x_{1}+\hat{\beta}_{2}x_{2}+...+\hat{\beta}_{p}x_{p}
ps : in my .emacs conf file I don't have anything closely related to mathjax or Latex.
Kr,
Enclose the latex fragment in \( ... \) or \[ ... \]and do C-c C-x C-l (bound to org-toggle-latex-fragment). See the doc string of this function for argument usage.
In recent versions of org, you customize org-preview-latex-default-process to set it to the value of the backend you want. You need either dvipng, dvisvgm or ImageMagick as the backend. See also the doc string of the variable org-preview-latex-process-alist: it might help explain some things, although you don't have to do anything with it.
If these variables don't exist, you might be using an earlier version of org where the setup is different. If that's the case, then please post which version you are using: M-x org-version would tell you.
EDIT: in earlier versions, the function is called org-preview-latex-fragment and it's not bound to a key by default. You can call it with M-x org-preview-latex-fragment and you can get rid of the preview with C-c C-c. The backend setup is different as well: there is support for dvipng and ImageMagick only and the variables are different.

How to make a link to external file line in Emacs org-mode

I have 2 files:
php file with code
org file with docs
How to create a link to a line in php file from org file? So clicking it will move the cursor to the appropriate line in php file.
Use this notation in the org mode to create a link:
[[/path/to/file.php::line][string-to-display]]
If you want the file name to be displayed, use just
[[/path/to/file.php::line]]
See Hyperlinks in the Org mode Info page for details and other ways to specify links.
If I understand the question right you can do it automatically with two org-mode commands:
Move the point to a line in a php file and M-x org-store-link.
Go to an org file and C-c C-l or M-x org-insert-link and follow the instructions in the minibuffer.
You are done, click the link or C-c C-o when the point is on it to open the link.
I have org-store-link on C-c l and org-insert-link on the default C-c C-l. This makes the process very convenient and fast to execute.
Have fun with org-mode.

Emacs command for searching in files

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!

Unable to put manuals open at Emacs directly from terminal

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`

Non-GUI Emacs with cscope

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 :)