免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: flw
打印 上一主题 下一主题

有关 Emacs 使用技巧的内容请在这个帖子讨论。 [复制链接]

论坛徽章:
0
731 [报告]
发表于 2008-08-25 14:42 |只看该作者
elisp 推广:

用 elisp 来处理这个问题:

http://bbs.chinaunix.net/thread-1253307-1-1.html


  1. (setq h (make-hash-table))
  2. (mapcar (lambda (x) (puthash (expt 2 x) x h))
  3.           (number-sequence 0 7))

  4. (gethash 8 h)
复制代码

论坛徽章:
0
732 [报告]
发表于 2008-08-26 11:37 |只看该作者

cvs中的emacs到底什么时候更新的?

我想下一个最新的emacs,可是每次去cvs里面都是显示几个月前更新的,怎么找到几周前更新的?
我找的CVS地址如下
http://cvs.savannah.gnu.org/view ... rev=emacs-unicode-2
截图

论坛徽章:
0
733 [报告]
发表于 2008-08-26 13:44 |只看该作者
python 版的这个帖

[ 删除重复行]

想用 emacs 来做,没找到现成的函数。自己写了一个:


  1. (defun unique (bufname)
  2.   (interactive "b")
  3.   (let ((buf (get-buffer bufname))
  4.         (h (make-hash-table :test 'equal))
  5.         (new (get-buffer-create "*new*")))
  6.     (set-buffer new)
  7.     (delete-region (point-min) (point-max))
  8.     (set-buffer buf)
  9.     (goto-char (point-min))
  10.     (let ((f (lambda (x y)
  11.                (if (not (eobp))
  12.                    (progn
  13.                      (let* ((s (point-at-bol))
  14.                             (e (point-at-eol))
  15.                             (l (buffer-substring s e)))
  16.                        (if (gethash l h)
  17.                            (next-line)
  18.                          (progn
  19.                            (puthash l t h)
  20.                            (princ (concat l "\n") y)
  21.                            (next-line)))
  22.                        (funcall f x y)))))))
  23.           (funcall f buf new)
  24.           (switch-to-buffer new))))
复制代码


大意是用一个函数 f 按行遍历一个 buf,把读入的行与 hash 表中的比较。如果在其中,就换到下一行;如果不在其中,就把此行放入 hash 表,然后在 *new* buffer 中输出此行。

这段代码写得不好,请给点修改意见。

论坛徽章:
0
734 [报告]
发表于 2008-08-26 14:28 |只看该作者
稍微修改了一下,直接改动指定 buf ,这样更 emacs 一点。


  1. (defun unique (bufname)
  2.   (interactive "b")
  3.   (let ((buf (get-buffer bufname))
  4.         (h (make-hash-table :test 'equal)))
  5.     (set-buffer buf)
  6.     (goto-char (point-min))
  7.     (let ((f (lambda (x)
  8.                (if (not (eobp))
  9.                    (progn
  10.                      (let* ((s (point-at-bol))
  11.                             (e (point-at-eol))
  12.                             (l (buffer-substring s e)))
  13.                        (if (gethash l h)
  14.                            (progn
  15.                              (kill-region s e) (kill-line))
  16.                          (progn
  17.                            (puthash l t h)
  18.                            (next-line)))
  19.                        (funcall f x)))))))
  20.           (funcall f buf))))
复制代码


只有在空行的情况下, kill-line 才删除换行符号。有没有一次到位,连内容带换行都删掉的?

论坛徽章:
0
735 [报告]
发表于 2008-08-27 17:03 |只看该作者
不用递归,往代码里加点糖,


  1. (defun unique (bufname)
  2.   (interactive "b")
  3.   (let ((buf (get-buffer bufname))
  4.         (h (make-hash-table :test 'equal)))
  5.     (set-buffer buf)
  6.     (goto-char (point-min))
  7.     (while (not (eobp))
  8.       (let ((l (buffer-substring (point-at-bol) (point-at-eol))))
  9.         (if (gethash l h) (progn (kill-line) (kill-line))
  10.           (progn (puthash l t h) (next-line)))))))
复制代码

[ 本帖最后由 retuor 于 2008-8-27 17:06 编辑 ]

论坛徽章:
0
736 [报告]
发表于 2008-08-29 16:07 |只看该作者
emacs虽然不会煮饭,但是会很调皮的给你庆祝生日。
搜遍了英文的文档也没找到,最后用ctrl+x 3 两个窗口,
然后用 M+x ,然后用ctrl+x o 切换到tab之后列表的窗口,
最后用ctrl+s,用模糊匹配找到了,命令。大家可以用以下步骤:
1  M-x animate-birthday-present   
2  Name (default Sarah): zhou____
结果是一些闪烁的字母,拼凑成一段话,如下:





                                                       Happy Birthday,
                                                          zhou____


                              You are my sunshine,
                              My only sunshine.
                              I'm awful sad that
                              You've moved away.

                              Let's talk together
                              And love more deeply.
                              Please bring back
                                  my sunshine
                                  to stay!
ps:我的机器没办法抓图。
不然看一眼就明白了。

论坛徽章:
0
737 [报告]
发表于 2008-09-13 23:09 |只看该作者

回复 #2 arcsiny 的帖子

外国大牛都是拿30几寸的大显示器来CODE,,,嘿嘿
pengchy 该用户已被删除
738 [报告]
发表于 2008-09-18 18:17 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
739 [报告]
发表于 2008-09-21 23:00 |只看该作者
哪位有没有试过copy啊??

emacs copy 很麻烦

论坛徽章:
0
740 [报告]
发表于 2008-09-22 10:01 |只看该作者
原帖由 nhuczp 于 2008-9-21 23:00 发表
哪位有没有试过copy啊??

emacs copy 很麻烦

什么意思?copy、paste?编辑文本哪离得开这个?

问题能否说详细点?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP