rc / ca53c69 emacs / scraps+misc.el

Tree @ca53c69 (Download .tar.gz)

scraps+misc.el @ca53c69raw · history · blame

(defun bqv/pmbootstrap-log ()
  "Open pmbootstrap log in a buffer."
   (let* ((title "*pmbootstrap-log*")
          (buffer (get-buffer title)))
     (or buffer
           (with-current-buffer (window-buffer
                                 (async-shell-command "pmbootstrap log"))
             (rename-buffer title t)))))))

(defun comint-sudo-run (program)
  "Run sudo PROGRAM in a Comint buffer and switch to it.
See `comint-run'."
  (declare (interactive-only make-comint))
  (interactive "sRun program: ")
  (let ((name (file-name-nondirectory program)))
    (switch-to-buffer (make-comint name "sudo" nil program))
    (run-hooks (intern-soft (concat "comint-" name "-hook")))))

;; source:
(defun rename-file-and-buffer (new-name)
  "Renames both current buffer and file it's visiting to NEW-NAME."
  (interactive "sNew name: ")
  (let ((name (buffer-name))
        (filename (buffer-file-name)))
    (if (not filename)
        (message "Buffer '%s' is not visiting a file!" name)
      (if (get-buffer new-name)
          (message "A buffer named '%s' already exists!" new-name)
          (rename-file filename new-name 1)
          (rename-buffer new-name)
          (set-visited-file-name new-name)
          (set-buffer-modified-p nil))))))

(defun bookmark-save-advice (&rest r)
  (let ((save-silently t))
(advice-add 'bookmark-set :after #'bookmark-save-advice)

(setq desktop-environment-volume-get-command "amixer -c0 get Master")
(setq desktop-environment-volume-set-command "amixer -c0 set Master %s")
(setq desktop-environment-volume-toggle-command "amixer -c0 set Master toggle")
(define-key desktop-environment-mode-map (kbd "<269025043>") #'desktop-environment-volume-increment) ; mouse v-up
(define-key desktop-environment-mode-map (kbd "S-<269025043>") #'desktop-environment-volume-increment-slowly)
(define-key desktop-environment-mode-map (kbd "<269025041>") #'desktop-environment-volume-decrement) ; mouse v-down
(define-key desktop-environment-mode-map (kbd "S-<269025041>") #'desktop-environment-volume-decrement-slowly)
(define-key desktop-environment-mode-map (kbd "<269025073>") #'emms-pause) ; headset btn