简体   繁体   中英

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. What is the keyboard shortcut for "evaluate phrase" or "evaluate buffer"?

I can only answer part (2):

  • To start an Ocaml top-level: Cc Cs
  • To evaluate a phrase: Cx Ce
  • To evaluate a buffer: Cc Cb
  • To evaluate a region: Cc Cr

Launch the tuareg mode (eg by Mx tuareg-mode ), and look at its documentation pressing Ch 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 Cx Ce (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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM