.emacs的helloworld

5 篇文章 0 订阅
webrtc :http://www.lookybang.cc/forum.php?mod=viewthread&tid=409&extra=page%3D1

emacs
[color=red]F10是菜单[/color]
编译el
emacs --batch -f batch-byte-compile haoning.el

查看变量定义
[color=red]c-h v[/color]

[b]etags使用[/b]

find -name "*.[chCH]" -exec etags -a {} ;
  或
find . -name "*.[chCH]" -print | etags -
创建好tag表后,告知emacs。
  M-x visit-tags-table
在.emacs中加入这样的语句:
  (setq tags-file-name "~/sim973/src/TAGS")
M-. 查找一个tag,比如函数定义类型定义等。
  C-u M-. 查找下一个tag的位置
  M-* 回到上一次运行M-.前的光标位置。
  M-TAB 自动补齐函数名。


[color=darkred]安装auto-complete后,只要emacs打开的文件都可以自动补全,
比如看的是c的代码,
我们可以把TAGS复制成TAGS.c然后,c-x c-f 打开TAGS.c
这样就可以即使用etags又使用自动补全了[/color]


.emacs

(require 'package)
(dolist (source '(("elpa" . "http://tromey.com/elpa/")
("melpa" . "http://melpa.milkbox.net/packages/")
))
(add-to-list 'package-archives source t))
(package-initialize)

(load-file "~/.emacs.d/hao-base.el")
(load-file "~/.emacs.d/hao-complete.el")
(load-file "~/.emacs.d/hao-study.el")
;(load-file "~/.emacs.d/hao-js.el")
(setq tags-file-name "/root/haoning/nginx-1.9.4/TAGS")


基本设置
hao-base.el

(setq indent-tabs-mode nil)
(setq default-tab-width 4)
(setq tab-width 4)
(show-paren-mode t)
(setq frame-title-format "haoning@%b")


自动提示,需要list-packages安装auto-complete,
auto-yasnippets
hao-complete.el

;;m-x list-packages; c-s auto-complete
(require 'auto-complete)
(require 'auto-complete-config)
(global-auto-complete-mode t)
(autoload 'auto-complete-mode "auto-complete-mode" nil t)
;(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete-20150618.1949/dict")
(ac-config-default)
(setq ac-use-quick-help nil)
(setq ac-auto-start 4) ;; 输入4个字符才开始补全
(global-set-key "\M-/" 'auto-complete) ;; 补全的快捷键,用于需要提前补全
(setq ac-auto-show-menu 0.8);; Show menu 0.8 second later
;; 选择菜单项的快捷键
(setq ac-use-menu-map t)
(define-key ac-menu-map "\C-n" 'ac-next)
(define-key ac-menu-map "\C-p" 'ac-previous)
(setq ac-menu-height 15);; menu设置为15 lines

;;;;;yasnippets
(defun dot-emacs (relative-path)
"Return the full path of a file in the user's emacs directory."
(expand-file-name (concat user-emacs-directory relative-path)))
(require 'yasnippet)
(yas/initialize)
(yas/load-directory (dot-emacs "elpa/yasnippet-20151108.1505/snippets"))


学习lisp的helloworld的
<<Emacs Lisp 15 分钟入门>>
参考[url]http://blog.jobbole.com/44932/[/url]
hao-study.el

(setq inhibit-startup-message t)
(setq gnus-inhibit-startup-message t)

;(switch-to-buffer-other-window "*haoning*")
(switch-to-buffer "*haoning*")
(setq my-name "haoning")
(insert "hello\n")
(insert my-name "\n")
;c-h v my-name
;c-x c-b scratch scratch

(defun hello () (insert "Hello, I am " my-name "\n"))
(hello)

(defun helloworld (name) (insert (format "hello, %s \n" name)))
(helloworld "you")

;(other-window 0)
(progn
;(switch-to-buffer-other-window "*test*")
;(erase-buffer)
(helloworld "your brothor")
;(other-window 1)
)

(let ((local-name "your sister"))
;(switch-to-buffer-other-window "*test*")
;(erase-buffer)
(helloworld local-name)
;(other-window 1)
)

;(defun greeting (from-name)
; (let ((your-name (read-from-minibuffer "hi haoning Enter your like : ")))
; (switch-to-buffer-other-window "*test*")
;; (erase-buffer)
; (insert (format "greeting(): hello %s!\n\nI am %s." your-name from-name))
; (other-window 1))
;)
;(greeting "zhy")


(setq list-of-names '("haohao" "ningning" "zhy"))
(car list-of-names)
(cdr list-of-names)
(push "mylove" list-of-names)

(mapcar 'helloworld list-of-names)

(defun mygreeting ()
;(switch-to-buffer-other-window "*test*")
; (erase-buffer)
(mapcar 'helloworld list-of-names)
;(other-window 1)
)
(mygreeting)


;(defun replace-hello-by-nihao ()
; ;(switch-to-buffer-other-window "*test*")
; (goto-char (point-min))
; (while (search-forward "hello" nil t)
; (replace-match "nihao")
; )
; ;(other-window 1)
;)
;(replace-hello-by-nihao)
;
;; 其中 nil参数表示 搜索的区域不加限制,直到buffer结束
;; 其中t参数指示search-foward函数 跳过错误信息 直接退出

;(list 'face 'bold)
;(defun boldify-names ()
; ;(switch-to-buffer-other-window "*test*")
; (goto-char (point-min))
; (insert "this is beginning -----\n")
; ;(while (re-search-forward "hao\\(.+\\).+!" nil t)
; (while (re-search-forward "hao" nil t)
; ;(insert "\n ---hahahah---\n")
; (add-text-properties (match-beginning 1) ;返回匹配模式中,最先匹配的位置
; (match-end 1) ;返回最后匹配的位置
; (list 'face 'bold)
; )
; )
; (insert "\nthis is ending ------")
; ;(other-window 1)
;)
;
;(boldify-names)


js2-mode
参考<<用emacs打造node.js开发环境>>
[url]http://www.open-open.com/lib/view/open1391687309114.html[/url]
有些似乎不好使
hao-js.el

(add-to-list 'load-path "~/.emacs.d/elpa/js2-mode-20151107.950")
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))


(load-file "~/.emacs.d/espresso.el")
(load-file "~/.emacs.d/nodejs.el")
(require 'nodejs)

;(load-file "~/.emacs.d/js2-highlight-vars.el")
;(require 'js2-highlight-vars)
;(if (featurep 'js2-highlight-vars)
; (js2-highlight-vars-mode)
;)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值