Commit be9b8b56 authored by La Fée Verte's avatar La Fée Verte
Browse files

Adding latest settings

parent 2442fe83
......@@ -3,3 +3,8 @@ session.1010a9ea0a4000142126951800000008710038
.emacs.desktop
.emacs.desktop.lock
tramp
"#!*#"
session.*
auto-save-list
network-security.data
transient/
This global minor mode provides a simple way to switch between layouts and
the buffers you left open before you switched (unless you closed it).
It doesn't require any setup at all more than:
(0blayout-mode)
When you start Emacs with 0blayout loaded, you will have a default layout
named "default", and then you can create new layouts (<prefix> C-c), switch
layouts (<prefix> C-b), and kill the current layout (<prefix> C-k).
The default <prefix> is (C-c C-l), but you can change it using:
(0blayout-add-keybindings-with-prefix "<your prefix>")
You can also customize-variable to change the name of the default session.
The project is hosted at https://github.com/etu/0blayout
There you can leave bug-reports and suggestions.
Another comparable mode is eyebrowse which have been developed for longer.
;;; 0x0-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "0x0" "0x0.el" (0 0 0 0))
;;; Generated autoloads from 0x0.el
(autoload '0x0-upload "0x0" "\
Upload current buffer to `0x0-url' from START to END.
If START and END are not specified, upload entire buffer.
\(fn START END SERVICE)" t nil)
(autoload '0x0-upload-file "0x0" "\
Upload FILE to `0x0-url'.
\(fn FILE SERVICE)" t nil)
(autoload '0x0-upload-string "0x0" "\
Upload STRING to `0x0-url'.
\(fn STRING SERVICE)" t nil)
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "0x0" '("0x0-")))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; 0x0-autoloads.el ends here
;;; -*- no-byte-compile: t -*-
(define-package "0x0" "20200220.1853" "Upload to 0x0.st" '((emacs "24.1")) :commit "ae55ae0397ff3cf28a3ea52111bfc053dffb126d" :keywords '("comm") :authors '(("Philip K." . "philip@warpmail.net")) :maintainer '("Philip K." . "philip@warpmail.net") :url "https://git.sr.ht/~zge/nullpointer-emacs")
;;; 0x0.el --- Upload to 0x0.st -*- lexical-binding: t -*-
;; Author: Philip K. <philip@warpmail.net>
;; Version: 0.2.0
;; Package-Version: 20200220.1853
;; Keywords: comm
;; Package-Requires: ((emacs "24.1"))
;; URL: https://git.sr.ht/~zge/nullpointer-emacs
;; This file is NOT part of Emacs.
;;
;; This file is in the public domain, to the extent possible under law,
;; published under the CC0 1.0 Universal license.
;;
;; For a full copy of the CC0 license see
;; https://creativecommons.org/publicdomain/zero/1.0/legalcode
;;; Commentary:
;;
;; This package defines three main functions: `0x0-upload',
;; `0x0-upload-file' and `0x0-upload-string', which respectively upload
;; (parts of) the current buffer, a file on your disk and a string from
;; the minibuffer to a 0x0.st-like or pomf-lie servers.
(require 'url)
(require 'json)
(require 'ert)
;;; Code:
(defgroup 0x0 nil
"Upload data to 0x0.st-compatible servers."
:group 'convenience
:prefix "0x0-")
(defcustom 0x0-services
`((0x0
:host "0x0.st"
:query "file"
:min-age 30
:max-age 365
:max-size ,(* 1024 1024 512))
(ttm
:host "ttm.sh"
:query "file"
:min-age 30
:max-age 365
:max-size ,(* 1024 1024 256))
(ix
:host "ix.io"
:query "f:1"
:no-tls t)
(w1r3
:host "w1r3.net"
:query "upload")
(sprunge
:host "sprunge.us"
:query "sprunge"
:no-tls t)
(sprunge
:host "sprunge.us"
:query "sprunge"
:no-tls t)
(you-die-if-you-work
:host "youdieifyou.work"
:path "upload.php"
:query "files[]"
:pomf t
:no-tls t)
(fiery
:host "safe.fiery.me"
:path "api/upload"
:query "files[]"
:pomf t)
(dmca-gripe
:host "dmca.gripe"
:path "api/upload"
:query "files[]"
:pomf t)
(uguu
:host "uguu.se"
:path "api.php?d=upload-tool"
:query "file"
:min-age 1
:max-age 1
:max-size ,(* 1024 1024 100)))
"Alist of different 0x0-like services.
The car is a symbol identifying the service, the cdr a plist,
with the following keys:
:host - domain name of the server (string, necessary)
:path - server path to send POST request to (string,
optional)
:no-tls - is tls not supported (bool, nil by default)
:query - query string used for file upload (string,
necessary)
:min-age - on 0x0-like servers, minimal number of days
a file is kept online (number, optional)
:max-age - on 0x0-like servers, maximal number of days
a file is kept online (number, optional)
:max-size - file limit for this server (number, optional)
:pomf - is pomf clone (bool, optional)
This variable only describes servers, but doesn't set anything.
See `0x0-default-host' if you want to change the server you use."
:type '(alist :key-type symbol
:value-type (plist :value-type sexp)))
(defcustom 0x0-default-service '0x0
"Symbol describing server to use.
The symbol must be a key from the alist `0x0-services'."
:type `(choice ,@(mapcar #'car 0x0-services)))
(defcustom 0x0-use-curl-if-installed t
"Automatically check if curl is installed."
:type 'boolean)
(defvar 0x0--filename)
(defvar 0x0--use-file nil)
(defvar 0x0--server)
(defvar 0x0--current-host)
(defun 0x0--calculate-timeout (size)
"Calculate days a file of size SIZE would last."
(condition-case nil
(let ((min-age (float (plist-get 0x0--server :min-age)))
(max-age (float (plist-get 0x0--server :max-age)))
(max-size (float (plist-get 0x0--server :max-size))))
(+ min-age (* (- min-age max-age)
(expt (- (/ size max-size) 1.0) 3))))
(wrong-type-argument nil)))
(defun 0x0--use-curl (start end)
"Backend function for uploading using curl.
Operate on region between START and END."
(let ((buf (generate-new-buffer (format " *%s response*" 0x0--current-host))))
(call-process-region start end "curl"
nil buf nil
"-s" "-S" "-F"
(format (if 0x0--use-file
"%s=@%s"
"%s=@-;filename=%s")
(plist-get 0x0--server :query)
0x0--filename)
(format "%s://%s/%s"
(if (plist-get 0x0--server :no-tls)
"http" "https")
(plist-get 0x0--server :host)
(or (plist-get 0x0--server :path) "")))
buf))
(defun 0x0--use-url (start end)
"Backend function for uploading using `url' functions.
Operate on region between START and END."
(let* ((boundary (format "%X-%X-%X" (random) (random) (random)))
(url-request-extra-headers
`(("Content-Type" . ,(concat "multipart/form-data; boundary=" boundary))))
(url-request-data
(let ((source (current-buffer))
(filename (if (boundp '0x0--filename)
0x0--filename
(buffer-name))))
(with-temp-buffer
(insert "--" boundary "\r\n")
(insert "Content-Disposition: form-data; ")
(insert "name=\"" (plist-get 0x0--server :query)
"\"; filename=\"" filename "\"\r\n")
(insert "Content-type: text/plain\r\n\r\n")
(insert-buffer-substring-no-properties source start end)
(insert "\r\n--" boundary "--")
(buffer-string))))
(url-request-method "POST"))
(with-current-buffer
(url-retrieve-synchronously
(concat (if (plist-get 0x0--server :no-tls)
"http" "https")
"://" (plist-get 0x0--server :host)
"/" (or (plist-get 0x0--server :path) "")))
(rename-buffer (format " *%s response*" 0x0--current-host) t)
(goto-char (point-min))
(save-match-data
(when (search-forward-regexp "^[[:space:]]*$" nil t)
(delete-region (point-min) (match-end 0))))
(current-buffer))))
(defun 0x0--choose-service ()
(if current-prefix-arg
(intern (completing-read "Service: "
(mapcar #'car 0x0-services)
nil t nil nil
0x0-default-service))
0x0-default-service))
(defun 0x0--parse-plain ()
(save-match-data
(unless (search-forward-regexp "^https?://.*$" nil t)
(error "Failed to upload/parse. See %s for more details"
(buffer-name)))
(match-string 0)))
(defun 0x0--parse-pomf ()
(let ((data (json-read)))
(unless data
(error "Empty response. See %s for more details"
(buffer-name)))
(unless (eq t (cdr (assq 'success data)))
(error "Failed to upload (%d): \"%s\""
(cdr (assq 'errorcode data))
(cdr (assq 'description data))))
(cdr (assq 'url (aref (cdr (assq 'files data)) 0)))))
;;;###autoload
(defun 0x0-upload (start end service)
"Upload current buffer to `0x0-url' from START to END.
If START and END are not specified, upload entire buffer."
(interactive (list (if (use-region-p) (region-beginning) (point-min))
(if (use-region-p) (region-end) (point-max))
(0x0--choose-service)))
(let ((0x0--current-host service)
(0x0--server (cdr (assq service 0x0-services)))
(0x0--filename (if (bound-and-true-p 0x0--filename)
0x0--filename (buffer-name))))
(unless 0x0--server
(error "Service %s unknown." service))
(unless (plist-get 0x0--server :host)
(error "Service %s has no :host field" service))
(unless (plist-get 0x0--server :query)
(error "Service %s has no :query field" service))
(let ((resp (if (and 0x0-use-curl-if-installed
(executable-find "curl"))
(0x0--use-curl start end)
(0x0--use-url start end)))
(timeout (0x0--calculate-timeout (- end start))))
(with-current-buffer resp
(goto-char (point-min))
(let ((result (cond ((plist-get 0x0--server :pomf)
(0x0--parse-pomf))
(t (0x0--parse-plain)))))
(kill-new result)
(message (concat (format "Yanked `%s' into kill ring." result)
(and timeout (format " Should last ~%g days." timeout))))
(kill-buffer resp)
result)))))
;;;###autoload
(defun 0x0-upload-file (file service)
"Upload FILE to `0x0-url'."
(interactive (list (read-file-name "Upload file: ")
(0x0--choose-service)))
(with-temp-buffer
(unless 0x0-use-curl-if-installed
(insert-file-contents file))
(let ((0x0--filename file)
(0x0--use-file t))
(0x0-upload (point-min) (point-max) service))))
;;;###autoload
(defun 0x0-upload-string (string service)
"Upload STRING to `0x0-url'."
(interactive (list (read-string "Upload string: ")
(0x0--choose-service)))
(with-temp-buffer
(insert string)
(let ((0x0--filename "upload.txt"))
(0x0-upload (point-min) (point-max) service))))
(defun 0x0--test-service (service)
(let ((rand (make-string 256 0)))
(dotimes (i (length rand))
(setf (aref rand i) (+ ?a (random (- ?z ?a)))))
(let* ((resp (0x0-upload-string rand service))
result)
(with-current-buffer (url-retrieve-synchronously resp)
(goto-char (point-min))
(forward-paragraph)
(delete-region (point-min) (1+ (point)))
(setq result (buffer-string)))
(should (or (equal rand result)
(save-match-data
(and (string-match "[[:space:]]*\\'" result)
(replace-match "" nil nil result))))))))
(dolist (service (mapcar #'car 0x0-services))
(let ((name (intern (format "0x0-test-%s" (symbol-name service))))
(name* (intern (format "0x0-test-%s-curl" (symbol-name service)))))
(eval `(ert-deftest ,name ()
(let ((0x0-use-curl-if-installed nil))
(0x0--test-service ',service))))
(eval `(ert-deftest ,name* ()
(let ((0x0-use-curl-if-installed t))
(0x0--test-service ',service))))))
(provide '0x0)
;;; 0x0.el ends here
To open a specific problem, use `4clojure-open-question':
e.g. "M-x 4clojure-open-question RET 2" opens question 2.
To check your answers, use `4clojure-check-answers':
e.g. `M-x 4clojure-check-answers`
To open the next question (or the first if you’re not in a 4clojure
buffer), use `4clojure-next-question'. Similarly,
`4clojure-previous-question' opens the previous question.
;;; a-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name
(or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "a" "a.el" (0 0 0 0))
;;; Generated autoloads from a.el
(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "a" '("a-")))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; coding: utf-8
;; End:
;;; a-autoloads.el ends here
;;; -*- no-byte-compile: t -*-
(define-package "a" "20180907.953" "Associative data structure functions" '((emacs "25")) :commit "18966975db7110d0aac726be95b593e2fc3d44ed" :keywords '("lisp") :authors '(("Arne Brasseur" . "arne@arnebrasseur.net")) :maintainer '("Arne Brasseur" . "arne@arnebrasseur.net") :url "https://github.com/plexus/a.el")
;;; a.el --- Associative data structure functions -*- lexical-binding: t; -*-
;; Copyright (C) 2017 Arne Brasseur
;; Author: Arne Brasseur <arne@arnebrasseur.net>
;; URL: https://github.com/plexus/a.el
;; Package-Version: 20180907.953
;; Keywords: lisp
;; Version: 0.1.1
;; Package-Requires: ((emacs "25"))
;; This file is not part of GNU Emacs.
;; This file 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, or (at your option)
;; any later version.
;; This file 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 GNU Emacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Library for dealing with associative data structures: alists, hash-maps, and
;; vectors (for vectors, the indices are treated as keys).
;;
;; This library is largely inspired by Clojure, it has many of the functions
;; found in clojure.core, prefixed with `a-'. All functions treat their
;; arguments as immutable, so e.g. `a-assoc' will clone the hash-table or alist
;; it is given. Keep this in mind when writing performance sensitive code.
;;; Code:
(eval-when-compile (require 'subr-x)) ;; for things like hash-table-keys
(require 'cl-lib)
(require 'seq)
(defun a-associative-p (obj)
(or (not obj)
(hash-table-p obj)
(and (consp obj) (consp (car obj)))))
(defalias 'a-associative? 'a-associative-p)
(defun a-get (map key &optional not-found)
"Return the value MAP mapped to KEY, NOT-FOUND or nil if key not present."
(cond
;; own implementation instead of alist-get so keys are checked with equal
;; instead of eq
((listp map)
(a--alist-get map key not-found))
((vectorp map)
(if (a-has-key? map key)
(aref map key)
not-found))
((hash-table-p map)
(gethash key map not-found))
(t (user-error "Not associative: %S" map))))
(defun a--alist-get (map key &optional not-found)
"Like alist-get, but uses equal instead of eq to look up in map MAP key KEY.
Returns NOT-FOUND if the key is not present, or `nil' if
NOT-FOUND is not specified."
(cl-block nil
(seq-doseq (pair map)
(when (equal (car pair) key)
(cl-return (cdr pair))))
not-found))
(defun a-get-in (m ks &optional not-found)
"Look up a value in a nested associative structure.
Given a data structure M, and a sequence of keys KS, find the
value found by using each key in turn to do a lookup in the next
\"layer\". Return `nil' if the key is not present, or the NOT-FOUND
value if supplied."
(let ((result m))
(cl-block nil
(seq-doseq (k ks)
(if (a-has-key? result k)
(setq result (a-get result k))
(cl-return not-found)))
result)))
(defmacro a-get* (&rest keys)
"Look up a value in a nested associative structure.
Like a-get-in, but takes the key sequence KEYS directly as vararg
arguments, rather than as a single sequence."
(cl-labels ((rec (keys)
`(a-get ,(if (and (consp (cdr keys))
(cddr keys))
(rec (cdr keys))
(cadr keys))
,(car keys))))
(rec (nreverse keys))))
(defun a-has-key (coll k)
"Check if the given associative collection COLL has a certain key K."
(cond
((listp coll) (not (eq (a--alist-get coll k :not-found) :not-found)))
((vectorp coll) (and (integerp k) (< -1 k (length coll))))
((hash-table-p coll) (not (eq (gethash k coll :not-found) :not-found)))
(t (user-error "Not associative: %S" coll))))
(defalias 'a-has-key? 'a-has-key)
(defun a-assoc-1 (coll k v)
"Like `a-assoc', (in COLL assoc K with V) but only takes a single k-v pair.
Internal helper function."
(cond
((listp coll)
(if (a-has-key? coll k)
(mapcar (lambda (entry)
(if (equal (car entry) k)
(cons k v)
entry))
coll)
(cons (cons k v) coll)))
((vectorp coll)
(if (and (integerp k) (> k 0))
(if (< k (length coll))
(let ((copy (copy-sequence coll)))
(aset copy k v)
copy)
(vconcat coll (make-list (- k (length coll)) nil) (list v)))))
((hash-table-p coll)
(let ((copy (copy-hash-table coll)))
(puthash k v copy)
copy))))
(defun a-assoc (coll &rest kvs)
"Return an updated collection COLL, associating values with keys KVS."
(when (not (cl-evenp (a-count kvs)))
(user-error "a-assoc requires an even number of arguments!"))
(seq-reduce (lambda (coll kv)
(seq-let [k v] kv
(a-assoc-1 coll k v)))
(seq-partition kvs 2)
coll))
(defun a-keys (coll)
"Return the keys in the collection COLL."
(cond
((listp coll)
(mapcar #'car coll))
((hash-table-p coll)
(hash-table-keys coll))))
(defun a-vals (coll)
"Return the values in the collection COLL."
(cond
((listp coll)
(mapcar #'cdr coll))
((hash-table-p coll)
(hash-table-values coll))))
(defun a-reduce-kv (fn from coll)
"Reduce with FN starting from FROM the collection COLL.
Reduce an associative collection COLL, starting with an initial
value of FROM. The reducing function FN receives the intermediate
value, key, and value."
(seq-reduce (lambda (acc key)
(funcall fn acc key (a-get coll key)))
(a-keys coll)
from))
(defun a-count (coll)
"Count the number of key-value pairs in COLL.
Like length, but can also return the length of hash tables."
(cond
((seqp coll)
(length coll))
((hash-table-p coll)
(hash-table-count coll))))
(defun a-equal (a b)
"Compare collections A, B for value equality.
Associative collections (hash tables and a-lists) are considered
equal if they contain equal key-value pairs, regardless of order.
Sequences (lists or vectors) are considered equal if they contain