mercredi 2 mai 2018

notmuch mark as spam

Adds a keybinding that applies/removes tags to the currently viewed email or --when looking at search results-- the thread under point.
(defun mark-spam ()
  (let ((tlist '("+spam" "-unread" "-inbox" "-new")))
    (if (eq major-mode 'notmuch-show-mode)
   (let ((id (notmuch-show-get-message-id)))
     (notmuch-tag id tlist)
      (notmuch-search-tag tlist)

(define-key 'notmuch-search-mode-map (kbd "S") 'mark-spam)
(define-key 'notmuch-show-mode-map (kbd "S") 'mark-spam)

vendredi 17 février 2017

_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build

_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build

If you are pulling your hair and wondering why your kernel does not have a /sys/kernel/debug/dynamic_debug directory despite having CONFIG_DYNAMIC_DEBUG enabled and debugfs mounted, the issue could be that you built the kernel using GOLD linker. You can simply switch through the LD Makefile variable (make LD=ld.bfd)

lundi 16 janvier 2017

Extracting and applying a clean git patchset from an email thread with notmuch

I just wrote a quick python script to filter the actual patches from a email thread send with git send-email (those "[PATCH 1/15] xyz" threads). The script assumes you use notmuch. Give it a search expression that returns a list of messages that includes all the patches like the thread-id (C-u c i while looking at the thread in emacs).

You can get it on github. There is a small elisp snippet in the README to run the script and apply the patchset from emacs.

vendredi 13 janvier 2017

Copy current buffer absolute file path to the OS clipboard

(defun copy-full-path ()
  (let ((path (buffer-file-name)))
    (when path
      (setq path (expand-file-name path))
      (funcall interprogram-cut-function path)
      (message "copied %s in clipboard" path))))

Quick-and-dirty email template for notmuch

(defun prepare-report ()
  (insert "")
  (search-forward "Subject: ")
  (insert "work report week " (format-time-string "%W"))
  (search-forward "\n\n")
  (insert "my super email content\n"))

Jump to code from Coverity report emails (notmuch)

If you use notmuch as your email client and receive Coverity reports emails, here's a quick function that compiles the reports to a single buffer (newest first), applies some color on the errors, and enables the compilation minor mode so you can use Emacs regular "jump to next error" key.

Adapt the default-directory to your project source.

(defun samba-coverity ()
  (let ((b (get-buffer-create "*coverity*")))
    (with-current-buffer b
      (setq default-directory (expand-file-name "~/prog/samba-git"))
  "for i in $(notmuch search --output=messages"
  " ''); do notmuch show $i; done"
  " | perl -pE 's,^/(\\S+): (\\d+) in,cov:$1:$2: in,'")))
      (goto-char (point-min))
      (while (search-forward-regexp (rx bol ">>>") nil t)
 (let ((beg (save-excursion (beginning-of-line) (point)))
       (end (save-excursion (end-of-line) (point))))
   (put-text-property beg end 'face 'error)))
      (goto-char (point-min))      
    (switch-to-buffer b)))

vendredi 8 avril 2016

Insert new rpm-style changelog entry

(defun new-changelog-entry ()
  (let ((line-len 67)
        (date (substring (shell-command-to-string "LC_ALL=C date -u") 0 -1))
        ;; (email user-mail-address) probably wrong
        (email (concat user-real-login-name ""))
    (goto-char (point-min))
    (insert (make-string line-len ?-) "\n"
            date " - " email "\n\n"
            " - ")
    (setq final-pos (point))
    (insert "\n\n")
    (goto-char final-pos)))