开发者

OCaml Emacs Tuareg: Evaluate phrase keyboard shortcut, and how to display actual greek symbols?

Two questions about Emacs Tuareg for OCaml:

  1. I have seen some configurations where it displays an alpha symbol instead of a'. How can I turn this on?

  2. 开发者_Python百科What is the keyboard shortcut for "evaluate phrase" or "evaluate buffer"?


I can only answer part (2):

  • To start an Ocaml top-level: C-c C-s
  • To evaluate a phrase: C-x C-e
  • To evaluate a buffer: C-c C-b
  • To evaluate a region: C-c C-r


Launch the tuareg mode (e.g. by M-x tuareg-mode), and look at its documentation pressing C-h m.

The symbols are displayed by the sym-lock mode only works for Xemacs and its variants I'm afraid, but you'll find how to configure it in your .emacs in the help mentioned above. The shortcut to execute a statement is C-x C-e (see section 'Special keys' of the help).


I'm not sure if this is exactly what you mean for part 1 of your question, but I have a font-lock-mode keyword to display the lambda keyword as the Greek lambda symbol, which could be adapted to do what you ask. It only requires that font-lock-mode be enabled. (I didn't write it, just found it floating around somewhere).

;; real lisp hackers use the lambda character
;; courtesy of stefan monnier on c.l.l
(defun sm-lambda-mode-hook ()
  (font-lock-add-keywords
   nil `(("\\<lambda\\>"
   (0 (progn (compose-region (match-beginning 0) (match-end 0)
        ,(make-char 'greek-iso8859-7 107))
      nil))))))
(add-hook 'emacs-lisp-mode-hook 'sm-lambda-mode-hook)
(add-hook 'lisp-interactive-mode-hook 'sm-lamba-mode-hook)
(add-hook 'scheme-mode-hook 'sm-lambda-mode-hook)


You can look to my existing configs, based on the code from EmacsWiki with some extensions - function to handle conversion from text to chars, and example of it use for erlang mode - you can change it for ocaml mode also

P.S. but this code has one disadvantage - it also displays these characters inside strings and comments

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜