Echo AreaJust a blog, ok2014-07-09T02:19:00Ztekutihttp://blog.ryuslash.org/feed/atomTom Willemsenhttp://blog.ryuslash.org/Clean completionshttp://blog.ryuslash.org/2014/07/08/clean-completions2014-07-09T02:19:00Z2014-07-09T02:19:00Z

Today's post is very short. In my quest to make GNU Emacs look ever better I thought about something new (to me). Not all buffers need have a mode line. As such I will now turn off the mode line for completion-list-mode, since that only shows up for a short while and I've so far never had any trouble distinguishing it from other buffers.

(add-hook 'completion-list-mode-hook
          (lambda () (setq mode-line-format nil)))

Now, whenever a completion buffer pops up, it'll use all the space available, including the line where the mode line used to be. If it shows up just above the minibuffer (which for me it always has done) it looks more like a part of the same thing instead of two separate windows.

Tom Willemsenhttp://blog.ryuslash.org/Filtering org taskshttp://blog.ryuslash.org/2013/08/24/filtering-org-tasks2013-08-24T22:38:00Z2013-08-24T22:38:00Z

I want to be able to easily see a list of tasks that are relevant to the currently loaded desktop file. As I use desktop.el as a kind of project system, this means I only want the tasks for the project I'm currently working on.

First I wrote the tagify function, because org-mode tags can't contain . or - characters (among others I'm sure, but these are the only ones that have caused me any trouble so far). It's a simple string replacement:

(defun tagify (str)
  "Remove dots, replace - with _ in STR."
  (replace-regexp-in-string
   "-" "_" (replace-regexp-in-string "\\." "" (downcase str))))

Then I wrote a function to filter the task list by not showing anything that wasn't tagged with the name of the currently loaded desktop, unless it isn't tagged at all or no desktop has been loaded. And set this function to be the value of org-agenda-before-sorting-filter-function.

(defun filter-by-desktop (entry)
  "Return ENTRY if it has no tags or a tag corresponding to the desktop."
  (require 'desktop)
  (let ((label (when desktop-dirname
                 (tagify (file-name-base
                          (directory-file-name
                           (expand-file-name desktop-dirname))))))
        (tags (get-text-property 0 'tags entry)))
    (when (or (null desktop-dirname) (null tags) (member label tags))
      entry)))

(setq org-agenda-before-sorting-filter-function #'filter-by-desktop)

This works fine. I keep untagged tasks in the list as well because they might be important at all times and I don't want them falling through the cracks. I also want a complete list if no desktop has been loaded so I can browse through my tasks and decide what I'm going to do next.

The downside of this solution is that I have to close my current project in order to see the whole list.

Then I discovered the / key in the agenda buffer. I can't believe I didn't notice this key before. Anyway, that changed my solution.

Instead of setting org-agenda-before-sorting-filter-function I add a hook to the org-agenda-finalize-hook. The filter-by-desktop function looks a little different now:

(defun org-init-filter-by-desktop ()
  "Filter agenda by current label."
  (when desktop-dirname
    (let ((label (tagify (file-name-base
                          (directory-file-name
                           (expand-file-name desktop-dirname))))))
      (org-agenda-filter-apply (cons label nil) 'tag))))

(add-hook 'org-agenda-finalize-hook 'org-init-filter-by-desktop)

I don't need to compare any tags now, and if I want to see my entire list of tasks I can easily just press / /. Since it is easier to get back to the overview of my tasks it also doesn't bother me so much that this way any untagged tasks don't show up in the filtered buffer.

I haven't stopped using / since I discovered it. Filtering in this way is one of the things I like about ibuffer as well, now for org-mode it works excellently as well.

Tom Willemsenhttp://blog.ryuslash.org/Some quick git diff tipshttp://blog.ryuslash.org/2013/08/11/some-quick-git-diff-tips2013-08-10T22:54:22Z2013-08-10T22:54:22Z

A couple of quick tips. As you possibly know you can specify some options to be used for diffs (and other things) per file type. The one I'm interested in is the function name.

For org-mode

The primary way of identifying which part of an org-mode document a change occurs in seems to me to be the heading. So, in your $HOME/.gitconfig put:

[diff "org"]
      xfuncname = "^\\*+.*"

Which should show any lines starting with one or more * characters. And then in $XDG_CONFIG_HOME/git/attributes or $HOME/.config/git/attributes put:

*.org   diff=org

For lisp and lisp-like langauges

For anything that resembles lisp (so Common Lisp, Emacs Lisp, Hy, scheme, etc.) I would think that the easiest thing to do is just see the closes top-level form. So, in your $HOME/.gitconfig put:

[diff "lisp"]
      xfuncname = "^\\([^ ]+ [^ ]+"

Which should show the opening parenthesis and the first two words. For example:

(defun some-function-name
(defclass my-awesome-class
(define-route this-strange-route

And then put in your $XDG_CONFIG_HOME/git/attributes or $HOME/.config/git/attributes:

*.lisp  diff=lisp
*.el    diff=lisp
*.hy    diff=lisp
*.scm   diff=lisp

And possibly any other lisp-like language files you can think of.