Created
October 27, 2020 16:26
-
-
Save seba-perez/b156f1cb3b8f9d7a66e364f207217c06 to your computer and use it in GitHub Desktop.
Basic configuration file for emacs. No menu, no bars, no scrollbar, darker theme, etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Seba Perez at USACH dot Emacs file | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(setq user-full-name "seba") | |
;; Package repositories | |
(require 'package) | |
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos)) | |
(not (gnutls-available-p)))) | |
(proto (if no-ssl "http" "https"))) | |
(when no-ssl | |
(warn "\ | |
Your version of Emacs does not support SSL connections, | |
which is unsafe because it allows man-in-the-middle attacks. | |
There are two things you can do about this warning: | |
1. Install an Emacs version that does support SSL and be safe. | |
2. Remove this warning from your init file so you won't see it again.")) | |
;; Comment/uncomment these two lines to enable/disable MELPA and MELPA Stable as desired | |
;; (add-to-list 'package-archives (cons "melpa" (concat proto "://melpa.org/packages/")) t) | |
(add-to-list 'package-archives (cons "melpa-stable" (concat proto "://stable.melpa.org/packages/")) t) | |
(when (< emacs-major-version 24) | |
;; For important compatibility libraries like cl-lib | |
(add-to-list 'package-archives (cons "gnu" (concat proto "://elpa.gnu.org/packages/"))))) | |
;; 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) | |
;; helm | |
;; (require 'helm-config) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Fullscreen in macOS (M-F) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defvar my-fullscreen-p t "Check if fullscreen is on or off") | |
(defun my-fullscreen () | |
(interactive) | |
(setq my-fullscreen-p (not my-fullscreen-p)) | |
(if my-fullscreen-p | |
(set-frame-parameter nil 'fullscreen nil) ) | |
(if (not my-fullscreen-p) | |
(set-frame-parameter nil 'fullscreen 'fullboth) | |
(setq my-fullscreen-p t)) | |
) | |
(global-set-key "\M-F" 'my-fullscreen) | |
(tool-bar-mode -1) | |
(scroll-bar-mode -1) | |
(menu-bar-mode -1) | |
(setq default-directory "/Users/seba/" ) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Unfilling paragraph | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(defun unfill-paragraph () | |
"Replace newline chars in current paragraph by single spaces. | |
This command does the reverse of `fill-paragraph'." | |
(interactive) | |
(let ((fill-column 90002000)) | |
(fill-paragraph nil))) | |
(defun unfill-region (start end) | |
"Replace newline chars in region by single spaces. | |
This command does the reverse of `fill-region'." | |
(interactive "r") | |
(let ((fill-column 90002000)) | |
(fill-region start end))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Font size | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; (set-face-attribute 'default nil :height 120) | |
;; DEFAULT CPERL MODE | |
;; (defalias 'perl-mode 'cperl-mode) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Clean STARTUP | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(split-window-horizontally) ;; want two windows at startup | |
(other-window 1) ;; move to other window | |
(shell) ;; start a shell | |
;; (rename-buffer "shell-first") ;; rename it | |
(other-window 1) ;; move back to first window | |
(kill-buffer-and-window) | |
;; ;; tracing the errors | |
;; (setq debug-on-error t) | |
;; not display welcome message | |
(setq inhibit-startup-message t) | |
(setq inhibit-default-init t) | |
(setq highlight-paren-mode t) | |
(setq transient-mark-mode t) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Nice PRINT | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(require 'ps-print) | |
(setq ps-font-size 18) | |
(setq ps-number-of-columns 1) | |
(setq ps-landscape-mode nil) | |
(setq lpr-command "lpr -Ppsbipac") | |
(setq ps-print-header t) | |
(setq ps-print-color-p t) | |
(setq ps-paper-type 'a4) | |
(defun seba-export-ps (filename) | |
"export to a PostScript file" | |
(interactive "File name: ") | |
(if (equal mark-active t) | |
(ps-print-region-with-faces (region-beginning) (region-end) filename) | |
(ps-print-buffer-with-faces filename)) | |
;; (ps-print-region (region-beginning) (region-end) filename) | |
;; (ps-print-buffer filename)) | |
) | |
(defun seba-export-ps-landscape (filename) | |
(setq ps-landscape-mode 1) | |
"export to a PostScript file" | |
(interactive "File name: ") | |
(if (equal mark-active t) | |
(ps-print-region-with-faces (region-beginning) (region-end) filename) | |
(ps-print-buffer-with-faces filename)) | |
;; (ps-print-region (region-beginning) (region-end) filename) | |
;; (ps-print-buffer filename)) | |
) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Tips | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Nice font | |
(set-face-font 'default "Menlo") | |
;; Line numbers | |
;; (global-linum-mode t) | |
;; Line numbers for programming mode only | |
(add-hook 'prog-mode-hook 'linum-mode) | |
;; bell OFF | |
(setq ring-bell-function 'ignore) | |
;; one-touch shell | |
;; (global-set-key "\M-s" 'shell) | |
;; Shell on same window | |
(push (cons "\\*shell\\*" display-buffer--same-window-action) display-buffer-alist) | |
;; ease saving | |
(global-set-key "\M-s" 'save-buffer) | |
;; will allow you to type just "y" instead of "yes" when you exit. | |
(fset 'yes-or-no-p 'y-or-n-p) | |
;; ill disalllow passwords to be shown in clear text (this is useful, | |
;; for example, if you use the shell and then, ssh/telnet/ftp/scp | |
;; etc. to other machines). | |
(add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt) | |
;; Load path | |
(add-to-list 'load-path "~/Libraries/Emacs/") | |
(add-to-list 'load-path "~/") | |
;; Spell checking (ispell can be installed with brew) | |
(setq ispell-program-name "/usr/local/bin/ispell") | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;; HTML ;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(require 'web-mode) | |
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.css?\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode)) | |
(setq web-mode-markup-indent-offset 2) | |
(setq web-mode-css-indent-offset 2) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;; LaTeX ;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; (load "auctex.el" nil t t) ; AUCTeX | |
;; (setq TeX-auto-save t) | |
;; (setq TeX-parse-self t) | |
;; (setq TeX-master nil) | |
;; (load "preview-latex.el" nil t t) | |
;; (global-set-key "\M-t" 'getpdflatex ) | |
;; (defun getpdflatex (buffer) | |
;; "pdflatex current buffer!" | |
;; (interactive) | |
;; (TeX-command "LaTeX" 'TeX-master-file)) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(global-font-lock-mode 1) | |
(setq font-lock-maximum-decoration t) | |
(set-background-color "black") | |
(set-foreground-color "white") | |
(set-cursor-color "white") | |
(set-face-background 'region "black") | |
(set-face-foreground 'region "medium slate blue") | |
(global-set-key "\M-g" 'goto-line) | |
;; to solve the max-specpdl-size error | |
(setq max-specpdl-size 1000) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;; Backups | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; Usually Emacs makes backups of all the codes that it runs. This has | |
;; an inconvenient: there are files ending in ~ spread everywhere. The | |
;; following function centralised backup files. | |
(setq make-backup-files t) | |
(setq auto-save-default nil) | |
(setq delete-old-versions t) | |
(defun make-backup-file-name (file) | |
"Create the non-numeric backup file name for FILE." | |
(require 'dired) | |
(let (path) | |
(cond ((eq system-type 'windows-nt) | |
(setq file (dired-replace-in-string ":" "" file)) | |
(setq path "backup/")) | |
(t | |
(setq path "/Users/seba/.emacs_backups/"))) | |
(concat path | |
(dired-replace-in-string "/" "~" file) | |
(format-time-string "~%Y%m%d%H%M%S~") | |
;; Repeat the name at the end so we'll have font-lock if | |
;; we open the bakup file. | |
(car (last (split-string file "/")))))) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(setq minibuffer-max-depth nil) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;; some more macOS specific | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
(setq mac-command-modifier 'meta) | |
(setq mac-option-modifier nil) | |
;; Colour | |
;; (setq default-frame-alist | |
;; (append default-frame-alist | |
;; '((foreground-color . "white") | |
;; (background-color . "black") | |
;; (cursor-color . "#dd9900"))))) | |
(put 'upcase-region 'disabled nil) | |
(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. | |
'(custom-safe-themes | |
(quote | |
("5057614f7e14de98bbc02200e2fe827ad897696bfd222d1bcab42ad8ff313e20" "23f1d50c7687a59aabf9773e40413e97e5c29b3b22c065f7c866cfcfc4538343" "274fa62b00d732d093fc3f120aca1b31a6bb484492f31081c1814a858e25c72e" default))) | |
'(package-selected-packages | |
(quote | |
(helm py-autopep8 github-theme nimbus-theme dracula-theme)))) | |
(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. | |
) | |
(put 'downcase-region 'disabled nil) | |
(load-theme 'misterioso t) | |
(set-cursor-color "white") | |
;; (setq python-shell-interpreter "ipython") | |
(defun ipython () | |
(interactive) | |
(term "/Users/seba/anaconda3/bin/ipython")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment