Change directory lisp/ to modules/

FS #2
This commit is contained in:
Jesús
2019-01-22 15:45:41 -05:00
parent d0f44d8546
commit ced0fe8f9e
44 changed files with 366 additions and 68 deletions

25
modules/init-ccc.el Normal file
View File

@@ -0,0 +1,25 @@
;;; init-ccc.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; c++ Mode
;;----------------------------------------------------------------------------
(add-hook 'c++-mode-hook
(lambda ()
(setq indent-tabs-mode t)
(setq c-basic-offset 4)
(setq tab-width 4)))
;; This is my default indent.
;; After moving the cursor to line 2 I see that the relevant symbol is comment-intro.
(c-set-offset 'comment-intro 6)
(provide 'init-ccc)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init-ccc.el ends here

16
modules/init-crystal.el Normal file
View File

@@ -0,0 +1,16 @@
;;; init-crystal.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; Crystal Mode
;;----------------------------------------------------------------------------
(use-package crystal-mode
:mode ("\\.cr\\'" . crystal-mode))
(provide 'init-crystal)
;; End:
;;; init-crystal.el ends here

17
modules/init-diminish.el Normal file
View File

@@ -0,0 +1,17 @@
;;; init-diminish.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; Diminish - is minor modes with no modeline display
;;----------------------------------------------------------------------------
(use-package diminish)
;; Hide undo-tree-mode
(diminish 'undo-tree-mode)
(provide 'init-diminish)
;; End:
;;; init-diminish.el ends here

12
modules/init-dokuwiki.el Normal file
View File

@@ -0,0 +1,12 @@
;;; init-dokuwiki.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;; dokuwiki-mode
(use-package dokuwiki-mode)
(provide 'init-dokuwiki)
;; End:
;;; init-dokuwiki.el ends here

29
modules/init-ecb.el Normal file
View File

@@ -0,0 +1,29 @@
;;; init-ecb.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; ECB
;;----------------------------------------------------------------------------
(use-package ecb
:config
(custom-set-variables '(ecb-options-version "2.50"))
(setq-default ecb-tip-of-the-day nil)
(setq ecb-examples-bufferinfo-buffer-name nil)
(defun ecb-toggle ()
(interactive)
(if ecb-minor-mode
(ecb-deactivate)
(ecb-activate)))
(global-set-key [f2] 'ecb-toggle)
)
(provide 'init-ecb)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init-ecb.el ends here

View File

@@ -0,0 +1,69 @@
;;; init-editing-utils.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; Remove whitespaces
;;----------------------------------------------------------------------------
;; Delete trailing whitespace before saving fil → all modes
;; (add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Delete-trailing-whitespace-when-saving-except-certain-modes
(add-hook 'before-save-hook
(lambda ()
(unless (eq major-mode 'diff-mode)
(delete-trailing-whitespace))))
;;----------------------------------------------------------------------------
;; Automatic pairs open symbols (, {, [...
;; Disable for default.
;; Uncomment the next 4 lines if you want to enable the pairs-mode
;;(when (fboundp 'electric-pair-mode)
;; (electric-pair-mode))
;;(when (eval-when-compile (version< "24.4" emacs-version))
;; (electric-indent-mode 1))
;; Active auto-revert-mode that automatically reloads modified files out of Emacs.
;; It is very useful to see logs (like auto-revert-tail-mode) among many other cases.
(global-auto-revert-mode)
(setq global-auto-revert-non-file-buffers t
auto-revert-verbose nil)
;;----------------------------------------------------------------------------
;; Show matching parens
;;----------------------------------------------------------------------------
(show-paren-mode 1)
;;----------------------------------------------------------------------------
;; More useful things - only one line
;;----------------------------------------------------------------------------
(set-default 'truncate-lines t)
(setq show-trailing-whitespace nil)
;;----------------------------------------------------------------------------
;; Some basic preferences
;;----------------------------------------------------------------------------
(setq-default
indent-tabs-mode nil)
;;----------------------------------------------------------------------------
;; Undo-tree
;;----------------------------------------------------------------------------
(use-package undo-tree
:diminish undo-tree-mode
:config
(progn
(global-undo-tree-mode)
(setq undo-tree-visualizer-timestamps nil)
(setq undo-tree-visualizer-diff nil)))
;;----------------------------------------------------------------------------
(load-file "~/.emacs.d/modules/lib/myemacs.el")
(provide 'init-editing-utils)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init-editing-utils.el ends here

View File

@@ -0,0 +1,16 @@
;;; init-editorconfig.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; EditorConfig
;;----------------------------------------------------------------------------
(use-package editorconfig
:config
(editorconfig-mode 1))
(provide 'init-editorconfig)
;; End:
;;; init-editorconfig.el ends here

41
modules/init-elpa.el Normal file
View File

@@ -0,0 +1,41 @@
;;; init-elpa.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;; Find and load the correct package.el
;; =====================================================
;; use-package → https://github.com/jwiegley/use-package
;; =====================================================
(require 'package)
;; Repositories
;; ================
(setq package-archives
'(("melpa" . "https://melpa.org/packages/")
;;("melpa-stable" . "https://stable.melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("org" . "https://orgmode.org/elpa/")))
(setq package-archive-priorities
'(("melpa" . 4)
("melpa-stable" . 0)
("gnu" . 1)
("org" . 3)))
;; =================
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(require 'use-package)
(setq use-package-always-ensure t)
;; =====================================================
;; End use-package
;; =====================================================
(provide 'init-elpa)
;; End:
;;; init-elpa.el ends here

View File

@@ -0,0 +1,18 @@
;;; init-emmet-mode.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;; emmet-mode
(use-package emmet-mode
;; Enable for only languages
:init
(add-hook 'sgml-mode-hook 'emmet-mode) ;; Auto-start on any markup modes
(add-hook 'web-mode-hook 'emmet-mode) ;; enable Emmet on web-mode
(add-hook 'css-mode-hook 'emmet-mode) ;; enable Emmet's css abbreviation.
)
(provide 'init-emmet-mode)
;; End:
;;; init-emmet-mode.el ends here

35
modules/init-flycheck.el Normal file
View File

@@ -0,0 +1,35 @@
;;; init-flycheck.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
(use-package flycheck
;; Enable for only languages
:init
;; (add-hook 'after-init-hook 'global-flycheck-mode)
(add-hook 'c++-mode-hook 'flycheck-mode)
;; (add-hook 'emacs-lisp-mode-hook 'flycheck-mode)
(add-hook 'html-mode-hook 'flycheck-mode)
(add-hook 'js-mode-hook 'flycheck-mode)
(add-hook 'web-mode-hook 'flycheck-mode)
(add-hook 'sh-mode-hook 'flycheck-mode)
:config
;; support web-mode with PHP
(flycheck-define-checker mix-php
"A PHP syntax checker using the PHP command line interpreter.
See URL `https://php.net/manual/en/features.commandline.php'."
:command ("php" "-l" "-d" "error_reporting=E_ALL" "-d" "display_errors=1"
"-d" "log_errors=0" source)
:error-patterns
((error line-start (or "Parse" "Fatal" "syntax") " error" (any ":" ",") " "
(message) " in " (file-name) " on line " line line-end))
:modes (php-mode php+-mode web-mode))
(add-to-list 'flycheck-checkers 'mix-php)
)
(provide 'init-flycheck)
;; End:
;;; init-flycheck.el ends here

103
modules/init-git.el Normal file
View File

@@ -0,0 +1,103 @@
;;; init-git.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
(setq vc-follows-symlinks t
find-file-visit-truename t
vc-handled-backends nil)
(if (display-graphic-p)
(use-package git-gutter-fringe
:ensure t
:config
(global-git-gutter-mode t)
(setq-default fringes-outside-margins t)
(setq-default left-fringe-width 10)
(setq indicate-empty-lines nil)
(set-face-foreground 'git-gutter-fr:modified "purple")
(set-face-foreground 'git-gutter-fr:added "green")
(set-face-foreground 'git-gutter-fr:deleted "red")
(defun my-reshape-git-gutter (gutter)
"Re-shape gutter for `ivy-read'."
(let* ((linenum-start (aref gutter 3))
(linenum-end (aref gutter 4))
(target-line "")
(target-linenum 1)
(tmp-line "")
(max-line-length 0))
(save-excursion
(while (<= linenum-start linenum-end)
(with-no-warnings
(goto-line linenum-start))
(setq tmp-line (replace-regexp-in-string "^[ \t]*" ""
(buffer-substring (line-beginning-position)
(line-end-position))))
(when (> (length tmp-line) max-line-length)
(setq target-linenum linenum-start)
(setq target-line tmp-line)
(setq max-line-length (length tmp-line)))
(setq linenum-start (1+ linenum-start))))
;; build (key . linenum-start)
(cons (format "%s %d: %s"
(if (eq 'deleted (aref gutter 1)) "-" "+")
target-linenum target-line)
target-linenum)))
(defun my-goto-git-gutter ()
(interactive)
(if git-gutter-fr:diffinfos
(ivy-read "git-gutters-fr:"
(mapcar 'my-reshape-git-gutter git-gutter-fr:diffinfos)
:action (lambda (e)
;; ivy9+ keep `(car e)'
;; ivy8- strip the `(car e)'
;; we handle both data structure
(unless (numberp e) (setq e (cdr e)))
(with-no-warnings
(goto-line e))))
(message "NO git-gutters-fringe!")))))
(use-package gitconfig-mode
:ensure t
:mode ("/\\.?git/?config$"
"/\\.gitmodules$")
:init (add-hook 'gitconfig-mode-hook 'flyspell-mode))
(use-package gitignore-mode
:ensure t
:mode ("/\\.gitignore$"
"/\\.git/info/exclude$"
"/git/ignore$"))
(use-package gitattributes-mode
:ensure t
:defer t)
(use-package git-timemachine
:ensure t
:commands git-timemachine
:bind (:map git-timemachine-mode
("c" . git-timemachine-show-current-revision)
("b" . git-timemachine-switch-branch)))
;;; smerge-mode video explain https://emacsgifs.github.io/public/videos/758861381898637313.mp4
(use-package smerge-mode
:ensure t
:config
(defun enable-smerge-maybe ()
(when (and buffer-file-name (vc-backend buffer-file-name))
(save-excursion
(goto-char (point-min))
(when (re-search-forward "^<<<<<<< " nil t)
(smerge-mode +1)))))
(add-hook 'buffer-list-update-hook #'enable-smerge-maybe))
(provide 'init-git)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init-git.el ends here

68
modules/init-gui.el Normal file
View File

@@ -0,0 +1,68 @@
;;; init-gui.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;-----------------------
;; 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) ; stop creating backup~ files
(setq auto-save-default nil) ; stop creating #autosave# files
;;----------------------------------------------------------------------------
;; 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)))
;; Font theme (Monospace, or DejaVu Sans Mono if Monospace is not
;; present)
(condition-case nil
(set-frame-font "Hack-9")
;; (set-frame-font "Monospace-9")
;; (set-frame-font "Anonymous Pro-10")
(error (set-frame-font "DejaVu Sans Mono-10")))
;;----------------------------------------------------------------------------
;; Configure keys
;;----------------------------------------------------------------------------
(global-unset-key (kbd "C-z")) ; Stops C-z from minimizing window
(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
;;----------------------------------------------------------------------------
;; clock
;;----------------------------------------------------------------------------
(setq display-time-day-and-date t)
(display-time)
(provide 'init-gui)
;; End:
;;; init-gui.el ends here

24
modules/init-html.el Normal file
View File

@@ -0,0 +1,24 @@
;;; init-html.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;
;; HTML Mode
;;;;;;;;;;;;;;;;;;;;;;;;;
(add-hook 'html-mode-hook
(lambda ()
;; Default indentation is usually 2 spaces, changing to 4.
(set (make-local-variable 'sgml-basic-offset) 4)))
;; highlight-indent-guides-mode
(add-hook 'html-mode-hook 'highlight-indent-guides-mode)
(provide 'init-html)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init-html.el ends here

28
modules/init-icons.el Normal file
View File

@@ -0,0 +1,28 @@
;;; init-icons.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------
;; All-the-icons
;;----------------------------------
(use-package all-the-icons)
;;----------------------------------
;; Fonts - connecting with neotree
;;---------------------------------
(if (file-exists-p "~/.local/share/fonts/all-the-icons.ttf")
(message "the icons are installed :)")
(setq neotree-mode-hook 'all-the-icons-install-fonts)
)
;; fix performace
(setq inhibit-compacting-font-caches t)
(provide 'init-icons)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init-icons.el ends here

View File

@@ -0,0 +1,18 @@
;;; init-indent-guides.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;; This minor mode highlights indentation levels via font-lock
(use-package highlight-indent-guides
:config
(setq highlight-indent-guides-method 'character)
;; Indent character samples: fill, column or character
(setq highlight-indent-guides-method 'character))
(provide 'init-indent-guides)
;; End:
;;; init-indent-guides.el ends here

15
modules/init-less.el Normal file
View File

@@ -0,0 +1,15 @@
;;; init-less.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; Less Mode
;;----------------------------------------------------------------------------
(use-package less-css-mode
:mode ("\\.less\\'" . less-css-mode))
(provide 'init-less)
;; End:
;;; init-less.el ends here

37
modules/init-markdown.el Normal file
View File

@@ -0,0 +1,37 @@
;;; init-markdown.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
(use-package markdown-mode
:mode (("\\.markdown\\'" . markdown-mode)
("\\.md\\'" . markdown-mode))
:config
;;----------------------------------------------------------------------------
;; Generated HTML 5 and UTF-8 with Markdown
;;----------------------------------------------------------------------------
(eval-after-load "markdown-mode"
'(defalias 'markdown-add-xhtml-header-and-footer 'as/markdown-add-xhtml-header-and-footer))
(defun as/markdown-add-xhtml-header-and-footer (title)
"Wrap XHTML header and footer with given TITLE around current buffer."
(goto-char (point-min))
(insert "<!DOCTYPE html>\n"
"<html>\n"
"<head>\n<title>")
(insert title)
(insert "</title>\n")
(insert "<meta charset=\"utf-8\" />\n")
(when (> (length markdown-css-paths) 0)
(insert (mapconcat 'markdown-stylesheet-link-string markdown-css-paths "\n")))
(insert "\n</head>\n\n"
"<body>\n\n")
(goto-char (point-max))
(insert "\n"
"</body>\n"
"</html>\n")))
(provide 'init-markdown)
;;; init-markdown.el ends here

54
modules/init-modeline.el Normal file
View File

@@ -0,0 +1,54 @@
;;; init-modeline.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; Modeline configuration
;;----------------------------------------------------------------------------
(use-package smart-mode-line)
(use-package smart-mode-line-powerline-theme)
(use-package sml-modeline
:config
;; Show number of occurrences when searching
(setq sml/theme 'powerline)
(setq sml/no-confirm-load-theme t)
(setq sml/shorten-modes t)
;; Show EOL mode
(setq sml/show-eol t)
;; Show remote buffers
(setq sml/show-remote t)
(sml/setup)
(add-to-list 'sml/replacer-regexp-list '("^~/Proyectos/git/" ":Git:") t)
(add-to-list 'sml/replacer-regexp-list '("^~/www/" ":www:") t)
(sml-modeline-mode t))
(use-package anzu
:config
(custom-set-variables
'(anzu-search-threshold 1000)
'(anzu-replace-threshold 1000)
'(anzu-deactivate-region t)
'(anzu-input-idle-delay 0.1)
'(anzu-replace-to-string-separator " => "))
(global-anzu-mode +1)
(set-face-attribute 'anzu-mode-line nil
:foreground "yellow" :weight 'bold)
(define-key isearch-mode-map [remap isearch-query-replace] #'anzu-isearch-query-replace)
(define-key isearch-mode-map [remap isearch-query-replace-regexp] #'anzu-isearch-query-replace-regexp)
;;----------------------------------------------------------------------------
;; Keyboard shortcuts in Anzu Mode
;;----------------------------------------------------------------------------
(global-set-key (kbd "M-%") 'anzu-query-replace)
(global-set-key (kbd "s-<SPC>") 'anzu-query-replace))
(load-file "~/.emacs.d/modules/lib/myemacs.el")
(provide 'init-modeline)
;; End:
;;; init-modeline.el ends here

90
modules/init-neotree.el Normal file
View File

@@ -0,0 +1,90 @@
;;; init-neotree.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;-----------------------------------
;; Neotree - NerdTree for Vim
;;-----------------------------------
(use-package shrink-path
:ensure t)
(use-package neotree
:ensure t
:commands (neotree-show
neotree-hide
neotree-toggle
neotree-dir
neotree-find
neo-global--with-buffer
neo-global--window-exists-p)
:bind (([f8] . neotree-toggle)
(:map neotree-mode-map
("<C-return>" . neotree-change-root)
("C" . neotree-change-root)
("c" . neotree-create-node)
("+" . neotree-create-node)
("d" . neotree-delete-node)
("r" . neotree-rename-node)))
:config
(setq neo-create-file-auto-open nil
neo-auto-indent-point nil
neo-autorefresh t
neo-smart-open t
neo-mode-line-type 'none
neo-window-width 25
neo-show-updir-line nil
neo-theme (if (display-graphic-p) 'icons 'arrow)
neo-banner-message nil
neo-confirm-create-file #'off-p
neo-confirm-create-directory #'off-p
neo-show-hidden-files nil
neo-keymap-style 'concise
neo-hidden-regexp-list
'(;; vcs folders
"^\\.\\(git\\|hg\\|svn\\)$"
;; compiled files
"\\.\\(pyc\\|o\\|elc\\|lock\\|css.map\\)$"
;; generated files, caches or local pkgs
"^\\(node_modules\\|vendor\\|.\\(project\\|cask\\|yardoc\\|sass-cache\\)\\)$"
;; org-mode folders
"^\\.\\(sync\\|export\\|attach\\)$"
"~$"
"^#.*#$"))
(when (bound-and-true-p winner-mode)
(push neo-buffer-name winner-boring-buffers))
(defun shrink-root-entry (node)
"shrink-print pwd in neotree"
(insert (propertize (concat (shrink-path-dirs node) "\n") 'face `(:inherit (,neo-root-dir-face)))))
(advice-add #'neo-buffer--insert-root-entry :override #'shrink-root-entry))
(defun neotree-project-dir-toggle ()
"Open NeoTree using the project root, using find-file-in-project or the current buffer directory."
(interactive)
(let ((project-dir
(ignore-errors
;;; Pick one: projectile or find-file-in-project
(projectile-project-root)))
(file-name (buffer-file-name))
(neo-smart-open t))
(if (and (fboundp 'neo-global--window-exists-p)
(neo-global--window-exists-p))
(neotree-hide)
(progn
(neotree-show)
(if project-dir
(neotree-dir project-dir))
(if file-name
(neotree-find file-name))))))
(provide 'init-neotree)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init-neotree.el ends here

15
modules/init-nginx.el Normal file
View File

@@ -0,0 +1,15 @@
;;; init-nginx.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;---------------------------
;; Nginx Mode
;;---------------------------
(use-package nginx-mode
:mode ("/nginx/sites-\\(?:available\\|enabled\\)/" . nginx-mode))
(provide 'init-nginx)
;; End:
;;; init-nginx.el ends here

106
modules/init-nlinum.el Normal file
View File

@@ -0,0 +1,106 @@
;;; init-nlinum.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; Line numbers
;;----------------------------------------------------------------------------
;; Linum snippets from: https://www.emacswiki.org/emacs/LineNumbers
(use-package nlinum
:config
(add-hook 'find-file-hook (lambda () (linum-mode 1)))
(linum-mode)
(setq global-linum-mode t))
(use-package linum)
(use-package 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 ()
"Format the string of the column in the buffer.
It helps to show the numbering plus a separation bar."
(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)
"Defines LINE-NUMBER the numbering format of each.
this helps maintain the format in the numbering"
(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)
"Defines LINUM-UPDATE for update lines.
this helps maintain the format in the numbering"
(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 ()
"Funtions for position lines.
this helps maintain the move visual."
(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))
(with-no-warnings
(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 ()
"Funtions for position lines.
this helps maintain the move visual."
(interactive)
(with-no-warnings
(goto-line (line-at-click)))
(set-mark (point))
(setq *linum-mdown-line*
(line-number-at-pos)))
(defun mu-select-linum ()
"Funtions for position lines.
this helps maintain the move visual."
(interactive)
(when *linum-mdown-line*
(let (mu-line)
;; (goto-line (line-at-click))
(setq mu-line (line-at-click))
(with-no-warnings
(goto-line (max *linum-mdown-line* mu-line)))
(set-mark (line-end-position))
(with-no-warnings
(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)
(provide 'init-nlinum)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init-nlinum.el ends here

29
modules/init-php.el Normal file
View File

@@ -0,0 +1,29 @@
;;; init-php.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
(use-package php-refactor-mode
:after (php-mode)
:mode ("\\.php\\'" . php-mode)
:config
(add-hook 'php-mode-hook 'php-refactor-mode))
(use-package php-mode
:ensure t)
(use-package company-php
:ensure t
:config
(defun cfg:php-mode-hook ()
(interactive)
(require 'company-php)
(company-mode t)
(add-to-list 'company-backends 'company-ac-php-backend))
(add-hook 'php-mode-hook 'cfg:php-mode-hook))
(add-hook 'php-mode-hook (lambda () (subword-mode 1)))
(provide 'init-php)
;;; init-php.el ends here

10
modules/init-pkgbuild.el Normal file
View File

@@ -0,0 +1,10 @@
;;; init-pkgbuild.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
(use-package pkgbuild-mode
:mode ("/PKGBUILD$" . pkgbuild-mode))
(provide 'init-pkgbuild)
;;; init-pkgbuild.el ends here

43
modules/init-python.el Normal file
View File

@@ -0,0 +1,43 @@
;;; init-python.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; Python Mode
;;----------------------------------------------------------------------------
(add-hook 'python-mode-hook
(lambda ()
(setq indent-tabs-mode nil)
(setq python-indent-guess-indent-offset nil)
(setq python-indent-offset 4)))
;;----------------------------------------------------------------------------
;; Jedi - Python auto-completion for Emacs
;;----------------------------------------------------------------------------
(use-package jedi)
(setq auto-mode-alist
(append '(("SConstruct\\'" . python-mode)
("SConscript\\'" . python-mode))
auto-mode-alist))
(use-package pip-requirements)
(defun my/python-mode-stuff ()
"Jedi make everything a lot easier for everybody!.
It's helps prepare jedi in Emacs."
(jedi:setup)
(define-key python-mode-map (kbd "C-]") 'jedi:goto-definition) ;goto define
(local-set-key (kbd "<f1>") 'jedi:show-doc)
(setq jedi:complete-on-dot t) ; optional
)
;; Added Jedi-mode to python-mode
(add-hook 'python-mode-hook 'my/python-mode-stuff)
;; M-x jedi:install-server
(provide 'init-python)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init-python.el ends here

17
modules/init-rainbow.el Normal file
View File

@@ -0,0 +1,17 @@
;;; init-rainbow.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;; rainbow-mode
(use-package rainbow-mode
:init
(add-hook 'css-mode-hook 'rainbow-mode)
(add-hook 'sass-mode-hook 'rainbow-mode)
(add-hook 'scss-mode-hook 'rainbow-mode)
(add-hook 'less-mode-hook 'rainbow-mode)
(add-hook 'web-mode-hook 'rainbow-mode)
(add-hook 'html-mode-hook 'rainbow-mode))
(provide 'init-rainbow)
;;; init-rainbow.el ends here

18
modules/init-ready.el Normal file
View File

@@ -0,0 +1,18 @@
;;; init-ready.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;-------------------------
;; Emacs Ready :)
;;-------------------------
(add-hook 'emacs-startup-hook
(lambda ()
(message "Emacs ready in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done)))
(provide 'init-ready)
;;; init-ready.el ends here

14
modules/init-sass.el Normal file
View File

@@ -0,0 +1,14 @@
;;; init-sass.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; Sass Mode
;;----------------------------------------------------------------------------
(use-package sass-mode
:mode ("\\.sass\\'" . sass-mode))
(provide 'init-sass)
;;; init-sass.el ends here

14
modules/init-scss.el Normal file
View File

@@ -0,0 +1,14 @@
;;; init-scss.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; Scss Mode
;;----------------------------------------------------------------------------
(use-package scss-mode
:mode ("\\.scss\\'" . scss-mode))
(provide 'init-scss)
;;; init-scss.el ends here

22
modules/init-security.el Normal file
View File

@@ -0,0 +1,22 @@
;;; init-security.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;---------------------------------------------------------------------------------------------
;; Security. Check https://web.archive.org/web/20170413150436/https://ogbe.net/emacsconfig.html
;;---------------------------------------------------------------------------------------------
(setq tls-checktrust t)
(setq gnutls-verify-error t)
(let ((trustfile "/etc/ssl/cert.pem"))
(setq tls-program
`(,(format "gnutls-cli --x509cafile %s -p %%p %%h" trustfile)
,(format "openssl s_client -connect %%h:%%p -CAfile %s -no_ssl2 -ign_eof" trustfile)))
(setq gnutls-trustfiles (list trustfile)))
(provide 'init-security)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; init-security.el ends here

17
modules/init-theme.el Normal file
View File

@@ -0,0 +1,17 @@
;;; init-theme.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
(use-package sublime-themes
:config
(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)
;;; init-theme.el ends here

31
modules/init-utils.el Normal file
View File

@@ -0,0 +1,31 @@
;;; init-utils.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;; Loads functions from libs
(defun load-directory (dir)
"Load functions from the libs DIR.
read the .el files"
(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/modules/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
(load-file "~/.emacs.d/modules/lib/myemacs.el")
(provide 'init-utils)
;;; init-utils.el ends here

20
modules/init-web-mode.el Normal file
View File

@@ -0,0 +1,20 @@
;;; init-web-mode.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
(use-package web-mode
:mode (("\\.html?\\'" . web-mode)
("\\.djhtml\\'" . web-mode)
("\\.tpl\\'" . web-mode)
("\\.jsp\\'" . web-mode)
("\\.gsp\\'" . web-mode)
("\\.ctp\\'" . web-mode))
:config
;; web-modeの設定
(setq web-mode-enable-current-element-highlight t)
(set-face-background 'web-mode-current-element-highlight-face "#a3a3a3")
)
(provide 'init-web-mode)
;;; init-web-mode.el ends here

View File

@@ -0,0 +1,12 @@
;;; init-whitespace.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;;----------------------------------------------------------------------------
;; Whitespace Mode | tool
;;----------------------------------------------------------------------------
(use-package whitespace-cleanup-mode)
(provide 'init-whitespace)
;;; init-whitespace.el ends here

11
modules/init-yaml.el Normal file
View File

@@ -0,0 +1,11 @@
;;; init-yaml.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;
;;; Code:
;; yaml-mode
(use-package yaml-mode
:mode ("\\.yml\\'" . yaml-mode))
(provide 'init-yaml)
;;; init-yaml.el ends here

37
modules/lib/myemacs.el Normal file
View File

@@ -0,0 +1,37 @@
;;; myemacs.el --- .Emacs Configuration -*- lexical-binding: t -*-
;;; Commentary:
;;; myemacs reloj
;;; Code:
;;----------------------------------------------------------------------------
;; Some cool functions
;;----------------------------------------------------------------------------
;; These functions are made by me (Quitter: @heckyel) or
;; heavily modified by me
;;----------------------------------------------------------------------------
;; Toggles fullscreen
;;----------------------------------------------------------------------------
(defun myemacs/toggle-fullscreen ()
"Return a message string if the current doc string is invalid."
(interactive)
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_FULLSCREEN" 0)))
;;----------------------------------------------------------------------------
;; Runtime Emacs
;;----------------------------------------------------------------------------
(defun elapsed-time ()
"Return a message string if the current doc string is invalid.
Emacs runtime: See the following URL for more details.
https://emacs.stackexchange.com/questions/13535/function-to-get-init-el-file-loading-times-multiple-times?rq=1"
(let ((elapsed (float-time (time-subtract (current-time)
emacs-start-time))))
(message "[STARTUP] Loading %s ... done (%.3fs)" load-file-name elapsed)))
(provide 'myemacs)
;; Local Variables:
;; byte-compile-warnings: (not free-vars)
;; End:
;;; myemacs.el ends here

39
modules/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))))