diff --git a/init.el b/init.el new file mode 100644 index 0000000..e8612d0 --- /dev/null +++ b/init.el @@ -0,0 +1,149 @@ +;; Initial window and default window +(setq inhibit-startup-screen t) + +(setq default-frame-alist + (if (display-graphic-p) + '((tool-bar-lines . 0) + (background-color . "honeydew") + (width . 155) + (height . 46)) + '((tool-bar-lines . 0)))) + +;; Package signature check disable +(setq package-check-signature nil) + +;; User interface +(when (version<= "26.0.50" emacs-version ) + (global-display-line-numbers-mode)) + +(set-face-attribute 'default nil :font "Source Code Pro" :height 125) +;;(load-theme 'atom-one-dark) +(column-number-mode 1) +(blink-cursor-mode 0) +(setq use-dialog-box nil) +(setq visible-bell t) + +(progn + ;; minibuffer setup + (setq enable-recursive-minibuffers t) + (savehist-mode 0) + ;; big minibuffer height, for ido to show choices vertically + (setq max-mini-window-height 0.5) + ;; minibuffer, stop cursor going into prompt + (customize-set-variable + 'minibuffer-prompt-properties + (quote (read-only t cursor-intangible t face minibuffer-prompt)))) + +(if (version< emacs-version "28.1") + (progn + (progn + ;; make buffer switch command do suggestions, also for find-file command + (require 'ido) + (ido-mode 1) + ;; show choices vertically + (setf (nth 2 ido-decorations) "\n") + ;; show any name that has the chars you typed + (setq ido-enable-flex-matching t) + ;; use current pane for newly opened file + (setq ido-default-file-method 'selected-window) + ;; use current pane for newly switched buffer + (setq ido-default-buffer-method 'selected-window) + ) + (progn + ;; minibuffer enhanced completion icomplete + (require 'icomplete) + (icomplete-mode 1) + ;; show choices vertically + (setq icomplete-separator "\n") + (setq icomplete-hide-common-prefix nil) + (setq icomplete-in-buffer t) + (define-key icomplete-minibuffer-map (kbd "") 'icomplete-forward-completions) + (define-key icomplete-minibuffer-map (kbd "") 'icomplete-backward-completions))) + (fido-vertical-mode 1)) + +;;; Editing related + +;; Make typing delete/overwr_ites selected text +(delete-selection-mode 1) + +;; Set highlighting brackets +(show-paren-mode 1) +(setq show-paren-style 'parenthesis) + +(setq save-interprogram-paste-before-kill t) +(setq x-select-enable-clipboard-manager nil) + +(setq hippie-expand-try-functions-list + '( + try-expand-dabbrev + try-expand-dabbrev-all-buffers + ;; try-expand-dabbrev-from-kill + try-complete-lisp-symbol-partially + try-complete-lisp-symbol + try-complete-file-name-partially + try-complete-file-name + ;; try-expand-all-abbrevs + ;; try-expand-list + ;; try-expand-line + )) + +;; Use short answer +(if (version< emacs-version "28.1") + (defalias 'yes-or-no-p 'y-or-n-p) + (setq use-short-answers t)) + +(global-set-key (kbd "") 'xah-cut-line-or-region) ; cut +(global-set-key (kbd "") 'xah-copy-line-or-region) ; copy +(global-set-key (kbd "") 'yank) ; paste + +(defun xah-copy-line-or-region () + "Copy current line or selection. +When called repeatedly, append copy subsequent lines. +When `universal-argument' is called first, copy whole buffer (respects `narrow-to-region'). + +URL `http://xahlee.info/emacs/emacs/emacs_copy_cut_current_line.html' +Version: 2010-05-21 2022-10-03" + (interactive) + (let ((inhibit-field-text-motion nil)) + (if current-prefix-arg + (progn + (copy-region-as-kill (point-min) (point-max))) + (if (region-active-p) + (progn + (copy-region-as-kill (region-beginning) (region-end))) + (if (eq last-command this-command) + (if (eobp) + (progn ) + (progn + (kill-append "\n" nil) + (kill-append + (buffer-substring-no-properties (line-beginning-position) (line-end-position)) + nil) + (progn + (end-of-line) + (forward-char)))) + (if (eobp) + (if (eq (char-before) 10 ) + (progn ) + (progn + (copy-region-as-kill (line-beginning-position) (line-end-position)) + (end-of-line))) + (progn + (copy-region-as-kill (line-beginning-position) (line-end-position)) + (end-of-line) + (forward-char)))))))) + +(defun xah-cut-line-or-region () + "Cut current line or selection. +When `universal-argument' is called first, cut whole buffer (respects `narrow-to-region'). + +URL `http://xahlee.info/emacs/emacs/emacs_copy_cut_current_line.html' +Version: 2010-05-21 2015-06-10" + (interactive) + (if current-prefix-arg + (progn ; not using kill-region because we don't want to include previous kill + (kill-new (buffer-string)) + (delete-region (point-min) (point-max))) + (progn (if (region-active-p) + (kill-region (region-beginning) (region-end) t) + (kill-region (line-beginning-position) (line-beginning-position 2))))))