显示标签为“emacs”的博文。显示所有博文
显示标签为“emacs”的博文。显示所有博文

2010年6月24日星期四

Emacs-w3m的安装与使用(转)


转:http://hi.baidu.com/muen2008/blog/item/d5df2909f45b9edb63d98604.html
1.安装
安装w3m是前提,Emacs-w3m是Emacs调用w3m的接口。
在Debian下安装w3m如下:sudo aptitude install w3m
装好w3m后,去如下网址:http://emacs-w3m.namazu.org/index-en.html#configuration 下载Emacs-w3m的源码包。
对Emacs23.1版本,需要使用cvs版本,下载如下:
cvs -d :pserver:anonymous@cvs.namazu.org:/storage/cvsroot co emacs-w3m
下载完成后,将源码拷贝到/usr/local/src目录下,
然后进入emacs-w3m目录,进行如下操作:
autoconf
./configure
make
sudo make install
如果没有装autoconf,需要先apt安装。

2.配置
参照网上众多高手的配置,给出如下的配置:

;;使用Emacs-w3m浏览网页
;; (add-to-list 'load-path "~/emacs/site-lisp/w3m")
;; (require 'w3m-load)
;; (require 'w3m-e21)
;; (provide 'w3m-e23)
;; (setq w3m-use-favicon nil)
;; (setq w3m-command-arguments '("-cookie" "-F"))
;; (setq w3m-use-cookies t)
;; (setq w3m-home-page "http://www.google.com")

;; (setq w3m-display-inline-image t)

;;启动和初始化w3m.el
(autoload 'w3m "w3m" "Interface for w3m on Emacs." t)
(autoload 'w3m-browse-url "w3m" "Ask a WWW browser to show a URL." t)
(autoload 'w3m-search "w3m-search" "Search words using emacs-w3m." t)
;;使用w3m作为默认的浏览器
(setq browse-url-browser-function 'w3m-browse-url)
;;使用mule-ucs,只有在你安装mule-ucs elisp扩展包时这个才有用,可以看Unicode解码的网页
;(setq w3m-use-mule-ucs t)
;;使用工具包
(setq w3m-use-toolbar t)
;;使用info的快件键绑定
;(set-default 'w3m-key-binding 'info)
;;启用cookie
(setq w3m-use-cookies t)
;;这个是作什么的?
(setq w3m-use-tab-menubar t)
;;设定w3m图标所在文件夹
;(setq w3m-icon-directory "/home/jerry/software/xemacs/w3m/emacs-w3m-1.4.4/icons")
;;显示图标
(setq w3m-show-graphic-icons-in-header-line t)
(setq w3m-show-graphic-icons-in-mode-line t)
;;设定w3m运行的参数,分别为使用cookie和使用框架
(setq w3m-command-arguments '("-cookie" "-F"))
;;用w3m浏览网页时也显示图片
(setq w3m-display-inline-image t)
;; ;;设定w3m的语言设置,以便方便使用和阅读中文-用了就乱码
;; ;;书签解码设置
;; (setq w3m-bookmark-file-coding-system 'chinese-iso-8bit)
;; ;;w3m的解码设置,后面最好都有,我也不详解了
;; (setq w3m-coding-system 'chinese-iso-8bit)
;; (setq w3m-default-coding-system 'chinese-iso-8bit)
;; (setq w3m-file-coding-system 'chinese-iso-8bit)
;; (setq w3m-file-name-coding-system 'chinese-iso-8bit)
;; (setq w3m-terminal-coding-system 'chinese-iso-8bit)
;; (setq w3m-input-coding-system 'chinese-iso-8bit)
;; (setq w3m-output-coding-system 'chinese-iso-8bit)
;;w3m是使用tab的,设定Tab的宽度
(setq w3m-tab-width 4)
;;设定w3m的主页
(setq w3m-home-page "http://www.google.cn")
;;当用 shift+RET 打开新链接时将不自动跳转到新的页面,等提示已经完全打开,才用 C-c C-n ,
;;C-c C-p 打开,这个好用
(setq w3m-view-this-url-new-session-in-background t)
(add-hook 'w3m-fontify-after-hook 'remove-w3m-output-garbages)
;;好像是有利于中文搜索的
(defun remove-w3m-output-garbages ()
"去掉w3m输出的垃圾."
(interactive)
(let ((buffer-read-only))
(setf (point) (point-min))
(while (re-search-forward "[\200-\240]" nil t)
(replace-match " "))
(set-buffer-multibyte t))
(set-buffer-modified-p nil))
;;颜色设置
;(setq w3m-
;;;;;;;;;;;;;;;;;;;;;
;;语言设置
;;这个不知道有用没,好像在下一版emacs对unicode支持好了就可以了
;;当然这个是用emacs-cvs
;;;;;;;;;;;;;;;;;;;;;
(when (boundp 'utf-translate-cjk)
(setq utf-translate-cjk t)
(custom-set-variables
'(utf-translate-cjk t)))
(if (fboundp 'utf-translate-cjk-mode)
(utf-translate-cjk-mode 1))
;;配置handle text/html part with emacs-w3m under SEMI MUAs such as Wanderlust
(require `mime-w3m)

3.使用
Emacs-w3m的使用基本与w3m的使用相同,快捷键稍有不同。快捷键列表如下:

key main
Shift-RET 新标签打开
RET | Mouse-1 打开当前链接
R 刷新
g 转到
G 新标签中转到
U 转到
H 主页
s 历史
M 用外部浏览器查看当前页面
d 下载
\ 查看源代码
= 查看头信息
key edit
u 复制链接地址到剪切板
c 复制本页地址到剪切板
E 编辑本页
e 编辑链接页
C-c C-c 提交textarea编辑
C-c C-w 删除当前页
C-c M-w 删除其他页
C-c C-t 复制当前页到新标签
key type
C-c C-n 下一个标签
C-c C-p 上一个标签
C-c C-s 选择当前标签
v 查看书签
a 添加当前页面到书签
M-a 添加链接到书签
M-i 保存当前位置图片
T 显示图片
M-[ 缩小当前图片
M-] 放大当前图片
I 用外部查看器显示当前图片
key move
M-g 跳到第 n 行
C-c C-@ 标记当前位置
C-c C-v 跳到上次标记位置
TAB 下一个链接
M-TAB 上一个链接
] 下一个表格
[ 上一个表格
} 下一幅图
{ 上一幅图
B 返回
N 前进
^ 退回上一层
SPC 下翻页
b 上翻页
DEL 上翻页
> 右平移
< 左平移
. 最左端
, 最右端
M-l 居中
C-a 行首
C-e 行尾
J 屏幕下滚
K 屏幕上滚
key other
M-x w3m 启动
q 挂起
Q 退出
r 重绘
C t 内容 重绘
C c 确定字符集 重绘
C C 确定字符集+内容 重绘

4.其他
暂无。

2010年5月25日星期二

解决mac emacs 字体 方框问题

用了两次进行解决
第一次:
方案:
(set-default-font "-apple-STKaiti-medium-normal-normal-*-*-*-*-*-p-0-iso10646-1")
(set-face-attribute 'default (selected-frame) :height 155)
原理:
用现有的字体, 替换目前的字体
效果:
勉强可以接受, 其实是用楷体, 但是楷体的默认英文字体 奇丑无比
补充方案:
(defun cha-b()
(interactive)
(set-default-font "-apple-Heiti_SC-bold-normal-normal-*-*-*-*-*-p-0-iso10646-1")
(set-face-attribute 'default (selected-frame) :height 130))

(defun cha-a()
(interactive)
(set-default-font "-apple-Monaco-medium-normal-normal-*-*-*-*-*-m-0-iso10646-1"))
补充方案效果:
通过命令进行切换, 暂时解决问题. 但跟吃了苍蝇一样.
第二次:
方案:
(create-fontset-from-fontset-spec
"-apple-bitstream vera sans mono-medium-r-normal--12-*-*-*-*-*-fontset-mymonaco,
ascii:-apple-Monaco-medium-normal-normal-*-12-*-*-*-m-0-iso10646-1,
chinese-gb2312:-apple-STHeiti-medium-normal-normal-12-*-*-*-*-p-0-iso10646-1,
latin-iso8859-1:-apple-Monaco-medium-normal-normal-*-12-*-*-*-m-0-iso10646-1,
mule-unicode-0100-24ff:-apple-Monaco-medium-normal-normal-*-12-*-*-*-m-0-iso10646-1")

(setq default-frame-alist (append '((font . "fontset-mymonaco")) default-frame-alist))
(set-default-font "fontset-mymonaco")
原理:
自己配置个完整的字体方案, 中文和英文分开设置. 愿意用啥字体就啥字体
效果:
终于爽了.

参考
http://www.emacswiki.org/emacs/SetFonts#toc6
http://strickland.spaces.live.com/Blog/cns!3B996A2BC0C32C32!512.entry

2010年3月30日星期二

ERC使用简介(转)

http://emacser.com/erc.htm
http://jianlee.ylinux.org/Computer/Emacs/erc.html#sec4
突然想找几个 erlang的irc 玩玩, 找两个探讨一下. 用emacs的好处凸显出来, 这很简单

2009年6月13日星期六

emacs cedet+ecb+cscope+gdb-ui

http://www.360doc.com/content/080321/14/7821_1133699.html
cedet: collection of emacs development environment tools
ecb : Emacs Code Browser

配上 php python 调试, 便于开发

http://www.linuxjournal.com/article/7876 emacs+gdb

---------------------
http://downloads.sourceforge.net/mingw/gdb-6.8-mingw-3.tar.bz2?modtime=1208982015&big_mirror=1

解压里面的bin/gdb.exe放到mingw/bin里面,然后就可以用了。

这个是mingw的下载主页,上面的链接就是在这个里面的。
http://sourceforge.net/project/showfiles.php?group_id=2435

2009年2月11日星期三

emacs 查看图片

有thumbs 和 tumme 我更喜欢 tumme,在info中有详细文档
info-aprops 直接找寻帮助更为方便.
虽然用picasa 等较专业看图工具更为使用, 但偶尔我也会用emacs 来看, 因为很酷

2009年1月8日星期四

dired

待整理
http://learn.tsinghua.edu.cn:8080/2005211356/emacs/Dired.html
http://blog.chinaunix.net/u1/54415/showart_1716689.html
http://www.emacs.cn/Doc/Dired
info

2009年1月4日星期日

ido 替代iswitchb

你可能用过 iswitchb。但是当有很多buffer时,iswitchb 还是很慢。你可 以使用ido。这是我见过的最方便的切换buffer,寻找文件的扩展了。在你的 .emacs 文件里加入

(require 'ido)
(ido-mode t)


2009年1月3日星期六

browse-kill-ring(转帖)

http://docs.huihoo.com/homepage/shredderyin/emacs_elisp.html 王垠的东东,很多年前看过,但没想到今日仍给我很大帮助

require 'browse-kill-ring)
(global-set-key [(control c)(k)] 'browse-kill-ring)
(browse-kill-ring-default-keybindings)

方便的在 kill-ring 里寻找需要的东西。

你是不是经常按 C-y 放进一个 kill-ring 里的单元。然后 M-y,M-y,…… 来寻找你需要的很久以前剪切下来的东西?很费事吧?用了 browse-kill-ring 就好了。你只需要把它绑定到一个热键,比如 C-c k: 就能出现这样一个buffer。[查看图形]

kill-ring 里的内容都可以方便的浏览,粘贴。具体操作请在这 个 buffer 里 C-h m 或者 ?.

2008年12月30日星期二

emacs outline

outline 有 major-mode 和 minor-mode 两种
一般major-mode,很少应用.通常我们用c-mode,lisp 等作为主模式, outline作为 minor-mode 来使用
默认的minor-mode 下的命令前缀 C-c @ ,比较傻,可做如下设置

(setq outline-minor-mode-prefix [(control o)])
(global-set-key [(meta o)] 'open-line)

可以挂到其他主模式下使用
(add-hook 'php-mode-hook
'(lambda ()
(c-set-style "Stroustrup")
(outline-minor-mode "t")))



sublevels ( C-c @ C-q.
This collapses the whole tree, showing only the topmost heading lines. Given a numeric prefix, this command shows deeply nested sublevels. M-3 C-c @ C-q thus shows the top most heading lines and two more levels of heading lines.

body ( C-c @ C-t.
This hides all the body lines of the document--that is, showing only the heading lines. This is a very convenient way to get an overview of the whole document.

other ( C-c @ C-o.
This hides everything except the body lines in which point is located and the branches above it. The body lines of the branches above the line with point are also hidden. Note this does not seem to work in GNU Emacs 20.


Hide--Subtree

entry ( C-c @ C-c.
This hides the body lines of the given headline, but not its subbranches.

leaves ( C-c @ C-l.
This hides all the body lines of the subtree rooted in the given headline, but not the branches. This is equivalent to hide body described previously, but only for the given subtree.

subtree ( C-c @ C-d.
This hides all body lines and branches in the subtree located at the given headline.


Show--Whole Document

all ( C-c @ C-a.
This shows the whole tree. That is, it unfolds anything hidden by any of the outline functions.


Show--Subtree

entry ( C-c @ C-e.
This shows the body lines of the given headline. That is, neither the branches nor any of their content.

children ( C-c @ C-i.
This shows the immediate branches of this headline. Section heading lines will be shown for a chapter, but subsections, subsubsections, and body lines are not shown.

branches ( C-c @ C-k.
This shows all branches in the subtree for the given headline.

subtree ( C-c @ C-s.
This shows the whole subtree for the given headline. That is, all heading lines and body lines below the given headline.

emacs 配置编写顺序问题

(setq load-path
(cons "~/Configurations"
(cons "~/Extensions" load-path)))
(load "macros") ;;宏定义文件
(load "modes")
(load "extensions");; 扩展配置
(load "emacs-std") ;; 标准配置
(load "bindings") ;; 绑定键
(setq outline-minor-mode-prefix [(control o)])

扩展配置放到了标准配置之前, 可今天遇到一个灵异问题 (setq outline-minor-mode-prefix [(control o)]),怎么都无效. 无奈之下 采用分段测试发, 一段段执行 找到问题...

在配置中有调用 org-mode(放在extensions.el中), (setq outline-minor-mode-prefix [(control o)]) 放在加载org-mode 之前有效而置后无效. 究其原因是因为 org-mode 是以outline-mode 为基础扩展的. 具体细节不得而知

需要重新思考 配置的加载顺序 是否要将 emacs-std 加载 拉到前边去

2008年12月23日星期二

emacs 下tab 变空格

    By default, Emacs inserts tabs in place of multiple spaces when it formats a region. (For example, you might indent many lines of text all at once with the indent-region command.) Tabs look fine on a terminal or with ordinary printing, but they produce badly indented output when you use TeX or Texinfo since TeX ignores tabs.

The following turns off Indent Tabs mode:

;;; Prevent Extraneous Tabs
(setq-default indent-tabs-mode nil)
Note that this line uses setq-default rather than the setq command that we have seen before. The setq-default command sets values only in buffers that do not have their own local values for the variable.

在php下我想按此进行设置..

照方抓药,通常来讲 (setq-default indent-tabs-mode nil), 这样设置就ok.
按此方法,依然无效. 仔细看过以前的配置, 原来是以前 抄来的配置中的问题
(defun my-c-common-hook()
(setq tab-width 4)
(define-key c++-mode-map "\C-m" 'reindent-then-newline-and-indent)
(define-key c++-mode-map "\C-ce" 'c-comment-edit)
;; (setq c++-auto-hungry-initial-state 'none)
(setq c++-delete-function 'backward-delete-char)
(setq c++-tab-always-indent t)
(setq c-indent-level 4)
(setq c-continued-statement-offset 4)
(setq compile-command "make"))
(add-hook 'c-mode-common-hook 'my-c-common-hook)

php-mode 是依赖c-mode-common-hook 的, 在上段配置中的设置如下 (setq tab-width 4),按照默认 tab是生效的,把 (setq-default indent-tabs-mode nil) 给覆盖了. 因此在php-mode 下依然失效. 改为 (setq tab-width 4 indent-tabs-mode nil) 一切ok

2008年12月13日星期六

emacs 文件对比 合并

M-x ediff-buffers
M-x ediff-files
M-x ediff-windows-linewise

比对模式
?  帮助
n 跳到下一处不同
p 跳到上一处不同
4j 跳到第4处不同
a/b copy A/B's region to B/A
ra/rb 如果你觉得之前的修改有问题可以 restore 一下 A/B
! 重新刷新
## You might often want to skip the diffs that contain only differences in the number of white spaces. To do this, press ## (two hash marks). Emacs then simply skips these regions
v 向下翻页
V 向上翻页

有一个很强大的应用,是在使用svn时, 你修改了一个文件. 突然发现有点问题, 想与修改改的代码做一个本地的比对.
这个时候可以应用 ediff-files A文件对应 有问题的文件, B文件对应 A文件所在目录下./svn/text-base/[A文件名].svn-base
------------------------------------------------
ediff-buffers3 and ediff-files3 同时比对3文件
ca 拷贝c处的变更到A处
------------------------------------------------
Merging Files
M-x ediff-merge-buffers
M-x ediff-merge-files
用法跟 文件比较差不多,
+ 将两边差异合并
r 恢复
------------------------------------------------
多文件merge
M-x ediff-directories
M-x ediff-directories3
M-x ediff-merge-directories

会将所有文件的异同做个列表
M 回到列表上去

这个功能可以用在 公司和家里边的 configure 文件的同步上
------------------------------------------------
M-x eregistry This brings you to a buffer called *Ediff Registry* 查看当前所有的 Ediff
session

2008年12月11日星期四

emacs下实用搜索命令

emacs 具有强大的搜索功能:
常用的有
1. 文件内搜索可以用 rgrep lgrep
2. dired mode 搜索文件可以用  find-dired, 很强大 但需要自己写参数
The most general command in this series is M-x find-dired, which lets you specify any condition that find can test. It takes two minibuffer arguments, directory and find-args; it runs find in directory, passing find-args to tell find what condition to test. To use this command, you need to know how to use find.
3.find-grep  通过 find grep 进行搜索,帮你拼好 常用的命令行,自己添参数
4.find-library   mmd 以前还傻乐吧唧的自己找lisp library中的el 文件. 靠一个find-library 要什么来什么 不亦乐乎
5.其余的有待研究

rgrep lgrep 比较傻之外 其余都要自己 添写参数. 也便于熟悉一下 find  和 grep 的用法. 免得学了忘 忘了再学的兜圈子

2008年12月9日星期二

emacs ibuffer

       自以为是
       ibuffer 是个我一直忽略掉的模式 ,虽然每天都在用, 但也不过略用皮毛而已. 
       今天突然想把所有 php 的文件标志出来, 并一切删除.  本打算用 宏来小试身手 却始终不够方便. 随意的 c-h m 看了下帮助, 才知道她的强大,  小看她了
       有点小感悟想写写,  未避免雷同 google 一下, 想写的已被人写的详尽, 那不如借他山之石以攻玉了
      Emacs中Ibuffer.el的使用 http://www.0-dong.com/blog/rewrite.php/read-473.html

补充:
     1.   所有ibuffer模式下的功能氛围  5大类
          +  在标记的buffer上的操作
          + 标记命令                 
          + 过滤命令
          + 过滤组命令
          + 其他命令   
   2.  / / 删除 所有过滤器..   这个很常用
        / a   +  [saved filters]
   3.  求人不如求己, 不会用了 c-h m 一下, 才是最方便的

2008年12月8日星期一

emacs 中显示todo

(defun task-list() 
(interactive) 
(occur "TODO"))

批量去掉bom头

windows下 find ./core -type f -name "*.php" -exec sed -i '1s/^\xef\xbb\xbf//' {} ;
linux 下 find ./core -type f -name "*.php" -exec sed -i '1s/^\xef\xbb\xbf//' {}  \;
bsd 下的sed比较奇怪 需要研究一下. 
bsd7.0下测试正常

emacs abbrev 献给懒人的利器

      缩写模式

If you want the abbreviation to exist from one session to the next, you must insert the following line into your .emacs file:
(read-abbrev-file) 

When this line is in the .emacs file, abbreviations are loaded during startup of Emacs; when Emacs exits they are written. If you want the abbreviations to be saved as soon as they are defined, insert the following into your .emacs file:

(sams-write-abbrev-at-once) 

C-x a i g (inverse-add-global-abbrev)
C-x a i l (inverse-add-mode-abbrev
M-x edit-abbrevs   然后可以直接编辑 php-mode-abbrev-table 这一块

2008年12月7日星期日

register

register 与bookmarks 混用,效果特佳. bookmarks 作为书签. 长久的习惯, register 属于临时性的享受跳跃的快感. 尤其是在想临时复制几个东西 到不同地点的时候, 可以应用 copy-to-register  insert-register
---------------------------------------------------------

Emacs中的register

在多个文件中逛的时候,我们常常需要快速切换到先前访问的某个位置。因此,我们需要把文件及其光标位置暂时存放在某个地方。

在Emacs中,我们可以使用register暂时性保存这些信息。

将当前光标所在位置保存入一个register中:

C-x r SPACE + register名(一个字符,比如a吧)
然后我们就可以到处瞎逛,若要回到保存的register a位置,我们可以输入:

C-x r j a
挺好用的吧:)

如果你记性和我一样不好,恐怕会常常想看看自己保存了哪些register,我们可以输入:

M-x view-register    查看某一个register
M-x list-registers   查看所有的register
其实我常用的就是以上功能,为了使笔记稍微完整一点,下面开始Copy 《GNU Emacs Manual》的相关章节:

在下面,我们使用r来命名所有的register:

Save Positions in Registers

C-x r SPC r
    Save position of point in register r (point-to-register). 
C-x r j r
    Jump to the position saved in register r (jump-to-register).
Saving Text in Registers

C-x r s r
    Copy region into register r (copy-to-register). 
C-x r i r
    Insert text from register r (insert-register). 
M-x append-to-register RET r
    Append region to text in register r. 
M-x prepend-to-register RET r
    Prepend region to text in register r.
Saving Rectangles in Registers

C-x r r r
    Copy the region-rectangle into register r (copy-rectangle-to-register). With numeric argument, delete it as well. 
C-x r i r
    Insert the rectangle stored in register r (if it contains a rectangle) (insert-register).
Saving Window Configurations in Registers

C-x r w r
    Save the state of the selected frame's windows in register r (window-configuration-to-register). 
C-x r f r
    Save the state of all frames, including all their windows, in register r (frame-configuration-to-register).
Keeping Numbers in Registers

C-u number C-x r n r
    Store number into register r (number-to-register). 
C-u number C-x r + r
    Increment the number in register r by number (increment-register). 
C-x r g r
    Insert the number from register r into the buffer.

bookmarks

C-x r m (bookmark-set)
C-x r b (bookmark-jump)
M-x (list-bookmarks)

bookmarks会自动保存在$HOME/.emacs.bmk, 这个地址是可以变更的. 详细请参见 info 内的相关说明

默认情况下bookmarks 只有当emacs 结束时才会保存. 如果你希望在更改bookmark 后及时生效,可进行如下设置
(setq bookmark-save-flag 1)

我的设置如下:
(global-set-key [(f8)] 'bookmark-jump)
(global-set-key [(shift f8)] 'bookmark-set)
(global-set-key [(control f8)] 'list-bookmarks)