I have several .org files, and I'd like to be able to create links between them using an ID. I am using DOIs as unique identifiers. I can link within a file by using properties:
* Paper 1
:PROPERTIES:
:CUSTOM_ID: 10.1088/0953-8984/23/21/213001
:END:
* Paper 2
:PROPERTIES:
:CUSTOM_ID: 10.1038/nphys2935
See also [[#10.1088/0953-8984/23/21/213001]]
Is there a way to make the custom_id global, so I can reference it from another file?
I think that org-id is what I need to go further, but I've found the documentation a little confusing. I tried adding the following lines in my .emacs
;; Use global IDs
(require 'org-id)
(setq org-id-link-to-org-use-id use-existing)
;; Update ID file .org-id-locations on startup
(org-id-update-id-locations)
but the file .emacs.d/.org-id-locations only has nil.
It seems like global links won't be automatically generated (Assign IDs to every entry in Org-mode). I tried (with cursor on the heading) to use M-x org-id-get-create, but this does not seem to do anything.
EDIT: (Based on helpful comment)
Within one session, I can store and create links using M-x org-store-link while on the heading (Paper 1 in my example above). Then I can use M-x org-insert-link, and type the ID to insert the link. The link looks like [[id:10.1088/0953-8984/23/21/213001][Paper 1]]. But I am running into two problems: (1) I'd like the ids to be stored automatically. (2) The links don't work when I close and re-open the file.
EDIT: A related question:
https://emacs.stackexchange.com/questions/2186/have-org-modes-exported-html-use-custom-id-when-linking-to-sub-sections-in-toc
So here's the solution I came up with.
In my .emacs configuration, I have kept the same settings as in my question:
(require 'org-id)
(setq org-id-link-to-org-use-id use-existing)
;; Update ID file on startup
(org-id-update-id-locations)
The files need to be part of the agenda list (or added to the list of additional files using org-id-extra-files (See org-id documentation))
Use ID instead of CUSTOM_ID in the PROPERTIES drawer:
* Paper 1
:PROPERTIES:
:ID: 10.1088/0953-8984/23/21/213001
:END:
Each ID needs to be created (if necessary; in my case I already have them), and a link added to the ID file (links are stored in .emacs.d/.org-id-locations). This is done using org-id-get-create: with the cursor on the heading, call it using
M-x org-id-get-create
Link to an ID using [[id:10.1088/0953-8984/23/21/213001][Paper 1]].
I have to think a little bit more about when I'd like the ID to be created; I can automate the process by tying the ID storing to another function that I'll do to all the headings.
Related
At work I frequently deal with support issues that my company keeps track of in a web-based bug tracker.
Each issue has an URL that looks like https://mycompany.com/support/SUPPORT-12345, but of course I don't want to spell this out every time I mention a support issue in my Org-mode file. I would like set up Org-mode in such a way that the pattern SUPPORT-(\d+) is treated as a hyperlink to https://mycompany.com/support/SUPPORT-\1.
I would like to be able to place my cursor over the SUPPORT-2345, type C-c C-o, and have Emacs point my browser to https://mycompany.com/support/SUPPORT-2345. Ideally, SUPPORT-2345 would behave no different than a hyperlink.
Can Org-mode be configured in this way? If not, what is the best alternative?
You should be able to do this with org-link-abbrev-alist. For example, see the below for some I use. You can then put [[Support:1234]] in your Org-mode file and have it treated as the expanded link.
(setq org-link-abbrev-alist
'(
("DOI" . "http://dx.doi.org/")
("FreshDesk" . "https://xyz.freshdesk.com/support/tickets/")
("JIRA" . "https://jira.apps.monash.edu/browse/")
("Support" . "https://support.xyz.com/helpdesk/tickets/")
("ISBN" . "http://isbn.nu/")))
I don't know whether Org-mode have this feature, but there is a bug-reference-mode for it.
Here is sample org file:
;; Local Variables:
;; eval: (bug-reference-mode)
;; bug-reference-bug-regexp: "\\(\\(?:\\(?:SUPPORT\\|support\\)-\\)\\([0-9]+\\)\\)"
;; bug-reference-url-format: "https://mycompany.com/support/SUPPORT-%s"
;; End:
* SUPPORT-123
* support-1234
And you can move point on support-* and press C-c RET (bug-reference-push-button) to open it.
For more detail about Bug Reference, please refer to C-h r g Bug Reference
I use Emacs org-mode to organise my todo list. Recently I found under each todo item it automatically generates a property drawer containing a key ID and the corresponding value, something like this:
** TODO meeting XXX
SCHEDULED: <2014-07-12 Sat 14:00>
:PROPERTIES:
:ID: 46673B08-F9D9-4966-B70A-A2ADBC2ADE0E
:END:
Entered on [2014-07-08 Tue 20:40]
I have no idea how this property drawer is generated, and I did not have it before. If delete it, next time I start Emacs to read the file, it will come back again. What would I do?
Would you have used MobileOrg? If yes, that's the culprit (and that clutter is something more that keeps me away from using MobileOrg ATM).
Posting your configuration file would definitely help diagnose what's causing this. For some, this is the desired behavior of the org-id package, which is explained in Handling Links in the Org-mode Manual:
The library org-id.el must first be loaded, either through org-customize by enabling org-id in org-modules, or by adding (require 'org-id) in your .emacs.
An init.el / .emacs file that enables this functionality, might for example, include the following:
;; Use global IDs
(require 'org-id)
(setq org-id-link-to-org-use-id t)
;; Update ID file .org-id-locations on startup
(org-id-update-id-locations)
Additionally, you could check your .emacs.d directory to see if there is a .org-id-locations file, which is generated by the org-id package.
To disable this behavior, you should remove all org-id package related code from your configuration files.
It's likely that this behavior occurs every time you use (org-store-link), commonly bound to C-l l. You might also want to check out Assign IDs to every entry in Org-mode
I have a directory "a" with a set of templates, for instance
$ ls a
b bcc cc ccdd
I would like to implement a keyboard shortcut in Emacs that will show a buffer with the template names, similar to dired or buffer-menu and then be able to select a template name by using arrow keys or mouse. Then insert the selected template into the current buffer at point.
How can this be done?
To augment Chris' answer with a little code, here is a small wrapper around ido-insert-file:
(require 'ido)
(defvar so/template-directory "/tmp/templates"
"Directory where template files are stored")
(defun so/insert-template ()
(interactive)
(let ((default-directory so/template-directory))
(ido-insert-file)))
This allows you to run (or bind a key to) so/insert-template no matter what directory you are currently in. Obviously set so/template-directory to your preferred directory.
insert-file, bound to C-x i by default, can insert a file into your buffer at point, but it doesn't give you a nice menu. Both helm and ido enhance this behaviour.
helm does not come with Emacs, but it can be installed via MELPA. When helm-mode is active, insert-file uses Helm's narrowing features. Once you're in the a directory, the up and down keys may be used to select a file, and Enter will insert it.
ido is shipped with Emacs. When ido-mode is active, C-x i is rebound to ido-insert-file. Once you're in the a directory, the left and right keys may be used to select a file, and Enter will insert it.
Both tools are excellent, both can be used in many other situations, and both offer effective filtering and navigation. Try one or both and use whichever you prefer.
Everything #Chris said about Helm and Ido is true also for Icicles, and with better "narrowing" features and on-the-fly sorting in different orders.
There is nothing extra to do --- just load Icicles and turn on Icicle minor mode. Whenever you use standard command insert-file (bound to C-x i) you get the behavior you requested for free. This behavior is in fact available for all completion in Emacs. In Icicle mode, standard commands become menus you can use the arrow keys on, etc.
In addition, your question title asks to be able to "select a set" of files. You can do that easily in Icicles, but not otherwise. IOW, selection is also multi-selection.
(However, I suspect that your question is mistitled, since the text describes something different, and I doubt that you want to insert a set of files. You probably meant that you want to select one file name from a set of file names. Consider retitling the question, if so.)
I want to give emacs' org-mode a try. What is the shortest path for me to accomplish that?
Assume NO previous experience with emacs.
(I'm aware that other editors, like vim and textmate, have similar task lists. I'm specifically interested in learning about the emacs org-mode)
My laptop runs Win7 Home Premium x64
I use Emacs (when I'm on Windows) with the official binaries at http://ftp.gnu.org/gnu/emacs/windows/emacs-22.3-barebin-i386.zip Just unzip to a directory and double click "runemacs".
In all the commands that follow, C stands for Ctrl.
Create a file ending in .org. If using recent Emacs, that will automatically start org-mode. You can create a file using C-x C-f.
Start creating outlines like this:
* Level 1
** Level 2
Collapse/Uncollapse outline levels with TAB
Todo's you can cycle by hitting C-c C-t
That's the basics, and pretty much all I know, but I already use it extensively :)
Have a look at the tutorials on http://orgmode.org/worg/org-tutorials/
I started org mode with an article in the linux journal and a very useful & simply tutorial.
David O'Toole Org tutorial
Get Organized with Emacs Org-mode
Both sources give you in my opinion a superb and fast introduction to org mode.
Start org mode with M-x org-mode RET, or by visiting a file with the .org extension.
Type C-h m in an org mode buffer to see the (brief) mode description and (importantly) all of its key-bindings.
Type C-h i m org RET to read the Org Mode manual.
(Typing q will bury either of the *Help* or *info* buffers.)
Visit the web site at http://orgmode.org/ for more.
I found a very extensive list of youtube video regarding org-mode. See it here : Org-Mode on Youtube. Use the latest Emacs release, it already has org-mode installed. Create a file with .org extension. Now, type the title of the file, then start create these:
* Roles
** Role 1
*** Todo 1
*** Todo 2
*** Todo 3
** Role 2
*** Todo 1
*** Todo 2
While your cursor on Role1, press TAB and see the way org-mode hide/show the only relevant tree structure. Press tab again to toggle the visibility status.
Now, while you are in Role 1, type C-x n s, or the command org-narrow-to-subtree. It will only displayed Role 1. To get back, use the command widen, or C-x n w.
I found it very helpful!
Lots of other great stuff in org-mode
By the way, you can easily convert and display in browser your org-file. Type : org-export-as-html-and-open. I use it a lot!
Since others already mentioned how to install and start using org-mode, I would like to point you to the excellent collection of tutorials on Worg (it is a community driven documentation effort in the form of tutorials, How tos and other articles).
Everyone starts Emacs without previous experience.You just need to:
Install Emacs
Install org-mode
Use org-mode to write something
I think both Emacs and org-mode are well documented.So if you have any trouble, read the official documents.
That's all. Good luck.
Org-mode beginning at the basics sounds promising, it starts with
The absolute minimum you need to know about Emacs
The absolute minimum you need to know about Emacs, to be able to do
anything, is more then you need to know about many other applications.
But, you might compare it to a regular toy and lego. Lego is harder to
begin with (you start with a box with little plastic pieces), but in
the long run, you can do more with it.
I have a portable version with .emacs configure ready, which setup org mode, etc. It also included org sample file. I think that is a better start point.
http://nd.edu/~gsong/portable_emacs.html
Best,
How can I make Emacs to complete words that are in C include files ?
#include <stdio.h>
int main(){
print//<-- this is where I want it to complete printf
What's the simplest way? (something simpler than Cedet)
First generate tags for the source and include files you'd like to be able to autocomplete for. See my blogpost for tips on using tags if you didn't use tag tables before.
Now if you have a TAGS table that includes the stdio.h, then you can autocomplete 'printf' using the command `complete-tag'.
Perhaps bind `complete-tag' to a key:
(global-set-key [f3] 'complete-tag)
Unlike complete-tag, dabbrev-expand, or hippie-expand (which does dabbrev-expand like things), the CEDET suite does exactly what the question describes. When asked to perform a completion, it looks and sees that you have included stdio.h, and then looks there for possible completions.
CEDET does a lot of other things related to completion as well which will provide very focused and correct suggestions, not just vaguely similar suggestions. A side affect is that CEDET takes more effort to setup. You need to teach it where you include files are, for example, and sometimes how to deal with macros, and what the project you are working on is like.
There is more detail on this here:
link text
You might want to try out M-/ (dabbrev-expand). This command attempts to complete the identifier immediately preceding the point (ie, where your cursor is) using the contents of the current buffer and then the contents of other buffers of the same mode. If the first completion offered isn't the one you want, just keep typing M-/. If you have the habit of keeping a single emacs session open continuously (which, if you don't have, you should really acquire), and have a handful of files from the current project open, you're quite likely to be able to find an the expansion you want for any particular prefix.
So, to answer you're original question, M-/ will find the printf completion you're looking for if (a) you've used printf anywhere else in the buffer you're editing, or (b) it appears in any other .c or .h file you have open in emacs.
You might also try hippie-expand, which has additional options regarding where it looks for completion information. I bind M-/ to hippie-expand, and then modified the order of the elements in hippie-expand-try-functions-list as follows:
(global-set-key (kbd "M-/") 'hippie-expand)
(setq hippie-expand-try-functions-list '(try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-complete-file-name-partially try-complete-file-name try-expand-all-abbrevs try-expand-list try-expand-line try-complete-lisp-symbol-partially try-complete-lisp-symbol))
This makes hippie-expand act like the normal M-/ at first, but repeated presses will yield more possible expansions.