Yasnippet & html-helper-mode

1:我们可以在YASnippet/Snippets,进入相应的mode进行修改;文件名不需要跟key 的值一样,key 的值决定了我们了我们completion实现所需要输入的形式,如果我们想定义一个Key下的不同形式,只需让name不一样就行,下面的逻辑一样无所谓,相反:如果key,name都一样,即使下面的逻辑不一样,也不会都显示出来.key 不一样,name一样的话,同样不能被识别,所以必须确保name 不一样

# contributor: ryu
#name :<select name="..."></select>
# key: select
# --
<select name="$1">
  $0
</select>

2:<>中的值都要有括号引着

# contributor: ryu
#name :<select name="..."></select>
# key: select
# --
<select name="$1">
  $0
</select>

3:可以进行默认的赋予一个值,如下形式

<style type="text/css" media="${1:screen}">
  $0
</style>

4:关于缩进的问题,我非常郁闷就是自定义的时候都有它都会在插入snippet以后,自动给我加一个空行,但是原文件带的模板就没有,我第一步看是不是因为我创建的时候,多加了一个可行,然后我用的是gedit打开的,发现确实没有空行。我于是就去stackoverflow搜了一下,有人说(setq require-final-newline nil)  就行了,然后我就在.emacs中还有yasnippet.el都加了这句话,就是不行。最后我就抱着试试看的态度,用emacs打开自定义的文件发现最后竟然有一个空行,我就崩溃了。。。。

stackoverflow中的博文http://stackoverflow.com/questions/7619640/emacs-latex-yasnippet-why-are-newlines-inserted-after-a-snippet


5:html-helper-mode的缩进真是一坨,然后根据help-mode中对tab的缩进设置,仿照一个html-helper-mode同样是为了让TAB能够缩进。最后太崩溃了。果断弃之,还是用emacs自带的help-mode 

(add-hook 'html-mode-hook
          (lambda()
            (setq sgml-basic-offset 4)
            (setq indent-tabs-mode t)))

6:在html-mode下,对文件的修改时间自动保存,关键是下面模式中对-4的理解,它是指明标签<p>Last modified: </p>所在文件中的位置。

;;setup for auto updating change time in html-mode file
;;auto-update time when you save the change.
(add-hook 'before-save-hook 'time-stamp)
;;if the file has time pattern, below setup is to ensure emacs can read the pattern in file.
;;(setq time-stamp-pattern nil)

;;-4 indicating search for "Last modified " on the fourth line from the end of file;but i found
;;acctually it was the third line.

;;about time zone, I found china should be "UTC+8" but i dont know the reason when i dont like 
;;this,it was the time of current time minus 8..so i change it to "UTC-8" 
(eval-after-load 'sgml-mode
  '(add-hook 'html-mode-hook (lambda ()
			       (set (make-local-variable 'time-stamp-pattern)
				    "-4/<p>Last modified:[ \t]+%3a %3b %02H:%02M:%02S %Z %:y by %u</p>")
			       (set (make-local-variable 'time-stamp-time-zone) "UTC-8"))))
Time stamp 

updating time stamp automatically 

Hooks 

http://www.xemacs.org/Documentation/packages/html/hm--html-mode_5.html

7上面的配置,最后显示星期的话,都是中文,可以更改下面的变量让他变成英文形式

;;timestamps get localized, should change this var to english.
(setq system-time-locale "C")

system-time-locale 

detail info for time pattern setup

resolution for my issue


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值