From cc11250b11615cb4a4e7afdd8978660f7b776386 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Mon, 18 Jul 2005 08:23:00 +0000 Subject: [PATCH] Make customize of muse-project-alist work in Emacs21 and XEmacs. * lisp/muse.el (muse-widget-type-value-create) (muse-widget-child-value-get, muse-widget-type-match): Minimum set of extra widgets from 'lazy type that are needed to get the `muse-project-alist' customize interface to work on XEmacs and Emacs21. * lisp/muse.el (muse-implicit-link-functions) (muse-explicit-link-functions): Remove predefined wiki-related options. These are added in muse-wiki via custom-add-option. * lisp/muse-mode.el (muse-mode-hook): Ditto. * lisp/muse-colors.el (muse-colors-emphasized): Use eq instead of memq. * lisp/muse-project.el (muse-project-alist-get): Turn :symbols into ":strings" to cope with Emacs21 and XEmacs. (muse-project-alist-set): Turn ":strings" back into ":symbols". * lisp/muse-project.el (muse-project): Derive from 'default rather than 'lazy, since that is an Emacs CVS-ism. Separate logical groups with newlines. Control indentation. Remove an unnecessary inlined repeat. * lisp/muse-project.el (muse-project-alist): Use cons instead of alist, since XEmacs doesn't support the alist widget. Deal with case where no projects are defined, or a strange expression is used. * lisp/muse-wiki.el: Insinuate muse-wiki link handlers and mode hook stuff using custom-add-option. git-archimport-id: mwolson@gnu.org--2005/muse--main--1.0--patch-155 --- ChangeLog | 40 +++++++++++++++++ lisp/muse-colors.el | 2 +- lisp/muse-mode.el | 3 +- lisp/muse-project.el | 119 ++++++++++++++++++++++++++++++++------------------- lisp/muse-wiki.el | 11 +++++ lisp/muse.el | 30 +++++++++++-- 6 files changed, 154 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20c6512..d0d68cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,46 @@ # arch-tag: automatic-ChangeLog--mwolson@gnu.org--2005/muse--main--1.0 # +2005-07-18 08:23:00 GMT Michael Olson patch-155 + + Summary: + Make customize of muse-project-alist work in Emacs21 and XEmacs. + Revision: + muse--main--1.0--patch-155 + + * lisp/muse.el (muse-widget-type-value-create) + (muse-widget-child-value-get, muse-widget-type-match): Minimum set of + extra widgets from 'lazy type that are needed to get the + `muse-project-alist' customize interface to work on XEmacs and Emacs21. + + * lisp/muse.el (muse-implicit-link-functions) + (muse-explicit-link-functions): Remove predefined wiki-related options. + These are added in muse-wiki via custom-add-option. + + * lisp/muse-mode.el (muse-mode-hook): Ditto. + + * lisp/muse-colors.el (muse-colors-emphasized): Use eq instead of memq. + + * lisp/muse-project.el (muse-project-alist-get): Turn :symbols into + ":strings" to cope with Emacs21 and XEmacs. + (muse-project-alist-set): Turn ":strings" back into ":symbols". + + * lisp/muse-project.el (muse-project): Derive from 'default rather than + 'lazy, since that is an Emacs CVS-ism. Separate logical groups with + newlines. Control indentation. Remove an unnecessary inlined repeat. + + * lisp/muse-project.el (muse-project-alist): Use cons instead of alist, + since XEmacs doesn't support the alist widget. Deal with case where no + projects are defined, or a strange expression is used. + + * lisp/muse-wiki.el: Insinuate muse-wiki link handlers and mode hook + stuff using custom-add-option. + + modified files: + ChangeLog lisp/muse-colors.el lisp/muse-mode.el + lisp/muse-project.el lisp/muse-wiki.el lisp/muse.el + + 2005-07-18 03:31:38 GMT Michael Olson patch-154 Summary: diff --git a/lisp/muse-colors.el b/lisp/muse-colors.el index 2870f84..ac248a0 100644 --- a/lisp/muse-colors.el +++ b/lisp/muse-colors.el @@ -196,7 +196,7 @@ whether progress messages should be displayed to the user." (int-to-string leader)))))) ;; beginning of line or space or symbol (when (or (= beg (point-min)) - (memq (char-syntax (char-before beg)) '(?\ ?\-)) + (eq (char-syntax (char-before beg)) ?\ ) (memq (char-before beg) '(?\- ?\[ ?\< ?\( ?\' ?\` ?\" ?\n))) (save-excursion diff --git a/lisp/muse-mode.el b/lisp/muse-mode.el index 37a5b1d..ca24fdf 100644 --- a/lisp/muse-mode.el +++ b/lisp/muse-mode.el @@ -86,8 +86,7 @@ so only enable this if you don't use either of these." "A hook that is run when Muse mode is entered." :type 'hook :options '(flyspell-mode footnote-mode turn-on-auto-fill - highlight-changes-mode - muse-wiki-update-custom-values) + highlight-changes-mode) :set #'(lambda (sym val) (when (featurep 'muse-wiki) (add-to-list 'val 'muse-wiki-update-custom-values)) diff --git a/lisp/muse-project.el b/lisp/muse-project.el index 236f92d..1acd824 100644 --- a/lisp/muse-project.el +++ b/lisp/muse-project.el @@ -60,16 +60,29 @@ Each function is passed the project object, a cons with the format (while val (let ((head (car (cdar val))) res) + ;; Turn settings of first part into cons cells, symbol->string (while head (cond ((stringp (car head)) - (add-to-list 'res (car head)) + (add-to-list 'res (car head) t) (setq head (cdr head))) ((symbolp (car head)) - (add-to-list 'res (list (car head) (cadr head)) t) + (add-to-list 'res (list (symbol-name (car head)) + (cadr head)) t) (setq head (cddr head))) (t (setq head (cdr head))))) (setcdr (car val) (cons res (cdr (cdar val))))) + (let ((styles (cdar val))) + ;; Symbol->string in every style + (while (cdr styles) + (let ((head (cadr styles)) + res) + (while (consp head) + (setq res (plist-put res (symbol-name (car head)) + (cadr head))) + (setq head (cddr head))) + (setcdr styles (cons res (cddr styles)))) + (setq styles (cdr styles)))) (setq val (cdr val))) head))) @@ -80,90 +93,108 @@ Muse can make use of." (while val (let ((head (car (cdar val))) res) + ;; Turn cons cells into flat list, string->symbol (while head (cond ((stringp (car head)) (add-to-list 'res (car head) t)) ((consp (car head)) - (add-to-list 'res (caar head) t) + (add-to-list 'res (intern (caar head)) t) (add-to-list 'res (car (cdar head)) t))) (setq head (cdr head))) (setcdr (car val) (cons res (cdr (cdar val))))) + (let ((styles (cdar val))) + ;; String->symbol in every style + (while (cdr styles) + (let ((head (cadr styles)) + res) + (while (consp head) + (setq res (plist-put res (intern (car head)) + (cadr head))) + (setq head (cddr head))) + (setcdr styles (cons res (cddr styles)))) + (setq styles (cdr styles)))) (setq val (cdr val)))) -(define-widget 'muse-project 'lazy +(define-widget 'muse-project 'default "A widget that defines a Muse project." - :tag "Project" - :type '(cons (repeat :tag "Settings" - (choice + :format "\n%v" + :value-create 'muse-widget-type-value-create + :value-get 'muse-widget-child-value-get + :match 'muse-widget-type-match + :type '(cons :format " %v" + (repeat :tag "Settings" :format "%{%t%}:\n%v%i\n\n" + (choice (string :tag "Directory") (list :tag "Book function" - (const :book-funcall) + (const :tag ":book-funcall" ":book-funcall") (choice (function) (sexp :tag "Unknown"))) (list :tag "Book part" - (const :book-part) + (const :tag ":book-part" ":book-part") (string :tag "Name")) (list :tag "Book style" - (const :book-style) + (const :tag ":book-style" ":book-style") (string :tag "Style")) (list :tag "Default file" - (const :default) + (const :tag ":default" ":default") (string :tag "File")) (list :tag "End of book" - (const :book-end) + (const :tag ":book-end" ":book-end") (const t)) (list :tag "Force publishing" - (const :force-publish) + (const :tag ":force-publish" ":force-publish") (repeat (string :tag "File"))) (list :tag "Major mode" - (const :major-mode) + (const :tag ":major-mode" ":major-mode") (choice (function :tag "Mode") (sexp :tag "Unknown"))) (list :tag "New chapter" - (const :book-chapter) + (const :tag ":book-chapter" ":book-chapter") (string :tag "Name")) (list :tag "No chapters" - (const :nochapters) + (const :tag ":nochapters" ":nochapters") (const t)) (list :tag "Set variables" - (const :set) + (const :tag ":set" ":set") (repeat (list (symbol :tag "Variable") (sexp :tag "Setting")))) (list :tag "Visit links using" - (const :visit-link) + (const :tag ":visit-link" ":visit-link") (choice (function) (sexp :tag "Unknown"))))) - (repeat :tag "Styles" - (repeat :tag "Style" :inline t - (set :tag "Setting" - (list :inline t - :tag "Publishing style" - (const :base) - (string :tag "Style")) - (list :inline t - :tag "Base URL" - (const :base-url) - (string :tag "URL")) - (list :inline t - :tag "Exclude matching" - (const :exclude) - (regexp)) - (list :inline t - :tag "Include matching" - (const :include) - (regexp)) - (list :inline t - :tag "Path" - (const :path) - (string :tag "Path"))))))) + (repeat :tag "Styles" :format "%{%t%}:\n%v%i\n\n" + (set :tag "Style" + (list :inline t + :tag "Publishing style" + (const :tag ":base" ":base") + (string :tag "Style")) + (list :inline t + :tag "Base URL" + (const :tag ":base-url" ":base-url") + (string :tag "URL")) + (list :inline t + :tag "Exclude matching" + (const :tag ":exclude" ":exclude") + (regexp)) + (list :inline t + :tag "Include matching" + (const :tag ":include" ":include") + (regexp)) + (list :inline t + :tag "Path" + (const :tag ":path" ":path") + (string :tag "Path")))))) (defcustom muse-project-alist nil "An alist of Muse projects. A project defines a fileset, and a list of custom attributes for use when publishing files in that project." - :type '(alist - :key-type (string :tag "Project name") - :value-type muse-project) + :type '(choice (const :tag "No projects defined." nil) + (repeat (cons :format "%{%t%}:\n\n%v" + :tag "Project" :indent 4 + (string :tag "Project name") + muse-project)) + (sexp :tag "Cannot parse expression")) :get 'muse-project-alist-get :set 'muse-project-alist-set :group 'muse-project) diff --git a/lisp/muse-wiki.el b/lisp/muse-wiki.el index c63ed79..2a64460 100644 --- a/lisp/muse-wiki.el +++ b/lisp/muse-wiki.el @@ -248,6 +248,14 @@ called manually." ;; Insinuate link handling +(custom-add-option 'muse-implicit-link-functions + 'muse-wiki-handle-interwiki) +(custom-add-option 'muse-implicit-link-functions + 'muse-wiki-handle-wikiword) + +(custom-add-option 'muse-explicit-link-functions + 'muse-wiki-handle-interwiki) + (add-to-list 'muse-implicit-link-functions 'muse-wiki-handle-interwiki t) (add-to-list 'muse-implicit-link-functions @@ -261,6 +269,9 @@ called manually." "Update some important muse-wiki values that may have been altered manually." (muse-wiki-update-interwiki-regexp muse-wiki-interwiki-alist)) +(custom-add-option 'muse-mode-hook + 'muse-wiki-update-custom-values) + (add-hook 'muse-mode-hook 'muse-wiki-update-custom-values) diff --git a/lisp/muse.el b/lisp/muse.el index 3cb6a72..0b48ddd 100644 --- a/lisp/muse.el +++ b/lisp/muse.el @@ -61,6 +61,7 @@ familiar with Emacs." (defvar muse-under-windows-p (memq system-type '(ms-dos windows-nt))) +(require 'wid-edit) (require 'muse-regexps) ;; Default file extension @@ -300,6 +301,30 @@ that can be added." (setq buffer-invisibility-spec (cons element buffer-invisibility-spec)))) +;; Widget compatibility functions + +(defun muse-widget-type-value-create (widget) + "Convert and instantiate the value of the :type attribute of WIDGET. +Store the newly created widget in the :children attribute. + +The value of the :type attribute should be an unconverted widget type." + (let ((value (widget-get widget :value)) + (type (widget-get widget :type))) + (widget-put widget :children + (list (widget-create-child-value widget + (widget-convert type) + value))))) + +(defun muse-widget-child-value-get (widget) + "Get the value of the first member of :children in WIDGET." + (widget-value (car (widget-get widget :children)))) + +(defun muse-widget-type-match (widget value) + "Non-nil if the :type value of WIDGET matches VALUE. + +The value of the :type attribute should be an unconverted widget type." + (widget-apply (widget-convert (widget-get widget :type)) :match value)) + ;; Link-handling functions and variables (defun muse-handle-url (&optional string) @@ -315,9 +340,7 @@ An implicit link is one that is not surrounded by brackets. By default, Muse handles URLs only. If you want to handle WikiWords, load muse-wiki.el." :type 'hook - :options '(muse-handle-url - muse-wiki-handle-interwiki - muse-wiki-handle-wikiword) + :options '(muse-handle-url) :group 'muse) (defun muse-handle-implicit-link (&optional link) @@ -352,7 +375,6 @@ that is an accepted link." "A list of functions to handle an explicit link. An explicit link is one [[like][this]] or [[this]]." :type 'hook - :options '(muse-wiki-handle-interwiki) :group 'muse) (defun muse-handle-explicit-link (&optional link) -- 2.11.4.GIT