rice

personal dot files and scripts for linux and macOS
Log | Files | Refs | README | LICENSE

core-macos.el (2611B)


      1 ;;; core-osx.el --- solarized module for my emacs
      2 
      3 ;; Author: Mark Feller <mark.feller@member.fsf.org>
      4 
      5 ;; This file is not part of GNU Emacs.
      6 
      7 ;; This file is free software; you can redistribute it and/or modify
      8 ;; it under the terms of the GNU General Public License as published by
      9 ;; the Free Software Foundation; either version 3, or (at your option)
     10 ;; any later version.
     11 
     12 ;; This file is distributed in the hope that it will be useful,
     13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 ;; GNU General Public License for more details.
     16 
     17 ;; You should have received a copy of the GNU General Public License
     18 ;; along with this file.  If not, see <http://www.gnu.org/licenses/>.
     19 
     20 ;;; Commentary:
     21 
     22 ;;; Code:
     23 
     24 ;; transparent title bar
     25 (use-package ns-auto-titlebar
     26   :config (ns-auto-titlebar-mode))
     27 
     28 (setq ns-use-srgb-colorspace t)
     29 (setq ns-use-proxy-icon nil)    ; hide icon in title bar
     30 (setq frame-title-format nil)   ; hide text in title bar
     31 (menu-bar-mode t)               ; use macos menu bar
     32 
     33 (setq mac-option-modifier 'meta)
     34 (setq mac-command-modifier 'hyper)
     35 
     36 ;; Enable emoji, and stop the UI from freezing when trying to display them.
     37 (if (fboundp 'set-fontset-font)
     38     (set-fontset-font t 'unicode "Apple Color Emoji" nil 'prepend))
     39 
     40 (use-package exec-path-from-shell
     41   :demand
     42   :config
     43   (exec-path-from-shell-initialize)
     44   (exec-path-from-shell-copy-env "GNUPGHOME")
     45   (exec-path-from-shell-copy-env "NOTMUCH_CONFIG")
     46   (exec-path-from-shell-copy-env "XDG_DOCUMENTS_DIR"))
     47 
     48 (defun finder ()
     49   "Opens file directory in Finder."
     50   (interactive)
     51   (let ((file (buffer-file-name)))
     52     (if file
     53         (shell-command
     54          (format "%s %s" (executable-find "open") (file-name-directory file)))
     55       (error "Buffer is not attached to any file."))))
     56 
     57 (when (not (display-graphic-p))
     58   (defun bw/copy-from-osx ()
     59     "Copies the current clipboard content using the `pbcopy` command"
     60     (shell-command-to-string "pbpaste"))
     61 
     62   (defun bw/paste-to-osx (text &optional push)
     63     "Copies the top of the kill ring stack to the OSX clipboard"
     64     (let ((process-connection-type nil))
     65       (let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
     66         (process-send-string proc text)
     67         (process-send-eof proc))))
     68 
     69   (setq interprogram-cut-function 'bw/paste-to-osx)
     70   (setq interprogram-paste-function 'bw/copy-from-osx))
     71 
     72 (defun mjf/center-window ()
     73   (interactive)
     74   (call-process-shell-command "osascript ~/.config/emacs/scripts/Center-Window.scpt" nil 0))
     75 
     76 (provide 'core-macos)
     77 
     78 ;;; core-osx.el ends here