浏览代码

Changes in emacs config

PeterParfenov 1 年之前
父节点
当前提交
c39cced4dd
共有 1 个文件被更改,包括 85 次插入12 次删除
  1. 85 12
      .emacs

+ 85 - 12
.emacs

@@ -6,6 +6,18 @@
 (defun system-is-macos()
   (string-equal system-type "darwin"))
 
+;; check OS type
+(cond
+ ((string-equal system-type "windows-nt") ; Microsoft Windows
+  (progn
+    (message "Microsoft Windows")))
+ ((string-equal system-type "darwin") ; Mac OS X
+  (progn
+    (message "Mac OS X")))
+ ((string-equal system-type "gnu/linux") ; linux
+  (progn
+    (message "Linux"))))
+
 ;; Start Emacs as a server
 (when (system-is-linux)
   (require 'server)
@@ -30,6 +42,17 @@
   (setq unix-init-slime-path   "/usr/share/common-lisp/source/slime/")
   (setq unix-init-ac-dict-path "~/.emacs.d/plugins/auto-complete/dict"))
 
+;; MacOS path-variable
+(when (system-is-macos)
+  (setq mac-sbcl-bin           "/opt/homebrew/Cellar/sbcl/2.2.9/bin/sbcl")
+  (setq mac-init-path          "~/.emacs.d/lisp")
+  (setq mac-init-ct-path       "~/.emacs.d/plugins/color-theme")
+  (setq mac-init-ac-path       "~/.emacs.d/plugins/auto-complete")
+  (setq mac-init-ac-dict-path  "~/.emacs.d/plugins/auto-complete/dict"))
+
+;; Open multiple files in tabs
+(setq display-buffer-base-action '(display-buffer-in-tab))
+
 ;; Dired
 (require 'dired)
 (setq dired-recursive-deletes 'top) ;; so we can delete non-empty directories
@@ -45,8 +68,11 @@
 
 ;; Load path for plugins
 (if (system-is-windows)
-  (add-to-list 'load-path win-init-path)
-  (add-to-list 'load-path unix-init-path))
+    (add-to-list 'load-path win-init-path))
+(if (system-is-linux)
+    (add-to-list 'load-path unix-init-path))
+(if (system-is-macos)
+    (add-to-list 'load-path mac-init-path))
 
 ;; Inhibit startup/splash screen
 (setq inhibit-splash-screen   t)
@@ -66,8 +92,16 @@
 ;; Disable GUI components
 (tooltip-mode      -1)
 (menu-bar-mode     -1) ;; turn off GUI menu bar
-(tool-bar-mode     -1) ;; turn off toolbar
-(scroll-bar-mode   -1) ;; turn off scrollbar
+;; Turn off toolbar
+(if (system-is-windows)
+    (tool-bar-mode     -1))
+(if (system-is-linux)
+    (tool-bar-mode     -1))
+;; Turn off scrollbar
+(if (system-is-windows)
+    (scroll-bar-mode   -1))
+(if (system-is-linux)
+    (scroll-bar-mode   -1))
 (blink-cursor-mode -1) ;; turn off cursor blink
 (setq use-dialog-box     nil) ;; all dialogs through mini-buffer
 (setq redisplay-dont-pause t)  ;; better buffer display
@@ -83,7 +117,17 @@
       (set-selection-coding-system            'utf-8)
       (set-keyboard-coding-system        'utf-8-unix)
       (set-terminal-coding-system             'utf-8)
-      (prefer-coding-system                   'utf-8))
+      (prefer-coding-system                   'utf-8)))
+(if (system-is-macos) ;; utf-8 for GNU/Linux and macOS, windows-1251 for MS Windows
+    (progn
+      (setq default-buffer-file-coding-system 'utf-8)
+      (setq-default coding-system-for-read    'utf-8)
+      (setq file-name-coding-system           'utf-8)
+      (set-selection-coding-system            'utf-8)
+      (set-keyboard-coding-system        'utf-8-unix)
+      (set-terminal-coding-system             'utf-8)
+      (prefer-coding-system                   'utf-8)))
+(if (system-is-windows)
     (progn
       (prefer-coding-system                   'windows-1251)
       (set-terminal-coding-system             'windows-1251)
@@ -93,15 +137,14 @@
       (setq-default coding-system-for-read    'windows-1251)
       (setq default-buffer-file-coding-system 'windows-1251)))
 
-;; Linum plugin
-(require 'linum) ;; call Linum
-(line-number-mode   t) ;; show line number in mode-line
-(global-linum-mode  t) ;; show line number in all buffers
-(column-number-mode t) ;; show column number in mode-line
-(setq linum-format " %d") ;; set up line numbering format
+;; Line numbers mode
+(global-display-line-numbers-mode)
 
 ;; Fringe settings
-(fringe-mode '(8 . 0)) ;; fringe is only on the left side
+(if (system-is-windows)
+    (fringe-mode '(8 . 0))) ;; fringe is only on the left side
+(if (system-is-linux)
+    (fringe-mode '(8 . 0)))
 (setq-default indicate-empty-lines t) ;; empty lines are marked
 (setq-default indicate-buffer-boundaries 'left) ;; indication are shown on the left side
 
@@ -150,6 +193,19 @@
 (setq scroll-step               1) ;; up-down scrolling speed is 1
 (setq scroll-margin            10) ;; set up scrolling margin
 (setq scroll-conservatively 10000)
+;;(if (system-is-macos)
+    (defun scroll-up-1-line ()
+      "Scroll up 1 line"
+      (interactive)
+      (scroll-up 1))
+
+    (defun scroll-down-1-line ()
+      "Scroll down 1 line"
+      (interactive)
+      (scroll-down 1))
+
+    (global-set-key (kbd "<mouse-4>") 'scroll-down-1-line) 
+    (global-set-key (kbd "<mouse-5>") 'scroll-up-1-line);;)
 
 ;; Short messages
 (defalias 'yes-or-no-p 'y-or-n-p)
@@ -182,3 +238,20 @@
 
 ;; Mouse support
 (xterm-mouse-mode 1)
+
+(setq mac-command-key-is-meta t)
+
+(setq load-path (cons (expand-file-name "/opt/homebrew/Cellar/cmake/3.24.3/share/emacs/site-lisp/cmake/cmake-mode.el") load-path))
+(require 'cmake-mode)
+
+(defun copy-line (arg)
+  "Copy lines (as many as prefix argument) in the kill ring"
+  (interactive "p")
+  (kill-ring-save (line-beginning-position)
+                  (line-beginning-position (+ 1 arg)))
+  (message "%d line%s copied" arg (if (= 1 arg) "" "s")))
+;; optional key binding
+(global-set-key "\C-c\C-k" 'copy-line)
+(global-set-key "\C-c\C-s" 'set-mark-command) ;; set C-c C-s for setting marker
+
+(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")