unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [ELPA] New package: shorten-url
@ 2019-03-01 12:21 Nicolas Rybkin
  2019-03-02  3:30 ` Amin Bandali
  2019-03-02  3:34 ` Richard Stallman
  0 siblings, 2 replies; 13+ messages in thread
From: Nicolas Rybkin @ 2019-03-01 12:21 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 4071 bytes --]

* SENT IT ON FEB 26 FROM ibmbull@yandex.ru, BUT GOT NO RESPNSE SO FAR.
MAYBE YOUR SPAM FILTER FILTERS OUT ALL MAIL COMING FROM yandex.ru SERVER? *

shorten-url allows you to insert a shortened alternative for a given URL.
Can be useful for chatting.

;;; shorten-url.el --- URL shortener         -*- lexical-binding: t; -*-

;; Copyright (C) 2019 Bad Blue Bull

;; Author: Bad Blue Bull <ibmbull@yandex.ru <bad_blue_bull@yandex.ru>>
;; Keywords: irc, icq

;; Version: 1.0

;; 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/>.

;;; Commentary:

;; shorten-url allows you to insert a shortened alternative for a given
;; URL.  Can be useful for chatting.
;;
;; A request for a URL produced by concatenation of shorten-url-base
;; with a URL passed as an argument is fulfilled and data from HTTP
;; response gets inserted into current buffer.
;;
;; At the moment of this release TIMEOUT optional variable of
;; url-retrieve-synchronously may break execution of this function
;; (bug  #34607), so it's unused.
;;
;; Also url-retrieve-synchronously takes long time to retrieve a URL
;; that hasn't been retrieved before in some interval of time in same
;; Emacs session (bug #34652).

;; Configuration:

;; You can customize shorten-url-base to use diffirent URL shortener web
;; service.

;; Usage:

;; Call shorten-url from Lisp or execute it as command with URL you want
;; to shorten passed as an argument.
;;
;; Example:
;;
;; M-x shorten-url https://debbugs.gnu.org/cgi/bugreport.cgi?bug=34607
;;
;; result inserted: https://qps.ru/MjrtW
;;
;; For convenient usage bind a key sequence so that it will insert
;; shortened version of URL stored in kill ring.
;; Here is example how you can bind C-c C-y key sequence so that when it
;; is used in ERC it inserts a shortened URL corresponding to element of
;; kill ring that the yank command would insert:
;;
;; (add-hook 'erc-mode-hook (lambda ()
;;                (local-set-key (kbd "C-c C-y")
;;                       (lambda (&optional arg)
;;                         (interactive "*P")
;;                         (shorten-url (current-kill
;;                               (cond
;;                                ((listp arg)
;;                                 0)
;;                                ((eq arg '-)
;;                                 -2)
;;                                (t
;;                                 (1- arg)))
;;                               ))))))

;;; Code:

(provide 'shorten-url)

(defcustom shorten-url-base "https://qps.ru/api?url="
  "base for URL shortener.
short-url will concatenate it with URL passed as argument"
  :type '(choice (const :tag "https://qps.ru/api?url="
            "https://qps.ru/api?url=")
         (const :tag "https://clck.ru/--?url="
            "https://clck.ru/--?url=")
         (string :tag "custom" "")))

(defun shorten-url (url)
  "Insert shortened URL (passed as argument).
Contact a URL produced by concatenation shorten-url-base and the
argument and insert data from response from the server into current
buffer."
       (interactive "sURL to shorten: ")
       (insert (with-current-buffer
           (url-retrieve-synchronously
            (concat shorten-url-base url) nil 't)
         (goto-char (point-min))
         (search-forward "\n\n" nil 't)
         (unwind-protect
             (buffer-substring (point) (point-max))
           (kill-buffer (current-buffer)))))
       (message "inserted shortened URL for %s" url))

;;; shorten-url.el ends here

[-- Attachment #2: Type: text/html, Size: 6235 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread
* [ELPA] New package: shorten-url
@ 2019-02-25 21:15 Bad Blue Bull
  0 siblings, 0 replies; 13+ messages in thread
From: Bad Blue Bull @ 2019-02-25 21:15 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/html, Size: 4967 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-03-04  6:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-01 12:21 [ELPA] New package: shorten-url Nicolas Rybkin
2019-03-02  3:30 ` Amin Bandali
2019-03-02  3:34 ` Richard Stallman
2019-03-02 11:52   ` Nicolas Rybkin
2019-03-03  3:00     ` Richard Stallman
2019-03-03 14:36       ` Nicolas Rybkin
2019-03-04  3:27         ` Richard Stallman
2019-03-04  6:52           ` Nicolas Rybkin
2019-03-02 13:37   ` Yuri Khan
2019-03-02 16:05     ` Nicolas Rybkin
2019-03-02 17:37       ` Yuri Khan
2019-03-03  2:46         ` Van L
  -- strict thread matches above, loose matches on Subject: below --
2019-02-25 21:15 Bad Blue Bull

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).