(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)))))
;;括号高亮设置 ;; show the matched parentheses (show-paren-mode t) ;; no jump, just highlight (setq show-paren-style 'parentheses)
;;有了这段代码之后,当你按 C-c a x (x 是任意一个字符) 时,光标就会到下一个 x 处。再次按 x,光标就到下一个 x。比如 C-c a w w w w ..., C-c a b b b b b b ... (defun wy-go-to-char (n char) "Move forward to Nth occurence of CHAR. Typing `wy-go-to-char-key' again will move forwad to the next Nth occurence of CHAR." (interactive "p\ncGo to char: ") (search-forward (string char) nil nil n) (while (char-equal (read-char) char) (search-forward (string char) nil nil n)) (setq unread-command-events (list last-input-event)))
;;;让dired只打开一个buffer (require 'dired) (require 'dired-single) ;;绑定 (defun my-dired-init () "Bunch of stuff to run for dired, either immediately or when it's loaded." ;; (define-key dired-mode-map [return] 'joc-dired-single-buffer) ; (define-key dired-mode-map [mouse-1] 'joc-dired-single-buffer-mouse) (define-key dired-mode-map "^" (function (lambda nil (interactive) (joc-dired-single-buffer "..")))) )
;; if dired's already loaded, then the keymap will be bound (if (boundp 'dired-mode-map) ;; we're good to go; just add our bindings (my-dired-init) ;; it's not loaded yet, so add our bindings to the load-hook (add-hook 'dired-load-hook 'my-dired-init))
;; toggles (define-key ido-mode-map "\C-t" 'ido-toggle-regexp) ;; same as in isearch (define-key ido-mode-map "\C-p" 'ido-toggle-prefix) (define-key ido-mode-map "\C-c" 'ido-toggle-case) (define-key ido-mode-map "\C-a" 'ido-toggle-ignore)
;; keys used in file and dir environment (when (memq ido-cur-item '(file dir)) (define-key ido-mode-map "\C-b" 'ido-enter-switch-buffer) (define-key ido-mode-map "\C-d" 'ido-enter-dired) (define-key ido-mode-map "\C-f" 'ido-fallback-command)
;; cycle among directories ;; use [left] and [right] for matching files (define-key ido-mode-map [down] 'ido-next-match-dir) (define-key ido-mode-map [up] 'ido-prev-match-dir)
;; search in the directories ;; use C-_ to undo this (define-key ido-mode-map [(meta ?s)] 'ido-merge-work-directories) (define-key ido-mode-map [(control ?_)] 'ido-undo-merge-work-directory) )
;;;临时记号 ;;;当你按 C-. 时就做了一个记号。然后你可以到别处,按 C-, 就可以在这两点之间来回跳转了。这虽然没有 vi 的 26 个 mark 多,但是你仔细;;想想,vi的26个 mark,你通常能用到几个? ;;{{{ (global-set-key [(control ?\.)] 'ska-point-to-register) (global-set-key [(control ?\,)] 'ska-jump-to-register) (defun ska-point-to-register() "Store cursorposition _fast_ in a register. Use ska-jump-to-register to jump back to the stored position." (interactive) (setq zmacs-region-stays t) (point-to-register 8))
(defun ska-jump-to-register() "Switches between current cursorposition and position that was stored with ska-point-to-register." (interactive) (setq zmacs-region-stays t) (let ((tmp (point-marker))) (jump-to-register 8) (set-register 8 tmp))) ;;}}}
(defun telnet (host) "Open a network login connection to host named HOST (a string). Communication with HOST is recorded in a buffer `*PROGRAM-HOST*' where PROGRAM is the telnet program being used. This program is controlled by the contents of the global variable `telnet-host-properties', falling back on the value of the global variable `telnet-program'. Normally input is edited in Emacs and sent a line at a time." (interactive "sOpen connection to host: ") (let* ((comint-delimiter-argument-list '(?\ ?\t)) (properties (cdr (assoc host telnet-host-properties))) (telnet-program (if properties (car properties) telnet-program)) (name (concat telnet-program "-" (comint-arguments host 0 nil) )) (buffer (get-buffer (concat "*" name "*"))) (telnet-options (if (cdr properties) (cons "-l" (cdr properties)))) process) (if (and buffer (get-buffer-process buffer)) (pop-to-buffer (concat "*" name "*")) (pop-to-buffer (apply 'make-comint name telnet-program nil telnet-options)) (setq process (get-buffer-process (current-buffer))) ;;(set-process-filter process 'telnet-initial-filter) ;; Don't send the `open' cmd till telnet is ready for it. ;;(accept-process-output process) (erase-buffer) (send-string process (concat "open " host "\n")) (telnet-mode) (setq telnet-remote-echoes nil) (setq telnet-new-line "\n") ;; needed for cygwin 1.3.11 (setq comint-input-sender 'telnet-simple-send) (setq telnet-count telnet-initial-count) (setq comint-process-echoes t) )))
;;;使用cygwin的ftp (defun ftp (host) "03Mar01, sailor" "Run the ftp program using cygwin ftp." "Fixed the problem that the login prompt cannot be seen." (interactive "sFtp to Host :") (let ((bufname) (bufobject)) (setq bufname (concat "*ftp-" host "*")) (setq bufobject (get-buffer bufname))
;; This assumes that Cygwin is installed in C:\cygwin (the ;; default) and that C:\cygwin\bin is not already in your ;; Windows Path (it generally should not be).
;; NT-emacs assumes a Windows command shell, which you change ;; here. (defun cygwin-shell() (interactive)
;; This removes unsightly ^M characters that would otherwise ;; appear in the output of java applications. (add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)
(defun copyright-comment () ;; insert a copyright code at the top of the class at cursor position (interactive) (insert " /* * Copyright (c) 2004, 2005 Works Systems (Tianjin) Co., Ltd. * All rights reserved. * * This software is the confidential and proprietary information of * Works Systems, Inc and Works Systems (Tianjin) Co., Ltd. (\"Confidential Information\"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Works Systems. * * @author Raphae */")(previous-line 13)(end-of-line))
评论