Skip to content

Instantly share code, notes, and snippets.

@aanoaa
Created November 15, 2011 23:53
Show Gist options
  • Save aanoaa/1368800 to your computer and use it in GitHub Desktop.
Save aanoaa/1368800 to your computer and use it in GitHub Desktop.
;; visible bell
(setq visible-bell nil)
;; allow selection deletion
(delete-selection-mode t)
;; make sure delete key is delete key
(global-set-key [delete] 'delete-char)
;; have emacs scroll line-by-line
(setq scroll-step 1)
;; set color-theme
(color-theme-zenburn)
;; tab-width
(setq-default tab-width 4)
(defun my-zoom (n)
"Increase or decrease font size based upon argument"
(set-face-attribute 'default (selected-frame) :height
(+ (face-attribute 'default :height) (* (if (> n 0) 1 -1) 10))))
;; minimalist emacs configuration
;; for korean emacs starter
;; language setting
(setq default-input-method "korean-hangul")
(global-set-key (kbd "<Hangul>") 'toggle-input-method)
;; font setting
(set-default-font "consolas-10")
(set-fontset-font t '(#x1100 . #xffdc) '("Malgun Gothic" . "unicode-bmp"))
(set-fontset-font t '(#xe0bc . #xf66e) '("Malgun Gothic" . "unicode-bmp"))
;; suport more languages?
(set-fontset-font t 'kana '("Kochi Gothic" . "unicode-bmp"))
(set-fontset-font t 'han '("Arial" . "unicode-bmp"))
;; Start shell or switch to it if it's active.
(global-set-key (kbd "C-x m") 'shell)
(global-set-key (kbd "C-x n") 'ansi-term)
;; joining && autojoing
;; make sure to use wildcards for e.g. freenode as the actual server
;; name can be be a bit different, which would screw up autoconnect
(erc-autojoin-mode t)
(setq erc-autojoin-channels-alist
'((".*\\.freenode.net" "#perl-kr" "#ream" "#ream-dev")
(".*\\.silex.kr" "#silex")))
(defun djcb-erc-start-or-switch ()
"Connect to ERC, or switch to last active buffer"
(interactive)
(if (get-buffer "irc.freenode.net:6667") ;; ERC already active?
(erc-track-switch-buffer 1) ;; yes: switch to last active
(when (y-or-n-p "Start ERC? ") ;; no: maybe start ERC
(erc :server "irc.freenode.net" :port 6667 :nick "hshong" :full-name "Hyungsuk Hong")
(erc :server "irc.silex.kr" :port 6667 :nick "hshong" :full-name "Hyungsuk Hong"))))
;; switch to ERC with Ctrl+c e
(global-set-key (kbd "C-c e") 'djcb-erc-start-or-switch) ;; ERC
;;; Notify me when a keyword is matched (someone wants to reach me)
(setq erc-keywords
'(("hshong *[,:;]")
("\\bhshong[!?.]+$")))
(erc-match-mode 1)
(defvar my-erc-page-message "%s is calling your name."
"Format of message to display in dialog box")
(defvar my-erc-page-nick-alist nil
"Alist of nicks and the last time they tried to trigger a
notification")
(defvar my-erc-page-timeout 30
"Number of seconds that must elapse between notifications from
the same person.")
(defun my-erc-page-popup-notification (nick)
(when window-system
;; must set default directory, otherwise start-process is unhappy
;; when this is something remote or nonexistent
(let ((default-directory "~/"))
;; 8640000 milliseconds = 1 day
(start-process "page-me" nil "notify-send"
"-u" "normal" "-t" "8640000" "ERC"
(format my-erc-page-message nick)))))
(defun my-erc-page-allowed (nick &optional delay)
"Return non-nil if a notification should be made for NICK.
If DELAY is specified, it will be the minimum time in seconds
that can occur between two notifications. The default is
`my-erc-page-timeout'."
(unless delay (setq delay my-erc-page-timeout))
(let ((cur-time (time-to-seconds (current-time)))
(cur-assoc (assoc nick my-erc-page-nick-alist))
(last-time))
(if cur-assoc
(progn
(setq last-time (cdr cur-assoc))
(setcdr cur-assoc cur-time)
(> (abs (- cur-time last-time)) delay))
(push (cons nick cur-time) my-erc-page-nick-alist)
t)))
(defun my-erc-page-me (match-type nick message)
"Notify the current user when someone sends a message that
matches a regexp in `erc-keywords'."
(interactive)
(when (and (eq match-type 'keyword)
;; I don't want to see anything from the erc server
(null (string-match "\\`\\([sS]erver\\|localhost\\)" nick))
;; or bots
(null (string-match "\\(bot\\|serv\\)!" nick))
;; or from those who abuse the system
(my-erc-page-allowed nick))
(my-erc-page-popup-notification nick)))
(add-hook 'erc-text-matched-hook 'my-erc-page-me)
(defun my-erc-page-me-PRIVMSG (proc parsed)
(let ((nick (car (erc-parse-user (erc-response.sender parsed))))
(target (car (erc-response.command-args parsed)))
(msg (erc-response.contents parsed)))
(when (and (erc-current-nick-p target)
(not (erc-is-message-ctcp-and-not-action-p msg))
(my-erc-page-allowed nick))
(my-erc-page-popup-notification nick)
nil)))
(add-hook 'erc-server-PRIVMSG-functions 'my-erc-page-me-PRIVMSG)
;; coffee-mode
(add-to-list 'load-path "~/.emacs.d/vendor/coffee-mode")
(require 'coffee-mode)
(defun coffee-custom ()
"coffee-mode-hook"
(set (make-local-variable 'tab-width) 2))
(add-hook 'coffee-mode-hook
'(lambda() (coffee-custom)))
(define-key coffee-mode-map [(meta r)] 'coffee-compile-buffer)
(define-key coffee-mode-map [(meta R)] 'coffee-compile-region)
;; move to pair {}, [], ()
(global-set-key "%" 'match-paren)
(defun match-paren (arg)
"Go to the matching paren if on a paren; otherwise insert %."
(interactive "p")
(cond ((looking-at "\\s\(") (forward-list 1) (backward-char 1))
((looking-at "\\s\)") (forward-char 1) (backward-list 1))
(t (self-insert-command (or arg 1)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment