Categories: geek » emacs

RSS - Atom - Subscribe via email
Recommended links:

Using inotify to add Plover Clippy suggestions into Emacs

| emacs

I don't have a lot of screen space on my laptop, so I don't usually have the Plover suggestion window open as I type. I came up with a Plover plugin to let me flash the last Plover Clippy suggestion as a temporary notification. It went by too quickly, though, so I wrote something that uses inotify to monitor the clippy.txt log and put it an Emacs buffer instead. It results in text like this:

Clippy -> KHREUP PEU; added -> ATD; have to -> STRO; I have -> SREU; to the -> TOT, TO*T; I had -> H*EU;
(defun my/clippy-last ()
  (let ((value (string-trim (shell-command-to-string "tail -1 ~/.config/plover/clippy.txt | cut -c 23-"))))
    (when (string-match "^\\(.*?\\)[ \t]+|| .*? -> \\(.+\\)" value)
      (cons (match-string 1 value) (match-string 2 value)))))

(defun my/clippy-show (&rest _)
  (interactive)
  (with-selected-window (get-buffer-window (get-buffer-create "*Clippy*"))
    (let ((last (my/clippy-last)))
      (goto-char (point-min))
      (insert (format "%s -> %s; " (car last) (cdr last))))))

(defvar my/clippy-monitor nil)
(defun my/clippy-toggle-monitor ()
  (interactive)
  (if (inotify-valid-p my/clippy-monitor)
      (progn
        (message "Turning off")
        (inotify-rm-watch my/clippy-monitor))
    (message "Turning on")
    (setq my/clippy-monitor
          (inotify-add-watch
           (expand-file-name "~/.config/plover/clippy.txt") 'modify
           #'my/clippy-show))))
This is part of my Emacs configuration.
View or add comments

2021-06-14 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar and emacs-devel.

View or add comments

2021-06-07 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar and emacs-devel.

View or add comments

2021-05-31 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar and emacs-devel.

View or add comments

2021-05-24 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar and emacs-devel.

View or add comments

2021-05-17 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar and emacs-devel.

View or add comments

2021-05-10 Emacs news

| emacs, emacs-news

Links from reddit.com/r/emacs, r/orgmode, r/spacemacs, r/planetemacs, Hacker News, planet.emacslife.com, YouTube, the Emacs NEWS file, Emacs Calendar and emacs-devel.

View or add comments