emacs에서 온라인 사전(firefox) 바로 이용하기
      글쓴이: happibum / 작성시간: 일, 2004/09/12 - 9:40오후    
  
  emacs에서 한자 키를 누르면 커서 아래 영단어를 naver 영어사전에서 찾아주는 코드입니다.
firefox가 미리 떠 있어야합니다.
~/.emacs에 아래 코드를 집어 넣어두시면 됩니다.
(require 'ispell)
(defun search-naver-dic ()
  (interactive)
  (save-excursion
    (let* ((word-to-find (car (ispell-get-word t))))
      (shell-command-to-string
       (concat "firefox -remote "
	       "'openURL(http://endic.naver.com/search.naver?mode=all&query="
	       word-to-find
	       "&x=0&y=0)'")))))
(global-set-key [(Hangul_Hanja)] 'search-naver-dic)
조잡... :oops:
Forums: 


감사합니다.
좋은 정보 감사 합니다. 저도 한번 해 봐야 겠네요
저같은 초보를 위해 .emacs 파일좀 공개 해 주실 수 있을까요?
---------------------------------------------
git init
git add .
git commit -am "project init"
---------------------------------------------
좋은 아이디어군요. browse-url.el 을 사용하면 더 간단히 됩니
좋은 아이디어군요. browse-url.el 을 사용하면 더 간단히 됩니다.(단, browse-url에서 지원 안하는 브라우저에 대해서는 별도의 수정이 필요)
처음 코드와는 달리 아마 브라우저가 없으면 브라우저가 실행되는 것으로 기억합니다.
제 경우는 구형 모질라인데, 아마 다른 브라우저를 모질라로 심볼릭 링크 해 놓으면, browse-url 수정 없이도 될 겁니다.
(defun search-naver-dic () (interactive) (browse-url (concat "http://endic.naver.com/search.naver?mode=all&query=" (thing-at-point 'word))))(제 .emacs는 Common Lisp 프로그래밍 용으로 작성되어서 공개해도 별 도움 안되리라고 생각합니다 :)
http://lisp.or.kr http://lisp.kldp.org - 한국 리습 사용자 모임
[quote="LispM"]...[code:1](def
"&x=0&y=0" 부분을 빼먹었군요. 이부분은 어디에 사용되는 것인지??
아뭏든,
(defun search-naver-dic () (interactive) (browse-url (concat "http://endic.naver.com/search.naver?mode=all&x=0&y=0&query=" (thing-at-point 'word))))하면 되겠네요.
http://lisp.or.kr http://lisp.kldp.org - 한국 리습 사용자 모임
LispM님이 깔끔하게 만들어 주셨네요. :D @ .emacs
LispM님이 깔끔하게 만들어 주셨네요. :D
@ .emacs는 내용없이 지저분하기만;;;;
보너스~ -_-;;X에서 하이라이팅 된 부분(X-seletion)을
보너스~ -_-;;
X에서 하이라이팅 된 부분(X-seletion)을 단축키로 온라인 사전에서 찾기.
http://www.niksula.cs.hut.fi/~vherva/xsel/ 에서 xsel.c 을 다운 받고,
로 컴파일합니다.거기 있는대로
를 적당한 이름으로 실행가능하게 만들어 두고
윈도우 매니저에서 위 스크립트에다 단축키를 연결시키면 됩니다.
마우스로 긁은 부분을 단축키로 바로 사전에서 찾을 수 있습니다.
@ 이번에도 좀더 나은 솔루션이 나오길... :oops:
그냥 불여우로 부르는 수고를 할 필요도 없이 그냥 emacs에서 보세요.
그냥 불여우로 부르는 수고를 할 필요도 없이 그냥 emacs에서 보세요. 조금 허잡한 포멧팅이지만 w3m/w3등의 기타 package를 깔 필요없이 돌아갑니다.
(require 'cl) (defun ndic (word) "simple naver dictionary browser" (interactive (list (let ((wd (current-word))) (read-string (format "dict naver (default '%s'): " wd))))) (let ((url (format "http://endic.naver.com/search.naver?where=dic&query=%s" (qs-url-encode word)))) (with-output-to-temp-buffer "*ndic*" (set-buffer "*ndic*") (setq buffer-read-only nil) (erase-buffer) (call-process "wget" nil (current-buffer) nil "-q" "-O-" url) (setf (point) (point-min)) (when (looking-at "<META HTTP-EQUIV=") (progn (re-search-forward "url=") (delete-region (point-min) (point)) (re-search-forward "\"") (setq url (format "http://endic.naver.com%s" (buffer-substring (point-min) (1- (point))))) (erase-buffer) (call-process "wget" nil (current-buffer) nil "-q" "-O-" url) (setf (point) (point-min)))) (when (search-forward "<!-- end :" nil t) (beginning-of-line 2) (delete-region (point-min) (point))) (when (search-forward "<!-- start :" nil t) (beginning-of-line 0) (delete-region (point) (point-max))) (setf (point) (point-min)) (while (re-search-forward "<[^>]+>" nil t) (replace-match "")) (setf (point) (point-min)) (while (re-search-forward "&[^;]+;" nil t) (replace-match "")) (setf (point) (point-min)) (when (re-search-forward (format "^%s" word) nil t) (beginning-of-line 0) (delete-region (point-min) (point))) (setf (point) (point-min)) (insert (format "definition of %s: %s\n" word url)) (pop-to-buffer "*ndic*")))) (defun qs-url-encode (str &optional coding) "urlencode the string" (loop for c across (encode-coding-string str (or coding 'euc-kr)) concat (cond ((eq c ?\n) "%0D%0A") ((string-match "[-a-zA-Z0-9_:/.]" (char-to-string c)) (char-to-string c)) ((char-equal c ?\x20) "+") (t (format "%%%02x" c)))))이왕 나온김에 하나 더 올려봅니다. MSIE에서 web accessori
이왕 나온김에 하나 더 올려봅니다. MSIE에서 web accessories를 깔고 난 후에 주소창에서 쓰던 기능을 emacs로 가져와 봤습니다.
(require 'ffap) (defconst qs-keywords '( a "http://www.google.com/answers/search?qtype=answered&q=%s" av "http://www.altavista.com/cgi-bin/query?text=yes&q=%s" bible "http://bible.gospelcom.net/cgi-bin/bible?passage=%s" dict "http://www.dictionary.com/cgi-bin/dict.pl?term=%s" dmoz "http://search.dmoz.org/cgi-bin/search?search=%s" e "http://www.thefreedictionary.com/%s" f "http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?query=%s&action=Search" fm "http://freshmeat.net/search/?q=%s" g "http://www.google.com/search?q=%s" gg "http://www.google.com/search?btnI=1&q=%s" gk "http://labs.google.com/cgi-bin/keys?q=%s" gl "http://labs.google.com/glossary?q=%s" gm "http://www.google.com/microsoft?hq=microsoft&q=%s" gn "http://groups.google.com/groups?q=%s" imdb "http://www.imdb.com/Tsearch?%s" isbn "http://isbn.nu/%s/price" m "http://planetmath.org/?op=search&term=%s" mskb "http://cryo.gen.nz/projects/mskb/?q=%s" mw "http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=%s" n "http://search.naver.com/search.naver?where=nexearch&query=%s" nb "http://100.naver.com/search.naver?query=%s" nd "http://dic.naver.com/endic?where=dic&query=%s" ni "http://kinsearch.naver.com/search.naver?where=allqna&query=%s" r "http://ragingsearch.altavista.com/cgi-bin/query?q=%s" rc5 "http://stats.distributed.net/rc5-64/psearch.php3?st=%s" rfc "http://www.faqs.org/rfcs/rfc%s.html" rhyme "http://rhyme.lycos.com/r/rhyme.cgi?Word=%s" s "http://citeseer.ist.psu.edu/cis?q=%s&submit=Search+Documents&cs=1" t "http://s.teoma.com/search?q=%s&qcat=1&qsrc=0" thes "http://www.thesaurus.com/cgi-bin/search?config=roget&words=%s" w "http://www.wikipedia.org/w/wiki.phtml?search=%s" whats "http://www.netcraft.com/whats/?host=%s" whois "http://www.domainwatch.com/getwho.cgi?dom=%s" wp "http://www.whitepages.co.nz/cgi-bin/search?loc=AK&key=%s" yd "http://kr.engdic.yahoo.com/search/engdic?p=%s" yp "http://www.yellowpages.co.nz/quick/search?lkey=Auckland&key=%s" ;; these are later add on -- not from registry fi "http://www.fact-index.com/search/search.html?search=%s" wi "http://en.wikipedia.org/wiki/%s" )) (defun qs-search (url-string) "immitage the search url facility in MSIE w/ web accessories" (interactive "sURL ('?' for help): ") (when (or (null url-string) (string= url-string "")) (setq url-string (ignore-errors (ffap-prompter)))) (flet ((browse (url) (browse-url url (or current-prefix-arg t)))) (let* ((pos (position ? url-string)) (key (intern (substring url-string 0 pos))) (idx (position key qs-keywords))) (if (and pos idx) (let ((buzzword (substring url-string (1+ pos)))) (browse (format (nth (1+ idx) qs-keywords) (qs-url-encode buzzword)))) (if (string= url-string "?") (with-output-to-temp-buffer "*Help*" (princ "Simply type any url ('https?://' is optional) or") (terpri) (terpri) (loop for key in qs-keywords by #'cddr for url in (cdr qs-keywords) by #'cddr do (princ (format " %-10s%s" key url)) do (terpri))) (or (string-match "^https?://" url-string) (setq url-string (concat "http://" url-string))) (browse url-string))))))간단히 쓰시는 방법은
등으로 키 바인딩을 하시고, C-c d를 누르시고 "w Poincare Conjecture"를 치시면 포앙카레 컨젝쳐가 뭔지 바로 알 수 있습니다.:p
아 물론 위에 올린 (require 'cl)하고 qs-url-encode 도 있어야 합니다.
[quote="happibum"]보너스~ -_-;;X에서 하이라이팅
흠 sawfish 윈도우 메니져를 쓰신다면 역쉬나 rep script로 해결이 됩니다. 가끔씩 sawfish가 먹통이 되는 경우가 있는데 디버깅이 귀찮아서 그냥 씁니다. ㅠ_ㅠ
(require 'sawfish.wm.util.selection) (defun open-mozilla-with-clipboard-contents () "open new mozilla windows with clipboard url" (let ((text (or (x-get-selection 'CLIPBOARD) (x-get-selection 'PRIMARY)))) (system (concat "firefox -remote 'openURL(" (trim-string text) ",new-tab)'")) ;; (when (string-match ("^https?://" text)) ;; (system (concat "mozilla -remote 'openURL(" text ", new-window)'"))) )) (defun open-mozilla-with-clipboard-contents-or-bypass () "call firefox for current selection or bypass the keystroke if current window is rdesktop." (interactive) (let ((win (input-focus))) (if (string= (window-class win) "rdesktop") (synthesize-event (current-event) win) (open-mozilla-with-clipboard-contents)))) (bind-keys global-keymap "Control-F1" 'open-mozilla-with-clipboard-contents-or-bypass)위에서 mozilla부르는 부분을 naver사전으로 대체하면 됩니다.
우오오... emacs committer의 등장... 잘쓰겠습니다. (_
우오오... emacs committer의 등장... 잘쓰겠습니다. (__)
@ 전 sawfish가 x-get-selection 부르기만 하면 뻣더군요... ㅠ_ㅠ
음...
이맥스의 길은 멀고도 험하다는걸 다시 한번 깨닫는군요.. ^.^
좋은 정보 감사합니다.
---------------------------------------------
git init
git add .
git commit -am "project init"
---------------------------------------------
댓글 달기