`
haoningabc
  • 浏览: 1442788 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

.emacs的helloworld

阅读更多
webrtc :http://www.lookybang.cc/forum.php?mod=viewthread&tid=409&extra=page%3D1

emacs
F10是菜单
编译el
emacs --batch -f batch-byte-compile haoning.el

查看变量定义
c-h v

etags使用
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 自动补齐函数名。


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



.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 分钟入门>>
参考http://blog.jobbole.com/44932/
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开发环境>>
http://www.open-open.com/lib/view/open1391687309114.html
有些似乎不好使
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)
;)
分享到:
评论

相关推荐

    linux编程Hello world

    $vim hello.c &gt;&gt;&gt;&gt; 进入emacs 编辑器环境 #include &lt;stdio.h&gt; int main() { printf("Hello world!\n"); return 0; }

    pm代码matlab-HelloWorld:HelloWorldforcommondeveloplanguages.各开发语言的HelloWo

    史上最全的50多种常用的不同语言、工具Hello World示例代码 文件后缀名 描述 .applescript 苹果公司开发的一种脚本语言 .asp ASP 是微软开发的在服务器端脚本环境 .aspx ASPX 是微软的在服务器端运行的动态网页文件 ...

    emacs-surround:vim.surround 的 Emacs 版本

    'Hello world!' 插 按Cq i"或Cq " &lt;return&gt; Hel | lo 将其更改为 "Hello" 删除 按Cq d" "He|llo \" world \" " 将其更改为 Hello \" world \" 安装和设置 使用cask或el-get或clone形式...

    Matlab代码verilog-helloworld:各种语言的Helloworld程序

    各种语言的Helloworld程序 b 阿达 adventure_game_studio_script 阿尔高 amiga_e 杀伤人员地雷 苹果脚本 弧 as3 自动 awk 基本的 批 f 贝努格 嘘声 脑干 二氧化硅 C 锡兰 厨师 Clojure 科博尔 咖啡脚本 coldfusion_...

    HPL: Vol. IV: Functional and Logic Programming Languages

    6.2.1. Hello World 6.2.2. The Genealogy Program 6.2.3. A Grammatical Summary 6.2.4. Equality and Variables 6.2.5. Lists 6.2.6. Predicates on Lists 6.2.7. Complex Terms in Heads of Clauses 6.2.8...

    react-mode:(尚不是一种模式)使用es6标准收集有用的React.js函数和宏

    React模式(还不是emacs模式...) 只是一些有用的emacs函数的集合,这些函数使在React和es6中的开发更加容易。 请随意添加您认为有用的任何...export default class HelloWorld extends React.Component {constructor(p

    在latex中添加matlab代码-helloworld:各种语言的Helloworld程序,欢迎提出请求:)

    各种语言的Helloworld程序 b 阿达 adventure_game_studio_script 阿尔高 amiga_e 杀伤人员地雷 苹果脚本 弧 as3 自动 awk 基本的 批 f 贝努格 嘘声 脑干 二氧化硅 C 锡兰 厨师 Clojure 科博尔 咖啡脚本 coldfusion_...

    three-pipes:三管是Emacs Lisp中joyfactor风格拼接子语言的实现

    (||| "Hello World!" 10 ((dup &lt;1&gt;insert) dip 1 - dup 0 &gt;) loop-while) ;; prints "Hello World" ten times 用法 将三管.el放在您的加载路径上,然后(require 'three-pipes) 。 基本语法 三管道的入口点是三个...

    nix-bundle:捆绑Nix衍生品可在任何地方运行!

    尼克束nix-bundle是一种将Nix属性打包到单文件可执行文件中的方法。好处单文件输出可以由非root用户运行没有运行时间不可知的没有... 其他一些尝试:./nix-bundle.sh nano /bin/nano./nix-bundle.sh emacs /bin/emac

    emacs-huffman:Emacs Lisp中的Huffman编码

    例子( setf tree (huffman-tree " hello, world! " )); ; =&gt; (((?d . ?!) . ?l) (?o ?h . ?e) (?, . ?\s) ?w . ?r)(huffman-encode-symbol tree ?l ); ; =&gt; (0 1)(huffman-encode-symbol tree ?o ); ; =&gt; (1 0 0)...

    emacs-rsa:Emacs Lisp中的RSA加密

    ( setf message " hello, world! " )( setf keypair (rsa-generate-keypair 128 )); ; =&gt; (:public (:n "74924929503799951536367992905751084593"; ; :e "65537"); ; :private (:n ...

    elisp-latch:Emacs Lisp的承诺和闩锁

    Emacs Lisp的承诺和闩锁 该软件包(ab)使用...( run-at-time 5 nil # 'deliver p " Hello, world " ) ; ; Retrieve the value from the promise. This blocks until a value is ; ; delivered. The timer can still

    urbit-api.el:elisp中用于emacs的Urbit API

    将操作系统与个人服务器连接。 安装 获取并然后使用Mx package-install-file安装 ,或仅将存储库克隆到您的加载路径中。 例子 ...(urbit-http-poke " hood " " helm-hi " " Hello, world! " ( la

    java8stream源码-awesome-stars:我自己的真棒清单!

    java8 ...Helloworld programs in different languages,pull requests are welcome :) Awk - A script that cleans up the php.ini file with security in mind Batchfile - Python best practices gui

    racket-5.0.1-bin-i386-win32.part2.rar

    毕竟,一图胜千言,至少是五百句“hello world”。 我们假设你用DrRacket来运行这些例子,这是了解这门语言的概貌和环境的最好途径,虽然你也可以时不时地用用Emacs,vi,或是别的编辑器。 1、准备 下载Racket,安装...

    racket-5.0.1-bin-i386-win32.part1.rar

    毕竟,一图胜千言,至少是五百句“hello world”。 我们假设你用DrRacket来运行这些例子,这是了解这门语言的概貌和环境的最好途径,虽然你也可以时不时地用用Emacs,vi,或是别的编辑器。 1、准备 下载Racket,安装...

    c.in.fork.book:书 C 在 Fork

    您是否曾经使用这种美妙的语言编译过 helloworld? 如果是这样,请成为这个项目的贡献者。 现在分叉并克隆这个存储库并动手吧! 你知道一些关于 C 的事情吗? 你有没有用那种华丽的语言编译过一个 hello world 程序...

    傅里叶变换三维测量matlab代码-learn-python:教你如何学习python

    首先写一个基本所有程序员都会接触到的第一个程序吧,新建一个文件,比如为hello.py,用你喜欢的文本编辑器打开,Windows上用记事本或者Notepad,Linux上可以用Vim或者Emacs,MacOSX上可以用xcode或者Vim打开。...

    Matlab代码verilog-hello:你好git

    各种语言的Helloworld程序 b 阿达 adventure_game_studio_script 阿尔高 amiga_e 杀伤人员地雷 苹果脚本 弧 as3 自动 awk 基本的 批 f 贝努格 嘘声 脑干 二氧化硅 C 锡兰 厨师 Clojure 科博尔 咖啡脚本 coldfusion_...

    grammarly:语法API介面

    语法上 语法API接口。 例子 下面是一个简单的示例,说明如何使用此库来调用Grammarly API...(grammarly-check-text " Hello World " ) 使用付费语法帐户 您将需要设置以下变量,以便使用语法的付费版本! ( setq gram

Global site tag (gtag.js) - Google Analytics