1997-04-16 22:13:18 +00:00
|
|
|
;;; score-mode.el --- mode for editing Gnus score files
|
2004-09-04 13:13:48 +00:00
|
|
|
|
2019-01-01 00:59:58 +00:00
|
|
|
;; Copyright (C) 1996, 2001-2019 Free Software Foundation, Inc.
|
1997-04-16 22:13:18 +00:00
|
|
|
|
1999-02-20 14:05:57 +00:00
|
|
|
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
|
1997-04-16 22:13:18 +00:00
|
|
|
;; Keywords: news, mail
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
2008-05-06 03:56:49 +00:00
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
1997-04-16 22:13:18 +00:00
|
|
|
;; it under the terms of the GNU General Public License as published by
|
2008-05-06 03:56:49 +00:00
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
1997-04-16 22:13:18 +00:00
|
|
|
|
|
|
|
;; GNU Emacs 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
|
2017-09-13 15:52:52 -07:00
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
1997-04-16 22:13:18 +00:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2004-09-04 13:13:48 +00:00
|
|
|
(require 'mm-util) ; for mm-universal-coding-system
|
2005-05-27 04:08:12 +00:00
|
|
|
(require 'gnus-util) ; for gnus-pp, gnus-run-mode-hooks
|
1997-04-16 22:13:18 +00:00
|
|
|
|
Leading "*" in the doc of defvars is long obsolete.
* lisp/plstore.el (plstore-encrypt-to):
* lisp/cedet/semantic/lex-spp.el
(semantic-lex-spp-macro-max-length-to-save):
* lisp/cedet/semantic/symref.el (semantic-symref-tool):
* lisp/cedet/semantic/bovine/el.el
(semantic-elisp-store-documentation-in-tag):
* lisp/cedet/semantic/wisent/comp.el (wisent-verbose-flag)
(wisent-expected-conflicts):
* lisp/cedet/semantic/wisent/wisent.el (wisent-parse-verbose-flag):
* lisp/gnus/gnus-agent.el (gnus-category-menu-hook):
* lisp/gnus/gnus-group.el (gnus-group-listing-limit):
* lisp/gnus/gnus-srvr.el (gnus-server-menu-hook)
(gnus-browse-menu-hook):
* lisp/gnus/message.el (message-shoot-gnksa-feet):
* lisp/gnus/mm-decode.el (mm-path-name-rewrite-functions):
* lisp/gnus/mm-util.el (mm-extra-numeric-entities):
* lisp/gnus/mm-view.el (mm-w3m-standalone-supports-m17n-p):
* lisp/gnus/mml.el (mml-generate-multipart-alist):
* lisp/gnus/nndraft.el (nndraft-required-headers):
* lisp/gnus/nnheader.el (nnheader-max-head-length)
(nnheader-head-chop-length, nnheader-file-name-translation-alist)
(nnheader-directory-separator-character)
(nnheader-pathname-coding-system):
* lisp/gnus/nnmail.el (nnmail-pathname-coding-system)
(nnmail-active-file-coding-system):
* lisp/gnus/nnrss.el (nnrss-file-coding-system):
* lisp/gnus/nntp.el (nntp-record-commands):
* lisp/gnus/score-mode.el (gnus-score-edit-done-hook)
(gnus-score-mode-hook, gnus-score-menu-hook):
* lisp/mail/rfc2047.el (rfc2047-header-encoding-alist)
(rfc2047-allow-irregular-q-encoded-words)
(rfc2047-allow-incomplete-encoded-text):
* lisp/mh-e/mh-alias.el (mh-alias-system-aliases):
* lisp/mh-e/mh-e.el (mh-mail-header-separator, mh-x-mailer-string):
* lisp/mh-e/mh-scan.el (mh-scan-format-mh, mh-scan-format-nmh):
* lisp/net/pop3.el (pop3-password):
* lisp/play/animate.el (animate-n-steps):
* lisp/progmodes/cc-vars.el (c-old-style-variable-behavior):
Convert from defvar with leading * to defcustom.
; * lisp/cedet/semantic/lex.el: Comments.
* lisp/emulation/viper-init.el (viper-heading-end):
* lisp/gnus/mm-url.el (mm-url-html-entities):
* lisp/gnus/nnmaildir.el (nnmaildir-article-file-name):
* lisp/mh-e/mh-e.el (mh-invisible-header-fields-compiled):
* lisp/net/tramp-adb.el (tramp-adb-method): Remove leading * from doc.
* lisp/gnus/messcompat.el: Mark (pointless) file not for compilation.
(message-from-style, message-interactive, message-indentation-spaces)
(message-signature, message-signature-file):
Remove settings that match the defaults.
(message-setup-hook, message-mode-hook, message-default-headers)
(message-send-hook, message-send-mail-function):
Just use setq rather than redefining.
* lisp/gnus/nnrss.el (nnrss):
* lisp/mail/rfc2047.el (rfc2047):
* lisp/play/animate.el (animate): New custom groups.
2016-06-10 00:23:33 -04:00
|
|
|
(defcustom gnus-score-edit-done-hook nil
|
|
|
|
"Hook run at the end of closing the score buffer."
|
|
|
|
:group 'gnus-score
|
|
|
|
:type 'hook)
|
|
|
|
|
|
|
|
(defcustom gnus-score-mode-hook nil
|
|
|
|
"Hook run in score mode buffers."
|
|
|
|
:group 'gnus-score
|
|
|
|
:type 'hook)
|
|
|
|
|
|
|
|
(defcustom gnus-score-menu-hook nil
|
|
|
|
"Hook run after creating the score mode menu."
|
|
|
|
:group 'gnus-score
|
|
|
|
:type 'hook)
|
1997-04-16 22:13:18 +00:00
|
|
|
|
|
|
|
(defvar gnus-score-edit-exit-function nil
|
|
|
|
"Function run on exit from the score buffer.")
|
|
|
|
|
2013-09-10 23:31:56 -04:00
|
|
|
(defvar gnus-score-mode-map
|
|
|
|
(let ((map (make-sparse-keymap)))
|
|
|
|
(set-keymap-parent map emacs-lisp-mode-map)
|
|
|
|
(define-key map "\C-c\C-c" 'gnus-score-edit-exit)
|
|
|
|
(define-key map "\C-c\C-d" 'gnus-score-edit-insert-date)
|
|
|
|
(define-key map "\C-c\C-p" 'gnus-score-pretty-print)
|
|
|
|
map))
|
1997-04-16 22:13:18 +00:00
|
|
|
|
1999-02-20 14:05:57 +00:00
|
|
|
(defvar score-mode-syntax-table
|
|
|
|
(let ((table (copy-syntax-table lisp-mode-syntax-table)))
|
|
|
|
(modify-syntax-entry ?| "w" table)
|
|
|
|
table)
|
|
|
|
"Syntax table used in score-mode buffers.")
|
|
|
|
|
2000-09-19 13:37:09 +00:00
|
|
|
;; We need this to cope with non-ASCII scoring.
|
2004-09-04 13:13:48 +00:00
|
|
|
(defvar score-mode-coding-system mm-universal-coding-system)
|
2000-09-19 13:37:09 +00:00
|
|
|
|
1997-04-16 22:13:18 +00:00
|
|
|
;;;###autoload
|
2013-09-10 23:31:56 -04:00
|
|
|
(define-derived-mode gnus-score-mode emacs-lisp-mode "Score"
|
1997-04-16 22:13:18 +00:00
|
|
|
"Mode for editing Gnus score files.
|
|
|
|
This mode is an extended emacs-lisp mode.
|
|
|
|
|
|
|
|
\\{gnus-score-mode-map}"
|
|
|
|
(gnus-score-make-menu-bar)
|
2013-09-10 23:31:56 -04:00
|
|
|
(make-local-variable 'gnus-score-edit-exit-function))
|
1997-04-16 22:13:18 +00:00
|
|
|
|
|
|
|
(defun gnus-score-make-menu-bar ()
|
|
|
|
(unless (boundp 'gnus-score-menu)
|
|
|
|
(easy-menu-define
|
|
|
|
gnus-score-menu gnus-score-mode-map ""
|
|
|
|
'("Score"
|
|
|
|
["Exit" gnus-score-edit-exit t]
|
|
|
|
["Insert date" gnus-score-edit-insert-date t]
|
|
|
|
["Format" gnus-score-pretty-print t]))
|
|
|
|
(run-hooks 'gnus-score-menu-hook)))
|
|
|
|
|
|
|
|
(defun gnus-score-edit-insert-date ()
|
|
|
|
"Insert date in numerical format."
|
|
|
|
(interactive)
|
Prefer nil to (current-time) when either works
* doc/misc/gnus.texi (Category Syntax):
* lisp/allout-widgets.el (allout-widgets-post-command-business):
* lisp/cedet/ede/detect.el (ede-detect-qtest):
* lisp/cedet/pulse.el (pulse-momentary-highlight-overlay)
(pulse-tick):
* lisp/cedet/semantic.el (bovinate):
* lisp/cedet/semantic/analyze.el:
(semantic-analyze-current-symbol-default, semantic-adebug-analyze):
* lisp/cedet/semantic/analyze/refs.el (semantic-analyze-current-tag):
* lisp/cedet/semantic/lex.el (semantic-lex-test):
* lisp/cedet/semantic/symref/filter.el:
(semantic-symref-test-count-hits-in-tag):
* lisp/cedet/srecode/dictionary.el (srecode-adebug-dictionary):
* lisp/cedet/srecode/map.el (srecode-adebug-maps):
* lisp/desktop.el (desktop-create-buffer):
* lisp/emacs-lisp/benchmark.el (benchmark-elapse):
* lisp/emacs-lisp/elp.el (elp--make-wrapper):
* lisp/epa.el (epa--show-key):
* lisp/erc/erc.el (erc-lurker-cleanup, erc-lurker-p):
* lisp/gnus/gnus-agent.el (gnus-agent-fetch-articles)
(gnus-agent-expire-group-1, gnus-agent-store-article):
* lisp/gnus/gnus-art.el (article-lapsed-string):
* lisp/gnus/gnus-cloud.el (gnus-cloud-update-newsrc-data)
(gnus-cloud-collect-full-newsrc):
* lisp/gnus/gnus-group.el (gnus-group-timestamp-delta):
* lisp/gnus/gnus-html.el (gnus-html-cache-expired):
* lisp/gnus/gnus-score.el (gnus-score-load-file)
(gnus-decay-scores):
* lisp/gnus/nndiary.el (nndiary-expired-article-p):
* lisp/gnus/nnmail.el (nnmail-expired-article-p):
* lisp/gnus/nnmaildir.el (nnmaildir--scan):
* lisp/gnus/score-mode.el (gnus-score-edit-insert-date):
* lisp/image/gravatar.el (gravatar-cache-expired):
* lisp/net/newst-backend.el (newsticker--image-get)
(newsticker--cache-mark-expired):
* lisp/nxml/rng-maint.el (rng-time-function):
* lisp/org/org-agenda.el (org-agenda-to-appt):
* lisp/org/org-clock.el (org-clock-resolve-clock)
(org-clock-resolve, org-resolve-clocks-if-idle):
* lisp/org/org-colview.el (org-columns-edit-value, org-columns)
(org-columns-compute-all, org-agenda-columns):
* lisp/org/org-element.el (org-element--cache-interrupt-p)
(org-element--cache-sync):
* lisp/org/org-habit.el (org-habit-get-faces)
(org-habit-insert-consistency-graphs):
* lisp/org/org-indent.el (org-indent-add-properties):
* lisp/org/org-timer.el (org-timer-start)
(org-timer-pause-or-continue, org-timer-seconds)
(org-timer-show-remaining-time, org-timer-set-timer):
* lisp/org/org.el (org-babel-load-file, org-current-time)
(org-today, org-auto-repeat-maybe, org-read-date-analyze)
(org-small-year-to-year, org-goto-calendar):
* lisp/org/ox.el (org-export-insert-default-template):
* lisp/time.el (emacs-uptime):
* lisp/type-break.el (type-break-mode, type-break)
(type-break-time-warning-schedule, type-break-check):
* lisp/url/url-cache.el (url-cache-expired):
* lisp/url/url.el (url-retrieve-synchronously):
* test/lisp/char-fold-tests.el (char-fold--speed-test):
* test/manual/cedet/semantic-ia-utest.el:
(semantic-symref-test-count-hits-in-tag):
* test/manual/cedet/semantic-tests.el (semantic-idle-pnf-test)
(semantic-lex-test-full-depth):
Use nil instead of (current-time) where either will do, as nil is
a bit more efficient and should have less timing error.
2017-10-20 19:40:09 -07:00
|
|
|
(princ (time-to-days nil) (current-buffer)))
|
1997-04-16 22:13:18 +00:00
|
|
|
|
|
|
|
(defun gnus-score-pretty-print ()
|
|
|
|
"Format the current score file."
|
|
|
|
(interactive)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(let ((form (read (current-buffer))))
|
|
|
|
(erase-buffer)
|
1999-02-20 14:05:57 +00:00
|
|
|
(let ((emacs-lisp-mode-syntax-table score-mode-syntax-table))
|
2004-09-04 13:13:48 +00:00
|
|
|
(gnus-pp form)))
|
1997-04-16 22:13:18 +00:00
|
|
|
(goto-char (point-min)))
|
|
|
|
|
|
|
|
(defun gnus-score-edit-exit ()
|
|
|
|
"Stop editing the score file."
|
|
|
|
(interactive)
|
|
|
|
(unless (file-exists-p (file-name-directory (buffer-file-name)))
|
|
|
|
(make-directory (file-name-directory (buffer-file-name)) t))
|
2000-09-19 13:37:09 +00:00
|
|
|
(let ((coding-system-for-write score-mode-coding-system))
|
|
|
|
(save-buffer))
|
1997-04-16 22:13:18 +00:00
|
|
|
(bury-buffer (current-buffer))
|
|
|
|
(let ((buf (current-buffer)))
|
|
|
|
(when gnus-score-edit-exit-function
|
|
|
|
(funcall gnus-score-edit-exit-function))
|
|
|
|
(when (eq buf (current-buffer))
|
|
|
|
(switch-to-buffer (other-buffer (current-buffer))))))
|
|
|
|
|
|
|
|
(provide 'score-mode)
|
|
|
|
|
|
|
|
;;; score-mode.el ends here
|