Prechádzať zdrojové kódy

Updated emacs config version checks and load hooks

Tom Flucke 8 rokov pred
rodič
commit
0a4bac955c
2 zmenil súbory, kde vykonal 230 pridanie a 146 odobranie
  1. 133 89
      .bashrc
  2. 97 57
      .emacs.d/init.el

+ 133 - 89
.bashrc

@@ -1,98 +1,142 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+# CSL default
+# by kkowal 2005-06-21 and updated by various other people
+# apence, 20120909: this is a very Sun centric set of options
+
+# DO NOT MAKE CHANGES TO THIS FILE.  Put your changes in your .mybashrc
+# file instead.
+
+# If not running interactively, don't do anything
+[ -z "$PS1" ] && return
+
 #
-# ~/.bashrc
+# `PS1' is run each time the bash prompt is drawn.  The following
+# line noise draws a colorful prompt with your user name, which
+# computer you're logged into, and what directory you're in.
 #
+#PS1="\@ \h \w\\$ " # non-colored
+PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \$ '
 
-# If not running interactively, don't do anything
-[[ $- != *i* ]] && return
+#
+# `PATH' determines the locations, in order, in which the shell will look for
+# executable programs.
+#
+#PATH=/bin:/usr/bin:/usr/sbin
+PATH=/bin:/usr/bin
+# IF it exists, Look in my home bin first, then the other path
+[ -d ~/bin ] && PATH=~/bin:$PATH
+# IF it exists, look here after the normal path
+[ -d /usr/local/bin ] && PATH=$PATH:/usr/local/bin
+[ -d /usr/share/bin ] && PATH=$PATH:/usr/share/bin
+
+### NO don't add PATH=$PATH:.
+# the better option is to type ./command when the command is in cwd
+# if you want to make a habbit of running other commands out of your path
+# append them to your path in your .mybashrc
+# YOU need to know what you are going to run
+
+export PATH
 
-MUSIC_DIR="/media/music"
-MTG_DIR="~/.local/share/data/Cockatrice/Cockatrice/decks"
-SH_DIR="~/.config/env"
-SERVER_IP="63.246.2.164"
+#
+# `MANPATH' determines the locations, in order, where `man' will look
+# for manual pages.
+#
+MANPATH=/usr/share/man
+[ -d ~/man ] && MANPATH=~/man:$MANPATH
 
-export EDITOR="/usr/bin/emacs -nw"
-export BROWSER=/usr/bin/firefox
-export TERM=xterm-256color
+# ML
+[ -d /usr/local/sml/bin ] && PATH=$PATH:/usr/local/sml/bin
 
-shopt -s checkwinsize
-shopt -s autocd
-shopt -s dirspell
-shopt -s xpg_echo
+[ -d /usr/local/man ] && MANPATH=$MANPATH:/usr/local/man
+[ -d /usr/local/share/man ] && MANPATH=$MANPATH:/usr/local/share/man
+
+export MANPATH
+
+#
+# `PAGER' is the name of the program that many applications will use to
+# limit their output to a page at a time.  `more' is the original pager.
+# `less' additionally allows you to back up.
+#
+PAGER=less
+#PAGER=more
+
+# make less more friendly for non-text input files, see lesspipe(1)
+[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
+
+#
+# `EDITOR' is the name of the program that many applications will invoke
+# to edit a text file.
+#
+#EDITOR=vim
+#EDITOR=emacs
+#EDITOR=pico # Warning: other users will be able to see
+             #  you using this with the ps command ;-)
+
+#
+# common aliases
+#
+# the following is a list of commonly used aliases, to use them simply remove
+# the '#' from the beginning of the line.  Read the man pages to find out 
+# exactly what each command does.
+#
+#alias h="history | $PAGER"
+#alias ls="ls -F1"
+#alias l.="ls -FA1"
+#alias ll="ls -slagFL"
+#alias lf="ls -F"
+#alias lr="ls -RF"
+#alias l="ls -FLAsC"
+#alias bye="logout"
 
-# Set up history search
-bind '"\e[A": history-search-backward'
-bind '"\e[B": history-search-forward'
+#
+# don't put duplicate lines in the history. See bash(1) for more options
+#
 export HISTCONTROL=ignoredups
 
-# Set up left/right word skipping
-bind '"\e[1;5D": backward-word'
-bind '"\e[1;5C": forward-word'
-
-# List of directories to look for git completion
-gitCompletion="/usr/share/git/completion/git-completion.bash /usr/share/bash-completion/completions/git"
-
-for f in $gitCompletion; do
-    if [ -f "$f" ]; then
-	source "$f"
-    fi
-done
-
-# TODO: Can't use SH_DIR, doesn't expand with *.
-for script in ~/.config/env/*.sh; do
-    source "$script"
-done
-
-getLyricalSongs()
-{
-  mpc list album | grep -v '\(Portal 2.*\)\|\(Avatar.*\)\|\(Frozen.*\)' | while read -r line; do
-    printf "$(mpc find album "$line" | grep -v 'Instrumental')\n"
-  done
-}
-
-# echo exec
-# Print command and execute ala make
-#if type -t ecex; then
-ecex()
-{
-    echo "$@"
-    $@
-    
-}
-
-#alias xterm='echo "xterm -rv" && xterm -rv'
-alias emacs='emacs -nw'
-alias xterm='ecex xterm -rv'
-alias decks='ecex "$MTG_DIR" && ecex mv /tmp/*.dec "$MTG_DIR"'
-alias newMusic='ecex sudo chown media /tmp/*.mp3 && ecex sudo -u media mv -v /tmp/*.mp3 /media/music && ecex mpc update'
-alias playMusic='ecex mpc clear && ecex getLyricalSongs | ecex mpc add && ecex mpc shuffle && ecex mpc play'
-alias conServer='ecex ssh tflucke@63.246.2.164'
-alias packageSize="pacman -Qi | gawk '/^Name/ { x = $3 }; /^Installed Size/ { sub(/Installed Size  *:/, ""); print x":" $0 }' | sort -k2,3nr"
-
-#[ $exitCode -eq 0 ] && color=$FGRN || color=$FRED
-PS1="[\u@\h->$BLD\w$RS]
-$BLD$([ $? -ne 0 ] && echo '\[$FRED')(\$?)$RS \$ "
-
-# Auto mount
-# Mounts or unmounts intelligently.  Useful for keyboard bindings
-amount () {
-    if mount | grep -q "/dev/$1"; then
-	udevil umount -l "/dev/$1"
-    else
-	udevil mount "/dev/$1"
-    fi	
-} 
-
-mysqlpermissions()
-{
-  mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
-    'SHOW GRANTS FOR \'', user, '\'@\'', host, '\';'
-    ) AS query FROM mysql.user" | \
-  mysql $@ | \
-  sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
-}
-
-# Syncs music dir to dir.  Useful for syncing phone music.
-syncMusic()
-{
-    ecex rsync -ruh --progress "$MUSIC_DIR" "$1"
-}
+#
+# `umask' is an octal bit mask which constrains the permissions you
+# will grant to new files by default.  077 completely denies other users
+# access to your files.  022 denies all other users write access.
+# The CSL mandates that you keep your umask set to 077, and only
+# change some small known set of files so that others may have access.
+#
+umask 077
+
+#
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+#
+shopt -s checkwinsize
+
+#
+# `TERM' determines what kind of terminal the system expects you are using.
+# This affects whether and what kinds of control characters will be sent
+# to your terminal client (like color codes and cursor positions).
+#
+#TERM=xtermc
+
+#
+# if this is an xterm set the title of the window to user@host:dir
+#
+case "$TERM" in
+	xterm*|rxvt*)
+		PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
+		;;
+	*)
+    ;;
+esac
+
+#
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc).
+#
+[ -f /etc/bash_completion ] && . /etc/bash_completion
+
+#
+# This runs a user defined script `.mybashrc', which by default does
+# nothing.
+#
+#[ -f ~/.bashrc.`uname` ] && . ~/.bashrc.`uname`
+#[ -f ~/.bashrc.`hostname` ] && . ~/.bashrc.`hostname`
+[ -f ~/.mybashrc ] && . ~/.mybashrc
+# end

+ 97 - 57
.emacs.d/init.el

@@ -14,7 +14,7 @@
               tab-width 4
 	          indent-tabs-mode nil
               x-select-enable-clipboard t
-              backup-directory-alist `(("." . backup-directory))
+              backup-directory-alist `(("." . ,backup-directory))
               delete-old-versions t)
 
 ;; (global-linum-mode)
@@ -22,23 +22,26 @@
 ;; Delete selected text when typing (normal editor behavior)
 (delete-selection-mode t)
 
+(defun mapcar-dot* (f list)
+  (loop for (a . b) on list
+        collect (funcall f a)
+        unless (listp b)
+        collect (funcall f b)))
+
 ;; ------------- Keybindings -------------
 (global-set-key (kbd "C-c /") 'comment-or-uncomment-region)
-(global-set-key (kbd "C-x g") 'magit-status)
 (global-set-key (kbd "C-c C-k") 'compile)
-(global-set-key (kbd "M-p") 'print-buffer)
 
 ;; ----------- Package Managing -----------
 ;; The package manager
 (require 'package)
 
 ;; Add package sources
-(setq
- package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
-                    ("org" . "https://orgmode.org/elpa/")
-                    ("melpa" . "https://melpa.org/packages/")
-                    ("melpa-stable" . "https://stable.melpa.org/packages/"))
- package-archive-priorities '(("melpa-stable" . 1)))
+(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
+                         ("org" . "https://orgmode.org/elpa/")
+                         ("melpa" . "https://melpa.org/packages/")
+                         ("melpa-stable" . "https://stable.melpa.org/packages/"))
+      package-archive-priorities '(("melpa-stable" . 1)))
 (package-initialize)
 
 (unless (package-installed-p 'use-package)
@@ -49,23 +52,43 @@
 
 ;; ---------- Use X11 clipboard -----------
 (use-package xclip
+  :if (executable-find "xclip")
+  :hook ((text-mode-hook prog-mode-hook) . xclip-mode))
+
+;; ---------- Color Themes ----------
+(use-package color-theme
+  :init
+  ;; TODO: Fixes error about missing directory.  Don't know why.
+  (unless (file-exists-p "~/.emacs.d/elpa/color-theme-20070910.1007/themes")
+    (make-directory "~/.emacs.d/elpa/color-theme-20070910.1007/themes"))
   :config
-  (dolist (hook '(text-mode-hook prog-mode-hook)) (add-hook hook (lambda () (xclip-mode)))))
+  (color-theme-initialize))
+
+(use-package base16-theme
+  :requires color-theme
+  :config (load-theme 'base16-tomorrow-night t))
 
 ;; --------- Parentheses Matching ---------
+(show-paren-mode)
 (use-package highlight-parentheses
   :config
   (define-globalized-minor-mode global-highlight-parentheses-mode
 	highlight-parentheses-mode
 	(lambda ()
 	  (highlight-parentheses-mode t)))
-  (global-highlight-parentheses-mode t)
-  )
+  (global-highlight-parentheses-mode t))
 
 (use-package autopair
   :config
   (autopair-global-mode))
 
+;; ------------ xTerm Mouse ------------
+;; Disable because it became annoying, sounds cool though.
+(use-package mouse
+  :disabled
+  :config
+  (xterm-mouse-mode t))
+
 ;; ----------- Ensime -----------
 ;; Java/Scala featues.  Includes:
 ;; * Inferred types
@@ -74,72 +97,67 @@
 ;; * Jump to source/docs
 ;; * Refactoring
 ;; * Error detection
+(use-package scala-mode
+  :mode "\\.scala\\'")
+
 (use-package ensime
+  :disabled
+  :if (version<= "24.4" emacs-version)
   :pin melpa-stable)
 
 ; --------- C Syntax checker ---------
-(use-package flycheck-irony)
-
-;; xTerm mouse support
-;; Disable because it became annoying, sounds cool though.
-;;
-;;(require 'mouse)
-;;(xterm-mouse-mode t)
-
-;; ---------- Color Themes ----------
-(use-package color-theme
-  ;; TODO: Fixes error about missing directory.  Don't know why.
-  :init
-  (unless (file-exists-p "~/.emacs.d/elpa/color-theme-20070910.1007/themes")
-    (make-directory "~/.emacs.d/elpa/color-theme-20070910.1007/themes"))
-  :config
-  (color-theme-initialize))
-
-(use-package base16-theme
-  :requires color-theme
-  :config (load-theme 'base16-tomorrow-night t))
+(use-package flycheck-irony
+  :hook c-mode
+  :mode ("\\.c\\'" "\\.h\\'"))
 
 ;; ------------ Web Mode ------------
 (use-package multi-web-mode
+  :init
+  (setq mweb-default-major-mode 'html-mode
+        mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
+                    (js-mode  "<script[^>]*>" "</script>")
+                    (css-mode "<style[^>]*>" "</style>"))
+        mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
+;  :mode (mapcar-dot* (format "\\.%s\\'" ext '("php" "htm" "html" "ctp" "phtml" "php4" "php5")))
   :config
-  (setq mweb-default-major-mode 'html-mode)
-  (setq mweb-tags 
-		'((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
-		  (js-mode  "<script[^>]*>" "</script>")
-		  (css-mode "<style[^>]*>" "</style>")))
-  (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
   (multi-web-global-mode 1))
 
 ;; ------------ Git Mode ------------
-(use-package magit)
+(when (version<= "24.4" emacs-version)
+  (use-package magit
+    :bind ("C-x g" . magit-status)))
 
 ;; ----------- Rust Mode ------------
-(use-package rust-mode)
+(use-package rust-mode
+  :mode ("\\.rs\\'"))
 (use-package rust-playground
   :requires rust-mode)
 (use-package cargo
-  :requires rust-mode)
+  :after rust-mode)
 (use-package flycheck-rust
-  :requires rust-mode)
+  :after rust-mode)
 
 ;; ----------- i3 Support ----------
-;(if (equal (getenv "DESKTOP_SESSION") "i3")
-;    (use-package i3wm))
+(use-package i3wm
+  :disabled
+  :if (equal (getenv "DESKTOP_SESSION") "i3"))
 
 ;; --------- Racket Mode ----------
 (use-package racket-mode)
 
-;; --------- Scala Mode -----------
-(use-package scala-mode)
-
 ;; ---------- C# Mode -------------
-(use-package csharp-mode)
+(use-package csharp-mode
+  :if (version<= "24.4" emacs-version)
+  :mode ("\\.cs\\'"))
 
 ;; ------- Markdown Mode ----------
-(use-package markdown-mode)
+(when (version<= "24.4" emacs-version)
+  (use-package markdown-mode
+    :mode ("\\.markdown\\'" "\\.md\\'")))
 
 ;; ---- StackOverflow Client ------
-;(use-package sx)
+(use-package sx
+  :disabled)
 
 ;; -------- Spellcheck ------------
 (defun flyspell-detect-ispell-args (&optional run-together)
@@ -149,6 +167,10 @@
 		 "-d en_US")))
 
 (use-package flyspell-correct-popup
+  :bind ("M-s" . ispell-word)
+  :hook ((text-mode . flyspell-mode)
+         (prog-mode . flyspell-prog-mode)
+         ((flyspell-mode flyspell-prog-mode) . flyspell-buffer))
   :config
   (cond
    ((executable-find "aspell")
@@ -160,21 +182,39 @@
    (t
 	(setq ispell-program-name nil)))
   (setq-default ispell-extra-args (flyspell-detect-ispell-args t))
-  (global-set-key (kbd "M-s") 'ispell-word)
-  (setq-default flyspell-issue-message-flag nil)
-  (dolist (hook '(text-mode-hook magit-mode-hook)) (add-hook hook (lambda () (flyspell-mode))))
-  (add-hook 'prog-mode-hook (lambda () (flyspell-prog-mode))))
+  (setq-default flyspell-issue-message-flag nil))
 
 ;; -------- REST Client ---------
-(use-package restclient)
+(use-package restclient
+  :commands (restclient-copy-curl-command
+             restclient-http-send-current
+             restclient-http-send-current-raw
+             restclient-http-send-current-stay-in-window
+             restclient-jump-next
+             restclient-jump-prev
+             restclient-mark-current
+             restclient-mode
+             restclient-narrow-to-current
+             restclient-outline-mode
+             restclient-toggle-body-visibility
+             restclient-toggle-body-visibility-or-indent))
 
 ;; ------- Highlight TODO -------
 (use-package hl-todo
-  :config
-  (add-hook 'prog-mode-hook (lambda () (hl-todo-mode))))
+  :commands (hl-todo-mode
+             hl-todo-next
+             hl-todo-occur
+             hl-todo-previous)
+  :hook (prog-mode . hl-todo-mode))
 
 ;; ---- Printer Integration -----
 (use-package printing
+  :bind ("M-p" . print-buffer)
+  :commands (print-buffer
+             print-region
+             lpr-buffer
+             lpr-customize
+             lpr-region)
   :config
   (pr-update-menus t))