Code Monkey home page Code Monkey logo

past-el's Introduction

past.el

This is an elisp code grabs a figure from {clipboard| screen selection}, save it under the folder ./drawings, and paste the proper reference to the figure into the currently open {TeX| org} file. When paste from clipboard, the clipboard contains either the image or the path pointing to an image. It runs with Emacs. A typical workflow is as follows, while having xournalpp (or any other drawing app) open:

  1. sketch inside xournalpp and copy the sketch
  2. switch back to the TeX file and invoke pastel-figure
  3. type in figure name after the prompt

Demo

xournalpp -> latex

demo gif

xournalpp/file path/screenshot -> org

demo gif

Prerequsite

xclip, scrot

How it works

Paste of image in clipboard pastel-figure

After copying the sketch into the clipboard, pastel-figure invokes xclip and creates a png file inside ./drawings. It saves the image inside the clipboard into a png file, then refers to the file using inclugraphics at the point of the tex file or bracket reference for org file.

Paste image with its path in clipboard pastel-file

It saves the image into ./drawings folder, and adds reference to the image.

Installation

Include the folder that contains past.el. Then load it. Inside init.el you can add the following

(add-to-list 'load-path "path/to/past.el/folder")
(load "past.el")

Keybindings

The default keybinding is the following. You can customize inside past.el:

(,(kbd "H-y") . ,(function pastel-figure))
(,(kbd "H-Y") . ,(function pastel-file))    
(,(kbd "H-o") . ,(function pastel-screenshot-part))

This means, in LaTeX mode, H-y inserts the plot together with the figure environment wrapping, while invoking it with a prefix such as C-- H-i only inserts the line of includegraphics. In org-mode, H-y inserts the link to the figure and toggle inline display automatically.

Debug

I tested with xournalpp, but I do not see any problem to substitute this as anything else that copy a figure into the X11 clipboard. To make sure the tool is compatible, copy whatever you want to paste, and check with the following xclip command

xclip -selection clipboard -t TARGETS -o

If you see there is "image/png" in it, it should in principle work.

Acknowledgement

I appreciate the help from bpalmer, wasamasa, and pjb from #emacs at irc.libera.chat.

past-el's People

Contributors

chensun-phys 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.