Skip to content

Instantly share code, notes, and snippets.

@Alexander-Miller
Created June 23, 2017 15:01
Show Gist options
  • Save Alexander-Miller/1ca7ccc9a53754084c998662824c86ab to your computer and use it in GitHub Desktop.
Save Alexander-Miller/1ca7ccc9a53754084c998662824c86ab to your computer and use it in GitHub Desktop.
;; -*- lexical-binding: t -*-
(require 'dash)
(require 's)
(require 'company)
(defun rofi-filter (proc msg)
(backward-delete-char (length company-prefix))
(insert (s-trim msg)))
(defun rofi-complete ()
(interactive)
(company-complete)
(when company-candidates
(let ((rofi
(make-process
:command (list "rofi" "-dmenu")
:name "Rofi Complete"
:filter #'rofi-filter)))
(unwind-protect
(progn
(dolist (buffer (-partition-all 50 company-candidates))
(--each buffer
(when (process-live-p rofi)
(process-send-string rofi (concat it "\n")))))
(when (process-live-p rofi) (accept-process-output rofi nil nil t)))
(when (process-live-p rofi) (kill-process rofi))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment