The way to change starting window (a.k.a frame) position and size:
Click Preferences | search for default-frame-alist, add var left 300, width 125, height 60, top 0 | Click the state and save for future
Do the same for initial-frame-alist
Command to have a better default GUI:
emacs -fh -geometry 180x160 {file}
sudo apt install xclip
wget http://www.emacswiki.org/emacs-en/download/xclip.el /home/$USER/.emacs.d/xclip.el
==== (Copy to ~/.emacs)
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(package-initialize)
(add-to-list 'default-frame-alist '(height . 80))
(add-to-list 'default-frame-alist '(width . 180))
;;(require 'py-yapf)
;;(add-hook 'python-mode-hook 'py-yapf-enable-on-save)
;;(add-hook 'prog-mode-hook 'highlight-numbers-mode)
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
(setq column-number-mode t)
(add-to-list 'auto-mode-alist '("BUILD" . python-mode))
(set-background-color "#F5E7D1")
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(blink-cursor-mode nil)
'(column-number-mode t)
'(inhibit-startup-screen t)
'(package-selected-packages
(quote
(py-yapf yaml-mode clang-format fill-column-indicator)))
'(py-yapf-options
(quote ("--style" "{based_on_style: google}"))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
;; https://github.com/cypro666/yahei.consolas-font to download and install YaHei Consolas
;; '(default ((t (:family "YaHei Consolas Hybrid" :slant normal :weight normal :height 105 :width normal :foundry "outline"))))
;; Ubuntu system
;; DejaVu Sans Mono
(setq mouse-wheel-scroll-amount '(4 ((shift) . 8))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
(setq scroll-step 1) ;; keyboard scroll one line at a time
(setq scroll-conservatively 10000)
(setq auto-window-vscroll nil)
(require 'dired)
(defun dired-mouse-find-file (event)
"In Dired, visit the file or directory name you click on."
(interactive "e")
(let (window pos file)
(save-excursion
(setq window (posn-window (event-end event))
pos (posn-point (event-end event)))
(if (not (windowp window))
(error "No file chosen"))
(set-buffer (window-buffer window))
(goto-char pos)
(setq file (dired-get-file-for-visit)))
(if (file-directory-p file)
(or (and (cdr dired-subdir-alist)
(dired-goto-subdir file))
(progn
(select-window window)
(dired file)))
(select-window window)
(find-file-other-window (file-name-sans-versions file t)))))
(define-key dired-mode-map [mouse-2] 'dired-mouse-find-file)
(setq split-height-threshold nil)
(setq split-width-threshold 160)
;;Matching parenthesis
(require 'paren)
(show-paren-mode 1)
(set-face-attribute 'show-paren-match nil :weight 'extra-bold)
(setq ring-bell-function 'ignore)
; Ctrl+right => forward word
(global-set-key "\M-[1;5C" 'forward-word)
; Ctrl+left => backward word
(global-set-key "\M-[1;5D" 'backward-word)
(setq-default indent-tabs-mode nil)
(setq default-tab-width 4)
(setq column-number-mode t)
(add-to-list 'auto-mode-alist '("BUILD" . python-mode))
(set-background-color "#F5E7D1")
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(blink-cursor-mode nil)
'(column-number-mode t)
'(inhibit-startup-screen t)
'(package-selected-packages
(quote
(py-yapf yaml-mode clang-format fill-column-indicator)))
'(py-yapf-options
(quote ("--style" "{based_on_style: google}"))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
;; https://github.com/cypro666/yahei.consolas-font to download and install YaHei Consolas
;; '(default ((t (:family "YaHei Consolas Hybrid" :slant normal :weight normal :height 105 :width normal :foundry "outline"))))
;; Ubuntu system
;; DejaVu Sans Mono
;; Hack if the font is installed
'(default ((t (:family "DejaVu Sans Mono" :foundry "PfEd" :slant normal :weight normal :height 90 :width normal))))
'(c-annotation-face ((t (:inherit font-lock-constant-face :foreground "yellow"))))
'(cursor ((t (:background "red"))))
'(font-lock-comment-delimiter-face ((t (:inherit font-lock-comment-face :foreground "forest green"))))
'(font-lock-comment-face ((t (:foreground "forest green"))))
'(font-lock-constant-face ((t (:foreground "#A52A2A"))))
'(font-lock-doc-face ((t (:foreground "forest green"))))
'(font-lock-function-name-face ((t (:foreground "black"))))
'(font-lock-keyword-face ((t (:foreground "royal blue" :weight bold))))
'(font-lock-string-face ((t (:foreground "#A52A2A"))))
'(font-lock-type-face ((t (:foreground "medium blue" :weight bold))))
'(font-lock-variable-name-face ((t (:foreground "black"))))
'(default ((t (:family "DejaVu Sans Mono" :foundry "PfEd" :slant normal :weight normal :height 90 :width normal))))
'(c-annotation-face ((t (:inherit font-lock-constant-face :foreground "yellow"))))
'(cursor ((t (:background "red"))))
'(font-lock-comment-delimiter-face ((t (:inherit font-lock-comment-face :foreground "forest green"))))
'(font-lock-comment-face ((t (:foreground "forest green"))))
'(font-lock-constant-face ((t (:foreground "#A52A2A"))))
'(font-lock-doc-face ((t (:foreground "forest green"))))
'(font-lock-function-name-face ((t (:foreground "black"))))
'(font-lock-keyword-face ((t (:foreground "royal blue" :weight bold))))
'(font-lock-string-face ((t (:foreground "#A52A2A"))))
'(font-lock-type-face ((t (:foreground "medium blue" :weight bold))))
'(font-lock-variable-name-face ((t (:foreground "black"))))
'(font-lock-builtin-face ((t (:foreground "#8817a2"))))
'(isearch ((t (:background "#ff7f00" :foreground "white"))))
'(lazy-highlight ((t (:background "#00F" :foreground "#FFF"))))
'(show-paren-match ((t (:background "dark gray" :foreground "blue")))))
(set-face-attribute 'region nil :background "#ff7f00" :foreground "#fff")
(put 'upcase-region 'disabled nil)
(setq linum-format "%03d ")
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
(global-linum-mode t)
;; disable auto indent in c/c++
(setq-default c-electric-flag nil)
(setq-default c-syntactic-indentation nil)
;; Bottom status bar
;;(setq-default mode-line-format nil)
(setq-default python-indent-offset 4)
(setq-default python-indent 4)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(electric-indent-mode -1)
(global-set-key (kbd "RET") 'newline-and-indent)
;; Windows postion
(setq initial-frame-alist '((left . 650) (top . 0)))
'(isearch ((t (:background "#ff7f00" :foreground "white"))))
'(lazy-highlight ((t (:background "#00F" :foreground "#FFF"))))
'(show-paren-match ((t (:background "dark gray" :foreground "blue")))))
(set-face-attribute 'region nil :background "#ff7f00" :foreground "#fff")
(put 'upcase-region 'disabled nil)
(setq linum-format "%03d ")
(setq backup-directory-alist
`((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t)))
(global-linum-mode t)
;; disable auto indent in c/c++
(setq-default c-electric-flag nil)
(setq-default c-syntactic-indentation nil)
;; Bottom status bar
;;(setq-default mode-line-format nil)
(setq-default python-indent-offset 4)
(setq-default python-indent 4)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(electric-indent-mode -1)
(global-set-key (kbd "RET") 'newline-and-indent)
;; Windows postion
(setq initial-frame-alist '((left . 650) (top . 0)))
(when window-system
(set-frame-size (selected-frame) 115 80))
(if (functionp 'tool-bar-mode) (tool-bar-mode -1))
;; better scrolling(setq mouse-wheel-scroll-amount '(4 ((shift) . 8))) ;; one line at a time
(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
(setq scroll-step 1) ;; keyboard scroll one line at a time
(setq scroll-conservatively 10000)
(setq auto-window-vscroll nil)
(require 'dired)
(defun dired-mouse-find-file (event)
"In Dired, visit the file or directory name you click on."
(interactive "e")
(let (window pos file)
(save-excursion
(setq window (posn-window (event-end event))
pos (posn-point (event-end event)))
(if (not (windowp window))
(error "No file chosen"))
(set-buffer (window-buffer window))
(goto-char pos)
(setq file (dired-get-file-for-visit)))
(if (file-directory-p file)
(or (and (cdr dired-subdir-alist)
(dired-goto-subdir file))
(progn
(select-window window)
(dired file)))
(select-window window)
(find-file-other-window (file-name-sans-versions file t)))))
(define-key dired-mode-map [mouse-2] 'dired-mouse-find-file)
(setq split-height-threshold nil)
(setq split-width-threshold 160)
;;Matching parenthesis
(require 'paren)
(show-paren-mode 1)
(set-face-attribute 'show-paren-match nil :weight 'extra-bold)
(setq ring-bell-function 'ignore)
; Ctrl+right => forward word
(global-set-key "\M-[1;5C" 'forward-word)
; Ctrl+left => backward word
(global-set-key "\M-[1;5D" 'backward-word)
(global-set-key (kbd "C-x k") 'kill-this-buffer)
(define-key input-decode-map "\e[1;5A" [C-up])
(define-key input-decode-map "\e[1;5B" [C-down])
;; load emacs 24's package system. Add MELPA repository.
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list
'package-archives
;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable
;;'("melpa" . "http://melpa.milkbox.net/packages/")
;; In China, use this
'("melpha" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
t))
(defalias 'yes-or-no-p 'y-or-n-p)
(setq frame-title-format
(list (format "%s %%S: %%j " (system-name))
'(buffer-file-name "%f" (dired-directory dired-directory "%b"))))
;; Column ruler, edge
;;(require 'fill-column-indicator)
(setq-default fill-column 80)
;;(define-globalized-minor-mode global-fci-mode fci-mode (lambda () (fci-mode 1)))
;;(global-fci-mode 1)
(setq fci-handle-truncate-lines nil)
(setq fci-rule-color "#606060")
;; Column ruler end
;; (require 'clang-format)
;; (defun clang-format-buffer-smart ()
;; "Enable clang when the mode is C++"
;; (when (eq major-mode 'c++-mode)
;; (clang-format-buffer))
;; (when (eq major-mode 'c-mode)
;; (clang-format-buffer)))
;; (add-hook 'before-save-hook 'buildifier)
;; (add-hook 'before-save-hook 'clang-format-buffer-smart)
;; (defcustom buildifier-bin "buildifier"
;; "Location of the buildifier binary."
;; :type 'string
;; :group 'buildifier)
;; (defcustom buildifier-path-regex
;; "BUILD\\|WORKSPACE"
;; "Regular expression describing base paths that need buildifier."
;; :type 'string
;; :group 'buildifier)
;; (defun buildifier ()
;; "Run buildifier on current buffer."
;; (interactive)
;; (when (and (string-match buildifier-path-regex
;; (file-name-nondirectory
;; (buffer-file-name)))
;; (executable-find buildifier-bin))
;; (let ((p (point))
;; (tmp (make-temp-file "buildifier")))
;; (write-region nil nil tmp)
;; (let ((result (with-temp-buffer
;; (cons (call-process buildifier-bin tmp t nil)
;; (buffer-string)))))
;; (if (= (car result) 0)
;; (save-excursion
;; (erase-buffer)
;; (insert (cdr result)))
;; (warn "%s failed: %s" buildifier-bin (cdr result)))
;; (goto-char p)
;; (delete-file tmp nil)))))
(define-key input-decode-map "\e[1;5A" [C-up])
(define-key input-decode-map "\e[1;5B" [C-down])
;; load emacs 24's package system. Add MELPA repository.
(when (>= emacs-major-version 24)
(require 'package)
(add-to-list
'package-archives
;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable
;;'("melpa" . "http://melpa.milkbox.net/packages/")
;; In China, use this
'("melpha" . "http://mirrors.tuna.tsinghua.edu.cn/elpa/melpa/")
t))
(defalias 'yes-or-no-p 'y-or-n-p)
(setq frame-title-format
(list (format "%s %%S: %%j " (system-name))
'(buffer-file-name "%f" (dired-directory dired-directory "%b"))))
;; Column ruler, edge
;;(require 'fill-column-indicator)
(setq-default fill-column 80)
;;(define-globalized-minor-mode global-fci-mode fci-mode (lambda () (fci-mode 1)))
;;(global-fci-mode 1)
(setq fci-handle-truncate-lines nil)
(setq fci-rule-color "#606060")
;; Column ruler end
;; (require 'clang-format)
;; (defun clang-format-buffer-smart ()
;; "Enable clang when the mode is C++"
;; (when (eq major-mode 'c++-mode)
;; (clang-format-buffer))
;; (when (eq major-mode 'c-mode)
;; (clang-format-buffer)))
;; (add-hook 'before-save-hook 'buildifier)
;; (add-hook 'before-save-hook 'clang-format-buffer-smart)
;; (defcustom buildifier-bin "buildifier"
;; "Location of the buildifier binary."
;; :type 'string
;; :group 'buildifier)
;; (defcustom buildifier-path-regex
;; "BUILD\\|WORKSPACE"
;; "Regular expression describing base paths that need buildifier."
;; :type 'string
;; :group 'buildifier)
;; (defun buildifier ()
;; "Run buildifier on current buffer."
;; (interactive)
;; (when (and (string-match buildifier-path-regex
;; (file-name-nondirectory
;; (buffer-file-name)))
;; (executable-find buildifier-bin))
;; (let ((p (point))
;; (tmp (make-temp-file "buildifier")))
;; (write-region nil nil tmp)
;; (let ((result (with-temp-buffer
;; (cons (call-process buildifier-bin tmp t nil)
;; (buffer-string)))))
;; (if (= (car result) 0)
;; (save-excursion
;; (erase-buffer)
;; (insert (cdr result)))
;; (warn "%s failed: %s" buildifier-bin (cdr result)))
;; (goto-char p)
;; (delete-file tmp nil)))))
(global-set-key (kbd "C-x p") (lambda () (interactive) (other-window -1)))
No comments:
Post a Comment