omglol-pastebin.el

An Emacs package for integrating with the omg.lol pastebin service. Create, retrieve, list, and delete pastes directly from Emacs with full API integration.

Features

  • Create/Update Pastes: From selected text, regions, or entire buffers
  • Retrieve Pastes: View existing pastes in dedicated buffers
  • List All Pastes: Browse all your pastes with previews and timestamps
  • Delete Pastes: Remove pastes with confirmation prompts
  • Configurable Settings: Customize API credentials, timeouts, and behavior
  • Interactive Setup: Easy configuration wizard
  • Error Handling: Comprehensive error reporting and user feedback
  • Keyboard Shortcuts: Convenient key bindings for all operations

Installation

Manual Installation

  1. Download omglol-pastebin.el and place it in your Emacs load path
  2. Add to your Emacs configuration:
(require 'omglol-pastebin)

Configuration

Before using the package, you need to configure your omg.lol credentials:

Interactive Setup (Recommended)

Run the interactive setup command:

M-x omglol-pastebin-setup

Manual Configuration

Add the following to your Emacs configuration:

(setq omglol-pastebin-address "your-address")      ; Your omg.lol address (without @)
(setq omglol-pastebin-api-token "your-api-token")  ; Your API token from https://home.omg.lol/account/api

Optional Configuration

;; Customize base URL (usually not needed)
(setq omglol-pastebin-base-url "https://api.omg.lol")

;; Set request timeout (default: 30 seconds)
(setq omglol-pastebin-timeout 30)

;; Show URL after creating paste (default: t)
(setq omglol-pastebin-show-url-after-create t)

Usage

Interactive Commands

Command Description
M-x omglol-pastebin-create Create paste from region or buffer
M-x omglol-pastebin-create-from-buffer Create paste from entire buffer
M-x omglol-pastebin-create-from-region Create paste from selected region
M-x omglol-pastebin-get Retrieve and view a specific paste
M-x omglol-pastebin-list List all your pastes with previews
M-x omglol-pastebin-delete Delete a paste (with confirmation)
M-x omglol-pastebin-setup Configure credentials interactively

Key Bindings

Enable the minor mode to access convenient key bindings:

(omglol-pastebin-mode 1)
Key Binding Command
C-c p c Create paste
C-c p b Create from buffer
C-c p r Create from region
C-c p g Get paste
C-c p l List pastes
C-c p d Delete paste
C-c p s Setup/configure

Global Key Bindings

To enable the key bindings globally:

(omglol-pastebin-enable-globally)

API Integration

The package implements all four core omg.lol pastebin API endpoints:

  • POST /address/:address/pastebin/ - Create or update pastes
  • GET /address/:address/pastebin/:paste - Retrieve specific paste
  • GET /address/:address/pastebin - List all pastes
  • DELETE /address/:address/pastebin/:paste - Delete paste

Authentication is handled automatically using your configured API token.

Examples

Basic Usage

;; Create a paste from selected text
(omglol-pastebin-create "my-code-snippet" "console.log('Hello World');")

;; Retrieve a paste
(omglol-pastebin-get "my-code-snippet")

;; List all pastes  
(omglol-pastebin-list)

;; Delete a paste
(omglol-pastebin-delete "my-code-snippet")

Workflow Examples

  1. Share Code Snippets:

    • Select code in your buffer
    • Run M-x omglol-pastebin-create-from-region
    • Enter a title when prompted
    • The paste URL is automatically copied to your clipboard
  2. Backup Buffer Content:

    • Run M-x omglol-pastebin-create-from-buffer
    • Enter a descriptive title
    • Your entire buffer is saved as a paste
  3. Browse Your Pastes:

    • Run M-x omglol-pastebin-list
    • View all pastes with timestamps and previews
    • Use the paste names with omglol-pastebin-get to view full content

Error Handling

The package includes comprehensive error handling:

  • Configuration Errors: Clear messages when API token or address is missing
  • Network Errors: Timeout handling and connection error reporting
  • API Errors: Detailed error messages from the omg.lol API
  • User Input Validation: Proper validation of paste names and content

Requirements

  • Emacs: Version 26.1 or later
  • Dependencies: Built-in packages only (url, json)
  • omg.lol Account: Required for API access
  • API Token: Available from your omg.lol account settings

API Reference

Based on the official omg.lol API documentation:

Authentication

  • Uses Bearer token authentication
  • Token required for create, update, and delete operations
  • Public read access available for individual pastes

Endpoints

  • Base URL: https://api.omg.lol
  • All requests use JSON format
  • Standard HTTP status codes for responses

Troubleshooting

Common Issues

  1. "API token is not set" error:

    • Run M-x omglol-pastebin-setup to configure credentials
    • Or manually set omglol-pastebin-api-token
  2. "Address is not set" error:

    • Run M-x omglol-pastebin-setup to configure credentials
    • Or manually set omglol-pastebin-address
  3. HTTP timeout errors:

    • Check internet connection
    • Increase omglol-pastebin-timeout value
    • Verify omg.lol service status
  4. "Paste not found" errors:

    • Verify paste name spelling
    • Check if paste was deleted
    • Ensure you're using the correct address

Debug Mode

Enable debug mode for detailed HTTP request logging:

(setq url-debug t)

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

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.

Changelog

Version 1.0.0

  • Initial release
  • Full API integration (create, retrieve, list, delete)
  • Interactive commands and key bindings
  • Configuration system with setup wizard
  • Comprehensive error handling
  • Documentation and examples