ivaneeo's blog自由的力量,自由的生活。 |
perl中的undef,false和0是屬于假的一方;其他的屬于真.
安裝mule-gbk后可以顯示更多的漢字,比如朱镕基的“镕”,如果不用mule-gbk是無法正確顯示的
??? (set-keyboard-coding-system 'chinese-iso-8bit) ??? (set-language-environment 'Chinese-GB) ??? (setq locale-coding-system 'chinese-iso-8bit) ??? (setq current-language-environment "Chinese-GB") ??? (if (not (member '("-*-tahoma-normal-r-*-*-16-*-*-*-c-*-fontset-chinese" ??? ??? . "fontset-gbk") fontset-alias-alist)) ??? (progn ??? ??? (create-fontset-from-fontset-spec ??? ??? "-*-tahoma-normal-r-*-*-16-*-*-*-c-*-fontset-gbk, ??? ??? ;ascii:-adobe-helvetica-medium-r-normal--16-*-*-*-*-*-iso8859-1, ??? ??? chinese-gb2312:-*-simsun-medium-r-normal-*-16-160-*-*-*-*-gb2312*-*, ??? ??? korean-ksc5601:-*-medium-r-normal-*-*-*-ksc5601*-*, ??? ??? chinese-cns11643-5:-*-simsun-medium-r-normal-*-16-160-*-*-*-*-gbk*-0, ??? ??? chinese-cns11643-6:-*-simsun-medium-r-normal-*-16-160-*-*-*-*-gbk*-0, ??? ??? chinese-cns11643-7:-*-simsun-medium-r-normal-*-16-160-*-*-*-*-gbk*-0, ??? ??? chinese-big5-1:-*-Ming(for ISO10646)-*-*-*-*-16-160-*-*-*-*-big5*-*, ??? ??? chinese-big5-2:-*-Ming(for ISO10646)-*-*-*-*-16-*-*-*-*-*-big5*-*" t) ??? ??? ) ??? )
1.在你的.emacs中添加:
??? (setq auto-mode-alist (append '(("\\.js$" . c-mode)) auto-mode-alist)) ??? ??? (autoload 'javascript-mode "javascript-mode" "JavaScript mode" t) ?? (setq auto-mode-alist (append '(("\\.js$" . javascript-mode)) ??? ? ??? auto-mode-alist)) ; Indent c code four spaces (setq c-basic-offset 4) ; Associate c-mode with the .js extension (setq auto-mode-alist (append '(("\\.js$" . c-mode)) auto-mode-alist)) 2.在你的site-lisp目錄下加入javascript-mode.el文件: ;; javascript-mode.el --- major mode for editing javascript (.js) files ;; ;; Copyright (C) 1997 Peter Kruse ;; Author: Peter Kruse <pete@netzblick.de> ;; Keywords: languages ;; Time-stamp: <Sun Apr 12 20:02:25 1998 pete> ;; This file is *NOT* part of GNU Emacs. ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2 of the License, or ;; (at your option) any later version. ;; javascript-mode.el is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.? See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this file; if not, write to the Free Software ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Commentary: ;; Get the latest version from ;; <http://www.brigadoon.de/peter/javascript-mode.el> ;; Basically this is c-mode, for indentation, that's where the line ;; (load-library "c-mode") comes from. colorization is done via hilit19.el. ;; Actually did not do much programming myself, just wanted to have ;; colorization, indentation and some functions (hm that's what major modes ;; are about?) hey, this is my first try! ;;; HOW TO INSTALL: ;; Put the following forms in your .emacs to enable autoloading of JavaScript ;; mode, and auto-recognition of ".js" files. ;; ;;?? (autoload 'javascript-mode "javascript-mode" "JavaScript mode" t) ;;?? (setq auto-mode-alist (append '(("\\.js$" . javascript-mode)) ;;??? ??? ??? ??? ?? auto-mode-alist)) ;; ;;?? This mode requires another lisp file, tempo.el. This can be ;;???? retrieved from ftp://ftp.lysator.liu.se/pub/emacs/tempo.el ;; ;;?? You might want to get browse-url.el, for the online help. ;;?? Get it from ;;?? http://wombat.doc.ic.ac.uk/emacs/browse-url.el ;;; Change Log: ;; ;; Sun Apr 12 19:48:48 1998 ;; ;;??? included a menu ;; ;; Mon Sep 22 20:03:12 MET DST 1997 ;; ;;??? improvement of Syntax-table ;; ;; Sun Sep? 7 17:57:50 MET DST 1997 ;; ;;??? new variable: javascript-interactive ;; ;; Mon Sep? 1 14:52:37 MET DST 1997 ;; ;;??? javascript online help - all it does, is browse-url to ;;????? javascript-base-help-href ;; ;; Fri Aug 29 21:01:22 MET DST 1997 Peter Kruse ;;??? <peter.kruse@psychologie.uni-regensburg.de> ;; ;;??? 1st release ;;; TODO ;;? ;;? - online help should work like describe-\(function\|variable\), ;;? but get the info from the web. Netscape's documention is in progress, ;;? there is no final complete docu on JavaScript1.2, so perhaps we wait. ;; ;;? - should include an interface to signing scripts, but zigbert is not ;;? available for linux ;;; Bugs ;; ;;? - strings in single-quotes do not highlight ;;; Code: ;; user-variables (defvar javascript-indentation 4 ? "The width for further indentation in JavaScript mode.") (defvar javascript-base-help-href "http://developer.netscape.com/library/documentation/communicator/jsguide/" ? "URL where the javascript guide can be found.") (defvar javascript-browse-url-function 'browse-url-w3 ? "how to view online help.") (defvar javascript-interactive t ? "If t user will be prompted for strings in templates.") ;;; (defvar javascript-mode-map (make-sparse-keymap) ? "Keymap for javascript-mode") (defvar javascript-mode-syntax-table nil ? "Syntax table for javascript-mode.") (defvar javascript-mode-hook nil ? "*Hook run when javascript-mode is started.") (if javascript-mode-syntax-table ??? () ? (setq javascript-mode-syntax-table (make-syntax-table text-mode-syntax-table)) ? (modify-syntax-entry ?_ "w" javascript-mode-syntax-table) ? (modify-syntax-entry ?' "\"" javascript-mode-syntax-table) ? (modify-syntax-entry ?% "_" javascript-mode-syntax-table) ? (modify-syntax-entry ?\" "\"" javascript-mode-syntax-table) ? (modify-syntax-entry ?\\ "\\" javascript-mode-syntax-table) ? (modify-syntax-entry ?. "_" javascript-mode-syntax-table)) ? (defvar javascript-mode-abbrev-table nil ? "Abbrev table used while in javascript-mode.") (define-abbrev-table 'javascript-mode-abbrev-table ()) (require 'tempo) (tempo-define-template ?"javascript-for" ?(list "for (" '(p "initial: ") "; " '(p "condition: ") "; " '(p "increment: ") ") {" 'n> 'p 'n "}" '>) ?nil "insert a for loop" nil) (tempo-define-template ?"javascript-for-in" ?(list "for (" '(p "variable: ") " in " '(p "object: ") ") {" '> 'n> 'p 'n "}" '>) ?nil "insert a for loop" nil) (tempo-define-template ?"javascript-if" ?(list "if (" '(p "condition: ") ") {" 'n> 'p 'n "}" '>) ?nil "insert an if statement" nil) (tempo-define-template ?"javascript-while" ?(list "while (" '(p "condition: ") ") {" 'n> 'p 'n "}" '>) ?nil "insert a while statement" nil) (tempo-define-template ?"javascript-do" ?(list "do {" '> 'n> 'p 'n "} while(" '(p "condition: ") ");" '>) ?nil "insert a do-while statement" nil) (tempo-define-template ?"javascript-with" ?(list "with (" '(p "with what? ") ") {" 'n> 'p 'n "}" '>) ?nil "insert a with statement" nil) (tempo-define-template ?"javascript-defun" ?(list "function " '(p "function name: ") "(" '(p "arguments: ") ") {" 'n> 'p 'n "}" '>) ?nil "insert a function definition" nil) (tempo-define-template ?"javascript-switch" ?(list "switch (" '(p "variable: ") ") {" '> 'n> "case '" 'p "' :" '> 'n> "break;" '> 'n> "default :" '> 'n> "}" '>) ?nil "insert a switch statement" nil) (tempo-define-template ?"javascript-case" ?(list "case '" 'p "' :" '> 'n> "break;" '>) ?nil "insert a case" nil) ;;; now for the help facility ;;; from man.el (defun javascript-help (entry) ? "Opens a browser via browse-url with a help entry on the current word." ? (interactive ?? (list (let* ((default-entry (current-word)) ??? ??? (input (read-string ??? ??? ??? (format "Help entry%s: " ??? ??? ??? ??? (if (string= default-entry "") ??? ??? ??? ??? ??? "" ??? ??? ??? ??? ? (format " (default %s)" default-entry)))))) ??? ?? (if (string= input "") ??? ?????? (if (string= default-entry "") ??? ??? ?? (error "No entry given") ??? ??? ?default-entry) ??? ???? input)))) ? (let ((url (concat javascript-base-help-href "contents.htm" "#" entry)) ??? (browse-url-browser-function javascript-browse-url-function)) ??? (if (boundp 'browse-url-browser-function) ??? (progn ??? ? (pop-to-buffer " javascript-help") ??? ? (apply browse-url-browser-function (list url))) ????? (error "browse-url not found")))) ????? (modify-frame-parameters (selected-frame) '((menu-bar-lines . 2))) (define-key javascript-mode-map [menu-bar javascript] ? (cons "JavaScript" javascript-mode-map)) (define-key javascript-mode-map [menu-bar javascript Help] ? '("Help" . javascript-help)) (define-key javascript-mode-map [menu-bar javascript for] ? '("for" . tempo-template-javascript-for)) (define-key javascript-mode-map [menu-bar javascript forin] ? '("for .. in" . tempo-template-javascript-for-in)) (define-key javascript-mode-map [menu-bar javascript if] ? '("if" . tempo-template-javascript-if)) (define-key javascript-mode-map [menu-bar javascript while] ? '("while" . tempo-template-javascript-while)) (define-key javascript-mode-map [menu-bar javascript with] ? '("with" . tempo-template-javascript-with)) (define-key javascript-mode-map [menu-bar javascript switch] ? '("switch" . tempo-template-javascript-switch)) (define-key javascript-mode-map [menu-bar javascript case] ? '("case" . tempo-template-javascript-case)) (define-key javascript-mode-map [menu-bar javascript do] ? '("do" . tempo-template-javascript-do)) (define-key javascript-mode-map [menu-bar javascript function] ? '("function" . tempo-template-javascript-defun)) (define-key javascript-mode-map "\C-c\C-h" 'javascript-help) (define-key javascript-mode-map "\C-c\C-f" 'tempo-template-javascript-for) (define-key javascript-mode-map "\C-c\C-n" 'tempo-template-javascript-for-in) (define-key javascript-mode-map "\C-c\C-i" 'tempo-template-javascript-if) (define-key javascript-mode-map "\C-c\C-w" 'tempo-template-javascript-while) (define-key javascript-mode-map "\C-c\C-t" 'tempo-template-javascript-with) (define-key javascript-mode-map "\C-c\C-s" 'tempo-template-javascript-switch) (define-key javascript-mode-map "\C-c\C-c" 'tempo-template-javascript-case) (define-key javascript-mode-map "\C-c\C-d" 'tempo-template-javascript-do) (define-key javascript-mode-map "\C-c(" 'tempo-template-javascript-defun) (define-key javascript-mode-map "{" 'electric-c-brace) (define-key javascript-mode-map "}" 'electric-c-brace) (defun javascript-mode () ? "Major mode for editing javascript code. Basically this is c-mode, because it does a nice indentation. c-mode gets called via `load-library'. Colorization is done with hilit19. A few commands are defined through `tempo.el'. The online help facility gets done through browse-url.el. \\{javascript-mode-map} You can set the indentation level by setting the variable `javascript-indentation' to an integer-value. Default is 4. The variable javascript-base-help-href sets the URL for the JavaScript guide." ? (interactive) ? (kill-all-local-variables) ? (load-library "c-mode") ? (require 'browse-url) ? (use-local-map javascript-mode-map) ? (setq major-mode 'javascript-mode) ? (setq mode-name "JavaScript") ? (set-syntax-table javascript-mode-syntax-table) ? (make-local-variable 'comment-start) ? (setq comment-start "http:// ") ? (make-local-variable 'comment-start-skip) ? (setq comment-start-skip "/\\*+ *\\|// *") ? (make-local-variable 'tempo-interactive) ? (setq tempo-interactive javascript-interactive) ? (make-local-variable 'indent-line-function) ? (setq indent-line-function 'c-indent-line) ? (make-local-variable 'c-indent-level) ? (setq c-indent-level javascript-indentation) ? (run-hooks 'javascript-mode-hook)) ;;; (if (featurep 'hilit19) ??? (hilit-set-mode-patterns ???? 'javascript-mode ???? '(("/\\*" "\\*/" comment) ?????? ("http://" "$" comment) ?????? ("\\<function\\>\\s +[^0-9]\\w+\\s *([^)]*)" nil defun) ?????? ("\\<\\(abstract\\|boolean\\|break\\|byte\\|case\\|catch\\|char\\|class\\|const\\|continue\\|default\\|delete\\|do\\|double\\|else\\|extends\\|false\\|final\\|finally\\|float\\|for\\|goto\\|if\\|implements\\|in\\|instanceof\\|int\\|interface\\|long\\|native\\|new\\|null\\|package\\|private\\|protected\\|public\\|return\\|short\\|static\\|super\\|switch\\|synchronized\\|this\\|throw\\|throws\\|transient\\|true\\|try\\|typeof\\|var\\|void\\|while\\)\\>" 1 keyword) ?????? ("\\<with\\>\\s *([^)]*)" nil include) ?????? ("\\<\\(import\\|export\\)\\>\\s +.*" nil include) ?????? ("\"[^\\\"]*\\(\\\\.[^\\\"]*\\)*\"" nil string) ?????? ("^\\s *\\w+\\s *:\\s *$" nil label)) ???? nil nil) ? nil) (provide 'javascript-mode) ;; javascript-mode.el ends here ;; Local Variables: ;; local-write-file-hooks:(time-stamp) ;; End: 默認情況下, Emacs 已經可支持 c/c++ 以及 Java 開發(其它的語言我沒試過,因為我機器上只有上述幾種語言的編譯器),但如果你想用它來開發 C# 還需要做一些其它的工作。 Emacs 就像一把槍,在需要時可以添入不同的子彈,我們現在需要的就是找一粒刻有 C# 字樣的子彈壓入槍膛。這粒子彈的名字叫 C# for Emacs mode ,是由微軟的一位工程師 Brad Merrill 利用業余時間開發的,可以在他的個人網站 http://www.cybercom.net/~zbrad/ 處下載,最新版本為 4.0 。
下載之后需要對所獲得的 package 文件進行一些簡單的配置。因為我此前也沒有接觸過 Lisp 語言,因此配置成了一大難題。經過一番 google 搜索后,終于在 http://www.experts-exchange.com/Programming/Q_20815476.html 找到了答案。原來配置竟是非常簡單:
1.? 把下載文件夾中 cite-lisp 子目錄下的文件復制到 Emacs 安裝目錄 \cite-lisp\ 下。 2.? 把下載文件中 zbrad.emacs 文件( .emacs 是 Emacs 的配置文件)也復制到 Emacs 安裝目錄 \cite-lisp 子目錄下,然后改名為 site-start.el 。 3.? 重新啟動 Emacs , OK !
在svnpublic/conf/有兩個文件:
svnserve.conf: [general] anon-access = read anon-access = none ##不讓guest訪問 auth-access = write password-db = passwd ###你指定存放密碼的文件名 realm = svnpublic passwd: [users] ivaneeo = XXX
第一步 :首先需要安裝Cygwin,
subversion
Admin/cygrunsrv 用于把cygwin服務加到windows服務中 Net/inetutils, inetd. 第二步 :Cygwin環境下,運行iu-config 第三步 : 運行 mkpasswd -l > /etc/passwd,將windows用戶導入到Cygwin中 第四步 :運行inetd服務。運行以下命令: 設置windows環境變量:CYGWIN=ntsec。將cygwin/bin加入到PATH中。 在cygwin中運行 cygrunsrv -I inetd -d " CYGWIN inetd " -p /usr/sbin/inetd -a -d -e CYGWIN=ntsec cygrunsrv -S inetd 就可以在windows服務管理器中看到CYGWIN inetd服務已經啟動了。 運行usr/sbin/inetd.exe --install-as-service 從新啟動。 第五步: 編輯修改/etc/services,加入: svn 3690/tcp #Subversion svn 3690/udp #Subversion 編輯修改/etc/inetd.conf文件,加入: svn stream tcp nowait root /usr/bin/svnserve svnserve -i -r /home/ivaneeo/svnpublic 正則表達式學習筆記 正則表達式(regular expression)描述了一種字符串匹配的模式,可以用來檢查一個串是否含有某種子串、將匹配的子串做替換或者從某個串中取出符合某個條件的子串等。 為便于理解和記憶,先從一些概念入手,所有特殊字符或字符組合有一個總表在后面,最后一些例子供理解相應的概念。 正則表達式是由普通字符(例如字符 a 到 z)以及特殊字符(稱為元字符)組成的文字模式。正則表達式作為一個模板,將某個字符模式與所搜索的字符串進行匹配。 可以通過在一對分隔符之間放入表達式模式的各種組件來構造一個正則表達式,即/expression/ 普通字符由所有那些未顯式指定為元字符的打印和非打印字符組成。這包括所有的大寫和小寫字母字符,所有數字,所有標點符號以及一些符號。 非打印字符
特殊字符所謂特殊字符,就是一些有特殊含義的字符,如上面說的"*.txt"中的*,簡單的說就是表示任何字符串的意思。如果要查找文件名中有*的文件,則需要對*進行轉義,即在其前加一個\。ls \*.txt。正則表達式有以下特殊字符。
限定符限定符用來指定正則表達式的一個給定組件必須要出現多少次才能滿足匹配。有*或+或?或{n}或{n,}或{n,m}共6種。 *、+和?限定符都是貪婪的,因為它們會盡可能多的匹配文字,只有在它們的后面加上一個?就可以實現非貪婪或最小匹配。 正則表達式的限定符有:
定位符用來描述字符串或單詞的邊界,^和$分別指字符串的開始與結束,\b描述單詞的前或后邊界,\B表示非單詞邊界。不能對定位符使用限定符。 選擇用圓括號將所有選擇項括起來,相鄰的選擇項之間用|分隔。但用圓括號會有一個副作用,是相關的匹配會被緩存,此時可用?:放在第一個選項前來消除這種副作用。 其中?:是非捕獲元之一,還有兩個非捕獲元是?=和?!,這兩個還有更多的含義,前者為正向預查,在任何開始匹配圓括號內的正則表達式模式的位置來匹配搜索字符串,后者為負向預查,在任何開始不匹配該正則表達式模式的位置來匹配搜索字符串。 后向引用對一個正則表達式模式或部分模式兩邊添加圓括號將導致相關匹配存儲到一個臨時緩沖區中,所捕獲的每個子匹配都按照在正則表達式模式中從左至右所遇到的 內容存儲。存儲子匹配的緩沖區編號從 1 開始,連續編號直至最大 99 個子表達式。每個緩沖區都可以使用 '\n' 訪問,其中 n 為一個標識特定緩沖區的一位或兩位十進制數。 可以使用非捕獲元字符 '?:', '?=', or '?!' 來忽略對相關匹配的保存。 各種操作符的運算優先級相同優先級的從左到右進行運算,不同優先級的運算先高后低。各種操作符的優先級從高到低如下:
全部符號解釋
部分例子
正則表達式 http://www.soulogic.com/code/doc/RegularExpressions/ 一個真正的二進制編輯器用兩種方式來顯示文本: 二進制和十六進制格式。你可以在 Vim
首先我先安裝rxvt(在shell中).
然后修改cygwin/cygwin.bat文件: ??? @echo off ??? D: ??? chdir D:\share\bin\cygwin\bin ??? set EDITOR=vi ??? set VISUAL=vi ??? set CYGWIN=codepage:oem tty binmode title ??? rxvt -fn "Lucida Console-14" -e bash --login -i 并配置rxvt控制臺的其他屬性,修改~/.Xdefaults文件: Rxvt*geometry: 100x40 Rxvt*background: gray16 Rxvt*foreground: #ffffbf !Rxvt*borderColor: Blue !Rxvt*scrollColor: Blue !Rxvt*troughColor: Gray Rxvt*scrollBar: True Rxvt*scrollBar_right: True !Rxvt*font: Lucida Console-14 !Rxvt.boldFont: Lucida Console-14 !Rxvt*font: -bitstream-bitstream vera sans mono-*-r-*-*-14-*-*-*-*-*-*-* !Rxvt*boldFont: -bitstream-bitstream vera sans mono-*-r-*-*-14-*-*-*-*-*-*-* Rxvt*font: -*-courier-medium-r-*-*-14-140-*-75-*-*-*-* Rxvt*boldFont: -*-courier-bold-r-*-*-14-140-*-75-*-*-*-* Rxvt*SaveLines: 2000 Rxvt*loginShell: True ! VIM-like colors Rxvt*color0:??? #000000 Rxvt*color1:??? #FFFFFF Rxvt*color2:??? #00A800 Rxvt*color3:??? #FFFF00 Rxvt*color4:??? #0000A8 Rxvt*color5:??? #A800A8 Rxvt*color6:??? #00A8A8 Rxvt*color7:??? #D8D8D8 Rxvt*color8:??? #000000 Rxvt*color9:??? #FFFFFF Rxvt*color10:?? #00A800 Rxvt*color11:?? #FFFF00 Rxvt*color12:?? #0000A8 Rxvt*color13:?? #A800A8 Rxvt*color14:?? #00A8A8 Rxvt*color15:?? #D8D8D8 ! eof emacs.font:? 8x16 emacs.paneFont:? 8x16 Emacs.pane.menubar.font: 8x16 Emacs.foreground: white Emacs.background: black emacs.geometry:? 100x32 你需要在你($HOME)下新增或編輯兩個文件: 在.inputrc中要有下面三行 在.bash_profile中要有下面三行 最后在.bashrc中添加: export LANG=C |