From b135b7bf531d478c236e27dd397a8a8c8aada0b8 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 19 Feb 2017 18:09:44 -0500 Subject: [PATCH] Add doom/toggle-sticky to core/autoload/editor --- core/autoload/editor.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/autoload/editor.el b/core/autoload/editor.el index 41e3d1237..088a0dcb5 100644 --- a/core/autoload/editor.el +++ b/core/autoload/editor.el @@ -186,3 +186,16 @@ consistent throughout a selected region, depending on `indent-tab-mode'." (tabify beg end) (untabify beg end))) +;;;###autoload +(defun doom/toggle-sticky (&optional beg end) + "Make a selection sticky by placing it in the header line. Possibly helpful +for function signatures or notes. Run again to clear the header line." + (interactive "r") + (setq header-line-format + (when mark-active + (concat (propertize (format nlinum-format (line-number-at-pos beg)) + 'face 'font-lock-comment-face) + (let ((content (buffer-substring beg end))) + (setq content (s-replace "\n" " " content)) + (setq content (replace-regexp-in-string "\\s-+" " " content)) + content)))))