English 中文(简体)
特殊标志
原标题:Unshifted symbols in Emacs
  • 时间:2011-06-08 11:10:30
  •  标签:
  • perl
  • emacs

我喜欢一种细小的模式,它使钥匙上的转头符号能够以非临时性的方式获得(然后将数字转移)。 看来这可能有助于佩雷尔法典(@%,等等)。 理想的情况是,将这种方式集中起来有关键。 缺乏像头锁一样的帽子,但只有钥匙。

这种方式是否已经存在?

最佳回答

推广你自己意愿的一种方式就是:

(define-minor-mode snoopy-mode
  "Toggle snoopy mode.
   With no argument, this command toggles the mode.
   Non-null prefix argument turns on the mode.
   Null prefix argument turns off the mode."
  ;;   The initial value.
  nil
  ;; The indicator for the mode line.
  " Snoopy"
  ;; The minor mode bindings.
   (("1" . (lambda () (interactive) (insert-char ?! 1)))
    ("!" . (lambda () (interactive) (insert-char ?1 1)))
    ;;etc
))

minor Modekeymaps

问题回答

非常感谢答案。 此处为所有数字的扩大定义:

(define-minor-mode shifted-numbers-mode
  "Toggle shifted numbers mode."
  nil
  " shifted"
   (("1" . (lambda () (interactive) (insert-char ?! 1)))
    ("2" . (lambda () (interactive) (insert-char ?@ 1)))
    ("3" . (lambda () (interactive) (insert-char ?# 1)))
    ("4" . (lambda () (interactive) (insert-char ?$ 1)))
    ("5" . (lambda () (interactive) (insert-char ?% 1)))
    ("6" . (lambda () (interactive) (insert-char ?^ 1)))
    ("7" . (lambda () (interactive) (insert-char ?& 1)))
    ("8" . (lambda () (interactive) (insert-char ?* 1)))
    ("9" . (lambda () (interactive) (insert-char ?( 1)))
    ("0" . (lambda () (interactive) (insert-char ?) 1)))

    ("!" . (lambda () (interactive) (insert-char ?1 1)))
    ("@" . (lambda () (interactive) (insert-char ?2 1)))
    ("#" . (lambda () (interactive) (insert-char ?3 1)))
    ("$" . (lambda () (interactive) (insert-char ?4 1)))
    ("%" . (lambda () (interactive) (insert-char ?5 1)))
    ("^" . (lambda () (interactive) (insert-char ?6 1)))
    ("&" . (lambda () (interactive) (insert-char ?7 1)))
    ("*" . (lambda () (interactive) (insert-char ?8 1)))
    ("(" . (lambda () (interactive) (insert-char ?9 1)))
    (")" . (lambda () (interactive) (insert-char ?0 1)))))

在珀尔,图书馆往往比括号更为常见,因此你也希望:

("[" . (lambda () (interactive) (insert-char ?{ 1)))
("]" . (lambda () (interactive) (insert-char ?} 1)))

("{" . (lambda () (interactive) (insert-char ?[ 1)))
("}" . (lambda () (interactive) (insert-char ?] 1)))




相关问题
Why does my chdir to a filehandle not work in Perl?

When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...

How do I use GetOptions to get the default argument?

I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...

Object-Oriented Perl constructor syntax and named parameters

I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...

Where can I find object-oriented Perl tutorials? [closed]

A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...

热门标签