Skip to content

Upload sharing to 0x0.st

License

Notifications You must be signed in to change notification settings

emacsmirror/0x0

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

emacs-0x0

Integration with 0x0.st services from emacs. Intended for use in ERC to share images, files, and blocks of code.

The commands this package offers:

  • 0x0-dwim chooses the right one of the following, based on location or previous commands.
  • 0x0-upload-text will upload the active region or if not existent the entire buffer
  • 0x0-upload-file will upload a selected file
  • 0x0-upload-kill-ring uploads the content of the kill ring
  • 0x0-popup creates and displays a buffer, lets you upload its contents later
  • 0x0-shorten-uri prompts for a uri, shortens it

Installation

MELPA

This project is on MELPA as 0x0.

Doom Emacs (straight.el recipe + use-package)

With doom and straight it is easy to install the package directly from this gitlab repository. In .doom.d/packages.el:

(package! 0x0
  :recipe (:host gitlab :repo "willvaughn/emacs-0x0"))

The minimal config to get started in your .doom.d/config.el is:

(use-package! 0x0)

Basic Usage

Use cases:

  • From anywhere: 0x0-upload-file, pick a file, you now have a 0x0 uri in your clipboard.
  • From anywhere: 0x0-shorten-uri, paste in the url you want shortened, you now have a 0x0 uri in your clipboard.
  • From a dired buffer: put your cursor on the file you want to share, use 0x0-upload-file or 0x0-dwim, you now have a 0x0 uri in your clipboard.
  • From a file: 0x0-upload-text or 0x0-dwim, the entire file is uploaded and you now have a 0x0 uri in your clipboard.
  • From a code file, with a region selected: 0x0-upload-text or 0x0-dwim, the selected text is uploaded and you now have a 0x0 uri in your clipboard.
  • From anywhere: 0x0-popup, opens a buffer, paste and write things into it, when you’re ready to upload it to 0x0 press C-c C-c, you now have a 0x0 uri in your clipboard.
  • Choosing servers: Add the C-u prefix argument and you’ll be prompted for a server choice. This lets you upload to https://envs.sh, https://ttm.sh, or a server you run yourself.

Known Bugs & Limitations

Multibyte Files (PNG, PDF, etc) Only Work With curl

If you have (setq 0x0-use-curl nil) you will fall back to the url package in emacs. You will not be able to upload an image, pdf, or any other type of file that contains multibyte data. If someone knows how to use the url in a way that makes this work, please contribute a patch.

URI Shortening Only Works With curl

Calling 0x0-shorten-uri without having support for curl is not implemented at this time. It throws an error if you don’t have curl installed, or if you have (setq 0x0-use-curl nil).

0x0-dwim Considered Dangerous

You can easily upload information you didn’t intend to when using 0x0-dwim. This command will attempt to guess your intentions, and it uses the Find File at Point (ffap) library in emacs to do so. In the past it could guess wrong, as in the following example. Now there is a yes/no prompt to confirm any selection made by ffap matches with the user’s intention.

Example: You highlighted and copied the following code using evil-yank and then hit M-x 0x0-dwim intending to upload it to 0x0.st from your Emacs kill-ring.

;;;###autoload
(defun my-fun-fun (a)
  (+ 2 a))

However, after yanking your cursor was on top of the word autoload! You didn’t just upload your yanked text, for some reason you just got prompted to upload an autoload.el file from somewhere on your system. When 0x0-dwim prompts you, read carefully. If you say no, no further action will be taken.

Help on IRC

Join the #systemcrafters channel on libera.chat and message nackjicholson. You can also query me directly on libera.

Licensing and Copying Information

This project was originally written by Philip Kaludercic here https://git.sr.ht/~pkal/nullpointer-emacs. It was put under the Creative Commons CC0 Public Domain License which offers the work with no conditions. It is now under the GPLv3 (as described by the COPYING file). This aligns the project with many packages in the Emacs ecosystem, MELPA, and ELPA.

emacs-0x0 – 0x0.el Upload to 0x0.st

Copyright (C) 2021 William Vaughn

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.