2015-06-15 09:05:52 +02:00
|
|
|
;;; defuns-ui.el
|
|
|
|
;; for ../core-ui.el
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun narf:toggle-transparency ()
|
|
|
|
(interactive)
|
|
|
|
(let* ((alpha (frame-parameter nil 'alpha))
|
|
|
|
(alpha-val (if (listp alpha) (car alpha) alpha)))
|
|
|
|
(if (/= alpha-val 97)
|
|
|
|
(set-frame-parameter nil 'alpha 100)
|
|
|
|
(set-frame-parameter nil 'alpha 0))))
|
|
|
|
|
2015-11-03 17:36:36 -05:00
|
|
|
;;;###autoload (autoload 'narf:toggle-fullscreen "defuns-ui" nil t)
|
2016-01-29 02:05:16 -05:00
|
|
|
(after! evil
|
2016-03-03 01:37:08 -05:00
|
|
|
(evil-define-command narf:toggle-fullscreen ()
|
|
|
|
(interactive)
|
|
|
|
(set-frame-parameter nil 'fullscreen (if (not (frame-parameter nil 'fullscreen)) 'fullboth))))
|
2015-11-10 18:10:32 -05:00
|
|
|
|
2015-10-01 03:41:16 -04:00
|
|
|
;;;###autoload
|
|
|
|
(defun narf/reset-theme ()
|
|
|
|
(interactive)
|
2016-03-23 11:55:52 -04:00
|
|
|
(narf/load-theme (or narf-current-theme narf-default-theme)))
|
2015-11-10 18:10:32 -05:00
|
|
|
|
|
|
|
;;;###autoload
|
2016-01-29 02:05:16 -05:00
|
|
|
(defun narf/load-font (font)
|
2015-11-10 18:10:32 -05:00
|
|
|
(interactive)
|
2016-02-04 19:00:03 -05:00
|
|
|
(set-frame-font font t)
|
2016-01-29 02:05:16 -05:00
|
|
|
(setq narf-current-font font))
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
(defun narf/load-theme (theme &optional suppress-font)
|
|
|
|
(interactive)
|
|
|
|
(when narf-current-theme
|
|
|
|
(disable-theme narf-current-theme))
|
|
|
|
(load-theme theme t)
|
|
|
|
(unless suppress-font
|
|
|
|
(narf/load-font narf-current-font))
|
|
|
|
(setq narf-current-theme theme))
|
2015-10-01 03:41:16 -04:00
|
|
|
|
2015-11-10 18:10:32 -05:00
|
|
|
;;;###autoload
|
|
|
|
(defun narf/show-as (how &optional pred)
|
|
|
|
(let* ((beg (match-beginning 1))
|
|
|
|
(end (match-end 1))
|
|
|
|
(ok (or (not pred) (funcall pred beg end))))
|
|
|
|
(when ok
|
|
|
|
(compose-region beg end how 'decompose-region))
|
|
|
|
nil))
|
|
|
|
|
2016-04-12 02:59:36 -04:00
|
|
|
;;;###autoload
|
|
|
|
(defun narf/add-whitespace (&optional start end)
|
2016-04-16 21:27:59 -04:00
|
|
|
"Maintain indentation whitespace in buffer. Used so that highlight-indentation will
|
|
|
|
display consistent guides. Whitespace is stripped out on save, so this doesn't affect the
|
|
|
|
end file."
|
2016-04-12 02:59:36 -04:00
|
|
|
(interactive (progn (barf-if-buffer-read-only)
|
|
|
|
(if (use-region-p)
|
|
|
|
(list (region-beginning) (region-end))
|
|
|
|
(list nil nil))))
|
2016-04-16 21:27:59 -04:00
|
|
|
(unless indent-tabs-mode
|
|
|
|
(save-match-data
|
|
|
|
(save-excursion
|
|
|
|
(let ((end-marker (copy-marker (or end (point-max))))
|
|
|
|
(start (or start (point-min))))
|
|
|
|
(goto-char start)
|
|
|
|
(while (and (re-search-forward "^$" end-marker t) (not (>= (point) end-marker)))
|
|
|
|
(let (line-start line-end
|
|
|
|
next-start next-end)
|
|
|
|
(save-excursion
|
|
|
|
;; Check previous line indent
|
|
|
|
(forward-line -1)
|
|
|
|
(setq line-start (point)
|
|
|
|
line-end (save-excursion (back-to-indentation) (point)))
|
|
|
|
;; Check next line indent
|
|
|
|
(forward-line 2)
|
|
|
|
(setq next-start (point)
|
|
|
|
next-end (save-excursion (back-to-indentation) (point)))
|
|
|
|
;; Back to origin
|
|
|
|
(forward-line -1)
|
|
|
|
;; Adjust indent
|
|
|
|
(let* ((line-indent (- line-end line-start))
|
|
|
|
(next-indent (- next-end next-start))
|
|
|
|
(indent (min line-indent next-indent)))
|
|
|
|
(insert (make-string indent ? )))))
|
|
|
|
(forward-line 1)))))
|
|
|
|
(set-buffer-modified-p nil))
|
2016-04-12 02:59:36 -04:00
|
|
|
nil)
|
|
|
|
|
2016-04-14 12:54:25 -04:00
|
|
|
;;;###autoload
|
|
|
|
(defun narf/imenu-list-quit ()
|
|
|
|
(interactive)
|
|
|
|
(quit-window)
|
|
|
|
(mapc (lambda (b) (with-current-buffer b
|
|
|
|
(when imenu-list-minor-mode
|
|
|
|
(imenu-list-minor-mode -1))))
|
|
|
|
(narf/get-visible-buffers (narf/get-real-buffers))))
|
|
|
|
|
2015-06-15 09:05:52 +02:00
|
|
|
(provide 'defuns-ui)
|
|
|
|
;;; defuns-ui.el ends here
|