diff --git a/org/elpa/alert-20221213.1619/alert-autoloads.el b/org/elpa/alert-20221213.1619/alert-autoloads.el new file mode 100644 index 0000000..7192db9 --- /dev/null +++ b/org/elpa/alert-20221213.1619/alert-autoloads.el @@ -0,0 +1,102 @@ +;;; alert-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "alert" "alert.el" (0 0 0 0)) +;;; Generated autoloads from alert.el + +(autoload 'alert-add-rule "alert" "\ +Programmatically add an alert configuration rule. + +Normally, users should custoimze `alert-user-configuration'. +This facility is for module writers and users that need to do +things the Lisp way. + +Here is a rule the author currently uses with ERC, so that the +fringe gets colored whenever people chat on BitlBee: + +\(alert-add-rule :status \\='(buried visible idle) + :severity \\='(moderate high urgent) + :mode \\='erc-mode + :predicate + #\\='(lambda (info) + (string-match (concat \"\\\\`[^&].*@BitlBee\\\\\\='\") + (erc-format-target-and/or-network))) + :persistent + #\\='(lambda (info) + ;; If the buffer is buried, or the user has been + ;; idle for `alert-reveal-idle-time' seconds, + ;; make this alert persistent. Normally, alerts + ;; become persistent after + ;; `alert-persist-idle-time' seconds. + (memq (plist-get info :status) \\='(buried idle))) + :style \\='fringe + :continue t) + +\(fn &key SEVERITY STATUS MODE CATEGORY TITLE MESSAGE PREDICATE ICON (STYLE alert-default-style) PERSISTENT CONTINUE NEVER-PERSIST APPEND)" nil nil) + +(autoload 'alert "alert" "\ +Alert the user that something has happened. +MESSAGE is what the user will see. You may also use keyword +arguments to specify additional details. Here is a full example: + +\(alert \"This is a message\" + :severity \\='high ;; The default severity is `normal' + :title \"Title\" ;; An optional title + :category \\='example ;; A symbol to identify the message + :mode \\='text-mode ;; Normally determined automatically + :buffer (current-buffer) ;; This is the default + :data nil ;; Unused by alert.el itself + :persistent nil ;; Force the alert to be persistent; + ;; it is best not to use this + :never-persist nil ;; Force this alert to never persist + :id \\='my-id) ;; Used to replace previous message of + ;; the same id in styles that support it + :style \\='fringe) ;; Force a given style to be used; + ;; this is only for debugging! + :icon \\=\"mail-message-new\" ;; if style supports icon then add icon + ;; name or path here + +If no :title is given, the buffer-name of :buffer is used. If +:buffer is nil, it is the current buffer at the point of call. + +:data is an opaque value which modules can pass through to their +own styles if they wish. + +Here are some more typical examples of usage: + + ;; This is the most basic form usage + (alert \"This is an alert\") + + ;; You can adjust the severity for more important messages + (alert \"This is an alert\" :severity \\='high) + + ;; Or decrease it for purely informative ones + (alert \"This is an alert\" :severity \\='trivial) + + ;; Alerts can have optional titles. Otherwise, the title is the + ;; buffer-name of the (current-buffer) where the alert originated. + (alert \"This is an alert\" :title \"My Alert\") + + ;; Further, alerts can have categories. This allows users to + ;; selectively filter on them. + (alert \"This is an alert\" :title \"My Alert\" + :category \\='some-category-or-other) + +\(fn MESSAGE &key (SEVERITY \\='normal) TITLE ICON CATEGORY BUFFER MODE DATA STYLE PERSISTENT NEVER-PERSIST ID)" nil nil) + +(register-definition-prefixes "alert" '("alert-" "x-urgen")) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; alert-autoloads.el ends here diff --git a/org/elpa/alert-20221213.1619/alert-pkg.el b/org/elpa/alert-20221213.1619/alert-pkg.el new file mode 100644 index 0000000..630f591 --- /dev/null +++ b/org/elpa/alert-20221213.1619/alert-pkg.el @@ -0,0 +1,2 @@ +;;; Generated package description from alert.el -*- no-byte-compile: t -*- +(define-package "alert" "20221213.1619" "Growl-style notification system for Emacs" '((gntp "0.1") (log4e "0.3.0") (cl-lib "0.5")) :commit "c762380ff71c429faf47552a83605b2578656380" :authors '(("John Wiegley" . "jwiegley@gmail.com")) :maintainer '("John Wiegley" . "jwiegley@gmail.com") :keywords '("notification" "emacs" "message") :url "https://github.com/jwiegley/alert") diff --git a/org/elpa/alert-20221213.1619/alert.el b/org/elpa/alert-20221213.1619/alert.el new file mode 100644 index 0000000..51af988 --- /dev/null +++ b/org/elpa/alert-20221213.1619/alert.el @@ -0,0 +1,1221 @@ +;;; alert.el --- Growl-style notification system for Emacs -*- lexical-binding: t; -*- + +;; Copyright (C) 2011-2013 John Wiegley + +;; Author: John Wiegley +;; Created: 24 Aug 2011 +;; Updated: 16 Mar 2015 +;; Version: 1.2 +;; Package-Version: 20221213.1619 +;; Package-Commit: c762380ff71c429faf47552a83605b2578656380 +;; Package-Requires: ((gntp "0.1") (log4e "0.3.0") (cl-lib "0.5")) +;; Keywords: notification emacs message +;; X-URL: https://github.com/jwiegley/alert + +;; 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 2, 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 GNU Emacs; see the file COPYING. If not, write to the +;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Commentary: + +;; Alert is a Growl-workalike for Emacs which uses a common notification +;; interface and multiple, selectable "styles", whose use is fully +;; customizable by the user. +;; +;; * For module writers +;; +;; Just use `alert' instead of `message' as follows: +;; +;; (require 'alert) +;; +;; ;; This is the most basic form usage +;; (alert "This is an alert") +;; +;; ;; You can adjust the severity for more important messages +;; (alert "This is an alert" :severity 'high) +;; +;; ;; Or decrease it for purely informative ones +;; (alert "This is an alert" :severity 'trivial) +;; +;; ;; Alerts can have optional titles. Otherwise, the title is the +;; ;; buffer-name of the (current-buffer) where the alert originated. +;; (alert "This is an alert" :title "My Alert") +;; +;; ;; Further, alerts can have categories. This allows users to +;; ;; selectively filter on them. +;; (alert "This is an alert" :title "My Alert" :category 'debug) +;; +;; * For users +;; +;; For the user, there are several variables to control when and how alerts +;; are presented. By default, they appear in the minibuffer much the same +;; as a normal Emacs message. But there are many more possibilities: +;; +;; `alert-fade-time' +;; Normally alerts disappear after this many seconds, if the style +;; supports it. The default is 5 seconds. +;; +;; `alert-default-style' +;; Pick the style to use if no other config rule matches. The +;; default is `message', but `growl' works well too. +;; +;; `alert-reveal-idle-time' +;; If a config rule choose to match on `idle', this is how many +;; seconds idle the user has to be. Defaults to 5 so that users +;; don't miss any alerts, but 120 is also good. +;; +;; `alert-persist-idle-time' +;; After this many idle seconds, alerts will become sticky, and not +;; fade away more. The default is 15 minutes. +;; +;; `alert-log-messages' +;; By default, all alerts are logged to *Alerts* (and to *Messages*, +;; if the `message' style is being used). Set to nil to disable. +;; +;; `alert-hide-all-notifications' +;; Want alerts off entirely? They still get logged, however, unless +;; you've turned that off too. +;; +;; `alert-user-configuration' +;; This variable lets you control exactly how and when a particular +;; alert, a class of alerts, or all alerts, get reported -- or if at +;; all. Use this to make some alerts use Growl, while others are +;; completely silent. +;; +;; * Programmatically adding rules +;; +;; Users can also programmatically add configuration rules, in addition to +;; customizing `alert-user-configuration'. Here is one that the author +;; currently uses with ERC, so that the fringe gets colored whenever people +;; chat on BitlBee: +;; +;; (alert-add-rule :status '(buried visible idle) +;; :severity '(moderate high urgent) +;; :mode 'erc-mode +;; :predicate +;; #'(lambda (info) +;; (string-match (concat "\\`[^&].*@BitlBee\\'") +;; (erc-format-target-and/or-network))) +;; :persistent +;; #'(lambda (info) +;; ;; If the buffer is buried, or the user has been +;; ;; idle for `alert-reveal-idle-time' seconds, +;; ;; make this alert persistent. Normally, alerts +;; ;; become persistent after +;; ;; `alert-persist-idle-time' seconds. +;; (memq (plist-get info :status) '(buried idle))) +;; :style 'fringe +;; :continue t) +;; +;; * Builtin alert styles +;; +;; There are several builtin styles, and it is trivial to create new ones. +;; The builtins are: +;; +;; fringe - Changes the current frame's fringe background color +;; mode-line - Changes the current frame's mode-line background color +;; gntp - Uses gntp, it requires gntp.el (see https://github.com/tekai/gntp.el) +;; growl - Uses Growl on OS X, if growlnotify is on the PATH +;; ignore - Ignores the alert entirely +;; libnotify - Uses libnotify if notify-send is on the PATH +;; log - Logs the alert text to *Alerts*, with a timestamp +;; message - Uses the Emacs `message' facility +;; momentary - Uses the Emacs `momentary-string-display' facility +;; notifications - Uses notifications library via D-Bus +;; notifier - Uses terminal-notifier on OS X, if it is on the PATH +;; osx-notifier - Native OSX notifier using AppleScript +;; toaster - Use the toast notification system +;; x11 - Changes the urgency property of the window in the X Window System +;; termux - Use termux-notification from the Termux API +;; +;; * Defining new styles +;; +;; To create a new style, you need to at least write a "notifier", which is +;; a function that receives the details of the alert. These details are +;; given in a plist which uses various keyword to identify the parts of the +;; alert. Here is a prototypical style definition: +;; +;; (alert-define-style 'style-name :title "My Style's title" +;; :notifier +;; (lambda (info) +;; ;; The message text is :message +;; (plist-get info :message) +;; ;; The :title of the alert +;; (plist-get info :title) +;; ;; The :category of the alert +;; (plist-get info :category) +;; ;; The major-mode this alert relates to +;; (plist-get info :mode) +;; ;; The buffer the alert relates to +;; (plist-get info :buffer) +;; ;; Severity of the alert. It is one of: +;; ;; `urgent' +;; ;; `high' +;; ;; `moderate' +;; ;; `normal' +;; ;; `low' +;; ;; `trivial' +;; (plist-get info :severity) +;; ;; Whether this alert should persist, or fade away +;; (plist-get info :persistent) +;; ;; Data which was passed to `alert'. Can be +;; ;; anything. +;; (plist-get info :data)) +;; +;; ;; Removers are optional. Their job is to remove +;; ;; the visual or auditory effect of the alert. +;; :remover +;; (lambda (info) +;; ;; It is the same property list that was passed to +;; ;; the notifier function. +;; )) +;; +;; You can test a specific style with something like this: +;; +;; (let ((alert-user-configuration '((((:severity high)) momentary nil)))) +;; (alert "Same buffer momentary alert" :title "My Alert" :severity 'high) +;; (alert "This is a momentary alert in another visible buffer" :title "My Alert" +;; :severity 'high :buffer (other-buffer (current-buffer) t))) + +;;; Code: + +(require 'cl-lib) +(require 'gntp nil t) +(eval-when-compile + ;; if not available, silence the byte compiler + (defvar gntp-server)) +(declare-function gntp-notify "gntp") +(require 'notifications nil t) +(require 'log4e nil t) + +;; shut up the byte compiler +(declare-function alert-gntp-notify "alert") +(declare-function alert-notifications-notify "alert") + +(defgroup alert nil + "Notification system for Emacs similar to Growl" + :group 'emacs) + +(defcustom alert-severity-faces + '((urgent . alert-urgent-face) + (high . alert-high-face) + (moderate . alert-moderate-face) + (normal . alert-normal-face) + (low . alert-low-face) + (trivial . alert-trivial-face)) + "Faces associated by default with alert severities." + :type '(alist :key-type symbol :value-type color) + :group 'alert) + +(defcustom alert-severity-colors + '((urgent . "red") + (high . "orange") + (moderate . "yellow") + (normal . "green") + (low . "blue") + (trivial . "purple")) + "Colors associated by default with alert severities. +This is used by styles external to Emacs that don't understand faces." + :type '(alist :key-type symbol :value-type color) + :group 'alert) + +(defcustom alert-log-severity-functions + '((urgent . alert--log-fatal) + (high . alert--log-error) + (moderate . alert--log-warn) + (normal . alert--log-info) + (low . alert--log-debug) + (trivial . alert--log-trace)) + "Log4e logging functions." + :type '(alist :key-type symbol :value-type color) + :group 'alert) + +(defcustom alert-log-level + 'normal + "Minimum level of messages to log." + :type 'symbol + :group 'alert) + +(defcustom alert-reveal-idle-time 15 + "If idle this many seconds, rules will match the `idle' property." + :type 'integer + :group 'alert) + +(defcustom alert-persist-idle-time 900 + "If idle this many seconds, all alerts become persistent. +This can be overridden with the Never Persist option (:never-persist)." + :type 'integer + :group 'alert) + +(defcustom alert-fade-time 5 + "If not idle, alerts disappear after this many seconds. +The amount of idle time is governed by `alert-persist-idle-time'." + :type 'integer + :group 'alert) + +(defcustom alert-hide-all-notifications nil + "If non-nil, no alerts are ever shown to the user." + :type 'boolean + :group 'alert) + +(defcustom alert-log-messages t + "If non-nil, all alerts are logged to the *Alerts* buffer." + :type 'boolean + :group 'alert) + +(defcustom alert-default-icon + (concat data-directory + "images/icons/hicolor/scalable/apps/emacs.svg") + "Filename of default icon to show for libnotify-alerts." + :type 'string + :group 'alert) + +(defvar alert-styles nil) + +(defun alert-styles-radio-type (widget-name) + (append + (list widget-name :tag "Style") + (mapcar #'(lambda (style) + (list 'const + :tag (or (plist-get (cdr style) :title) + (symbol-name (car style))) + (car style))) + (setq alert-styles + (sort alert-styles + #'(lambda (l r) + (string< (symbol-name (car l)) + (symbol-name (car r))))))))) + +(defcustom alert-default-style 'message + "The style to use if no rules match in the current configuration. +If a configured rule does match an alert, this style is not used; +it is strictly a fallback." + :type (alert-styles-radio-type 'radio) + :group 'alert) + +(defun alert-configuration-type () + (list 'repeat + (list + 'list :tag "Select style if alert matches selector" + '(repeat + :tag "Selector" + (choice + (cons :tag "Severity" + (const :format "" :severity) + (set (const :tag "Urgent" urgent) + (const :tag "High" high) + (const :tag "Moderate" moderate) + (const :tag "Normal" normal) + (const :tag "Low" low) + (const :tag "Trivial" trivial))) + (cons :tag "User Status" + (const :format "" :status) + (set (const :tag "Buffer not visible" buried) + (const :tag "Buffer visible" visible) + (const :tag "Buffer selected" selected) + (const :tag "Buffer selected, user idle" idle))) + (cons :tag "Major Mode" + (const :format "" :mode) + regexp) + (cons :tag "Category" + (const :format "" :category) + regexp) + (cons :tag "Title" + (const :format "" :title) + regexp) + (cons :tag "Message" + (const :format "" :message) + regexp) + (cons :tag "Predicate" + (const :format "" :predicate) + function) + (cons :tag "Icon" + (const :format "" :icon) + regexp))) + (alert-styles-radio-type 'choice) + '(set :tag "Options" + (cons :tag "Make alert persistent" + (const :format "" :persistent) + (choice :value t (const :tag "Yes" t) + (function :tag "Predicate"))) + (cons :tag "Never persist" + (const :format "" :never-persist) + (choice :value t (const :tag "Yes" t) + (function :tag "Predicate"))) + (cons :tag "Continue to next rule" + (const :format "" :continue) + (choice :value t (const :tag "Yes" t) + (function :tag "Predicate"))) + ;;(list :tag "Change Severity" + ;; (radio :tag "From" + ;; (const :tag "Urgent" urgent) + ;; (const :tag "High" high) + ;; (const :tag "Moderate" moderate) + ;; (const :tag "Normal" normal) + ;; (const :tag "Low" low) + ;; (const :tag "Trivial" trivial)) + ;; (radio :tag "To" + ;; (const :tag "Urgent" urgent) + ;; (const :tag "High" high) + ;; (const :tag "Moderate" moderate) + ;; (const :tag "Normal" normal) + ;; (const :tag "Low" low) + ;; (const :tag "Trivial" trivial))) + )))) + +(defcustom alert-user-configuration nil + "Rules that determine how and when alerts get displayed." + :type (alert-configuration-type) + :group 'alert) + +(defvar alert-internal-configuration nil + "Rules added by `alert-add-rule'. +For user customization, see `alert-user-configuration'.") + +(defface alert-urgent-face + '((t (:foreground "Red" :bold t))) + "Urgent alert face." + :group 'alert) + +(defface alert-high-face + '((t (:foreground "Dark Orange" :bold t))) + "High alert face." + :group 'alert) + +(defface alert-moderate-face + '((t (:foreground "Gold" :bold t))) + "Moderate alert face." + :group 'alert) + +(defface alert-normal-face + '((t)) + "Normal alert face." + :group 'alert) + +(defface alert-low-face + '((t (:foreground "Dark Blue"))) + "Low alert face." + :group 'alert) + +(defface alert-trivial-face + '((t (:foreground "Dark Violet"))) + "Trivial alert face." + :group 'alert) + +(defun alert-define-style (name &rest plist) + "Define a new style for notifying the user of alert messages. +To create a new style, you need to at least write a \"notifier\", +which is a function that receives the details of the alert. +These details are given in a plist which uses various keyword to +identify the parts of the alert. Here is a prototypical style +definition: + +\(alert-define-style 'style-name :title \"My Style's title\" + :notifier + (lambda (info) + ;; The message text is :message + (plist-get info :message) + ;; The :title of the alert + (plist-get info :title) + ;; The :category of the alert + (plist-get info :category) + ;; The major-mode this alert relates to + (plist-get info :mode) + ;; The buffer the alert relates to + (plist-get info :buffer) + ;; Severity of the alert. It is one of: + ;; `urgent' + ;; `high' + ;; `moderate' + ;; `normal' + ;; `low' + ;; `trivial' + (plist-get info :severity) + ;; Whether this alert should persist, or fade away + (plist-get info :persistent) + ;; Data which was passed to `alert'. Can be + ;; anything. + (plist-get info :data)) + + ;; Removers are optional. Their job is to remove + ;; the visual or auditory effect of the alert. + :remover + (lambda (info) + ;; It is the same property list that was passed to + ;; the notifier function. + ))" + (add-to-list 'alert-styles (cons name plist)) + (put 'alert-user-configuration 'custom-type (alert-configuration-type)) + (put 'alert-define-style 'custom-type (alert-styles-radio-type 'radio))) + +(alert-define-style 'ignore :title "Ignore Alert" + :notifier #'ignore + :remover #'ignore) + +;;;###autoload +(cl-defun alert-add-rule (&key severity status mode category title + message predicate icon (style alert-default-style) + persistent continue never-persist append) + "Programmatically add an alert configuration rule. + +Normally, users should custoimze `alert-user-configuration'. +This facility is for module writers and users that need to do +things the Lisp way. + +Here is a rule the author currently uses with ERC, so that the +fringe gets colored whenever people chat on BitlBee: + +\(alert-add-rule :status \\='(buried visible idle) + :severity \\='(moderate high urgent) + :mode \\='erc-mode + :predicate + #\\='(lambda (info) + (string-match (concat \"\\\\`[^&].*@BitlBee\\\\\\='\") + (erc-format-target-and/or-network))) + :persistent + #\\='(lambda (info) + ;; If the buffer is buried, or the user has been + ;; idle for `alert-reveal-idle-time' seconds, + ;; make this alert persistent. Normally, alerts + ;; become persistent after + ;; `alert-persist-idle-time' seconds. + (memq (plist-get info :status) \\='(buried idle))) + :style \\='fringe + :continue t)" + (let ((rule (list (list t) style (list t)))) + (if severity + (nconc (nth 0 rule) + (list (cons :severity + (if (listp severity) + severity + (list severity)))))) + (if status + (nconc (nth 0 rule) + (list (cons :status + (if (listp status) + status + (list status)))))) + (if mode + (nconc (nth 0 rule) + (list (cons :mode + (if (stringp mode) + mode + (concat "\\`" (symbol-name mode) + "\\'")))))) + (if category + (nconc (nth 0 rule) (list (cons :category category)))) + (if title + (nconc (nth 0 rule) (list (cons :title title)))) + (if message + (nconc (nth 0 rule) (list (cons :message message)))) + (if predicate + (nconc (nth 0 rule) (list (cons :predicate predicate)))) + (if icon + (nconc (nth 0 rule) (list (cons :icon icon)))) + (setcar rule (cdr (nth 0 rule))) + + (if persistent + (nconc (nth 2 rule) (list (cons :persistent persistent)))) + (if never-persist + (nconc (nth 2 rule) (list (cons :never-persist never-persist)))) + (if continue + (nconc (nth 2 rule) (list (cons :continue continue)))) + (setcdr (cdr rule) (list (cdr (nth 2 rule)))) + + (if (null alert-internal-configuration) + (setq alert-internal-configuration (list rule)) + (if append + (nconc alert-internal-configuration (list rule)) + (setq alert-internal-configuration + (cons rule alert-internal-configuration)))) + + rule)) + +(alert-define-style 'ignore :title "Don't display alerts") + +(defun alert-log-notify (info) + (let* ((mes (plist-get info :message)) + (sev (plist-get info :severity)) + (len (length mes)) + (func (cdr (assoc sev alert-log-severity-functions)))) + (if (not (featurep 'log4e)) + (alert-legacy-log-notify mes sev len) + ;; when we get here you better be using log4e or have your logging + ;; functions defined + (unless (fboundp func) + (when (fboundp 'log4e:deflogger) + (log4e:deflogger "alert" "%t [%l] %m" "%H:%M:%S") + (when (functionp 'alert--log-set-level) + (alert--log-set-level alert-log-level))) + (alert--log-enable-logging)) + (when (fboundp func) + (apply func (list mes)))))) + +(defun alert-legacy-log-notify (mes sev len) + (with-current-buffer + (get-buffer-create "*Alerts*") + (goto-char (point-max)) + (insert (format-time-string "%H:%M %p - ")) + (insert mes) + (set-text-properties (- (point) len) (point) + (list 'face (cdr (assq sev + alert-severity-faces)))) + (insert ?\n))) + +(defun alert-log-clear (info) + (if (functionp 'alert--log-clear-log) + (alert--log-clear-log) + (if (bufferp "*Alerts*") + (with-current-buffer + (get-buffer-create "*Alerts*") + (goto-char (point-max)) + (insert (format-time-string "%H:%M %p - ") + "Clear: " (plist-get info :message) + ?\n))))) + +(alert-define-style 'log :title "Log to *Alerts* buffer" + :notifier #'alert-log-notify + ;;:remover #'alert-log-clear + ) + +(defun alert-message-notify (info) + ;; the message text might contain `%' and we don't want them to be + ;; interpreted as format specifiers: + (message "%s" (plist-get info :message)) + ;;(if (memq (plist-get info :severity) '(high urgency)) + ;; (ding)) + ) + +(defun alert-message-remove (_info) + (message "")) + +(alert-define-style 'message :title "Display message in minibuffer" + :notifier #'alert-message-notify + :remover #'alert-message-remove) + +(defun alert-momentary-notify (info) + (save-excursion + (with-current-buffer (or (plist-get info :buffer) (current-buffer)) + (momentary-string-display + (format "%s: %s (%s/%s/%s)" + (or (plist-get info :title) "untitled") + (or (plist-get info :message) "no message") + (or (plist-get info :severity) "no priority") + (or (plist-get info :category) "no category") + (or (plist-get info :mode) "no mode")) + (progn + (beginning-of-line) + (point)))))) + +(alert-define-style 'momentary :title "Display message momentarily in buffer" + :notifier #'alert-momentary-notify + ;; explicitly, we don't need a remover + :remover #'ignore) + +(copy-face 'fringe 'alert-saved-fringe-face) + +(defun alert-fringe-notify (info) + (set-face-background 'fringe (cdr (assq (plist-get info :severity) + alert-severity-colors)))) + +(defun alert-fringe-restore (_info) + (copy-face 'alert-saved-fringe-face 'fringe)) + +(alert-define-style 'fringe :title "Change the fringe color" + :notifier #'alert-fringe-notify + :remover #'alert-fringe-restore) + +(copy-face 'mode-line 'alert-saved-mode-line-face) +(defun alert-mode-line-notify (info) + (set-face-background 'mode-line (cdr (assq (plist-get info :severity) + alert-severity-colors))) + (set-face-foreground 'mode-line "white")) + +(defun alert-mode-line-restore (_info) + (copy-face 'alert-saved-mode-line-face 'mode-line)) + +(alert-define-style 'mode-line :title "Change the mode-line color" + :notifier #'alert-mode-line-notify + :remover #'alert-mode-line-restore) + + + +(defcustom alert-growl-command (executable-find "growlnotify") + "Path to the growlnotify command. +This is found in the Growl Extras: http://growl.info/extras.php." + :type 'file + :group 'alert) + +(defcustom alert-growl-priorities + '((urgent . 2) + (high . 2) + (moderate . 1) + (normal . 0) + (low . -1) + (trivial . -2)) + "A mapping of alert severities onto Growl priority values." + :type '(alist :key-type symbol :value-type integer) + :group 'alert) + +(defsubst alert-encode-string (str) + (encode-coding-string str (keyboard-coding-system))) + +(defun alert-growl-notify (info) + (if alert-growl-command + (let* ((title (alert-encode-string (plist-get info :title))) + (priority (number-to-string + (cdr (assq (plist-get info :severity) + alert-growl-priorities)))) + (args + (cl-case system-type + ('windows-nt (mapcar + (lambda (lst) (apply #'concat lst)) + `( + ;; http://www.growlforwindows.com/gfw/help/growlnotify.aspx + ("/i:" ,(file-truename (concat invocation-directory "../share/icons/hicolor/48x48/apps/emacs.png"))) + ("/t:" ,title) + ("/p:" ,priority)))) + (t (list + "--appIcon" "Emacs" + "--name" "Emacs" + "--title" title + "--priority" priority))))) + (if (and (plist-get info :persistent) + (not (plist-get info :never-persist))) + (cl-case system-type + ('windows-nt (nconc args (list "/s:true"))) + (t (nconc args (list "--sticky"))))) + (let ((message (alert-encode-string (plist-get info :message)))) + (cl-case system-type + ('windows-nt (nconc args (list message))) + (t (nconc args (list "--message" message))))) + (apply #'call-process alert-growl-command nil nil nil args)) + (alert-message-notify info))) + +(alert-define-style 'growl :title "Notify using Growl" + :notifier #'alert-growl-notify) + + +(defcustom alert-libnotify-command (executable-find "notify-send") + "Path to the notify-send command. +This is found in the libnotify-bin package in Debian based +systems." + :type 'file + :group 'alert) + +(defcustom alert-libnotify-additional-args + nil + "Additional args to pass to notify-send. +Must be a list of strings." + :type '(repeat string) + :group 'alert) + +(defcustom alert-libnotify-priorities + '((urgent . critical) + (high . critical) + (moderate . normal) + (normal . normal) + (low . low) + (trivial . low)) + "A mapping of alert severities onto libnotify priority values." + :type '(alist :key-type symbol :value-type symbol) + :group 'alert) + +(defun alert-libnotify-notify (info) + "Send INFO using notify-send. +Handles :ICON, :CATEGORY, :SEVERITY, :PERSISTENT, :NEVER-PERSIST, :TITLE +and :MESSAGE keywords from the INFO plist. :CATEGORY can be +passed as a single symbol, a string or a list of symbols or +strings." + (if alert-libnotify-command + (let* ((args + (append + (list "--icon" (or (plist-get info :icon) + alert-default-icon) + "--app-name" "Emacs" + "--urgency" (let ((urgency (cdr (assq + (plist-get info :severity) + alert-libnotify-priorities)))) + (if urgency + (symbol-name urgency) + "normal"))) + (copy-tree alert-libnotify-additional-args))) + (category (plist-get info :category))) + (nconc args + (list "--expire-time" + (number-to-string + (* 1000 ; notify-send takes msecs + (if (and (plist-get info :persistent) + (not (plist-get info :never-persist))) + 0 ; 0 indicates persistence + alert-fade-time))))) + (when category + (nconc args + (list "--category" + (cond ((symbolp category) + (symbol-name category)) + ((stringp category) category) + ((listp category) + (mapconcat (if (symbolp (car category)) + #'symbol-name + #'identity) + category ",")))))) + (nconc args (list + (alert-encode-string (plist-get info :title)) + (alert-encode-string (plist-get info :message)))) + (apply #'call-process alert-libnotify-command nil + (list (get-buffer-create " *libnotify output*") t) nil args)) + (alert-message-notify info))) + +(alert-define-style 'libnotify :title "Notify using libnotify" + :notifier #'alert-libnotify-notify) + + +(defcustom alert-gntp-icon + "http://cvs.savannah.gnu.org/viewvc/*checkout*/emacs/emacs/etc/images/icons/hicolor/48x48/apps/emacs.png" + "Icon file using gntp." + :type 'string + :group 'alert) + +(when (featurep 'gntp) + (defun alert-gntp-notify (info) + (gntp-notify 'alert + (alert-encode-string (plist-get info :title)) + (alert-encode-string (plist-get info :message)) + gntp-server nil + (number-to-string + (cdr (assq (plist-get info :severity) + alert-growl-priorities))) + (if (eq (plist-get info :icon) nil) + alert-gntp-icon + (plist-get info :icon))) + (alert-message-notify info)) + + (alert-define-style 'gntp :title "Notify using gntp" + :notifier #'alert-gntp-notify)) + + +(defcustom alert-notifications-priorities + '((urgent . critical) + (high . critical) + (moderate . normal) + (normal . normal) + (low . low) + (trivial . low)) + "A mapping of alert severities onto Growl priority values." + :type '(alist :key-type symbol :value-type symbol) + :group 'alert) + +(defvar alert-notifications-ids (make-hash-table :test #'equal) + "Internal store of notification ids returned by the `notifications' backend. +Used for replacing notifications with the same id. The key is +the value of the :id keyword to `alert'. An id is only stored +here if there `alert' was called with an :id keyword and handled +by the `notifications' style.") + +(when (featurep 'notifications) + (defun alert-notifications-notify (info) + "Show the alert defined by INFO with `notifications-notify'." + (let ((id (notifications-notify :title (plist-get info :title) + :body (plist-get info :message) + :app-icon (plist-get info :icon) + :timeout (if (plist-get info :persistent) 0 -1) + :replaces-id (gethash (plist-get info :id) alert-notifications-ids) + :urgency (cdr (assq (plist-get info :severity) + alert-notifications-priorities)) + :actions '("default" "Open corresponding buffer") + :on-action (lambda (id action) + (when (string= action "default") + (switch-to-buffer (plist-get info :buffer))))))) + (when (plist-get info :id) + (puthash (plist-get info :id) id alert-notifications-ids))) + (alert-message-notify info)) + + (defun alert-notifications-remove (info) + "Remove the `notifications-notify' message based on INFO :id." + (let ((id (and (plist-get info :id) + (gethash (plist-get info :id) alert-notifications-ids)))) + (when id + (notifications-close-notification id) + (remhash (plist-get info :id) alert-notifications-ids)))) + + (alert-define-style 'notifications :title "Notify using notifications" + :notifier #'alert-notifications-notify)) + + +(defcustom alert-notifier-command (executable-find "terminal-notifier") + "Path to the terminal-notifier command. +From https://github.com/julienXX/terminal-notifier." + :type 'file + :group 'alert) + +(defcustom alert-notifier-default-icon + (concat data-directory + "images/icons/hicolor/128x128/apps/emacs.png") + "Filename of default icon to show for terminal-notifier alerts." + :type 'string + :group 'alert) + +(defun alert-notifier-notify (info) + (if alert-notifier-command + (let ((args + (list "-title" (alert-encode-string (plist-get info :title)) + "-appIcon" (or (plist-get info :icon) alert-notifier-default-icon) + "-message" (alert-encode-string (plist-get info :message))))) + (apply #'call-process alert-notifier-command nil nil nil args)) + (alert-message-notify info))) + +(alert-define-style 'notifier :title "Notify using terminal-notifier" + :notifier #'alert-notifier-notify) + +(defun alert-osx-notifier-notify (info) + (apply #'call-process "osascript" nil nil nil "-e" + (list (format "display notification %S with title %S" + (alert-encode-string (plist-get info :message)) + (alert-encode-string (plist-get info :title))))) + (alert-message-notify info)) + +(when (fboundp 'do-applescript) + ;; Use built-in AppleScript support when possible. + (defun alert-osx-notifier-notify (info) + (do-applescript (format "display notification %S with title %S" + (alert-encode-string (plist-get info :message)) + (alert-encode-string (plist-get info :title)))) + (alert-message-notify info))) + +(alert-define-style 'osx-notifier :title "Notify using native OSX notification" :notifier #'alert-osx-notifier-notify) + +(defun alert-frame-notify (info) + (let ((buf (plist-get info :buffer))) + (if (eq (alert-buffer-status buf) 'buried) + (let ((current-frame (selected-frame))) + (with-selected-frame + (make-frame '((width . 80) + (height . 20) + (top . -1) + (left . 0) + (left-fringe . 0) + (right-fringe . 0) + (tool-bar-lines . nil) + (menu-bar-lines . nil) + (vertical-scroll-bars . nil) + (unsplittable . t) + (has-modeline-p . nil) + (minibuffer . nil))) + (switch-to-buffer buf) + ;;(set (make-local-variable 'mode-line-format) nil) + (nconc info (list :frame (selected-frame)))) + (select-frame current-frame))))) + +(defun alert-frame-remove (info) + (unless (eq this-command 'handle-switch-frame) + (delete-frame (plist-get info :frame) t))) + +;; This code was kindly borrowed from Arne Babenhauserheide: +;; http://www.draketo.de/proj/babcore/#sec-3-14-2 +(defun x-urgency-hint (frame arg &optional source) + "Set the x-urgency hint for FRAME to ARG. + +- If arg is nil, unset the urgency. +- If arg is any other value, set the urgency. + +If you unset the urgency, you still have to visit the frame to make the urgency +setting disappear (at least in KDE)." + (let* ((wm-hints (append (x-window-property + "WM_HINTS" frame "WM_HINTS" + source nil t) nil)) + (flags (car wm-hints))) + (setcar wm-hints + (if arg + (logior flags #x00000100) + (logand flags #x1ffffeff))) + (x-change-window-property "WM_HINTS" wm-hints frame "WM_HINTS" 32 t))) + +(defun x-urgent (&optional arg) + "Mark the current Emacs frame as requiring urgent attention. + +With non-nil ARG, remove the urgency flag (which might or might +not change display, depending on the window manager)." + (interactive "P") + (let ((frame (car (car (cdr (current-frame-configuration)))))) + (x-urgency-hint frame (not arg)))) + +(defun alert-x11-notify (_info) + "Call `x-urgent'." + (x-urgent)) + +(alert-define-style 'x11 :title "Set the X11 window property" + :notifier #'alert-x11-notify) + + +(defcustom alert-toaster-default-icon + (let ((exec-bin (executable-find "emacs.exe"))) + (cond (exec-bin + (concat (file-name-directory exec-bin) "../share/icons/hicolor/128x128/apps/emacs.png")) + (t nil))) + "Icon file using toaster." + :type 'string + :group 'alert + ) + +(defcustom alert-toaster-command (executable-find "toast") + "Path to the toast command. +This is found at https://github.com/nels-o/toaster." + :type 'file + :group 'alert + ) + +(defun alert-toaster-notify (info) + (if alert-toaster-command + (let ((args (list + "-t" (alert-encode-string (plist-get info :title)) + "-m" (alert-encode-string (plist-get info :message)) + "-p" (expand-file-name (or (plist-get info :icon) alert-toaster-default-icon)) + ))) + (apply #'call-process alert-toaster-command nil nil nil args)) + (alert-message-notify info))) + +(alert-define-style 'toaster :title "Notify using Toaster" + :notifier #'alert-toaster-notify) + +(defcustom alert-termux-command (executable-find "termux-notification") + "Path to the termux-notification command. +This is found in the termux-api package, and it requires the Termux +API addon app to be installed." + :type 'file + :group 'alert) + +(defun alert-termux-notify (info) + "Send INFO using termux-notification. +Handles :TITLE and :MESSAGE keywords from the +INFO plist." + (if alert-termux-command + (let ((args (nconc + (when (plist-get info :title) + (list "-t" (alert-encode-string (plist-get info :title)))) + (list "-c" (alert-encode-string (plist-get info :message)))))) + (apply #'call-process alert-termux-command nil + (list (get-buffer-create " *termux-notification output*") t) + nil args)) + (alert-message-notify info))) + +(alert-define-style 'termux :title "Notify using termux" + :notifier #'alert-termux-notify) + +;; jww (2011-08-25): Not quite working yet +;;(alert-define-style 'frame :title "Popup buffer in a frame" +;; :notifier #'alert-frame-notify +;; :remover #'alert-frame-remove) + +(defun alert-buffer-status (&optional buffer) + (with-current-buffer (or buffer (current-buffer)) + (let ((wind (get-buffer-window))) + (if wind + (if (eq wind (selected-window)) + (if (and (current-idle-time) + (> (float-time (current-idle-time)) + alert-reveal-idle-time)) + 'idle + 'selected) + 'visible) + 'buried)))) + +(defvar alert-active-alerts nil) + +(defun alert-remove-when-active (remover info) + (let ((idle-time (and (current-idle-time) + (float-time (current-idle-time))))) + (cond + ((and idle-time (> idle-time alert-persist-idle-time))) + ((and idle-time (> idle-time alert-reveal-idle-time)) + (run-with-timer alert-fade-time nil + #'alert-remove-when-active remover info)) + (t + (funcall remover info))))) + +(defun alert-remove-on-command () + (let (to-delete) + (dolist (alert alert-active-alerts) + (when (eq (current-buffer) (nth 0 alert)) + (push alert to-delete) + (if (nth 2 alert) + (funcall (nth 2 alert) (nth 1 alert))))) + (dolist (alert to-delete) + (setq alert-active-alerts (delq alert alert-active-alerts))))) + +(defun alert-send-notification + (alert-buffer info style-def &optional persist never-per) + (let ((notifier (plist-get style-def :notifier))) + (if notifier + (funcall notifier info))) + (let ((remover (plist-get style-def :remover))) + (add-to-list 'alert-active-alerts (list alert-buffer info remover)) + (with-current-buffer alert-buffer + (add-hook 'post-command-hook #'alert-remove-on-command nil t)) + (if (and remover (or (not persist) never-per)) + (run-with-timer alert-fade-time nil + #'alert-remove-when-active + remover info)))) + +;;;###autoload +(cl-defun alert (message &key (severity 'normal) title icon category + buffer mode data style persistent never-persist + id) + "Alert the user that something has happened. +MESSAGE is what the user will see. You may also use keyword +arguments to specify additional details. Here is a full example: + +\(alert \"This is a message\" + :severity \\='high ;; The default severity is `normal' + :title \"Title\" ;; An optional title + :category \\='example ;; A symbol to identify the message + :mode \\='text-mode ;; Normally determined automatically + :buffer (current-buffer) ;; This is the default + :data nil ;; Unused by alert.el itself + :persistent nil ;; Force the alert to be persistent; + ;; it is best not to use this + :never-persist nil ;; Force this alert to never persist + :id \\='my-id) ;; Used to replace previous message of + ;; the same id in styles that support it + :style \\='fringe) ;; Force a given style to be used; + ;; this is only for debugging! + :icon \\=\"mail-message-new\" ;; if style supports icon then add icon + ;; name or path here + +If no :title is given, the buffer-name of :buffer is used. If +:buffer is nil, it is the current buffer at the point of call. + +:data is an opaque value which modules can pass through to their +own styles if they wish. + +Here are some more typical examples of usage: + + ;; This is the most basic form usage + (alert \"This is an alert\") + + ;; You can adjust the severity for more important messages + (alert \"This is an alert\" :severity \\='high) + + ;; Or decrease it for purely informative ones + (alert \"This is an alert\" :severity \\='trivial) + + ;; Alerts can have optional titles. Otherwise, the title is the + ;; buffer-name of the (current-buffer) where the alert originated. + (alert \"This is an alert\" :title \"My Alert\") + + ;; Further, alerts can have categories. This allows users to + ;; selectively filter on them. + (alert \"This is an alert\" :title \"My Alert\" + :category \\='some-category-or-other)" + (cl-destructuring-bind + (alert-buffer current-major-mode current-buffer-status + current-buffer-name) + (with-current-buffer (or buffer (current-buffer)) + (list (current-buffer) + (or mode major-mode) + (alert-buffer-status) + (buffer-name))) + + (let ((base-info (list :message message + :title (or title current-buffer-name) + :icon icon + :severity severity + :category category + :buffer alert-buffer + :persistent persistent + :mode current-major-mode + :id id + :data data + :persistent persistent)) + matched) + + (if alert-log-messages + (alert-log-notify base-info)) + + (unless alert-hide-all-notifications + (catch 'finish + (dolist (config (or (append alert-user-configuration + alert-internal-configuration) + (when style '(nil)))) + (let* ((style-def (cdr (assq (or style (nth 1 config)) + alert-styles))) + (options (nth 2 config)) + (persist-p (or persistent + (cdr (assq :persistent options)))) + (persist (if (functionp persist-p) + (funcall persist-p base-info) + persist-p)) + (never-persist-p + (or never-persist + (cdr (assq :never-persist options)))) + (never-per (if (functionp never-persist-p) + (funcall never-persist-p base-info) + never-persist-p)) + (continue (cdr (assq :continue options))) + info) + (setq info (if (not (memq :persistent base-info)) + (append base-info (list :persistent persist)) + base-info) + info (if (not (memq :never-persist info)) + (append info (list :never-persist never-per)) + info)) + (when + (or style ; :style always "matches", for testing + (not + (memq + nil + (mapcar + #'(lambda (condition) + (cl-case (car condition) + (:severity + (memq severity (cdr condition))) + (:status + (memq current-buffer-status (cdr condition))) + (:mode + (string-match + (cdr condition) + (symbol-name current-major-mode))) + (:category + (and category (string-match + (cdr condition) + (if (stringp category) + category + (symbol-name category))))) + (:title + (and title + (string-match (cdr condition) title))) + (:message + (string-match (cdr condition) message)) + (:predicate + (funcall (cdr condition) info)) + (:icon + (string-match (cdr condition) icon)))) + (nth 0 config))))) + + (alert-send-notification alert-buffer info style-def + persist never-per) + (setq matched t) + (if (or style (not (if (functionp continue) + (funcall continue info) + continue))) + (throw 'finish t))))))) + + (if (and (not matched) alert-default-style) + (alert-send-notification alert-buffer base-info + (cdr (assq alert-default-style + alert-styles))))))) + +(provide 'alert) + +;;; alert.el ends here diff --git a/org/elpa/gntp-20141025.250/gntp-autoloads.el b/org/elpa/gntp-20141025.250/gntp-autoloads.el new file mode 100644 index 0000000..0d8ddfe --- /dev/null +++ b/org/elpa/gntp-20141025.250/gntp-autoloads.el @@ -0,0 +1,28 @@ +;;; gntp-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "gntp" "gntp.el" (0 0 0 0)) +;;; Generated autoloads from gntp.el + +(autoload 'gntp-notify "gntp" "\ +Send notification NAME with TITLE, TEXT, PRIORITY and ICON to SERVER:PORT. +PORT defaults to `gntp-server-port' + +\(fn NAME TITLE TEXT SERVER &optional PORT PRIORITY ICON)" nil nil) + +(register-definition-prefixes "gntp" '("gntp-")) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; gntp-autoloads.el ends here diff --git a/org/elpa/gntp-20141025.250/gntp-pkg.el b/org/elpa/gntp-20141025.250/gntp-pkg.el new file mode 100644 index 0000000..00cd830 --- /dev/null +++ b/org/elpa/gntp-20141025.250/gntp-pkg.el @@ -0,0 +1,2 @@ +;;; Generated package description from gntp.el -*- no-byte-compile: t -*- +(define-package "gntp" "20141025.250" "Growl Notification Protocol for Emacs" 'nil :commit "767571135e2c0985944017dc59b0be79af222ef5" :authors '(("Engelke Eschner" . "tekai@gmx.li")) :maintainer '("Engelke Eschner" . "tekai@gmx.li")) diff --git a/org/elpa/gntp-20141025.250/gntp.el b/org/elpa/gntp-20141025.250/gntp.el new file mode 100644 index 0000000..ca17a1c --- /dev/null +++ b/org/elpa/gntp-20141025.250/gntp.el @@ -0,0 +1,244 @@ +;;; gntp.el --- Growl Notification Protocol for Emacs -*- lexical-binding: t -*- + +;; Author: Engelke Eschner +;; Version: 0.1 +;; Package-Version: 20141025.250 +;; Package-Commit: 767571135e2c0985944017dc59b0be79af222ef5 +;; Created: 2013-03-21 + +;; LICENSE +;; Copyright (c) 2013 Engelke Eschner +;; All rights reserved. + +;; Redistribution and use in source and binary forms, with or without +;; modification, are permitted provided that the following conditions +;; are met: +;; * Redistributions of source code must retain the above copyright +;; notice, this list of conditions and the following disclaimer. +;; * Redistributions in binary form must reproduce the above +;; copyright notice, this list of conditions and the following +;; disclaimer in the documentation and/or other materials provided +;; with the distribution. +;; * Neither the name of the gntp.el nor the names of its +;; contributors may be used to endorse or promote products derived +;; from this software without specific prior written permission. + +;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +;; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +;; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +;; OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +;;; Commentary: +;; This package implements the Growl Notification Protocol GNTP +;; described at http://www.growlforwindows.com/gfw/help/gntp.aspx +;; It is incomplete as it only lets you send but not receive +;; notifications. + +;;; Code: + +(defgroup gntp nil + "GNTP, send/register growl notifications via GNTP from within emacs." + :group 'external) + +(defcustom gntp-application-name "Emacs/gntp.el" + "Name of the application gntp registers itself." + :type '(string)) + +(defcustom gntp-application-icon nil + "Icon to display as the application icon. +Either a URL or a path to a file." + :type '(string)) + +(defcustom gntp-server "localhost" + "Default port of the server. +Standard says can't be changed, but port-forwarding etc." + :type '(string)) + +(defcustom gntp-server-port 23053 + "Default port of the server. +Standard says can't be changed, but port-forwarding etc." + :type '(integer)) + +(defcustom gntp-register-alist nil + "Registration item list." + :type '(choice string (const nil))) + +(defun gntp-register (&optional notifications server port) + (interactive) + "Register NOTIFICATIONS at SERVER:PORT. +PORT defaults to `gntp-server-port'." + (let ((message (gntp-build-message-register (if notifications notifications gntp-register-alist)))) + (gntp-send message (if server server gntp-server) port))) + +;;;###autoload +(defun gntp-notify (name title text server &optional port priority icon) + "Send notification NAME with TITLE, TEXT, PRIORITY and ICON to SERVER:PORT. +PORT defaults to `gntp-server-port'" + (let ((message (gntp-build-message-notify name title text priority icon))) + (gntp-send message server port))) + +(defun gntp-build-message-register (notifications) + "Build the message to register NOTIFICATIONS types." + (let ((lines (list "GNTP/1.0 REGISTER NONE" + (format "Application-Name: %s" + gntp-application-name) + (format "Notifications-Count: %d" + (length notifications)))) + (icon-uri (gntp-app-icon-uri)) + (icon-data (gntp-app-icon-data)) + (icons (list))) + + ;; append icon uri + (when icon-uri + (nconc lines (list (format "Application-Icon: %s" icon-uri))) + ;; and data when it exists + (when icon-data + (setq icons (cons icon-data icons)))) + + (dolist (notice notifications) + ;; "For each notification being registered: + ;; Each notification being registered should be seperated by a + ;; blank line, including the first notification + (nconc lines (cons "" (gntp-notification-lines notice))) + ;; c + (let ((icon (gntp-notice-icon-data notice))) + (when icon + (nconc icons (list "" icon))))) + + ;; icon data must come last + (when icons + (nconc lines (cons "" icons))) + + (mapconcat 'identity (remove nil lines) "\r\n"))) + +(defun gntp-notification-lines (notice) + "Transform NOTICE into a list of strings." + (let ((display-name (gntp-notice-get notice :display)) + (enabled (gntp-notice-get notice :enabled)) + (icon-uri (gntp-notice-icon-uri notice))) + (list + ;; Required - The name (type) of the notification being registered + (concat "Notification-Name: " (gntp-notice-name notice)) + ;; Optional - The name of the notification that is displayed to + ;; the user (defaults to the same value as Notification-Name) + (when display-name + (concat "Notification-Display-Name: " display-name)) + ;; Optional - Indicates if the notification should be enabled by + ;; default (defaults to False) + (when enabled + "Notification-Enabled: True") + ;; Optional - The default icon to use for notifications of this type + (when icon-uri + (concat "Notification-Icon: " icon-uri))))) + +(defun gntp-build-message-notify (name title text &optional priority icon) + "Build a message of type NAME with TITLE and TEXT." + + (format + "GNTP/1.0 NOTIFY NONE\r\n\ +Application-Name: %s\r\n\ +Notification-Name: %s\r\n\ +Notification-Title: %s\r\n\ +Notification-Text: %s\r\n\ +Notification-Priority: %s\r\n\ +Notification-Icon: %s\r\n\ +\r\n" + gntp-application-name + (if (symbolp name) (symbol-name name) name) + title + ;; no CRLF in the text to avoid accidentel msg end + (replace-regexp-in-string "\r\n" "\n" text) + (if priority priority "0") + (if icon (gntp-icon-uri icon) ""))) + +;; notice +;;(list name ; everthing else is optional +;; :display "name to display" +;; :enabled nil +;; :icon "url or file") + + +(defun gntp-notice-icon-uri (notice) + "Get the icon URI from NOTICE." + (gntp-icon-uri (gntp-notice-get notice :icon))) + +(defun gntp-notice-icon-data (notice) + "Get icon data from NOTICE." + (gntp-icon-data (gntp-notice-get notice :icon))) + +(defun gntp-app-icon-uri () + "Return the value to be used in the Application-Icon header." + (gntp-icon-uri gntp-application-icon)) + +(defun gntp-app-icon-data () + "Return the value to be used in the Application-Icon header." + (gntp-icon-data gntp-application-icon)) + +(defun gntp-icon-uri (icon) + "Get the URI of ICON." + (when icon + (cond ((string-equal (substring icon 0 7) "http://") icon) + ((and (file-exists-p icon) (file-readable-p icon)) + (concat "x-growl-resource://" (md5 icon)))))) + +(defun gntp-icon-data (icon) + "Get the URI of ICON." + (when (and icon (not (string-equal (substring icon 0 7) "http://")) + (file-exists-p icon) (file-readable-p icon)) + (let ((id (md5 icon)) + (data (gntp-file-string icon))) + (format "Identifier: %s\r\nLength: %d\r\n\r\n%s" + id (length data) data)))) + +(defun gntp-notice-name (notice) + "Get the name of NOTICE. The name must be either a symbol or string." + (let ((name (car notice))) + (if (symbolp name) + (symbol-name name) + name))) + +(defun gntp-notice-get (notice property) + "Get PROPERTY from NOTICE." + (plist-get (cdr notice) property)) + +(defun gntp-send (message server &optional port) + "Send MESSAGE to SERVER:PORT. PORT defaults to `gntp-server-port'." + (let ((proc (make-network-process + :name "gntp" + :host server + :server nil + :service (if port port gntp-server-port) + ;;:sentinel 'gntp-sentinel + :filter 'gntp-filter))) + ;; hmm one CRLF too much? + (process-send-string proc (concat message "\r\n\r\n\r\n")))) + +(defun gntp-filter (proc string) + "Filter for PROC started by `gntp-send'. +Argument STRING reply from the server." + (when (string-equal "GNTP/1.0 -ERROR" (substring string 0 15)) + (error "GNTP: Something went wrong take a look at the reply:\n %s" + string))) + +;; (defun gntp-sentinel (proc msg) +;; (when (string= msg "connection broken by remote peer\n") +;; (message (format "client %s has quit" proc)))) + + +(defun gntp-file-string (file) + "Read the contents of a FILE and return as a string." + (with-temp-buffer + (insert-file-contents-literally file) + (buffer-string))) + +(provide 'gntp) + +;;; gntp.el ends here diff --git a/org/elpa/log4e-20211019.948/log4e-autoloads.el b/org/elpa/log4e-20211019.948/log4e-autoloads.el new file mode 100644 index 0000000..4488e46 --- /dev/null +++ b/org/elpa/log4e-20211019.948/log4e-autoloads.el @@ -0,0 +1,33 @@ +;;; log4e-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "log4e" "log4e.el" (0 0 0 0)) +;;; Generated autoloads from log4e.el + +(autoload 'log4e-mode "log4e" "\ +Major mode for browsing a buffer made by log4e. + +\\ +\\{log4e-mode-map} + +\(fn)" t nil) + +(autoload 'log4e:insert-start-log-quickly "log4e" "\ +Insert logging statment for trace level log at start of current function/macro." t nil) + +(register-definition-prefixes "log4e" '("log4e")) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; log4e-autoloads.el ends here diff --git a/org/elpa/log4e-20211019.948/log4e-pkg.el b/org/elpa/log4e-20211019.948/log4e-pkg.el new file mode 100644 index 0000000..928765c --- /dev/null +++ b/org/elpa/log4e-20211019.948/log4e-pkg.el @@ -0,0 +1,2 @@ +;;; Generated package description from log4e.el -*- no-byte-compile: t -*- +(define-package "log4e" "20211019.948" "provide logging framework for elisp" 'nil :commit "737d275eac28dbdfb0b26d28e99da148bfce9d16" :authors '(("Hiroaki Otsu" . "ootsuhiroaki@gmail.com")) :maintainer '("Hiroaki Otsu" . "ootsuhiroaki@gmail.com") :keywords '("log") :url "https://github.com/aki2o/log4e") diff --git a/org/elpa/log4e-20211019.948/log4e.el b/org/elpa/log4e-20211019.948/log4e.el new file mode 100644 index 0000000..a90f9e4 --- /dev/null +++ b/org/elpa/log4e-20211019.948/log4e.el @@ -0,0 +1,592 @@ +;;; log4e.el --- provide logging framework for elisp + +;; Copyright (C) 2013 Hiroaki Otsu + +;; Author: Hiroaki Otsu +;; Keywords: log +;; Package-Version: 20211019.948 +;; Package-Commit: 737d275eac28dbdfb0b26d28e99da148bfce9d16 +;; URL: https://github.com/aki2o/log4e +;; Version: 0.3.3 + +;; 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 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 this program. If not, see . + +;;; Commentary: +;; +;; This extension provides logging framework for elisp. + +;;; Dependency: +;; +;; Nothing. + +;;; Installation: +;; +;; Put this to your load-path. +;; And put the following lines in your elisp file. +;; +;; (require 'log4e) + +;;; Configuration: +;; +;; See +;; Otherwise, eval following sexp. +;; (describe-function 'log4e:deflogger) + +;;; API: +;; +;; [EVAL] (autodoc-document-lisp-buffer :type 'command :prefix "log4e:" :docstring t) +;; `log4e:next-log' +;; Move to start of next log on log4e-mode. +;; `log4e:previous-log' +;; Move to start of previous log on log4e-mode. +;; `log4e:insert-start-log-quickly' +;; Insert logging statment for trace level log at start of current function/macro. +;; +;; *** END auto-documentation +;; +;; For detail, see +;; +;; [Note] Other than listed above, Those specifications may be changed without notice. + +;;; Tested On: +;; +;; - Emacs ... GNU Emacs 23.3.1 (i386-mingw-nt5.1.2600) of 2011-08-15 on GNUPACK + + +;; Enjoy!!! + + +;;; Code: +(eval-when-compile (require 'cl-lib)) +(require 'rx) + + +(defconst log4e-log-level-alist '((fatal . 6) + (error . 5) + (warn . 4) + (info . 3) + (debug . 2) + (trace . 1)) + "Alist of log level value.") + +(defconst log4e-default-logging-function-name-alist '((fatal . "log-fatal") + (error . "log-error") + (warn . "log-warn") + (info . "log-info") + (debug . "log-debug") + (trace . "log-trace")) + "Alist of logging function name at default.") + + +(defmacro log4e--def-symmaker (symnm) + `(progn + (defsubst ,(intern (concat "log4e--make-symbol-" symnm)) (prefix) + (intern (concat ,(format "log4e--%s-" symnm) prefix))))) + +(log4e--def-symmaker "log-buffer") +(log4e--def-symmaker "msg-buffer") +(log4e--def-symmaker "log-template") +(log4e--def-symmaker "time-template") +(log4e--def-symmaker "min-level") +(log4e--def-symmaker "max-level") +(log4e--def-symmaker "toggle-logging") +(log4e--def-symmaker "toggle-debugging") +(log4e--def-symmaker "buffer-coding-system") +(log4e--def-symmaker "author-mail-address") + +(defmacro log4e--def-level-logger (prefix suffix level) + (let ((argform (if suffix + '(msg &rest msgargs) + '(level msg &rest msgargs))) + (buff (log4e--make-symbol-log-buffer prefix)) + (msgbuff (log4e--make-symbol-msg-buffer prefix)) + (codsys (log4e--make-symbol-buffer-coding-system prefix)) + (logtmpl (log4e--make-symbol-log-template prefix)) + (timetmpl (log4e--make-symbol-time-template prefix)) + (minlvl (log4e--make-symbol-min-level prefix)) + (maxlvl (log4e--make-symbol-max-level prefix)) + (logging-p (log4e--make-symbol-toggle-logging prefix))) + `(progn + + ;; Define logging function + (defun ,(intern (concat prefix "--" (or suffix "log"))) ,argform + ,(format "Do logging for %s level log. +%sMSG/MSGARGS are passed to `format'." + (if suffix level "any") + (if suffix "" "LEVEL is symbol as a log level in '(trace debug info warn error fatal).\n")) + (let ((log4e--current-msg-buffer ,msgbuff)) + (apply 'log4e--logging ,buff ,codsys ,logtmpl ,timetmpl ,minlvl ,maxlvl ,logging-p ,(if suffix level 'level) msg msgargs))) + + ;; Define logging macro + (defmacro ,(intern (concat prefix "--" (or suffix "log") "*")) ,argform + ,(format "Do logging for %s level log. +%sMSG/MSGARGS are passed to `format'. +Evaluation of MSGARGS is invoked only if %s level log should be printed." + (if suffix level "any") + (if suffix "" "LEVEL is symbol as a log level in '(trace debug info warn error fatal).\n") + (if suffix level "the")) + (let (,@(if suffix (list `(level ',level)) '()) + (buff (log4e--make-symbol-log-buffer ,prefix)) + (msgbuff (log4e--make-symbol-msg-buffer ,prefix)) + (codsys (log4e--make-symbol-buffer-coding-system ,prefix)) + (logtmpl (log4e--make-symbol-log-template ,prefix)) + (timetmpl (log4e--make-symbol-time-template ,prefix)) + (minlvl (log4e--make-symbol-min-level ,prefix)) + (maxlvl (log4e--make-symbol-max-level ,prefix)) + (logging-p (log4e--make-symbol-toggle-logging ,prefix))) + `(let ((log4e--current-msg-buffer ,msgbuff)) + (when (and ,logging-p + (log4e--logging-level-p ,minlvl ,maxlvl ,level)) + (log4e--logging ,buff ,codsys ,logtmpl ,timetmpl ,minlvl ,maxlvl ,logging-p ,level ,msg ,@msgargs))))) + + ))) + +(defsubst log4e--logging-level-p (minlevel maxlevel currlevel) + (let ((minlvlvalue (or (assoc-default minlevel log4e-log-level-alist) + 1)) + (maxlvlvalue (or (assoc-default maxlevel log4e-log-level-alist) + 6)) + (currlvlvalue (or (assoc-default currlevel log4e-log-level-alist) + 0))) + (and (>= currlvlvalue minlvlvalue) + (<= currlvlvalue maxlvlvalue)))) + +(defsubst log4e--get-or-create-log-buffer (buffnm &optional codesys) + (or (get-buffer buffnm) + (let ((buff (get-buffer-create buffnm))) + (with-current-buffer buff + (log4e-mode) + (when codesys + (setq buffer-file-coding-system codesys))) + buff))) + +(defvar log4e--regexp-msg-format + (rx-to-string `(and "%" + (* (any "+#-0")) ; flags + (* (any "0-9")) ; width + (? "." (+ (any "0-9"))) ; precision + (any "a-zA-Z")))) + +(defsubst log4e--insert-log (logtmpl timetmpl level msg msgargs propertize-p) + (let ((timetext (format-time-string timetmpl)) + (lvltext (format "%-05s" (upcase (symbol-name level)))) + (buffer-read-only nil)) + (when propertize-p + (put-text-property 0 (length timetext) 'face 'font-lock-doc-face timetext) + (put-text-property 0 (length lvltext) 'face 'font-lock-keyword-face lvltext)) + (let* ((logtext logtmpl) + (logtext (replace-regexp-in-string "%t" timetext logtext)) + (logtext (replace-regexp-in-string "%l" lvltext logtext)) + (logtext (replace-regexp-in-string "%m" msg logtext)) + (begin (point))) + (insert logtext "\n") + (when propertize-p + (put-text-property begin (+ begin 1) 'log4e--level level)) + (cl-loop initially (goto-char begin) + while (and msgargs + (re-search-forward log4e--regexp-msg-format nil t)) + do (let* ((currtype (match-string-no-properties 0)) + (currarg (pop msgargs)) + (failfmt nil) + (currtext (condition-case e + (format currtype currarg) + (error (setq failfmt t) + (format "=%s=" (error-message-string e)))))) + (save-match-data + (when propertize-p + (ignore-errors + (cond (failfmt (put-text-property 0 (length currtext) 'face 'font-lock-warning-face currtext)) + (t (put-text-property 0 (length currtext) 'face 'font-lock-string-face currtext)))))) + (replace-match currtext t t))) + (goto-char begin)))) + +(defvar log4e--current-msg-buffer nil) + +;; We needs this signature be stay for other compiled plugins using old version +(defun log4e--logging (buffnm codsys logtmpl timetmpl minlevel maxlevel logging-p level msg &rest msgargs) + (when (and logging-p + (log4e--logging-level-p minlevel maxlevel level)) + (save-match-data + (with-current-buffer (log4e--get-or-create-log-buffer buffnm codsys) + (goto-char (point-max)) + (let* ((buffer-read-only nil) + (begin (point)) + (currlog (progn + (log4e--insert-log logtmpl timetmpl level msg msgargs t) + (goto-char (point-max)) + (buffer-substring-no-properties begin (point)))) + (msgbuf (or (when (and log4e--current-msg-buffer + (not (eq log4e--current-msg-buffer t))) + (ignore-errors (get-buffer log4e--current-msg-buffer))) + log4e--current-msg-buffer))) + (when msgbuf + (let ((standard-output (if (buffer-live-p msgbuf) + msgbuf + standard-output))) + (princ currlog)))) + nil)))) + +(defun log4e--get-current-log-line-level () + (save-excursion + (beginning-of-line) + (get-text-property (point) 'log4e--level))) + +;; We needs this signature be stay for other plugins compiled with this old version +(defun log4e--clear-log (buffnm) + (with-current-buffer (log4e--get-or-create-log-buffer buffnm) + (setq buffer-read-only nil) + (erase-buffer))) + +;; We needs this signature be stay for other plugins compiled with this old version +(defun log4e--open-log (buffnm) + (let* ((buff (get-buffer buffnm))) + (if (not (buffer-live-p buff)) + (message "[Log4E] Not exist log buffer.") + (with-current-buffer buff + (setq buffer-read-only t)) + (pop-to-buffer buff)))) + +;; We needs this signature be stay for other plugins compiled with this old version +(defun log4e--open-log-if-debug (buffnm dbg) + (when dbg + (log4e--open-log buffnm))) + +;; (defun log4e--send-report-if-not-debug (buffnm dbg addr prefix) +;; (let* ((buff (get-buffer buffnm))) +;; (when (and (not dbg) +;; (stringp addr) +;; (buffer-live-p buff)) +;; (reporter-submit-bug-report addr prefix nil nil nil nil)))) + + +(defmacro log4e:deflogger (prefix msgtmpl timetmpl &optional log-function-name-custom-alist) + "Define the functions of logging for your elisp. + +Specification: + After eval this, you can use the functions for supporting about logging. They are the following ... + - do logging for each log level. Log level are trace, debug, info, warn, error and fatal. + - set max and min log level. + - switch logging. + - switch debugging. + - open and clear log buffer. + - send bug report for you. + For details, see Functions section. + +Argument: + - PREFIX is string as your elisp prefix. + - MSGTMPL is string as format of log. The following words has a special meaning. + - %t ... Replaced with time string. About it, see TIMETMPL argument. + - %l ... Replaced with log level. They are 'TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'. + - %m ... Replaced with log message that passed by you. + - TIMETMPL is string as format of time. This value is passed to `format-time-string'. + - LOG-FUNCTION-NAME-CUSTOM-ALIST is alist as the function name of logging. + - If this value is nil, define the following functions. + yourprefix--log-trace + yourprefix--log-debug + ... + yourprefix--log-fatal + - If you want to custom the name of them, give like the following value. + '((fatal . \"fatal\") + (error . \"error\") + (warn . \"warn\") + (info . \"info\") + (debug . \"debug\") + (trace . \"trace\")) + Then, define the following functions. + yourprefix--trace + yourprefix--debug + ... + yourprefix--fatal + +Functions: + List all functions defined below. PREFIX is your prefix. + - PREFIX--log-fatal ... #1 + - PREFIX--log-error ... #1 + - PREFIX--log-warn ... #1 + - PREFIX--log-info ... #1 + - PREFIX--log-debug ... #1 + - PREFIX--log-trace ... #1 + - PREFIX--log-fatal* ... #2 + - PREFIX--log-error* ... #2 + - PREFIX--log-warn* ... #2 + - PREFIX--log-info* ... #2 + - PREFIX--log-debug* ... #2 + - PREFIX--log-trace* ... #2 + - PREFIX--log + - PREFIX--log-set-level + - PREFIX--log-enable-logging ... #3 + - PREFIX--log-disable-logging ... #3 + - PREFIX--log-enable-messaging ... #3 + - PREFIX--log-disable-messaging ... #3 + - PREFIX--log-enable-debugging ... #3 + - PREFIX--log-disable-debugging ... #3 + - PREFIX--log-debugging-p + - PREFIX--log-set-coding-system + - PREFIX--log-set-author-mail-address + - PREFIX--log-clear-log ... #3 + - PREFIX--log-open-log ... #3 + - PREFIX--log-open-log-if-debug + + #1 : You can customize this name + #2 : Name is a #1 name + \"*\" + #3 : This is command + +Example: +;; If you develop elisp that has prefix \"hoge\", write and eval the following sexp in your elisp file. + + (require 'log4e) + (log4e:deflogger \"hoge\" \"%t [%l] %m\" \"%H:%M:%S\") + +;; Eval the following + (hoge--log-enable-logging) + +;; Then, write the following + + (defun hoge-do-hoge (hoge) + (if (not (stringp hoge)) + (hoge--log-fatal \"failed do hoge : hoge is '%s'\" hoge) + (hoge--log-debug \"start do hoge about '%s'\" hoge) + (message \"hoge!\") + (hoge--log-info \"done hoge about '%s'\" hoge))) + +;; Eval the following + (hoge-do-hoge \"HOGEGE\") + +;; Do M-x hoge--log-open-log +;; Open the buffer which name is \" *log4e-hoge*\". The buffer string is below +12:34:56 [INFO ] done hoge about 'HOGEGE' + +;; Eval the following + (hoge--log-set-level 'trace) + (hoge-do-hoge \"FUGAGA\") + +;; Do M-x hoge--log-open-log +;; Open the buffer. its string is below +12:34:56 [INFO ] done hoge about 'HOGEGE' +12:35:43 [DEBUG] start do hoge about 'FUGAGA' +12:35:43 [INFO ] done hoge about 'FUGAGA' + +" + (declare (indent 0)) + (if (or (not (stringp prefix)) (string= prefix "") + (not (stringp msgtmpl)) (string= msgtmpl "") + (not (stringp timetmpl)) (string= timetmpl "")) + (message "[LOG4E] invalid argument of deflogger") + (let* ((bufsym (log4e--make-symbol-log-buffer prefix)) + (msgbufsym (log4e--make-symbol-msg-buffer prefix)) + (logtmplsym (log4e--make-symbol-log-template prefix)) + (timetmplsym (log4e--make-symbol-time-template prefix)) + (minlvlsym (log4e--make-symbol-min-level prefix)) + (maxlvlsym (log4e--make-symbol-max-level prefix)) + (tglsym (log4e--make-symbol-toggle-logging prefix)) + (dbgsym (log4e--make-symbol-toggle-debugging prefix)) + (codsyssym (log4e--make-symbol-buffer-coding-system prefix)) + (addrsym (log4e--make-symbol-author-mail-address prefix)) + (funcnm-alist (cl-loop with custom-alist = (car (cdr log-function-name-custom-alist)) + for lvl in '(fatal error warn info debug trace) + for lvlpair = (assq lvl custom-alist) + for fname = (or (cdr-safe lvlpair) "") + collect (or (if (string-match "\*" fname) + (progn + (message "[LOG4E] ignore %s level name in log-function-name-custom-alist. can't use '*' for the name." lvl) + nil) + lvlpair) + (assq lvl log4e-default-logging-function-name-alist))))) + `(progn + + ;; Define variable for prefix + (defvar ,bufsym (format " *log4e-%s*" ,prefix)) + (defvar ,logtmplsym ,msgtmpl) + (defvar ,timetmplsym ,timetmpl) + (defvar ,minlvlsym 'info) + (defvar ,maxlvlsym 'fatal) + (defvar ,tglsym nil) + (defvar ,msgbufsym nil) + (defvar ,dbgsym nil) + (defvar ,codsyssym nil) + (defvar ,addrsym nil) + + ;; Define level set function + (defun ,(intern (concat prefix "--log-set-level")) (minlevel &optional maxlevel) + "Set range for doing logging. + +MINLEVEL is symbol of lowest level for doing logging. its default is 'info. +MAXLEVEL is symbol of highest level for doing logging. its default is 'fatal." + (setq ,minlvlsym minlevel) + (setq ,maxlvlsym maxlevel)) + + ;; Define logging toggle function + (defun ,(intern (concat prefix "--log-enable-logging")) () + "Enable logging by logging functions." + (interactive) + (setq ,tglsym t)) + (defun ,(intern (concat prefix "--log-disable-logging")) () + "Disable logging by logging functions." + (interactive) + (setq ,tglsym nil)) + + ;; Define messaging toggle function + (defun ,(intern (concat prefix "--log-enable-messaging")) (&optional buffer) + "Enable dump the log into other buffer by logging functions. + +BUFFER is a buffer dumped log into. nil means *Messages* buffer." + (interactive) + (setq ,msgbufsym (or buffer t))) + (defun ,(intern (concat prefix "--log-disable-messaging")) () + "Disable dump the log into other buffer by logging functions." + (interactive) + (setq ,msgbufsym nil)) + + ;; Define debugging toggle function + (defun ,(intern (concat prefix "--log-enable-debugging")) () + "Enable debugging and logging. + +`PREFIX--log-debugging-p' will return t." + (interactive) + (setq ,tglsym t) + (setq ,dbgsym t)) + (defun ,(intern (concat prefix "--log-disable-debugging")) () + "Disable debugging. + +`PREFIX--log-debugging-p' will return nil." + (interactive) + (setq ,dbgsym nil)) + (defun ,(intern (concat prefix "--log-debugging-p")) () + ,dbgsym) + + ;; Define coding system set funtion + (defun ,(intern (concat prefix "--log-set-coding-system")) (coding-system) + "Set charset and linefeed of LOG-BUFFER. + +CODING-SYSTEM is symbol for setting to `buffer-file-coding-system'. +LOG-BUFFER is a buffer which name is \" *log4e-PREFIX*\"." + (setq ,codsyssym coding-system)) + + ;; ;; Define author mail set function + ;; (defun ,(intern (concat prefix "--log-set-author-mail-address")) (before-atmark after-atmark) + ;; "Set mail address of author for elisp that has PREFIX. This value is used SEND-REPORT. + + ;; BEFORE-ATMARK is string as part of mail address. If your address is \"hoge@example.co.jp\", it is \"hoge\". + ;; AFTER-ATMARK is string as part of mail address. If your address is \"hoge@example.co.jp\", it is \"example.co.jp\". + ;; SEND-REPORT is `PREFIX--log-send-report-if-not-debug'." + ;; (setq ,addrsym (concat before-atmark "@" after-atmark))) + + ;; Define log buffer handle function + (defun ,(intern (concat prefix "--log-clear-log")) () + "Clear buffer string of buffer which name is \" *log4e-PREFIX*\"." + (interactive) + (log4e--clear-log ,bufsym)) + (defun ,(intern (concat prefix "--log-open-log")) () + "Open buffer which name is \" *log4e-PREFIX*\"." + (interactive) + (log4e--open-log ,bufsym)) + (defun ,(intern (concat prefix "--log-open-log-if-debug")) () + "Open buffer which name is \" *log4e-PREFIX*\" if debugging is enabled." + (log4e--open-log-if-debug ,bufsym ,dbgsym)) + + ;; ;; Define report send function + ;; (defun ,(intern (concat prefix "--log-send-report-if-not-debug")) () + ;; "Send bug report to author if debugging is disabled. + + ;; The author mailaddress is set by `PREFIX--log-set-author-mail-address'. + ;; About the way of sending bug report, see `reporter-submit-bug-report'." + ;; (log4e--send-report-if-not-debug ,bufsym ,dbgsym ,addrsym ,prefix)) + + ;; Define each level logging function + (log4e--def-level-logger ,prefix nil nil) + (log4e--def-level-logger ,prefix ,(assoc-default 'fatal funcnm-alist) 'fatal) + (log4e--def-level-logger ,prefix ,(assoc-default 'error funcnm-alist) 'error) + (log4e--def-level-logger ,prefix ,(assoc-default 'warn funcnm-alist) 'warn) + (log4e--def-level-logger ,prefix ,(assoc-default 'info funcnm-alist) 'info) + (log4e--def-level-logger ,prefix ,(assoc-default 'debug funcnm-alist) 'debug) + (log4e--def-level-logger ,prefix ,(assoc-default 'trace funcnm-alist) 'trace) + + )))) + + +;;;###autoload +(define-derived-mode log4e-mode view-mode "Log4E" + "Major mode for browsing a buffer made by log4e. + +\\ +\\{log4e-mode-map}" + (define-key log4e-mode-map (kbd "J") 'log4e:next-log) + (define-key log4e-mode-map (kbd "K") 'log4e:previous-log)) + +(defun log4e:next-log () + "Move to start of next log on log4e-mode." + (interactive) + (let* ((level)) + (while (and (not level) + (< (point) (point-max))) + (forward-line 1) + (setq level (log4e--get-current-log-line-level))) + level)) + +(defun log4e:previous-log () + "Move to start of previous log on log4e-mode." + (interactive) + (let* ((level)) + (while (and (not level) + (> (point) (point-min))) + (forward-line -1) + (setq level (log4e--get-current-log-line-level))) + level)) + +;;;###autoload +(defun log4e:insert-start-log-quickly () + "Insert logging statment for trace level log at start of current function/macro." + (interactive) + (let* ((fstartpt (when (re-search-backward "(\\(?:defun\\|defmacro\\|defsubst\\)\\*? +\\([^ ]+\\) +(\\([^)]*\\))" nil t) + (point))) + (fncnm (when fstartpt (match-string-no-properties 1))) + (argtext (when fstartpt (match-string-no-properties 2))) + (prefix (save-excursion + (goto-char (point-min)) + (cl-loop while (re-search-forward "(log4e:deflogger[ \n]+\"\\([^\"]+\\)\"" nil t) + for prefix = (match-string-no-properties 1) + for currface = (get-text-property (match-beginning 0) 'face) + if (not (eq currface 'font-lock-comment-face)) + return prefix)))) + (when (and fstartpt prefix) + (let* ((fncnm (replace-regexp-in-string (concat "\\`" prefix "[^a-zA-Z0-9]+") "" fncnm)) + (fncnm (replace-regexp-in-string "-" " " fncnm)) + (argtext (replace-regexp-in-string "\n" " " argtext)) + (argtext (replace-regexp-in-string "^ +" "" argtext)) + (argtext (replace-regexp-in-string " +$" "" argtext)) + (args (split-string argtext " +")) + (args (cl-loop for arg in args + if (and (not (string= arg "")) + (not (string-match "\\`&" arg))) + collect arg)) + (logtext (cl-loop with ret = (format "start %s." fncnm) + for arg in args + do (setq ret (concat ret " " arg "[%s]")) + finally return ret)) + (sexpformat (cl-loop with ret = "(%s--log 'trace \"%s\"" + for arg in args + do (setq ret (concat ret " %s")) + finally return (concat ret ")"))) + (inserttext (apply 'format sexpformat prefix logtext args))) + (forward-char) + (forward-sexp 3) + (when (re-search-forward "\\=[ \n]+\"" nil t) + (forward-char -1) + (forward-sexp)) + (newline-and-indent) + (insert inserttext))))) + + +(provide 'log4e) +;;; log4e.el ends here diff --git a/org/elpa/org-alert-20220721.1721/org-alert-autoloads.el b/org/elpa/org-alert-20220721.1721/org-alert-autoloads.el new file mode 100644 index 0000000..a84e609 --- /dev/null +++ b/org/elpa/org-alert-20220721.1721/org-alert-autoloads.el @@ -0,0 +1,22 @@ +;;; org-alert-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "org-alert" "org-alert.el" (0 0 0 0)) +;;; Generated autoloads from org-alert.el + +(register-definition-prefixes "org-alert" '("org-alert-")) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; org-alert-autoloads.el ends here diff --git a/org/elpa/org-alert-20220721.1721/org-alert-pkg.el b/org/elpa/org-alert-20220721.1721/org-alert-pkg.el new file mode 100644 index 0000000..46f1d33 --- /dev/null +++ b/org/elpa/org-alert-20220721.1721/org-alert-pkg.el @@ -0,0 +1,2 @@ +;;; Generated package description from org-alert.el -*- no-byte-compile: t -*- +(define-package "org-alert" "20220721.1721" "Notify org deadlines via notify-send" '((org "9.0") (alert "1.2")) :commit "f1801e061722843329b95409957c7dbd5cc223e9" :authors '(("Stephen Pegoraro" . "spegoraro@tutive.com")) :maintainer '("Stephen Pegoraro" . "spegoraro@tutive.com") :keywords '("org" "org-mode" "notify" "notifications" "calendar") :url "https://github.com/spegoraro/org-alert") diff --git a/org/elpa/org-alert-20220721.1721/org-alert.el b/org/elpa/org-alert-20220721.1721/org-alert.el new file mode 100644 index 0000000..d44cd56 --- /dev/null +++ b/org/elpa/org-alert-20220721.1721/org-alert.el @@ -0,0 +1,169 @@ +;;; org-alert.el --- Notify org deadlines via notify-send + +;; Copyright (C) 2015 Stephen Pegoraro + +;; Author: Stephen Pegoraro +;; Version: 0.2.0 +;; Package-Version: 20220721.1721 +;; Package-Commit: f1801e061722843329b95409957c7dbd5cc223e9 +;; Package-Requires: ((org "9.0") (alert "1.2")) +;; Keywords: org, org-mode, notify, notifications, calendar +;; URL: https://github.com/spegoraro/org-alert + +;; 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 . + +;;; Commentary: + +;; This package provides functions to display system notifications for +;; any org-mode deadlines that are due in your agenda. To perform a +;; one-shot check call (org-alert-deadlines). To enable repeated +;; checking call (org-alert-enable) and to disable call +;; (org-alert-disable). You can set the checking interval by changing +;; the org-alert-interval variable to the number of seconds you'd +;; like. + + +;;; Code: + +(require 'cl-lib) +(require 'alert) +(require 'org-agenda) + + +(defvar org-alert-interval 300 + "Interval in seconds to recheck and display deadlines.") + +;; TODO look for a property of the agenda entry as suggested in +;; https://github.com/spegoraro/org-alert/issues/20 +(defvar org-alert-notify-cutoff 10 + "Time in minutes before a deadline a notification should be sent.") + +(defvar org-alert-notify-after-event-cutoff nil + "Time in minutes after a deadline to stop sending notifications. +If nil, never stop sending notifications.") + +(defvar org-alert-notification-title "*org*" + "Title to be sent with notify-send.") + +(defvar org-alert-match-string + "SCHEDULED>=\"\"+SCHEDULED<\"\"|DEADLINE>=\"\"+DEADLINE<\"\"" + "property/todo/tags match string to be passed to `org-map-entries'.") + +(defvar org-alert-time-match-string + "\\(?:SCHEDULED\\|DEADLINE\\):.*<.*\\([0-9]\\{2\\}:[0-9]\\{2\\}\\).*>" + "regex to find times in an org subtree. The first capture group +is used to extract the time") + +(defun org-alert--read-subtree () + "Return the current subtree as a string. Adapted from +`org-copy-subtree` from org-mode." + (org-preserve-local-variables + (let (beg end folded (beg0 (point))) + (org-back-to-heading t) + (setq beg (point)) + (skip-chars-forward " \t\r\n") + (save-match-data + (save-excursion (outline-end-of-heading) + (setq folded (org-invisible-p))) + (ignore-errors (org-forward-heading-same-level (1- n) t)) + (org-end-of-subtree t t)) + ;; Include the end of an inlinetask + (when (and (featurep 'org-inlinetask) + (looking-at-p (concat (org-inlinetask-outline-regexp) + "END[ \t]*$"))) + (end-of-line)) + (setq end (point)) + (goto-char beg0) + (when (> end beg) + (setq org-subtree-clip-folded folded) + (buffer-substring-no-properties beg end))))) + +;; I think this is unnecessary now that we're using read-subtree +;; instead of copy-subtree +(defun org-alert--strip-text-properties (text) + "Strip all of the text properties from a copy of TEXT and +return the stripped copy" + (let ((text (substring text))) + (set-text-properties 0 (length text) nil text) + text)) + +(defun org-alert--grab-subtree () + "Return the current org subtree as a string with the +text-properties stripped" + (let* ((subtree (org-alert--read-subtree)) + (text (org-alert--strip-text-properties subtree))) + (apply #'concat + (cl-remove-if #'(lambda (s) (string= s "")) + (cdr (split-string text "\n")))))) + +(defun org-alert--to-minute (hour minute) + "Convert HOUR and MINUTE to minutes" + (+ (* 60 hour) minute)) + +(defun org-alert--check-time (time &optional now) + "Check if TIME is less than `org-alert-notify-cutoff` from NOW. If +`org-alert-notify-after-event-cutoff` is set, also check that NOW +is less than `org-alert-notify-after-event-cutoff` past TIME." + (let* ((time (mapcar #'string-to-number (split-string time ":"))) + (now (or now (decode-time (current-time)))) + (now (org-alert--to-minute (decoded-time-hour now) (decoded-time-minute now))) + (then (org-alert--to-minute (car time) (cadr time))) + (time-until (- then now))) + (if org-alert-notify-after-event-cutoff + (and + (<= time-until org-alert-notify-cutoff) + ;; negative time-until past events + (> time-until (- org-alert-notify-after-event-cutoff))) + (<= time-until org-alert-notify-cutoff)))) + +(defun org-alert--parse-entry () + "Parse an entry from the org agenda and return a list of the +heading and the scheduled/deadline time" + (let ((head (org-alert--strip-text-properties (org-get-heading t t t t))) + (body (org-alert--grab-subtree))) + (string-match org-alert-time-match-string body) + (list head (match-string 1 body)))) + +(defun org-alert--dispatch () + (let* ((entry (org-alert--parse-entry)) + (head (car entry)) + (time (cadr entry))) + (if time + (when (org-alert--check-time time) + (alert (concat time ": " head) :title org-alert-notification-title)) + (alert head :title org-alert-notification-title)))) + +(defun org-alert-check () + "Check for active, due deadlines and initiate notifications." + (interactive) + (org-map-entries 'org-alert--dispatch org-alert-match-string 'agenda + '(org-agenda-skip-entry-if 'todo + org-done-keywords-for-agenda)) + t) + +(defun org-alert-enable () + "Enable the notification timer. Cancels existing timer if running." + (interactive) + (org-alert-disable) + (run-at-time 0 org-alert-interval 'org-alert-check)) + +(defun org-alert-disable () + "Cancel the running notification timer." + (interactive) + (dolist (timer timer-list) + (if (eq (elt timer 5) 'org-alert-check) + (cancel-timer timer)))) + +(provide 'org-alert) +;;; org-alert.el ends here diff --git a/org/init.el b/org/init.el index 6e00645..a391b1c 100644 --- a/org/init.el +++ b/org/init.el @@ -63,14 +63,21 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; additional packages (add-to-list 'package-selected-packages - '(ox-hugo org-super-agenda org-alert) + '(ox-hugo org-super-agenda org-alert alert) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Load misc extensions (require 'org) -(use-package org-alert) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; org-alert +;(use-package org-alert) +;(setq alert-default-style 'message) +;(setq org-alert-interval 60 +; org-alert-notify-cutoff 15 +; org-alert-notify-after-event-cutoff 86400) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Update/add auto file handling @@ -214,4 +221,5 @@ ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(custom-safe-themes - '("dde643b0efb339c0de5645a2bc2e8b4176976d5298065b8e6ca45bc4ddf188b7" "bfc0b9c3de0382e452a878a1fb4726e1302bf9da20e69d6ec1cd1d5d82f61e3d" default))) + '("dde643b0efb339c0de5645a2bc2e8b4176976d5298065b8e6ca45bc4ddf188b7" "bfc0b9c3de0382e452a878a1fb4726e1302bf9da20e69d6ec1cd1d5d82f61e3d" default)) +)