1 ;;; smiles-mode.el --- Major mode for SMILES.
2 ;;; -*- coding: utf-8 -*-
6 ;; Homepage: https://repo.or.cz/smiles-mode.git
11 ;;; http://kitchingroup.cheme.cmu.edu/blog/2016/03/26/A-molecule-link-for-org-mode
13 ;; Author: John Kitchin [jkitchin@andrew.cmu.edu]
21 "Convert the smiles string in the buffer to CML."
23 (let ((smiles (buffer-string)))
24 (switch-to-buffer (get-buffer-create "SMILES-CML"))
27 (shell-command-to-string
28 (format "obabel -:\"%s\" -ocml 2> /dev/null"
30 (goto-char (point-min))
33 (defun smiles-names ()
36 (format "http://cactus.nci.nih.gov/chemical/structure/%s/names"
39 (defvar smiles-mode-map
41 "Keymap for smiles-mode.")
43 ;; adapted from http://ergoemacs.org/emacs/elisp_menu_for_major_mode.html
44 (define-derived-mode smiles-mode fundamental-mode
"smiles-mode"
45 "Major mode for SMILES code."
46 (setq buffer-invisibility-spec
'(t)
49 (when (not smiles-mode-map
)
50 (setq smiles-mode-map
(make-sparse-keymap)))
51 (define-key smiles-mode-map
(kbd "C-c C-c") 'smiles-cml
)
52 (define-key smiles-mode-map
(kbd "C-c C-n") 'smiles-names
)
54 (define-key smiles-mode-map
[menu-bar
] (make-sparse-keymap))
56 (let ((menuMap (make-sparse-keymap "SMILES")))
57 (define-key smiles-mode-map
[menu-bar smiles
] (cons "SMILES" menuMap
))
59 (define-key menuMap
[cml]
60 '("CML" . smiles-cml))
61 (define-key menuMap [names]
62 '("Names" . smiles-names))))
65 (provide 'smiles-mode)
67 ;;; smiles-mode.el ends here