first commit

This commit is contained in:
Jesús
2018-06-29 22:31:11 -05:00
commit 15ea85ee14
14 changed files with 1032 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
;; Delete trailing whitespace before saving fil
(add-hook 'before-save-hook 'delete-trailing-whitespace)
(myemacs/elapsed-time)
(provide 'init-editing-utils)

38
lisp/init-elpa.el Normal file
View File

@@ -0,0 +1,38 @@
(require 'package)
;; Repositories
;; ================
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(proto (if no-ssl "http" "https")))
;; 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 '("gnu" . (concat proto "://elpa.gnu.org/packages/")))))
;; =================
;;; Find packages if not installed
;; =================
;;; On-demand installation of packages
(defun require-package (package &optional min-version no-refresh)
"Install given PACKAGE, optionally requiring MIN-VERSION.
If NO-REFRESH is non-nil, the available package lists will not be
re-downloaded in order to locate PACKAGE."
(if (package-installed-p package min-version)
t
(if (or (assoc package package-archive-contents) no-refresh)
(if (boundp 'package-selected-packages)
;; Record this as a package the user installed explicitly
(package-install package nil)
(package-install package))
(progn
(package-refresh-contents)
(require-package package min-version t)))))
;; =================
(package-initialize)
(provide 'init-elpa)

45
lisp/init-gui.el Normal file
View File

@@ -0,0 +1,45 @@
;;-----------------------
;; Remove some GUI stuff
;;-----------------------
(setq use-file-dialog nil)
(setq use-dialog-box nil)
(setq inhibit-startup-screen t)
(setq inhibit-startup-echo-area-message t)
(tool-bar-mode 0)
(set-scroll-bar-mode nil)
(menu-bar-mode 0)
(setq make-backup-files nil)
;;----------------------------------------------------------------------------
;; Editor configuration
;;----------------------------------------------------------------------------
(setq indicate-empty-lines t)
(let ((no-border '(internal-border-width . 0)))
(add-to-list 'default-frame-alist no-border)
(add-to-list 'initial-frame-alist no-border))
(setq frame-title-format
'((:eval (if (buffer-file-name)
(abbreviate-file-name (buffer-file-name))
"%b"))))
;; Non-zero values for `line-spacing' can mess up ansi-term and co,
;; so we zero it explicitly in those cases.
(add-hook 'term-mode-hook
(lambda ()
(setq line-spacing 0)))
;;----------------------------------------------------------------------------
;; Configure keys
;;----------------------------------------------------------------------------
(global-unset-key (kbd "C-z")) ; Stops C-z from minimizing window
(global-set-key (kbd "M-<down>") (lambda () (interactive) (sanityinc/adjust-opacity nil -2))) ; M-down less visibility
(global-set-key (kbd "M-<up>") (lambda () (interactive) (sanityinc/adjust-opacity nil 2))) ; M-up more visibility
(global-set-key (kbd "M-0") (lambda () (interactive) (modify-frame-parameters nil '((alpha . 100))))) ; M-0 standard visibility
(global-set-key (kbd "<f11>") 'myemacs/toggle-fullscreen) ; F11 FullScreen
(global-set-key (kbd "s-C-+") 'sacha/increase-font-size) ; C-+ increase font size
(global-set-key (kbd "s-C--") 'sacha/decrease-font-size) ; C-- decrease font size
(global-set-key (kbd "<f12>") 'revert-buffer-no-confirm)
(global-set-key (kbd "s-h") 'global-hl-line-mode) ; Highlight current line
(provide 'init-gui)

76
lisp/init-nlinum.el Normal file
View File

@@ -0,0 +1,76 @@
;;----------------------------------------------------------------------------
;; Line numbers
;;----------------------------------------------------------------------------
;; Linum snippets from: https://www.emacswiki.org/emacs/LineNumbers
(require-package 'nlinum)
(require 'linum)
(require 'hl-line)
(defface my-linum-hl
`((t :inherit linum :background ,(face-background 'hl-line nil t)))
"Face for the current line number."
:group 'linum)
(add-hook 'linum-before-numbering-hook 'my-linum-get-format-string)
(defun my-linum-get-format-string ()
(let* ((width (1+ (length (number-to-string
(count-lines (point-min) (point-max))))))
(format (concat "%" (number-to-string width) "d \u2502")))
(setq my-linum-format-string format)))
(defvar my-linum-current-line-number 0)
(defun my-linum-format (line-number)
(propertize (format my-linum-format-string line-number) 'face
(if (eq line-number my-linum-current-line-number)
'my-linum-hl
'linum)))
(setq linum-format 'my-linum-format)
(defadvice linum-update (around my-linum-update)
(let ((my-linum-current-line-number (line-number-at-pos)))
ad-do-it))
(ad-activate 'linum-update)
(defvar *linum-mdown-line* nil)
(defun line-at-click ()
(save-excursion
(let ((click-y (cdr (cdr (mouse-position))))
(line-move-visual-store line-move-visual))
(setq line-move-visual t)
(goto-char (window-start))
(next-line (1- click-y))
(setq line-move-visual line-move-visual-store)
;; If you are using tabbar substitute the next line with
;; (line-number-at-pos))))
(1+ (line-number-at-pos)))))
(defun md-select-linum ()
(interactive)
(goto-line (line-at-click))
(set-mark (point))
(setq *linum-mdown-line*
(line-number-at-pos)))
(defun mu-select-linum ()
(interactive)
(when *linum-mdown-line*
(let (mu-line)
;; (goto-line (line-at-click))
(setq mu-line (line-at-click))
(goto-line (max *linum-mdown-line* mu-line))
(set-mark (line-end-position))
(goto-line (min *linum-mdown-line* mu-line))
(setq *linum-mdown*
nil))))
(global-set-key (kbd "<left-margin> <down-mouse-1>") 'md-select-linum)
(global-set-key (kbd "<left-margin> <mouse-1>") 'mu-select-linum)
(global-set-key (kbd "<left-margin> <drag-mouse-1>") 'mu-select-linum)
(add-hook 'find-file-hook (lambda () (linum-mode 1)))
(linum-mode)
(setq global-linum-mode t)
(provide 'init-nlinum)

10
lisp/init-theme.el Normal file
View File

@@ -0,0 +1,10 @@
(require-package 'sublime-themes)
(load-theme 'spolsky t)
;; Fix linum current-line highlight. Doesn't looks good with this theme
(defface my-linum-hl
'((t :background "gray30" :foreground "gold"))
"Face for the currently active Line number"
:group 'linum)
(provide 'init-theme)

24
lisp/init-utils.el Normal file
View File

@@ -0,0 +1,24 @@
;; Loads functions from libs
(defun load-directory (dir)
(let ((load-it (lambda (f)
(load-file (concat (file-name-as-directory dir) f)))
))
(mapc load-it (directory-files dir nil "\\.el$"))))
;; Load lib functions
(load-directory (expand-file-name "~/.emacs.d/lisp/lib/" user-emacs-directory))
;; This is borrowed from https://github.com/purcell/emacs.d/blob/master/lisp/init-utils.el by Steve Purcell but I have added some stuff.
(if (fboundp 'with-eval-after-load)
(defalias 'after-load 'with-eval-after-load)
(defmacro after-load (feature &rest body)
"After FEATURE is loaded, evaluate BODY."
(declare (indent defun))
'(eval-after-load ,feature
'(progn ,@body))))
;; Elapsed time
(myemacs/elapsed-time)
(provide 'init-utils)

18
lisp/lib/myemacs.el Normal file
View File

@@ -0,0 +1,18 @@
;;----------------------------------------------------------------------------
;; Some cool functions
;;----------------------------------------------------------------------------
;; These functions are made by me (Quitter: @heckyel) or
;; heavily modified by me
;;----------------------------------------------------------------------------
;; Toggles fullscreen
;;----------------------------------------------------------------------------
(defun myemacs/toggle-fullscreen ()
(interactive)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0)))
(defun myemacs/elapsed-time ()
(let ((elapsed (float-time (time-subtract (current-time)
emacs-start-time))))
(message "[STARTUP] Loading %s ... done (%.3fs)" load-file-name elapsed)))

39
lisp/lib/sachachua.el Normal file
View File

@@ -0,0 +1,39 @@
;; Increase-decrease functions from Sacha Chua
(defun sacha/increase-font-size ()
(interactive)
(set-face-attribute 'default
nil
:height
(ceiling (* 1.10
(face-attribute 'default :height)))))
(defun sacha/decrease-font-size ()
(interactive)
(set-face-attribute 'default
nil
:height
(floor (* 0.9
(face-attribute 'default :height)))))
;; Not original from Sacha. Taken from: http://emacsredux.com/blog/2013/05/22/smarter-navigation-to-the-beginning-of-a-line/
(defun sacha/smarter-move-beginning-of-line (arg)
"Move point back to indentation of beginning of line.
Move point to the first non-whitespace character on this line.
If point is already there, move to the beginning of the line.
Effectively toggle between the first non-whitespace character and
the beginning of the line.
If ARG is not nil or 1, move forward ARG - 1 lines first. If
point reaches the beginning or end of the buffer, stop there."
(interactive "^p")
(setq arg (or arg 1))
;; Move lines first
(when (/= arg 1)
(let ((line-move-visual nil))
(forward-line (1- arg))))
(let ((orig-point (point)))
(back-to-indentation)
(when (= orig-point (point))
(move-beginning-of-line 1))))