Irreal: Remote Code Blocks

As Irreal readers know, John Kitchin, a Chemical Engineering Professor at Carnegie Mellon, produces virtually all of his group's journal articles in Org mode. Those articles typically contain a lot of figures and graphs. In his latest post, Kitchin shows us how to put the calculations for those graphs and figures into code blocks that reside in other files. That makes it easy to reuse those code blocks in other papers or situations and to organize the article source and supplemental information in an orderly way.

The remote code blocks turn out to be really easy to do. Basically you just use a #+call: statement in your main org file that points to the remote code block by name and file. See Kitchin's post for the details and an example. In the example, the calculations and graphing are performed by a Python program of about 40 lines. Everything is contained in a code block that resides with the supplemental information for the paper.

It's an impressive technique that makes reproducible research easier and more natural.

-1:-- Remote Code Blocks (Post jcs)--L0--C0--February 11, 2016 02:25 PM

Grant Rettke: Switch to nlinum Immediately

A lot of headings in your Org-Mode file can make Emacs unusably slow when you collapse all of them.

My original solution was to avoid collapsing them with #+STARTUP: showeverything. Major problem with that approach is that you still can’t use collapsing because if you do, Emacs is again unusable.

Months ago I switched to nlinum and now there are no more performance issues, even on the largest file that I work on.

-1:-- Switch to nlinum Immediately (Post Grant)--L0--C0--February 11, 2016 12:27 AM

Grant Rettke: Switch to nlinum Immediately

A lot of headings in your Org-Mode file can make Emacs unusably slow when you collapse all of them.

My original solution was to avoid collapsing them with #+STARTUP: showeverything. Major problem with that approach is that you still can’t use collapsing because if you do, Emacs because again unusable.

Months ago I switched to nlinum and now there are no more performance issues, even on the largest file that I work on.

-1:-- Switch to nlinum Immediately (Post Grant)--L0--C0--February 11, 2016 12:27 AM

Irreal: Looking for Emacs?

Here you go:

-1:-- Looking for Emacs? (Post jcs)--L0--C0--February 10, 2016 06:01 PM

Alex Schroeder: New Look for Emacs Wiki

The last redesign was in 2013. When Brian Burns approached me at the end of 2015 and offered to design a new theme, I liked the idea. I installed it today—and I moved the site to HTTPS. As you do, these days.

You can look at the CSS Preview page if you want to see most of the new theme in action.

Yay for change! :)

Tags: RSS

-1:-- New Look for Emacs Wiki (Post)--L0--C0--February 08, 2016 08:22 PM

sachachua: 2016-02-08 Emacs News

Links from reddit.com/r/emacs, /r/orgmode, Hacker News, planet.emacsen.org, Youtube, EmacsWiki:RecentChanges, the Emacs commit log, the changes to the Emacs NEWS file, and emacs-devel.

Past Emacs News round-ups

The post 2016-02-08 Emacs News appeared first on sacha chua :: living an awesome life.

-1:-- 2016-02-08 Emacs News (Post Sacha Chua)--L0--C0--February 08, 2016 05:04 PM

Endless Parentheses: New in Emacs 25.1: EWW improvements

In the upcoming version, EWW is getting a number of small improvements. This web browser, written by Lars Ingebrigtsen, is something of a new kid on the block, as it just came to life at the very end of the Emacs 24 cycle. Although it’s hard, if not impossible, to reliably render HTML inside an editor that’s 100% line-based, EWW tends to find a reasonable compromise and deserves at least a short post to cherish new features.

HTML can now be rendered using variable-width fonts.

A new command F (eww-toggle-fonts) can be used to toggle whether to use variable-pitch fonts or not.

It goes without saying that this is very good, monospace fonts are not the most appropriate for reading webpages. It might sound like something simple, but this was probably the hardest feature to implement. Filling paragraphs in variable-width fonts is not something Emacs does by default.

A new command R (eww-readable) will try do identify the main textual parts of a web page and display only that, leaving menus and the like off the page.

I just tested this on the round quotes post and it worked well—the buffer correctly hid everything but the post content. Unfortunately, it also hid images that were inside the post.

https pages with valid certificates have headers marked in green, while invalid certificates are marked in red.

Awareness about security is always a good thing.

You can now use several eww buffers in parallel by renaming eww buffers you want to keep separate.

Partial state of the eww buffers (the URIs and the titles of the pages visited) is now preserved in the desktop file.

The new S command will list all eww buffers, and allow managing them.

All of these contribute to giving EWW a more complete browser experience. While we don’t have actual tabs yet, you can have multiple open pages, manage them all with S, and even “remember open tabs” by enabling desktop-mode.

Comment on this.

-1:-- New in Emacs 25.1: EWW improvements (Post)--L0--C0--February 08, 2016 12:00 AM

Emacs Redux: Auto-indent your code with aggressive-indent-mode

One of the things I hate the most while programming, is having to manually adjust the indentation of some code, after I’ve moved or renamed something in it. While it’s pretty easy to do such re-indent operations using commands like crux-indent-defun or advices like crux-with-region-or-buffer (you remember, crux, right?), there’s an even more efficient way to tackle the issue at hand. Enter aggressive-indent-mode.

aggressive-indent-mode’s name is a bit of a misnomer - it should probably have been named auto-indent-mode, as this is what it does. When you edit your code it will adjust the indentation automatically. It’s easier to show this than to explain it.

Here’s one example showing agressive-indent-mode enabled in emacs-lisp-mode:

And another example using cc-mode:

Provided you’ve installed the mode, enabling it for particular major modes is a piece of cake:

1
2
3
(add-hook 'emacs-lisp-mode-hook #'aggressive-indent-mode)
(add-hook 'clojure-mode-hook #'aggressive-indent-mode)
(add-hook 'ruby-mode-hook #'aggressive-indent-mode)

If you want to enable it in all major modes you can do this as well:

1
(global-aggressive-indent-mode 1)

Note that this is not going to work well with modes like python-mode and haml-mode where the proper indentation can’t be reliably determined. When global-aggressive-indent-mode is enabled it will not affect major modes listed in aggressive-indent-excluded-modes.

For more info - head over to the project’s readme.

-1:-- Auto-indent your code with aggressive-indent-mode (Post)--L0--C0--February 07, 2016 09:28 AM

Julien Danjou: FOSDEM 2016, recap

Last week-end, I was in Brussels, Belgium for the FOSDEM, one of the greatest open source developer conference. I was not sure to go there this year (I already skipped it in 2015), but it turned out I was requested to do a talk in the shared Lua & GNU Guile devroom.

As a long time Lua user and developer, and a follower of GNU Guile for several years, the organizer asked me to run a talk that would be a link between the two languages.

I've entitled my talk "How awesome ended up with Lua and not Guile" and gave it to a room full of interested users of the awesome window manager 🙂.

We continued with a panel discussion entitled "The future of small languages Experience of Lua and Guile" composed of Andy Wingo, Christopher Webber, Ludovic Courtès, Etiene Dalcol, Hisham Muhammaad and myself. It was a pretty interesting discussion, where both language shared their views on the state of their languages.

It was a bit awkward to talk about Lua & Guile whereas most of my knowledge was year old, but it turns out many things didn't change. I hope I was able to provide interesting hindsight to both community. Finally, it was a pretty interesting FOSDEM to me, and it was a long time I didn't give talk here, so I really enjoyed it. See you next year!

-1:-- FOSDEM 2016, recap (Post Julien Danjou)--L0--C0--February 06, 2016 10:54 AM

Marcin Borkowski: An attachment reminder in mu4e

A nice feature of Gmail is that you can ask it to remind you about attachments if the message contains things like “I attach” and there is no attachment. Some time ago I decided that I want my mu4e to do this, too. (And it seems that I'm far from being the only one.) And here it my take on the subject.
-1:-- An attachment reminder in mu4e (Post)--L0--C0--February 06, 2016 08:37 AM

Got Emacs?: Ma Gnus v0.16 is released

The last separate release of Gnus.  Future releases will be from the Emacs git trunk.  This release is mostly bug fixes and the release notes are found in the link above
-1:-- Ma Gnus v0.16 is released (Post sivaram (noreply@blogger.com))--L0--C0--February 06, 2016 06:33 AM

Got Emacs?: First Pretest of Emacs 25.1 out

The first pretest of Emacs 25.1 is out. Do test and report any bugs
-1:-- First Pretest of Emacs 25.1 out (Post sivaram (noreply@blogger.com))--L0--C0--February 06, 2016 06:30 AM

sachachua: Publishing Emacs News as plain text, HTML, and attached Org file

Update 2016-02-05: Since @ThierryStoehr linked to this post about Emacs News-related code, I figured I’d add a link to the other support functions I’ve been using to help me with Emacs News summarization. There’s also this bit:

(let ((date (org-read-date nil nil "-mon")))
    (concat
     (my/org-list-from-rss "http://planet.emacsen.org/atom.xml" date) "\n"
     (shell-command-to-string (concat "~/bin/list-reddit-links.coffee emacs " date)) "\n"
     (shell-command-to-string (concat "~/bin/list-reddit-links.coffee org-mode " date)) "\n"
     "- New packages:\n"
     (my/list-new-packages) 
     "\n"))

Handy little things!

——

I’ve been publishing these weekly summaries of Emacs-related links on my blog and to the emacs-tangents mailing list / newsgroup. I started by posting plain text from Org Mode’s ASCII export, and people asked for Org Mode and HTML formats. So here’s some code that prepares things for pasting into a Gnus message buffer.

It turns out that order matters for multipart/alternative – start with plain text, then include richer alternatives. First time around, I put the HTML version first, so people didn’t end up seeing it. Anyway, here’s something that shows up properly now: text/plain, then text/html, with text/x-org attached. The heavy lifting is done with org-export-string-as, which exports into different formats.

  (defun my/share-emacs-news ()
    "Prepare current subtree for yanking into post."
    (interactive)
    ;; Draft Gnus article
    (save-restriction
      (org-narrow-to-subtree)
      (let ((org-export-html-preamble nil)
            (org-html-toplevel-hlevel 3)
            output)
        (setq output
              (apply
               'format
               "<#multipart type=alternative>
<#part type=\"text/plain\" disposition=inline>
%s
<#/part>
<#part type=\"text/html\" disposition=inline>
%s
<#/part>
<#/multipart>
<#part type=\"text/x-org\" disposition=attachment name=\"emacs-news.org\">
%s
<#/part>
"
               (mapcar
                (lambda (format)
                  (org-export-string-as (buffer-substring (point-min) (point-max)) format t))
                '(ascii html org))))
        (kill-new output))))

Howard Abrams showed me something like this in June 2015’s Emacs Hangout (~1:18:26) using org-mime-org-buffer-htmlize, which probably does the job in a much cooler way. =) I thought he had a blog post about it, but I can’t seem to find it. Anyway, there’s my little hack above!

The post Publishing Emacs News as plain text, HTML, and attached Org file appeared first on sacha chua :: living an awesome life.

-1:-- Publishing Emacs News as plain text, HTML, and attached Org file (Post Sacha Chua)--L0--C0--February 04, 2016 02:25 AM

Chen Bin (redguardtoo): Grab email address in Gnus

That's easy in Gnus.

I just re-use the mail sent from PM because she is good at the things.

Usage

  • Go to the Summary Buffer (press Enter on a mail folder).
  • Press `/ a PM-name Enter`
  • M-x gnus-summary-extract-mail-address, extracted mail addresses is inserted to kill ring

Code

Insert below code into ~/.emacs,

(defun gnus-summary-extract-mail-address(regexp)
  "Extract TO/CC/FROM fields from mails in current Gnus Summary Buffer.
REGEXP is pattern to exclude extracted address.  For example, 'Tom|gmail' excludes Tom or gmail.
Final result is inserted into kill-ring and returned."
  (interactive
   (let* ((regexp (read-regexp "Regex to exclude mail address (OPTIONAL):")))
     (list regexp)))

  (unless (featurep 'cl)
    (require 'cl))

  (let ((rlt "") (i 0))
    (dolist (d gnus-newsgroup-data)
      (let ((header (gnus-data-header d)) cc-to)
        (setq i (+ 1 i))
        (if (= (mod i 100) 0) (message "%s mails scanned ..." i))
        (when (vectorp header)
          (if (setq cc-to (mail-header-extra header))
              ;; (message "cc-to=%s cc=%s" cc-to (assoc 'Cc cc-to))
              (setq rlt (concat rlt
                                (cdr (assoc 'To cc-to))
                                ", "
                                (cdr (assoc 'Cc cc-to))
                                ", ")))
          (setq rlt (concat rlt (if (string= "" rlt) "" ", ") (mail-header-from header) ", "))
          )))
    ;; trim trailing ", "
    (setq rlt (split-string (replace-regexp-in-string (rx (* (any ", ")) eos)
                                                      ""
                                                      rlt) ", *"))

    ;; remove empty strings
    (setq rlt (delq nil (remove-if (lambda (s) (or (not s) (string= "" s)))
                               rlt)))
    ;; remove actually duplicated mails
    (setq rlt (delq nil (remove-duplicates rlt
                                 :test (lambda (x y)
                                         (let (x1 y1)
                                           ;; Tom W <tom.w@gmail.com> | tom.w@gmail.com (Tom W)
                                           (if (string-match "^[^<]*<\\([^ ]*\\)> *$" x)
                                               (setq x1 (match-string 1 x))
                                             (setq x1 (replace-regexp-in-string " *([^()]*) *" "" (if x x ""))))
                                           (if (string-match "^[^<]*<\\([^ ]*\\)> *$" y)
                                               (setq y1 (match-string 1 y))
                                             (setq y1 (replace-regexp-in-string " *([^ ]*) *" "" (if y y ""))))
                                           (string= x1 y1)))
                                 :from-end t)))
    ;; exclude mails
    (if (and regexp (not (string= regexp "")))
        (setq rlt (delq nil (remove-if (lambda (s)
                                         (string-match (concat "\\(" (replace-regexp-in-string "|" "\\\\|" regexp) "\\)") s))
                                       rlt))))
    (kill-new (mapconcat 'identity rlt ", "))
    (message "Mail addresses => kill-ring")
    rlt))

I tested on my office mail inbox. 8K+ mails is scanned in less than one minute.

Technical details

Global variable gnus-newsgroup-data contains the information of displayed mails in current folder. It's updated dynamically.

gnus-summary-extract-mail-address could also be used as an API. It return the list of mail addresses.

If you want to use it to update the BBDB database, study code from my project gmail2bbdb which use plain Lisp to insert Name and Mail Address into "~/.bbdb".

-1:-- Grab email address in Gnus (Post Chen Bin)--L0--C0--February 03, 2016 11:35 AM

Pragmatic Emacs: Email attachment reminders in mu4e

Continuing my series of posts on using mu4e for emails in emacs, I wanted to duplicate the functionality of other email clients that warn you if you appear to have forgotten an attachment when you send an email.

My solution is decidedly lo-fi, but it does the trick. It is based on this post (coincidentally by the author of mu4e), which shows how to create highlighting for arbitrary keywords in emacs. This is a versatile trick and with the simple code below, any strings in a mu4e composition buffer that match “attach”, “pdf” or “file” get a nice red on yellow highlight.

;; attachment reminder based on
;; http://emacs-fu.blogspot.co.uk/2008/12/highlighting-todo-fixme-and-friends.html
(set-face-attribute 'font-lock-warning-face nil :foreground "red" :weight 'bold :background "yellow")
(add-hook 'mu4e-compose-mode-hook
          (defun bjm/mu4e-highlight-attachment ()
            "Flag attachment keywords"
            (font-lock-add-keywords nil
                                    '(("\\(attach\\|pdf\\|file\\)" 1 font-lock-warning-face t)))))

It’s not pretty but it works for me! I’d prefer something that checked my email to see if it actually had an attachment and then warned me when I tried to send if there was no attachement there. I’ve not had time to work on that though, but if you know of anything similar, let me know!

Update

There were some helpful suggestions in the comments for improved methods that prompt the user if they try to send a mail without an attachment. mbork has a nice clear example on their website.

-1:-- Email attachment reminders in mu4e (Post Ben Maughan)--L0--C0--February 02, 2016 09:55 PM

Endless Parentheses: New in Emacs 25.1: Easily search for non-ASCII characters

Since last week’s post was about Unicode characters, it makes sense to continue that trend today. This feature might go unnoticed by a lot of people who live in an ASCII world, but it will probably jump out at everyone else at one point or another. The name, if a bit odd, is “character-folding search”.

In Emacs 25, Isearch can find a wide range of Unicode characters (like á, ⓐ, or 𝒶) when you search for ASCII characters (a in this example). To enable this feature, set the variable search-default-mode to character-fold-to-regexp.

This first came up due to a new feature of a recent version of Texinfo, where some markup styles are exported in “round quotes” when generating the info manual. This is a nice improvement in readability, but when you’re trying to search for something with C-s, things can get a little difficult if your keyboard can’t type some of the characters.

With char-folding, when you hit C-s and search for ", Emacs will also search for a variety of double quotes, from the aforementioned “” to many others like «» and ❝❞. The same goes for the single quote, and for pretty much any other ASCII character.

You could always type any Unicode character by name with C-x 8 RET, and many of them even have their own shortcuts under C-x 8, but not having to type them can be a significant convenience when it comes up. As any Brazilian, I am a daily user of diacritical marks (ó, ã, ê, and the likes), and even though my keyboard can type these characters, I still enjoy the simplicity of not having to.

Finally, if you’d like to extend this feature to the query-replace command, set replace-character-fold to t.

Comment on this.

-1:-- New in Emacs 25.1: Easily search for non-ASCII characters (Post)--L0--C0--February 02, 2016 12:00 AM

Emacs Redux: Display the Keybinding for a Command with substitute-command-keys

If you ever need to show the keybinding for a particular command to the users of your package (e.g. you’re adding some tips functionality), you should avoid resisting the urge to write something like this:

1
(message "Press <C-c p p> to switch between projects.")

Why is this a bad idea? Because you might change the keybinding of the command in question (e.g. projectile-switch-project, but you might forget to update messages like this. Is there a better way? substitute-command-keys to the rescue:

1
(message (substitute-command-keys "Press <\\[projectile-switch-project]> to switch between projects"))

This will produce exactly the same message as before and you’re guaranteed the keybinding will always be in sync with the command.

Neat!

P.S. If you want to check interactively the keybinding of some command use C-h f (describe-function). Here’s an example - C-h f RET projectile-switch-project RET will produce this:

1
2
3
4
5
6
7
8
projectile-switch-project is an interactive compiled Lisp function.

It is bound to C-c p p, s-p p, <menu-bar> <tools> <Projectile> <Switch
to project>.

(projectile-switch-project &optional ARG1)

...

You can also check which command is bound to some key with C-h k.

-1:-- Display the Keybinding for a Command with substitute-command-keys (Post)--L0--C0--February 01, 2016 06:23 AM

Jorgen Schäfer: Elpy 1.11.0 released

I just released version 1.11.0 of Elpy, the Emacs Python Development Environment. This is a feature release.

Elpy is an Emacs package to bring powerful Python editing to Emacs. It combines and configures a number of other packages, both written in Emacs Lisp as well as Python.

Quick Installation

Evaluate this:

(require 'package)
(add-to-list 'package-archives
'("elpy" .
"https://jorgenschaefer.github.io/packages/"))

Then run M-x package-install RET elpy RET.

Finally, run the following (and add them to your .emacs):

(package-initialize)
(elpy-enable)

Changes in 1.11.0

  • Elpy now supports yapf in addition to autopep8 to format your code.
  • You can now adjust whether Elpy should hide modes from the mode line or not using elpy-remove-modeline-lighter
  • When the new option elpy-disable-backend-error-display is set, Elpy will not show its error pop-up anymore. This can be useful if you run into an annoying bug in Jedi, for example.
  • New command elpy-goto-definition-other-window on C-x 4 M-..
  • Expanding super now gives the short form supported in Python 3.
  • All Rope errors are now caught, as the upstream maintainers did not show interest in distinguishing between malformed input and bugs in their library.
  • Various other bug fixes.

Thanks to ChillarAnand, Clément Pit–Claudel, Daniel Gopar, Moritz Kuett, Shuai Lin and Zhaorong Ma for their contributions!

-1:-- Elpy 1.11.0 released (Post Jorgen Schäfer (noreply@blogger.com))--L0--C0--January 31, 2016 09:26 AM

Marcin Borkowski: Dimming out tildes in AUCTeX

I often write LaTeX in Emacs with AUCTeX. One thing I use a lot is tildes (these little ~ signs, which for LaTeX mean “unbreakable space”). [...] The problem with tildes is that they don’t look like spaces, and if you use them a lot, it becomes a bit more difficult to actually read the LaTeX source.
-1:-- Dimming out tildes in AUCTeX (Post)--L0--C0--January 30, 2016 10:17 PM

Da Zhang: How to achieve auto-compilation for the org–>latex–>pdf publishing chain — configurations around latexmk

1 Summary:

  1. how to set up latexmk, a perl program that monitors the status of a tex and run compilation automatically
  2. my Emacs, bash/zsh, and latexmkrc configurations around this tool
  3. my workflow of generating org–>latex–>pdf using this tool
  4. a few notes/tricks

3 installation/configuration of latexmk

  1. no need to install, latexmk is included within MikTex package, CTex, and TexLive
    which latexmk
    latexmk is /cygdrive/c/CTEX/MiKTeX/miktex/bin/latexmk
    
  2. but the INSTALL file in the downloaded package is quite info-rich
  3. check availability and if it is working properly:
    latexmk -v
    

4 Workflow

  1. in the org file, have the following headers (the following uses beamer)
    +LATEX_CLASS: beamer
    
  2. in Emacs, edit org file, then C-c C-e l l to export to latex
  3. open a mintty shell (consolez will not work properly)
    1. type
      latexmk -pvc -pdf -view=none paper.tex
      
    2. a latexmk process will run, and keeps monitoring the status of the tex file “paper.tex”
    3. you can then type
      sumatrapdf -reuse-instance paper.pdf
      
    4. the tex will be automatically compiled into pdf, and sumatrapdf will update the view automatically
  4. why consolez does not work
    1. the $TERM type needs to be xterm-256 or xterm, for properly stopping the latexmk program by typing Control-C
    2. in zsh or bash of consolez, the $TERM is “cygwin”, and Control-C will not work

5 Configurations

  1. my .latexmkrc file in ~
    1. note the default location of .latexmkrc is in your $HOME directory
    2. the language of this configuration file is perl
    3. I specified sumatrapdf as the viewer, because Adobe will lock the file
    4. I added additional extensions for clean_ext
      $pdf_previewer = 'sumatrapdf -reuse-instance %O %S';
      $clean_ext = 'paux lox pdfsync out';
      
  2. my aliases in bash/zsh:
    # for viewing pdf but not locking the file
    alias pdfview='sumatrapdf -reuse-instance'
    
    # for easily use latexmk
    alias mklatex='latexmk -pvc -pdf'
    # -f for non stop
    alias mktex='latexmk -f -pvc -pdf -view=pdf'
    
  3. my set up for different latex classes in init-org:
    (add-to-list 'org-latex-classes
                 '("compact"
                   "\\documentclass [letterpaper, 10pt]{article}
    \\usepackage{fullpage}
    \\usepackage{setspace}
    \\singlespacing
    \\usepackage{times}
    \\usepackage[compact]{titlesec}
    \\titlespacing{\\section}{0pt}{*0}{*0}
    \\titlespacing{\\subsection}{0pt}{*0}{*0}
    \\titlespacing{\\subsubsection}{0pt}{*0}{*0}
    \\usepackage{mdwlist}
    \\usepackage[T1]{fontenc}
    \\usepackage[left=2cm,top=1cm,right=2cm,nohead,nofoot]{geometry}"
                   ("\\section{%s}" . "\\section*{%s}")
                   ("\\subsection{%s}" . "\\subsection*{%s}")
                   ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                   ("\\subsubsubsection{%s}" . "\\subsubsubsection*{%s}")))
    
    (add-to-list 'org-latex-classes
                 '("article"
                   "\\documentclass [letterpaper, 11pt]{article}\n
    \\usepackage{fullpage}\n
    \\usepackage{setspace}\n
    \\doublespacing\n
    \\usepackage{amssymb}\n
    \\usepackage{graphicx}\n
    \\usepackage{subfigure}\n
    \\usepackage{float}\n
    \\usepackage{amsmath}\n
    \\usepackage{cite}\n
    \\usepackage{times}\n
    \\usepackage[T1]{fontenc}\n
    \\usepackage[pdfpagemode = colorlinks, pdffitwindow = true, bookmarks = true, pdftoolbar = false, pdfmenubar = true, pdfnewwindow = true]{hyperref}\n
    \\usepackage[left]{lineno}\n"
                   ("\\section{%s}" . "\\section*{%s}")
                   ("\\subsection{%s}" . "\\subsection*{%s}")
                   ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                   ("\\paragraph{%s}" . "\\paragraph*{%s}")
                   ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
    
    (add-to-list 'org-latex-classes
                 '("beamer"
                   "\\documentclass[red]{beamer}\n
         \\usetheme{Darmstadt}\n
         \\usefonttheme[onlylarge]{structurebold}\n
         \\setbeamerfont*{frametitle}{size=\\normalsize,series=\\bfseries}\n
         \\setbeamertemplate{navigation symbols}{}\n
         \\usepackage[english]{babel}\n
         \\usepackage{times}\n
         \\usepackage[T1]{fontenc}\n
         \\usepackage{graphicx}\n
         \\usepackage{color}\n
         \\usepackage{tikz}\n
         \\usetikzlibrary{arrows}\n
         \\tikzstyle{block}=[draw opacity=0.7,line width=1.4cm]\n
         \\usepackage{listings}
         \\lstset{numbers=none,language=[ISO]C++,tabsize=4,
         frame=single,
         basicstyle=\\small,
         showspaces=false,showstringspaces=false,
         showtabs=false,
         keywordstyle=\\color{blue}\\bfseries,
         commentstyle=\\color{red},
         }\n
         \\institute{BIDMC}\n"
                   ("\\section{%s}" . "\\section*{%s}")
                   ("\\begin{frame}[fragile]\\frametitle{%s}"
                    "\\end{frame}"
                    "\\begin{frame}[fragile]\\frametitle{%s}"
                    "\\end{frame}")))
    

6 How to run this file as a demo

  1. C-c C-e l l to create the tex file
  2. invoke the latexmk command in a mintty terminal
mktex latex_auto_compilation.tex
  1. open the resultant pdf file in sumatrapdf
pdfview latex_auto_compilation.pdf
  1. change the option line #+LATEX_CLASS:compact, among report, article, MP (not working well now), beamer
  2. repeat step 1 and you will see the latexmk and sumatrapdf working automatically for you.

-1:-- How to achieve auto-compilation for the org–&gt;latex–&gt;pdf publishing chain — configurations around latexmk (Post zhangda)--L0--C0--January 28, 2016 03:37 PM

Chen Bin (redguardtoo): Diff regions in Emacs

I know M-x ediff-regions-linewise.

But it's kind of too generic. I only want to view the different lines of two regions as quickly as possible.

So here is my code,

;; Diff two regions
;; Step 1: Select a region and `M-x diff-region-tag-selected-as-a'
;; Step 2: Select another region and `M-x diff-region-compare-with-b'
(defun diff-region-format-region-boundary (b e)
  "Make sure lines are selected and B is less than E"
  (let (tmp rlt)
    ;; swap b e, make sure b < e
    (when (> b e)
      (setq tmp b)
      (setq b e)
      (set e tmp))

    ;; select lines
    (save-excursion
      ;; Another workaround for evil-visual-line bug:
      ;; In evil-mode, if we use hotkey V or `M-x evil-visual-line` to select line,
      ;; the (line-beginning-position) of the line which is after the last selected
      ;; line is always (region-end)! Don't know why.
      (if (and (> e b)
               (save-excursion (goto-char e) (= e (line-beginning-position)))
               (boundp 'evil-state) (eq evil-state 'visual))
          (setq e (1- e)))
      (goto-char b)
      (setq b (line-beginning-position))
      (goto-char e)
      (setq e (line-end-position)))
    (setq rlt (list b e))
    rlt))

(defun diff-region-tag-selected-as-a ()
  "Select a region to compare"
  (interactive)
  (when (region-active-p)
    (let (tmp buf)
      ;; select lines
      (setq tmp (diff-region-format-region-boundary (region-beginning) (region-end)))
      (setq buf (get-buffer-create "*Diff-regionA*"))
      (save-current-buffer
        (set-buffer buf)
        (erase-buffer))
      (append-to-buffer buf (car tmp) (cadr tmp))))
  (message "Now select other region to compare and run `diff-region-compare-with-b`"))

(defun diff-region-compare-with-b ()
  "Compare current region with region selected by `diff-region-tag-selected-as-a' "
  (interactive)
  (if (region-active-p)
      (let (rlt-buf
            diff-output
            (fa (make-temp-file (expand-file-name "scor"
                                                  (or small-temporary-file-directory
                                                      temporary-file-directory))))
            (fb (make-temp-file (expand-file-name "scor"
                                                  (or small-temporary-file-directory
                                                      temporary-file-directory)))))
        (when fb
          (setq tmp (diff-region-format-region-boundary (region-beginning) (region-end)))
          (write-region (car tmp) (cadr tmp) fb))

        (setq rlt-buf (get-buffer-create "*Diff-region-output*"))
        (when (and fa (file-exists-p fa) fb (file-exists-p fb))
          (save-current-buffer
            (set-buffer (get-buffer-create "*Diff-regionA*"))
            (write-region (point-min) (point-max) fa))
          (setq diff-output (shell-command-to-string (format "diff -Nabur %s %s" fa fb)))
          ;; show the diff output
          (if (string= diff-output "")
              (message "Two regions are SAME!")
              (save-current-buffer
                (switch-to-buffer-other-window rlt-buf)
                (set-buffer rlt-buf)
                (erase-buffer)
                (insert diff-output)
                (diff-mode))))

        (if (and fa (file-exists-p fa))
            (delete-file fa))
        (if (and fb (file-exists-p fb))
            (delete-file fb)))
    (message "Please select region at first!")))
-1:-- Diff regions in Emacs (Post Chen Bin)--L0--C0--January 27, 2016 01:44 PM

Pragmatic Emacs: Speed up pdf export from org-mode with latexmk

These days I write almost everything (e.g. research papers, lecture notes and slides) in org-mode, and then export to pdf (see my posts on org-mode here). This is a really pleasant and efficient way to create documents, but when working on a long document, it can take several seconds for emacs to compile the exported latex to pdf. During that time, emacs is hung up waiting for the compilation to finish, which is annoying.

I thought I’d share my workflow for streamlining this process. The key ingredient is not part of emacs. I use latexmk which is a perl script that watches a latex file and compiles it if it changes (or any file that it depends on changes). It will repeat the compilation (including calling bibtex) as many times as needed to resolve all references.

So, if I am working on a file, say document.org, I will run latexmk on the corresponding tex file using

latexmk -pvc -pdf -view=none document.tex

Here, the -pcv option means to keep watching the file for changes and recompile as needed; the -pdf option means build a pdf from the latex using pdflatex, and -view=none tells latexmk not to open a pdf viewer to show the resulting pdf.

I then open the resulting document.pdf in skim, an excellent pdf viewer for the Mac (unfortunately hosted on sourceforge). The killer feature of skim compared to the built-in OS X preview app, is that it will automatically redisplay a pdf if the file changes (I believe evince or okular on linux do the same).

Putting the pieces together, I have latexmk running in a terminal, and an emacs window and skim window side by side. I then export my org file to latex with e.g. C-c C-e l l which happens almost instantly and gives me control back of emacs. The latex is compiled in the background by latexmk and then a few seconds later the pdf updates in skim and I can see my changes.

-1:-- Speed up pdf export from org-mode with latexmk (Post Ben Maughan)--L0--C0--January 26, 2016 09:06 PM

Raimon Grau: Pointy org-bullets

As it seems everyone in my internet neighborhood is publishing their org-bullet configs, that's how my bullets in org look like now.

 It's quite intuitive: the more pointed, the more important. And there are no differences in the line height.

Here's a screenshot:

;; http://nadeausoftware.com/articles/2007/11/latency_friendly_customized_bullets_using_unicode_characters
(eval-after-load 'org-bullets
  '(setq org-bullets-bullet-list '("✺" "✹" "✸" "✷" "✶" "✭" "✦" "■" "▲" "●" )))

-1:-- Pointy org-bullets (Post Raimon Grau (noreply@blogger.com))--L0--C0--January 26, 2016 06:28 PM

Alex Schroeder: Testing Encrypted Mail Setup

I’ve updated my guide, the Gmail Gnus GPG Guide (GGGG) to incorporate the latest addition to the FSF’s Email Self-Defense guide to free software-powered encryption. They even have a guide on how to help your friends and family, including talking points if want to make your case.

Anyway, the thing I added to the guide is how to initiate communication with the bot:

  1. send him your Public key
  2. get his public key from a keyserver
  3. how to set up a keyserver in order to achieve step #2
  4. send him an encrypted mail

Tags: RSS RSS RSS RSS

-1:-- Testing Encrypted Mail Setup (Post)--L0--C0--January 23, 2016 10:31 AM

(or emacs: avy 0.4.0 is out

This release consists of 77 commits done over the course of the last 7 months by me and many contributors. Similarly to the 0.3.0 release, the release notes are in Changelog.org. You can read them either at github or inside Emacs. Big thanks to all contributors.

avy.png

Highlights

A lot of new code is just straight upgrades, you don't need to do anything extra to use them. Below, I'll describe the other part of the new code, which is new commands and custom vars.

avy-goto-char-timer

This command now allows as many characters as you like, which makes it similar to a isearch + avy-isearch combination. As you type, you get an isearch-like highlight, then after a short delay you automatically get the avy selection.

Switch the action midway from goto to kill/mark/copy

This is similar to the cool feature of ace-window that allows you to switch the action after you get the avy prompt.

For example, suppose you have:

(global-set-key (kbd "M-t") 'avy-goto-word-1)

Here's what you can do now to a word that starts with a "w" and is select-able with "a":

  • To jump there: M-t w a.
  • To copy the word instead of jumping to it: M-t w na
  • To mark the word after jumping to it: M-t w ma.
  • To kill the word after jumping to it: M-t w xa.

You can customize avy-dispatch-alist to modify these actions, and also ensure that it plays nicely with your avy-keys, if you customized them. By default, it works fine, since avy-keys is '(?a ?s ?d ?f ?g ?h ?j ?k ?l) and the keys on avy-dispatch-alist are '(?x ?m ?n).

avy-pop-mark

This command reverses avy-push-mark which most of avy commands call. It has its own history and works across multiple windows and frames. I'm using it currently as an upgrade to my old (set-mark-command 4) lambda:

(global-set-key (kbd "M-p") 'avy-pop-mark)

Here's a line to make avy-pop-mark work also for swiper:

(advice-add 'swiper :before 'avy-push-mark)
-1:-- avy 0.4.0 is out (Post)--L0--C0--January 22, 2016 11:00 PM

Ryan Rix: Matrix-Client.el 0.3.0

I just pushed a new tag to the Matrix-Client repository and the features should be available in MELPA shortly.
-1:-- Matrix-Client.el 0.3.0 (Post)--L0--C0--January 18, 2016 12:00 AM

(or emacs: Using Emacs as system-wide Rhythmbox interface

In an earlier post, I described how I've been managing Rhythmbox from Emacs. I've bound the entry point to C-S-o:

(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)

Obviously, this entry point won't work while outside Emacs. Today, I'll describe how I've made it work everywhere. Everywhere on Ubuntu 14.04, that is, although a similar approach should work for other distributions.

Step 1: Make sure the Emacs server is running

Here's the relevant part of my init.el:

(require 'server)
(or (server-running-p) (server-start))

Using emacsclient is essential to avoiding the extra startup time: even a startup time of one second feels sluggish when all I need is to open a menu with a song playlist.

Step 2: Install the relevant X window tool

Initially, I only wrote a call to emacsclient, which resulted in the Emacs window gaining focus in the end. Then I thought it would be nice to give the focus back the original window after the end of selection, and raise it as well.

I wanted to do something with wmctrl, but I found that xdotool can do what I want in a simple way.

sudo apt-get install xdotool

Step 3: Write a shell script

#!/bin/bash
wnd_id="$(xdotool getwindowfocus)"
emacsclient --eval "(progn (x-focus-frame nil) (counsel-rhythmbox))"
xdotool windowfocus $wnd_id
xdotool windowraise $wnd_id

Here, (x-focus-frame nil) will raise the Emacs window and give the keyboard input focus. emacsclient will return as soon as I select something or press C-g. At that point the keyboard focus will be returned to whatever window had it when the script was invoked.

By the way, here's a cool configuration that automatically makes a file executable if it starts with #!.

(add-hook
 'after-save-hook
 'executable-make-buffer-file-executable-if-script-p)

Step 4: Bind the shell script to a key

Open this (possibly using gnome-control-center instead, if applicable):

unity-control-center keyboard

And add a new shortcut in Shortcuts/Custom Shortcuts. I've bound that one to C-S-o as well.

The final result

It's pretty convenient: as I'm scrolling something I'm reading in Firefox with j (via Firemacs), I can seamlessly press C-S-o moo RET to play "Sisters of the Moon", and continue scrolling the web page with j.

What's more, Emacs has very nice support for input methods with C-\ (toggle-input-method), so I can also quickly select Ukrainian-titled songs, while still keeping shortcuts like C-n and C-m (without having to switch the input method back).

The whole experience is similar to gnome-do/synapse, which I was using a few years back, except better because now it's in Emacs.

-1:-- Using Emacs as system-wide Rhythmbox interface (Post)--L0--C0--January 17, 2016 11:00 PM

Jorgen Schäfer: Buttercup 1.3 released

I just released version 1.3 of Buttercup, the Behavior-Driven Emacs Lisp Testing framework.

Buttercup is a behavior-driven development framework for testing Emacs Lisp code. It is heavily inspired by Jasmine.

Installation and Use

Buttercup is available from MELPA Stable.

Example test suite:

(describe "A suite"
(it "contains a spec with an expectation"
(expect t :to-be t)))

Suites group tests, and suites can be nested. Contrary to ERT, suites can share set-up and tear-down code for tests, and Buttercup comes with built-in support for mocks in the form of spies. See the package homepage above for a full description of the syntax for test suites and specs.

Buttercup comes with a shell script to run the default discover runner. If used together with cask, cask exec buttercupwill find, load and run test suites in your project.

Changes Since 1.2

  • The test discovery can now skip tests based on a pattern, given by the -p command line argument.
  • The buttercup-pending signal now takes an argument which is displayed during spec execution. This enables users to provide a visual explanation as to why a spec was skipped.
-1:-- Buttercup 1.3 released (Post Jorgen Schäfer (noreply@blogger.com))--L0--C0--January 09, 2016 08:30 AM

Raimon Grau: TIL: ediff-revision

When editing a file in some git branch I often want to take a quick look at the same file in other branch (usually master).  I always did it by
 git diff HEAD master -- file.rb 
but today I discovered there's an emacs way to do it.
 M-x ediff-revision
. it asks you for a file (defaults to the current one), and two branches. And that's it!
-1:-- TIL: ediff-revision (Post Raimon Grau (noreply@blogger.com))--L0--C0--January 07, 2016 06:14 PM

Yann Hodique: How modern languages will save the text editor

I’ve been an Emacs user for many years, and a coder for just as long. Somewhere in the middle, something weird happened: while a text editor was initially considered a perfectly appropriate way of writing code (in C, Lisp, Perl, Shell, …), that ceased to be true for a while. With the gain in popularity of complex languages like Java, or C++, coders started to crave “fancy” features like code completion, refactoring, …

And quite unfortunately, these advanced features relied to complex tooling living outside of the languages themselves. Worse, the languages were developed in complete ignorance of these tools, which made them somewhat hostile to those goals (anybody who tried to implement a correct C++ parser knows what I mean, life before clang was just painful). As a result, very complex tools making heavy use of specialized partial parsers, static analysis, and crazy heuristics emerged. And they emerged as part of even more complex development suites to combine them all in a coherent form: the IDE was born.

To tell the truth, I’ve never been a fan of the concept, and even though I contributed to KDevelop for a while, I did so from the comfort of my beloved Emacs… Still, it’d be dishonest to pretend IDEs like Visual Studio, Eclipse and the likes don’t have a great impact, even today, on how people ultimately develop code.

I guess my main gripe with this abundant tooling is that it’s an all-or-nothing deal: there’s just no (easy) way I can take some of that experience and integrate it somewhere else. At a more fundamental level, it seemed simply “odd”: why would we introduce “deficiencies” at the language level, just to hope somebody else would work around them the best they can in tools? For those reasons, I never actually used an IDE. But then, I also stayed away from the languages that were “requiring” them as much as possible (with mixed results, as I ended up writing a ton of code in those as well :)). Not everybody has that luxury though, so text editors declined.

But more recently, things took a different turn (for the best I think): a new language emerged that was promoting a different paradigm: Go. Instead of making the tooling an afterthought, it’s been pretty much there at some level since inception. It even shows in the language grammar itself, which is designed to enable fast compilation, partial parsing, and a whole bunch of analysis tools. So instead of designing a language to give programmers arbitrary bells and whistles they’re used to (completely disregarding the resulting complexity in the larger ecosystem), the Go creators have made careful choices to create the best overall experience, which includes not only code writing, but also code reading, code maintaining and so on. So while some “features” that people might expect are noticeably missing (macros, generics, …), it’s not just because those guys are lazy (although all great engineers are :)) but also because the balance to maintain is very subtle.

I personally find the result quite brilliant (some people obviously disagree), and it’s a real pleasure to write code in Go, but more importantly to me, I can take the tooling, and integrate it pretty much anywhere. So a complex IDE is not even particularly useful: all you need from your editor is to be able to display the information the tools give, and to act on it.

And then, just like that, Emacs is a perfect environment to develop in Go. It’s not exactly free of course, in the sense that some integration code has to be developed. But it’s definitely several orders of magnitude easier than getting a proper environment for Java or C++, and even Python, despite Elpy’s greatness.

If anybody’s curious, here’s my Go configuration for Emacs. Except for some GOPATH-related gymnastics, it’s pretty straighforward.

I believe this new ability to embrace whatever environment the developer is most familiar with, and with minimal effort, is part of Go’s appeal. I, for one, am most excited about the prospect of many developer-friendly tools to come, and I really hope Go is just the first of many languages to follow the same approach.

-1:-- How modern languages will save the text editor (Post)--L0--C0--January 02, 2016 06:53 PM