Git Product home page Git Product logo

cctbxsnips-emacs's Introduction

cctbxsnips for the yasnippets package in Emacs

Version License: MIT

CCTBX

CCTBX is the Computational Crystallography Toolbox. Its development is based at Lawrence-Berkeley National Laboratory. It provides code for computations with diffraction data and atomic coordinates of proteins and small molecules. It has C++ and Python ports. It is available in Anaconda in the conda-forge channel as cctbx-base for python3.8 through 3.11 for Windows, macOS, and Linux.

Blaine's cctbx install protocol

I assume that Anaconda has already been installed. We also create the Jupyter notebook kernel while we are at it. Execute one line at a time: Wait for the execution to finish before executing the next line.

conda create --name cctbx39 python=3.9
conda activate cctbx39
conda install -c conda-forge cctbx-base -y
conda install ipykernel -y
python -m ipykernel install --user --name cctbx39 --display-name "cctbx python3.9"

The second to last command triggers the installation of Jupyter in the cctbx39 env. The last command creates and installs the Jupyter kernel in ~/Library/Jupyter/kernels/cctbx39 on the Mac. Select cctbx python3.9 from the list of kernels when opening a new notebook in Jupyter.

Replace the 3.9 or 39 above with whatever version of Python you want to use (between 3.8 and 3.11).

yasnippets

The yasnippets package is a top-rated snippet manager for Emacs. There are other snippets managers for Emacs, but yasnippets is very popular. The yasnippets package is not built into Emacs and must be installed separately. It is available in MELPA.

The problems that this repo addresses

  1. Facilitation of code reuse. Code snippets can save time by reusing existing code. The presence of tab stops in code snippets can help ensure that all parameters that need customization to a new problem are considered. Thus, tab stops can reduce subsequent debugging.

  2. Use Emacs to edit Jupyter and Colab code and markdown cells The existing snippet formats for Jupyter and Colab notebooks do not support tab triggers and tab stops, which are standard features of code snippet systems in most text editors. We can overcome these limitations by sending the active code cell to Emacs via the GhostText extension for the browser and the atomic-chrome package for Emacs.

Installation

  1. Install the snippets
cd ~/.emacs.d/snippets/python-mode
git clone https://github.com/MooersLab/cctbxsnips-Emacs.git
cd cctbxsnips-Emacs/yasnippets
mv * ../../.
cd ../..
rm -rf cctbxsnips-Emacs
  1. Optional If you want to use these snippets from Emacs to edit live cells in Jupyter or Colab notebooks, install GhostText in your browser and atomic-chrome in Emacs.

Below is the related configuration for my Emacs initialization file. Note that I have set the default programming language scope to Python so that code cells in Jupyter notebooks open in Emacs as being in the python-mode were sent to Emacs from the web browser running the Jupyter session.

;; atomic-chrome, used to interact with GhostText extension for Google Chrome.
(use-package atomic-chrome
      :ensure t)
;; uncomment the line below to start the server on start-up of Emacs.      
;; (atomic-chrome-start-server)
(setq atomic-chrome-default-major-mode 'python-mode)
(setq atomic-chrome-extension-type-list '(ghost-text))
;;(atomic-chrome-start-httpd)
(setq atomic-chrome-server-ghost-text-port 4001)
(setq atomic-chrome-url-major-mode-alist
      '(("github\\.com" . gfm-mode)
        ("overleaf.com" . latex-mode)
        ("750words.com" . latex-mode)))
; Select the style of opening the editing buffer by atomic-chrome-buffer-open-style.
; full: Open in the selected window.
; split: Open in the new window by splitting the selected window (default).
; frame: Create a new frame and window in it. You must be using some windowing package.
(setq atomic-chrome-buffer-open-style 'split)

Example of use

Note that the user experience will vary widely with regards to autocompletion and the use of the yasnippets package depending on how Emacs has been configured. I use Gnu Emacs configured from scratch.

Related repositories

Update History

Version Changes Date
Version 0.2 Fixed typos in README.md 2024 April 10

Sources of funding

  • NIH: R01 CA242845
  • NIH: R01 AI088011
  • NIH: P30 CA225520 (PI: R. Mannel)
  • NIH P20GM103640 and P30GM145423 (PI: A. West)

cctbxsnips-emacs's People

Contributors

mooerslab avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.