让emacs完美显示BMP文件的办法
2010-11-30 01:20
381 查看
首先感谢http://emacser.com/的ahei,
这个想法是在和TA谈话时想到,
由于是边试边写,程序中用到了本人以前写的ppm-gen( http://www.emacswiki.org/emacs/ppm-gen.el )
基本思路是使用emacs lisp强大的advice功能,
在.emacs中加入以下代码:
然后你就把BMP文件往emacs里拖就可以拉。 C-cC-c也是可用,所谓完美就指这个。
善用这个例子,可以让emacs显示任何图片的喔。
这个想法是在和TA谈话时想到,
由于是边试边写,程序中用到了本人以前写的ppm-gen( http://www.emacswiki.org/emacs/ppm-gen.el )
基本思路是使用emacs lisp强大的advice功能,
在.emacs中加入以下代码:
(require 'ppm-gen) (defadvice image-type (around image-type-bmp first (source &optional type data-p) activate) (setq ad-return-value (cond (data-p (if (string-match "^BM" source) 'bmp ad-do-it)) (t (if (string-match ".*//.bmp" source) 'bmp ad-do-it))))) (defadvice create-image (around create-image-bmp (file-or-data &optional type data-p &rest props) activate) (setq ad-return-value (cond ((eq 'bmp type) (let (ppm-obj ppm-data) (setq ppm-obj (ppm-from-bmp file-or-data)) (setq ppm-data (with-temp-buffer (set-buffer-multibyte nil) (with-slots ((w width) (h height) pixels) ppm-obj (insert (format "P6 %d %d 255/r" w h)) (insert (concat pixels))) (buffer-substring-no-properties (point-min) (point-max)))) (create-image ppm-data 'pbm t))) (t ad-do-it)))) (add-to-list 'auto-mode-alist '("//.//(bmp//|BMP//)$" . image-mode))
然后你就把BMP文件往emacs里拖就可以拉。 C-cC-c也是可用,所谓完美就指这个。
善用这个例子,可以让emacs显示任何图片的喔。
相关文章推荐
- 用emacs显示BMP文件
- 利用COM组件IPicture读取jpg、gif、bmp图片文件数据和显示图片的两个函数
- win32 应用程序 显示 bmp 文件
- 针对eclipse安装spring插件安装失败或者后不显示spring文件或者的解决办法
- IE浏览器不能自动显示PDF文件的解决办法
- 读取SD卡里面的BMP文件 显示到TFT上
- vim 文件在linux不换行,只显示^M解决办法
- VC/MFC读取BMP文件并显示
- svn 日志文件显示时间为1970-01-01 No data ----------最终解决办法
- Aspose.Words 直接写response导出docx文档显示文件已损坏需要修复的解决办法
- 【转】NDK编译可执行文件在Android L中运行显示error: only position independent executables (PIE) are supported.失败问题解决办法。
- VGA 13H模式显示BMP256色文件
- OpenOffice将MS docx转换成pdf文件偶数页眉不显示问题解决办法
- 关于VirtualBox自动挂载文件不显示的解决办法
- 安卓 接入Weex Base64位图片无法显示完美解决办法
- Windows系统下,往硬盘里复制粘贴文件不显示,也不提示进度条的解决办法
- PP助手安装ipa文件显示"Install Prohibited"安装失败解决办法
- 完美解决无法无法显示隐藏文件的问题(svohost.exe xsx.exe)
- OpenGL(十一) BMP真彩文件的显示和复制操作
- 以正常的途径删除文件后,xcode仍然显示文件意外丢失报警 解决办法