6104 comments
2357 subscribers
6264 on Twitter
Subscribe! Feed reader E-mail

info links from Emacs

;;
;; The following functions to insert info-links into a buffer were originaly
;; posted on gnu.emacs.gnus by Reiner Steib, August 2003.
;; Message-ID: 
;;

(defvar jk/info-goto-node-string "info" ; "Info-goto-node"
  ;; Stefan Monnier suggested to use `info' instead of `Info-goto-node', but
  ;; this doesn't work for XEmacs.  OTOH, Reiner says he submitted a patch for
  ;; XEmacs, so "info" should be okay.
  "Command string to insert with `jk/insert-current-info-node'")

(defun jk/current-info-node (&optional arg)
  "Insert reference to current Info node in buffer.

If ARG is...
- nil:	Insert `\(info \"\(file\)node\"\)'.
- 4 (\\[universal-argument]):	Add a note about `C-x C-e', too.
- 16 (2 \\[universal-argument]'s):	Insert `'
- the symbol `string':	Only return the string, don't insert.

In emacs-lisp-mode a custom link is inserted."
  (interactive "p")
  (let ((what
	 (cond
	  ((eq major-mode 'emacs-lisp-mode)
	   'lisp)
	  ((numberp arg)
	   (cond
	    ((= arg 4) 'gnus-url)
	    ((= arg (* 4 4)) 'info-press)
	    (t 'info)))
	  ((eq arg 'string)
	   'string)
	  (t 'info)))
	(buffer (buffer-name))
	(ret ""))
    ;; The next lines are borrowed from Karl Pflaesterer's code in
    ;; .
    (set-buffer "*info*")
    (let* ((node Info-current-node)
	   (nodeurl (jk/replace-in-string node " " "+"))
	   (file Info-current-file)
	   (fileurl (file-name-nondirectory file))
	   (fileurl (jk/replace-in-string fileurl "\\.gz$" ""))
	   (fileurl (jk/replace-in-string fileurl "\\.info$" "")))
      (set-buffer buffer)
      (setq ret
	    (cond
	     ((eq what 'lisp)
	      (beginning-of-line)
	      (insert ":link '(custom-manual \"(" fileurl ")" node "\")")
	      (lisp-indent-line)
	      (newline))
	     ((eq what 'gnus-url)
	      (concat ""))
	     (t ;; (or (eq what 'info) (eq what 'info-press))
	      (concat "(" jk/info-goto-node-string
		      " \"(" fileurl ")" node "\")"
		      (if (eq what 'info-press)
			  "; <== Press C-x C-e here!"
			"")))))
      (if (or (eq what 'string) (eq what 'lisp))
	  ret
	(insert ret)))))

(defun jk/boxquote-info ()
  "Boxquote current yank-buffer and put current info node in title"
  (interactive)
  (boxquote-yank)
  (boxquote-title (jk/current-info-node 'string)))
Short URL: http://sachachua.com/blog/p/1144

On This Day...

  • 2011: Batch cooking, community-supported agriculture, and gardening — W- and I are big fans of batch cooking. Making large batches of food and freezing individual portions means that [...]
  • 2010: New note-taking workflow with Emacs Org-mode — The new workflow looks like it works better for me. Or rather, it’s an old workflow with new tools. [...]
  • 2009: Shifting gears — I woke up with a terrible cough–the same one from last week, but worse–and decided not to inflict it on [...]
  • 2008: Leia’s home! — Water: Drank a number of laps of water. Food: Ate a third of an 85g can of Fancy Feast Turkey. We took [...]
  • 2008: Bio: “IBM: The Next Generation” — I thought I’d start keeping track of the bios I use in presentations, hiding company-specific information as necessary. =) Sacha Chua [...]
  • 2005: More about Spec Ops — Jon_P wrote: Also, don’t forget that most hardcore geeks in the Philippines dabble in Linux. The extent of familiarity with MS technologies [...]
  • 2005: Annoyed with self — Update: 2013/01/12: Getting better at this! =) Belt bag + digitizing as much as possible helps a lot. One of my [...]
  • 2005: Blog envy — How can Zak make Planner look so cool? I need to develop mad CSS skillz.
  • 2004: Whew! — Long list of checked-off TODO items. Planner is good for the heart. Today I bought four more spools of yarn, anticipating [...]
  • 2003: Links from the past — First noticed on 2003.02.12 - Redesigning an Introductory Java Course to Bridge the Gender Gap (http://www.contrib.andrew.cmu.edu/~tshih/THESIS/thesisFinal.doc) - Introduction to Programming Using Java [...]
  • 2003: CS21a ideas for vectors — (education) I want students to be able to keep track of the elements of vectors. I also want them to become familiar [...]
  • 2003: Khaire – literary night for tomorrow — From the announcement: “Khaire: Magsaya!:A Literary Night,” reading by accomplished poets, 6-8:30 p.m., Quad 1. Be alive and rejoice at the medley [...]
  • 2003: HTML_Form and passwords — Pfft. HTML_Form from http://pear.php.net is not so nice when it comes to passwords in forms.
  • 2003: chora — http://www.horde.org/chora/about/ Chora is a CVS repository viewer that I learned about from #php. I _thought_ I’d blogged about it, but I grepped [...]
  • 2003: Flash MX on Linux — Apparently, Flash MX is supposed to work under WINE. I should look into installing it, then. =) http://frankscorner.org/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=28&page=1 for more information. Update [...]
  • 2003: Ethics talk with the philosophy department — Introductions - Sandra Lovenia, introduction to IT for comtech, introduction to MIS. - Ariel Maguyon, seniors and juniors, computer architecture, MIS administration - [...]
  • 2003: CS21A today and Monday — (education) The files mentioned can be found at http://sacha.free.net.ph/cs21a/ . Looks like my thinking out loud does have its uses, so I’ll [...]

Get the highlights as a PDF!

Stories from my Twenties: Highlights from a Decade of Blogging

Free sample!