view lisp/gnus/legacy-gnus-agent.el @ 110523:a5ad4f188e19

Synch Semantic to CEDET 1.0. Move CEDET ChangeLog entries to new file lisp/cedet/ChangeLog. * semantic.el (semantic-version): Update to 2.0. (semantic-mode-map): Add "," and "m" bindings. (navigate-menu): Update. * semantic/symref.el (semantic-symref-calculate-rootdir): New function. (semantic-symref-detect-symref-tool): Use it. * semantic/symref/grep.el (semantic-symref-grep-shell): New var. (semantic-symref-perform-search): Use it. Calculate root dir with semantic-symref-calculate-rootdir. (semantic-symref-derive-find-filepatterns): Improve error message. * semantic/symref/list.el (semantic-symref-results-mode-map): New bindings. (semantic-symref-auto-expand-results): New option. (semantic-symref-results-dump): Obey auto-expand. (semantic-symref-list-expand-all, semantic-symref-regexp) (semantic-symref-list-contract-all) (semantic-symref-list-map-open-hits) (semantic-symref-list-update-open-hits) (semantic-symref-list-create-macro-on-open-hit) (semantic-symref-list-call-macro-on-open-hits): New functions. (semantic-symref-list-menu-entries) (semantic-symref-list-menu): New vars. (semantic-symref-list-map-open-hits): Move cursor to beginning of match before calling the mapped function. * semantic/doc.el (semantic-documentation-comment-preceeding-tag): Do nothing if the mode doesn't provide comment-start-skip. * semantic/scope.el (semantic-analyze-scope-nested-tags-default): Strip duplicates. (semantic-analyze-scoped-inherited-tag-map): Take the tag we are looking for as part of the scoped tags list. * semantic/html.el (semantic-default-html-setup): Add senator-step-at-tag-classes. * semantic/decorate/include.el (semantic-decoration-on-unknown-includes): Change light bgcolor. (semantic-decoration-on-includes-highlight-default): Check that the include tag has a postion. * semantic/complete.el (semantic-collector-local-members): (semantic-complete-read-tag-local-members) (semantic-complete-jump-local-members): New class and functions. (semantic-complete-self-insert): Save excursion before completing. * semantic/analyze/complete.el (semantic-analyze-possible-completions-default): If no completions are found, return the raw by-name-only completion list. Add FLAGS arguments. Add support for 'no-tc (type constraint) and 'no-unique, or no stripping duplicates. (semantic-analyze-possible-completions-default): Add FLAGS arg. * semantic/util-modes.el (semantic-stickyfunc-show-only-functions-p): New option. (semantic-stickyfunc-fetch-stickyline): Don't show stickytext for the very first line in a buffer. * semantic/util.el (semantic-hack-search) (semantic-recursive-find-nonterminal-by-name) (semantic-current-tag-interactive): Deleted. (semantic-describe-buffer): Fix expand-nonterminal. Add lex-syntax-mods, type relation separator char, and command separation char. (semantic-sanity-check): Only message if called interactively. * semantic/tag.el (semantic-tag-deep-copy-one-tag): Copy the :filename property and the tag position. * semantic/lex-spp.el (semantic-lex-spp-lex-text-string): Add recursion limit. * semantic/imenu.el (semantic-imenu-bucketize-type-members): Make this buffer local, not the obsoleted variable. * semantic/idle.el: Add breadcrumbs support. (semantic-idle-summary-current-symbol-info-default) (semantic-idle-tag-highlight) (semantic-idle-completion-list-default): Use semanticdb-without-unloaded-file-searches for speed, and to conform to the controls that specify if the idle timer is supposed to be parsing unparsed includes. (semantic-idle-symbol-highlight-face) (semantic-idle-symbol-maybe-highlight): Rename from *-summary-*. Callers changed. (semantic-idle-work-parse-neighboring-files-flag): Default to nil. (semantic-idle-work-update-headers-flag): New var. (semantic-idle-work-for-one-buffer): Use it. (semantic-idle-local-symbol-highlight): Rename from semantic-idle-tag-highlight. (semantic-idle-truncate-long-summaries): New option. * semantic/ia.el (semantic-ia-cache) (semantic-ia-get-completions): Deleted. Callers changed. (semantic-ia-show-variants): New command. (semantic-ia-show-doc): If doc is empty, don't make a temp buffer. (semantic-ia-show-summary): If there isn't anything to show, say so. * semantic/grammar.el (semantic-grammar-create-package): Save the buffer even in batch mode. * semantic/fw.el (semanticdb-without-unloaded-file-searches): New macro. * semantic/dep.el (semantic-dependency-find-file-on-path): Fix case dereferencing ede-object when it is a list. * semantic/db-typecache.el (semanticdb-expand-nested-tag) (semanticdb-typecache-faux-namespace): New functions. (semanticdb-typecache-file-tags) (semanticdb-typecache-merge-streams): Use them. (semanticdb-typecache-file-tags): When deriving tags from a file, give the mode a chance to monkey with the tag copy. (semanticdb-typecache-find-default): Wrap find in save-excursion. (semanticdb-typecache-find-by-name-helper): Merge found names down. * semantic/db-global.el (semanticdb-enable-gnu-global-in-buffer): Don't show messages if GNU Global is not available and we don't want to throw an error. * semantic/db-find.el (semanticdb-find-result-nth-in-buffer): When trying to normalize the tag to a buffer, don't error if set-buffer method doesn't exist. * semantic/db-file.el (semanticdb-save-db): Simplify msg. * semantic/db.el (semanticdb-refresh-table): If forcing a refresh on a file not in a buffer, use semantic-find-file-noselect and delete the buffer after use. (semanticdb-current-database-list): When calculating root via hooks, force it through true-filename and skip the list of possible roots. * semantic/ctxt.el (semantic-ctxt-imported-packages): New. * semantic/analyze/debug.el (semantic-analyzer-debug-insert-tag): Reset standard output to current buffer. (semantic-analyzer-debug-global-symbol) (semantic-analyzer-debug-missing-innertype): Change "prefix" to "symbol" in messages. * semantic/analyze/refs.el: (semantic-analyze-refs-impl) (semantic-analyze-refs-proto): When calculating value, make sure the found tag is 'similar' to the originating tag. (semantic--analyze-refs-find-tags-with-parent): Attempt to identify matches via imported symbols of parents. (semantic--analyze-refs-full-lookup-with-parents): Do a deep search during the brute search. * semantic/analyze.el (semantic-analyze-find-tag-sequence-default): Be robust to calculated scopes being nil. * semantic/bovine/c.el (semantic-c-describe-environment): Add project macro symbol array. (semantic-c-parse-lexical-token): Add recursion limit. (semantic-ctxt-imported-packages, semanticdb-expand-nested-tag): New overrides. (semantic-expand-c-tag-namelist): Split a full type from a typedef out to its own tag. (semantic-expand-c-tag-namelist): Do not split out a typedef'd inline type if it is an anonymous type. (semantic-c-reconstitute-token): Use the optional initializers as a clue that some function is probably a constructor. When defining the type of these constructors, split the parent name, and use only the class part, if applicable. * semantic/bovine/c-by.el: * semantic/wisent/python-wy.el: Regenerate.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 18 Sep 2010 22:49:54 -0400
parents 1d1d5d9bd884
children 8d09094063d0 376148b31b5e
line wrap: on
line source

;;; gnus-agent.el --- Legacy unplugged support for Gnus

;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.

;; Author: Kevin Greiner <kgreiner@xpediantsolutions.com>
;; Keywords: news

;; This file is part of GNU Emacs.

;; GNU Emacs 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.

;; 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
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:

;; Conversion functions for the Agent.

;;; Code:
(require 'gnus-start)
(require 'gnus-util)
(require 'gnus-range)
(require 'gnus-agent)

;; Oort Gnus v0.08 - This release updated agent to no longer use
;;                   history file and to support a compressed alist.

(defvar gnus-agent-compressed-agentview-search-only nil)

(defun gnus-agent-convert-to-compressed-agentview (converting-to)
  "Iterates over all agentview files to ensure that they have been
converted to the compressed format."

  (let ((search-in (list gnus-agent-directory))
        here
        members
        member
        converted-something)
    (while (setq here (pop search-in))
      (setq members (directory-files here t))
      (while (setq member (pop members))
        (cond ((string-match "/\\.\\.?$" member)
	       nil)
	      ((file-directory-p member)
	       (push member search-in))
              ((equal (file-name-nondirectory member) ".agentview")
               (setq converted-something
                     (or (gnus-agent-convert-agentview member)
                         converted-something))))))

    (if converted-something
        (gnus-message 4 "Successfully converted Gnus %s offline (agent) files to %s" gnus-newsrc-file-version converting-to))))

(defun gnus-agent-convert-to-compressed-agentview-prompt ()
  (catch 'found-file-to-convert
    (let ((gnus-agent-compressed-agentview-search-only t))
      (gnus-agent-convert-to-compressed-agentview nil))))

(gnus-convert-mark-converter-prompt 'gnus-agent-convert-to-compressed-agentview 'gnus-agent-convert-to-compressed-agentview-prompt)

(defun gnus-agent-convert-agentview (file)
  "Load FILE and do a `read' there."
  (with-temp-buffer
      (nnheader-insert-file-contents file)
      (goto-char (point-min))
      (let ((inhibit-quit t)
            (alist (read (current-buffer)))
            (version (condition-case nil (read (current-buffer))
                       (end-of-file 0)))
            changed-version
            history-file)

        (cond
	 ((= version 0)
	  (let (entry
                (gnus-command-method nil))
            (mm-disable-multibyte) ;; everything is binary
            (erase-buffer)
            (insert "\n")
            (let ((file (concat (file-name-directory file) "/history")))
              (when (file-exists-p file)
                (nnheader-insert-file-contents file)
                (setq history-file file)))

	    (goto-char (point-min))
	    (while (not (eobp))
	      (if (and (looking-at
			"[^\t\n]+\t\\([0-9]+\\)\t\\([^ \n]+\\) \\([0-9]+\\)")
		       (string= (gnus-agent-article-name ".agentview" (match-string 2))
				file)
		       (setq entry (assoc (string-to-number (match-string 3)) alist)))
		  (setcdr entry (string-to-number (match-string 1))))
	      (forward-line 1))
	    (setq changed-version t)))
	 ((= version 1)
	  (setq changed-version t)))

        (when changed-version
	  (when gnus-agent-compressed-agentview-search-only
	    (throw 'found-file-to-convert t))

          (erase-buffer)
          (let (article-id day-of-download comp-list compressed)
	    (while alist
	      (setq article-id (caar alist)
		    day-of-download (cdar alist)
		    comp-list (assq day-of-download compressed)
		    alist (cdr alist))
	      (if comp-list
		  (setcdr comp-list (cons article-id (cdr comp-list)))
		(push (list day-of-download article-id) compressed)))
	    (setq alist compressed)
	    (while alist
	      (setq comp-list (pop alist))
	      (setcdr comp-list
		      (gnus-compress-sequence (nreverse (cdr comp-list)))))
            (princ compressed (current-buffer)))
          (insert "\n2\n")
          (write-file file)
          (when history-file
            (delete-file history-file))
          t))))

;; End of Oort Gnus v0.08 updates

;; No Gnus v0.3 - This release provides a mechanism for upgrading gnus
;;                from previous versions.  Therefore, the previous
;;                hacks to handle a gnus-agent-expire-days that
;;                specifies a list of values can be removed.

(defun gnus-agent-unlist-expire-days (converting-to)
  (when (listp gnus-agent-expire-days)
    (let (buffer)
      (unwind-protect
          (save-window-excursion
            (setq buffer (gnus-get-buffer-create " *Gnus agent upgrade*"))
            (set-buffer buffer)
            (erase-buffer)
            (insert "The definition of gnus-agent-expire-days has been changed.\nYou currently have it set to the list:\n  ")
            (gnus-pp gnus-agent-expire-days)

            (insert "\nIn order to use version '" converting-to "' of gnus, you will need to set\n")
            (insert "gnus-agent-expire-days to an integer. If you still wish to set different\n")
            (insert "expiration days to individual groups, you must instead set the\n")
            (insert "'agent-days-until-old group and/or topic parameter.\n")
            (insert "\n")
            (insert "If you would like, gnus can iterate over every group comparing its name to the\n")
            (insert "regular expressions that you currently have in gnus-agent-expire-days.  When\n")
            (insert "gnus finds a match, it will update that group's 'agent-days-until-old group\n")
            (insert "parameter to the value associated with the regular expression.\n")
            (insert "\n")
            (insert "Whether gnus assigns group parameters, or not, gnus will terminate with an\n")
            (insert "ERROR as soon as this function completes.  The reason is that you must\n")
            (insert "manually edit your configuration to either not set gnus-agent-expire-days or\n")
            (insert "to set it to an integer before gnus can be used.\n")
            (insert "\n")
            (insert "Once you have successfully edited gnus-agent-expire-days, gnus will be able to\n")
            (insert "execute past this function.\n")
            (insert "\n")
            (insert "Should gnus use gnus-agent-expire-days to assign\n")
            (insert "agent-days-until-old parameters to individual groups? (Y/N)")

            (switch-to-buffer buffer)
            (beep)
            (beep)

            (let ((echo-keystrokes 0)
                  c)
              (while (progn (setq c (read-char-exclusive))
                            (cond ((or (eq c ?y) (eq c ?Y))
                                         (save-excursion
                                           (let ((groups (gnus-group-listed-groups)))
                                             (while groups
                                               (let* ((group (pop groups))
                                                      (days gnus-agent-expire-days)
                                                      (day (catch 'found
                                                             (while days
                                                               (when (eq 0 (string-match
                                                                            (caar days)
                                                                            group))
                                                                 (throw 'found (cadr (car days))))
                                                               (setq days (cdr days)))
                                                             nil)))
                                                 (when day
                                                   (gnus-group-set-parameter group 'agent-days-until-old
                                                                             day))))))
                                   nil
                                   )
                                  ((or (eq c ?n) (eq c ?N))
                                   nil)
                                  (t
                                   t))))))
        (kill-buffer buffer))
      (error "Change gnus-agent-expire-days to an integer for gnus to start"))))

;; The gnus-agent-unlist-expire-days has its own conversion prompt.
;; Therefore, hide the default prompt.
(gnus-convert-mark-converter-prompt 'gnus-agent-unlist-expire-days t)

(defun gnus-agent-unhook-expire-days (converting-to)
  "Remove every lambda from gnus-group-prepare-hook that mention the
symbol gnus-agent-do-once in their definition.  This should NOT be
necessary as gnus-agent.el no longer adds them.  However, it is
possible that the hook was persistently saved."
    (let ((h t)) ; iterate from bgn of hook
      (while h
        (let ((func (progn (when (eq h t)
                             ;; init h to list of functions
                             (setq h (cond ((listp gnus-group-prepare-hook)
                                            gnus-group-prepare-hook)
                                           ((boundp 'gnus-group-prepare-hook)
                                            (list gnus-group-prepare-hook)))))
                           (pop h))))

          (when (cond ((eq (type-of func) 'compiled-function)
                       ;; Search def. of compiled function for gnus-agent-do-once string
                       (let* (definition
                               print-level
                               print-length
                               (standard-output
                                (lambda (char)
                                  (setq definition (cons char definition)))))
                         (princ func) ; populates definition with reversed list of characters
                         (let* ((i (length definition))
                                (s (make-string i 0)))
                           (while definition
                             (aset s (setq i (1- i)) (pop definition)))

                           (string-match "\\bgnus-agent-do-once\\b" s))))
                      ((listp func)
                       (eq (cadr (nth 2 func)) 'gnus-agent-do-once) ; handles eval'd lambda
                       ))

            (remove-hook 'gnus-group-prepare-hook func)
            ;; I don't what remove-hook is going to actually do to the
            ;; hook list so start over from the beginning.
            (setq h t))))))

;; gnus-agent-unhook-expire-days is safe in that it does not modify
;; the .newsrc.eld file.
(gnus-convert-mark-converter-prompt 'gnus-agent-unhook-expire-days t)

(provide 'legacy-gnus-agent)

;; arch-tag: 845c7b8a-88f7-4468-b8d7-94e8fc72cf1a
;;; legacy-gnus-agent.el ends here