How Fast Can You Tangle In Org-Mode?

Last year I converted my Emacs Literate Configuration File from a complicated document full of out-of-order noweb objects to a simple sequential document that took the tangle times down from 3-10 minutes (because of how I set up my document not because of Org-Mode itself!!!) down to 30-90 seconds. But who doesn’t want more speed? I didn’t at least until I read this article which led me to reading this article and this page on garbage collection.

I tangle my config files what feels like every few minutes at least when I am playing around with stuff. So here is some code to effectively avoid garbage collection when tangling. It speeds up tangling on my computer when I tangle the same document in a row five or ten times so I’m happy but that clearly isn’t a detailed analysis.

Here is the code:

(setq help/default-gc-cons-threshold gc-cons-threshold)
(defun help/set-gc-cons-threshold (&optional multiplier notify)
  "Set `gc-cons-threshold' either to its default value or a
   `multiplier' thereof."
  (let* ((new-multiplier (or multiplier 1))
         (new-threshold (* help/default-gc-cons-threshold
                           new-multiplier)))
    (setq gc-cons-threshold new-threshold)
    (when notify (message "Setting `gc-cons-threshold' to %s"
                          new-threshold))))
(defun help/double-gc-cons-threshold () "Double `gc-cons-threshold'." (help/set-gc-cons-threshold 2))
(add-hook 'org-babel-pre-tangle-hook #'help/double-gc-cons-threshold)
(add-hook 'org-babel-post-tangle-hook #'help/set-gc-cons-threshold)

Yet Another Ag Hydra

(defhydra help/hydra/ag (:color blue
                                :hint nil)
  "
`ag', The Silver Searcher:
  Present in window:
    Search in folder:
      _j_ limit search by file type _k_ search in everything
    Search in project:
      _l_ limit search by file type _;_ search in everything
  Present in dired:
    Search in folder:
      _u_ limit search by file type _i_ search in everything
    Search in project:
      _o_ limit search by file type _p_ search in everything
  Other:
    _n_ close every other buffer _m_ close every buffer _q_ quit
"
  ("u" ag-dired-regexp)
  ("i" ag-dired)
  ("o" ag-project-dired-regexp)
  ("p" ag-project-dired)
  ("j" ag-files)
  ("k" ag)
  ("l" ag-project-files)
  (";" ag-project)
  ("n" ag-kill-other-buffers)
  ("m" ag-kill-buffers)
  ("q" nil))

Org-Mode Documents Can Generate PDFs Which Include Any Data Including Themselves

This Org-Mode document

#+LATEX_HEADER: \usepackage{attachfile}
Jon this is an Org-Mode file which generated a PDF which contains itself.
@@latex:\attachfile{orginorg.org}@@

Generates this pdf that contains itself. Open it with Adobe Acrobat (or some other tool that can handle embedded files).

You can include any data you want inside a PDF using attachfile and it is easy to extract that data.

It is a toy example but you can script everything to work with embedded data in PDF.

Continue reading “Org-Mode Documents Can Generate PDFs Which Include Any Data Including Themselves”

Consider C-s Or M-s For Key Bindings Because There Is A Lot Of Space In There

As key-binding name-spaces start to run out due to the massive expansion of packages out there today consider the C-s and the M-s name-spaces. Clicking around on my keyboard they don’t seem to be used much if at all. There is probably a reason for that and I’m going to ignore it because I want more name-space free for key-bindings.

Using Org-Mode For Disqus Comments

The Disqus commenting system is used on 2/5 blogs out there today. So I was pretty happy to discover today that Disqus allows tags within comments. The cool thing is that for Org-Mode users to post rich Disqus comments it probably just means doing an Export to HTML as HTML buffer and pasting the results into the comment box.

Can Run Emacs But Can't Compile Org-Mode After Upgrading ImageMagick With Solution

Today on my box I upgraded ImageMagick and now I can’t compile Org-Mode but I can run Emacs. Here is what I did to make Org-Mode build again on my box.

Continue reading “Can Run Emacs But Can't Compile Org-Mode After Upgrading ImageMagick With Solution”

Inviting Non Programmers To Emacs: (A) Super Text Editor

When my friends look at my computer screen I want to invite them to use Emacs. But the name “Emacs”, like Honda or Maserati tells them nothing. Honda and Maserati have advertising everywhere though! So I set a frame title that tells them something about this program! Well, they probably have to like text editors already. And if they do, then they might be interested in a Super text editor.

BTW: I am totally serious about this. I want to invite my friends to use this. Programmers or not, Emacs is still Free Software and that matters for everyone. And I find Emacs to be super. It is super. You and I know that it’s power comes from Lisp and buffers but “Super Text Editor” also works for me.

(setq frame-title-format '("" "%b - Super Text Editor "))

Super Text Editor Screenshot

Two Ways To Share Static Key Pair Values Across Different Tangled Source Files With Org-Mode Literate Programming

This post asks about how you can share static key pair values across different tangled source files. The following are my two tries.

Continue reading “Two Ways To Share Static Key Pair Values Across Different Tangled Source Files With Org-Mode Literate Programming”

Remove Every Source Block Results

Sometimes you accidentally evaluate your entire Org-Mode document resulting in result blocks everywhere. Maybe you can’t easily revert the change so you are stuck with a ton of code you don’t need. Here is a function to remove all of your result blocks. It is pretty good for documents that you probably never wanted to evaluate in the first place:

(defconst help/org-special-pre "^\s*#[+]")
(defun help/org-2every-src-block (fn)
  "Visit every Source-Block and evaluate `FN'."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (let ((case-fold-search t))
      (while (re-search-forward (concat help/org-special-pre "BEGIN_SRC") nil t)
        (let ((element (org-element-at-point)))
          (when (eq (org-element-type element) 'src-block)
            (funcall fn element)))))
    (save-buffer)))
(define-key org-mode-map (kbd "s-]") (lambda () (interactive)
                                       (help/org-2every-src-block
                                        'org-babel-remove-result)))