diff --git a/elpa/buffer-move-20160615.1103/buffer-move-autoloads.el b/elpa/buffer-move-20160615.1103/buffer-move-autoloads.el deleted file mode 100644 index d1f4ba0..0000000 --- a/elpa/buffer-move-20160615.1103/buffer-move-autoloads.el +++ /dev/null @@ -1,53 +0,0 @@ -;;; buffer-move-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "buffer-move" "buffer-move.el" (22387 29375 -;;;;;; 754161 271000)) -;;; Generated autoloads from buffer-move.el - -(autoload 'buf-move-up "buffer-move" "\ -Swap the current buffer and the buffer above the split. - If there is no split, ie now window above the current one, an - error is signaled. - -\(fn)" t nil) - -(autoload 'buf-move-down "buffer-move" "\ -Swap the current buffer and the buffer under the split. - If there is no split, ie now window under the current one, an - error is signaled. - -\(fn)" t nil) - -(autoload 'buf-move-left "buffer-move" "\ -Swap the current buffer and the buffer on the left of the split. - If there is no split, ie now window on the left of the current - one, an error is signaled. - -\(fn)" t nil) - -(autoload 'buf-move-right "buffer-move" "\ -Swap the current buffer and the buffer on the right of the split. - If there is no split, ie now window on the right of the current - one, an error is signaled. - -\(fn)" t nil) - -(autoload 'buf-move "buffer-move" "\ -Begin moving the current buffer to different windows. - -Use the arrow keys to move in the desired direction. Pressing -any other key exits this function. - -\(fn)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; buffer-move-autoloads.el ends here diff --git a/elpa/buffer-move-20160615.1103/buffer-move-pkg.el b/elpa/buffer-move-20160615.1103/buffer-move-pkg.el deleted file mode 100644 index a9e0a04..0000000 --- a/elpa/buffer-move-20160615.1103/buffer-move-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "buffer-move" "20160615.1103" "easily swap buffers" 'nil :url "https://github.com/lukhas/buffer-move" :keywords '("lisp" "convenience")) diff --git a/elpa/buffer-move-20160615.1103/buffer-move.el b/elpa/buffer-move-20160615.1103/buffer-move.el deleted file mode 100644 index 8f2c16e..0000000 --- a/elpa/buffer-move-20160615.1103/buffer-move.el +++ /dev/null @@ -1,179 +0,0 @@ -;;; buffer-move.el --- easily swap buffers - -;; Copyright (C) 2004-2014 Lucas Bonnet -;; Copyright (C) 2014 Mathis Hofer -;; Copyright (C) 2014-2015 Geyslan G. Bem - -;; Authors: Lucas Bonnet -;; Geyslan G. Bem -;; Mathis Hofer -;; Keywords: lisp,convenience -;; Package-Version: 20160615.1103 -;; Version: 0.6.2 -;; URL : https://github.com/lukhas/buffer-move - -;; 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 -;; 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, write to the Free Software -;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -;; 02111-1307, USA. - -;;; Commentary: - -;; This file is for lazy people wanting to swap buffers without -;; typing C-x b on each window. This is useful when you have : - -;; +--------------+-------------+ -;; | | | -;; | #emacs | #gnus | -;; | | | -;; +--------------+-------------+ -;; | | -;; | .emacs | -;; | | -;; +----------------------------+ - -;; and you want to have : - -;; +--------------+-------------+ -;; | | | -;; | #gnus | .emacs | -;; | | | -;; +--------------+-------------+ -;; | | -;; | #emacs | -;; | | -;; +----------------------------+ - -;; With buffer-move, just go in #gnus, do buf-move-left, go to #emacs -;; (which now should be on top right) and do buf-move-down. - -;; To use it, simply put a (require 'buffer-move) in your ~/.emacs and -;; define some keybindings. For example, i use : - -;; (global-set-key (kbd "") 'buf-move-up) -;; (global-set-key (kbd "") 'buf-move-down) -;; (global-set-key (kbd "") 'buf-move-left) -;; (global-set-key (kbd "") 'buf-move-right) - -;; Alternatively, you may let the current window switch back to the previous -;; buffer, instead of swapping the buffers of both windows. Set the -;; following customization variable to 'move to activate this behavior: - -;; (setq buffer-move-behavior 'move) - - -;;; Code: - - -(require 'windmove) - - -(defconst buffer-move-version "0.6.1" - "Version of buffer-move.el") - -(defgroup buffer-move nil - "Swap buffers without typing C-x b on each window" - :group 'tools) - -(defcustom buffer-move-behavior 'swap - "If set to 'swap (default), the buffers will be exchanged - (i.e. swapped), if set to 'move, the current window is switch back to the - previously displayed buffer (i.e. the buffer is moved)." - :group 'buffer-move - :type 'symbol) - -(defcustom buffer-move-stay-after-swap nil - "If set to non-nil, point will stay in the current window - so it will not be moved when swapping buffers. This setting - only has effect if `buffer-move-behavior' is set to 'swap." - :group 'buffer-move - :type 'boolean) - -(defun buf-move-to (direction) - "Helper function to move the current buffer to the window in the given - direction (with must be 'up, 'down', 'left or 'right). An error is - thrown, if no window exists in this direction." - (let* ((other-win (windmove-find-other-window direction)) - (buf-this-buf (window-buffer (selected-window)))) - (if (null other-win) - (error "No window in this direction") - (if (window-dedicated-p other-win) - (error "The window in this direction is dedicated")) - (if (string-match "^ \\*Minibuf" (buffer-name (window-buffer other-win))) - (error "The window in this direction is the Minibuf")) - (if (eq buffer-move-behavior 'move) - ;; switch selected window to previous buffer (moving) - (switch-to-prev-buffer (selected-window)) - - ;; switch selected window to buffer of other window (swapping) - (set-window-buffer (selected-window) (window-buffer other-win)) - ) - - ;; switch other window to this buffer - (set-window-buffer other-win buf-this-buf) - - (when (or (null buffer-move-stay-after-swap) - (eq buffer-move-behavior 'move)) - (select-window other-win))))) - -;;;###autoload -(defun buf-move-up () - "Swap the current buffer and the buffer above the split. - If there is no split, ie now window above the current one, an - error is signaled." - ;; "Switches between the current buffer, and the buffer above the - ;; split, if possible." - (interactive) - (buf-move-to 'up)) - -;;;###autoload -(defun buf-move-down () - "Swap the current buffer and the buffer under the split. - If there is no split, ie now window under the current one, an - error is signaled." - (interactive) - (buf-move-to 'down)) - -;;;###autoload -(defun buf-move-left () - "Swap the current buffer and the buffer on the left of the split. - If there is no split, ie now window on the left of the current - one, an error is signaled." - (interactive) - (buf-move-to 'left)) - -;;;###autoload -(defun buf-move-right () - "Swap the current buffer and the buffer on the right of the split. - If there is no split, ie now window on the right of the current - one, an error is signaled." - (interactive) - (buf-move-to 'right)) - -;;;###autoload -(defun buf-move () - "Begin moving the current buffer to different windows. - -Use the arrow keys to move in the desired direction. Pressing -any other key exits this function." - (interactive) - (let ((map (make-sparse-keymap))) - (dolist (x '(("" . buf-move-up) - ("" . buf-move-left) - ("" . buf-move-down) - ("" . buf-move-right))) - (define-key map (read-kbd-macro (car x)) (cdr x))) - (set-transient-map map t))) - -(provide 'buffer-move) -;;; buffer-move.el ends here diff --git a/elpa/django-manage-20160818.1912/django-manage-autoloads.el b/elpa/django-manage-20160818.1912/django-manage-autoloads.el deleted file mode 100644 index 292d239..0000000 --- a/elpa/django-manage-20160818.1912/django-manage-autoloads.el +++ /dev/null @@ -1,22 +0,0 @@ -;;; django-manage-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "django-manage" "django-manage.el" (22501 5677 -;;;;;; 768491 198000)) -;;; Generated autoloads from django-manage.el - -(autoload 'django-manage "django-manage" "\ -Minor mode for handling Django's manage.py - -\(fn &optional ARG)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; django-manage-autoloads.el ends here diff --git a/elpa/django-manage-20160818.1912/django-manage-pkg.el b/elpa/django-manage-20160818.1912/django-manage-pkg.el deleted file mode 100644 index de62cc9..0000000 --- a/elpa/django-manage-20160818.1912/django-manage-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "django-manage" "20160818.1912" "Django minor mode for commanding manage.py" '((hydra "0.13.2")) :keywords '("languages")) diff --git a/elpa/django-manage-20160818.1912/django-manage.el b/elpa/django-manage-20160818.1912/django-manage.el deleted file mode 100644 index cca8c8d..0000000 --- a/elpa/django-manage-20160818.1912/django-manage.el +++ /dev/null @@ -1,319 +0,0 @@ -;;; django-manage.el --- Django minor mode for commanding manage.py - -;; Copyright (C) 2015 Daniel Gopar - -;; Author: Daniel Gopar -;; Package-Requires: ((hydra "0.13.2")) -;; Package-Version: 20160818.1912 -;; Version: 0.1 -;; Keywords: languages - -;; This file is NOT 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 . - -;;; Commentary: -;; -;; Simple package to be to be able to control `manage.py', the standard -;; file that every Django project comes with. You are able to call any -;; command with `django-manage-command' plus it comes with code -;; completion so third party plugins will also be completed. - -;;; Code: - -(condition-case nil - (require 'python) - (error - (require 'python-mode))) -(require 'hydra) - -(defcustom django-manage-shell-preference 'pyshell - "What shell to use." - :type 'symbol - :options '(eshell term pyshell) - :group 'shell) - -(defcustom django-manage-server-ipaddr "127.0.0.1" - "What address Django will use when running the dev server." - :type 'string - :group 'server) - -(defcustom django-manage-server-port "8000" - "What port Django will use when running the dev server." - :type 'string - :group 'server) - -(defcustom django-manage-prompt-for-command nil - "When non-nil will ask for confirmation on command. -Will affect every function other than `django-manage-command'." - :type 'boolean - :group 'django-manage) - -(defcustom django-manage-root "" - "The directory where 'manage.py' lives." - :type 'string - :group 'django-manage) -(make-local-variable 'django-manage-root) - -(defun django-manage-root () - "Return the root directory of Django project." - ;; Check if projectile is in use, and if it is. Return root directory - (if (not (string= django-manage-root "")) - django-manage-root - (if (fboundp 'projectile-project-root) - (projectile-project-root) - ;; Try looking for the directory holding 'manage.py' - (locate-dominating-file default-directory "manage.py")))) - -(defun django-manage-python-command () - "Return Python version to use with args." - (if (boundp 'python-shell-interpreter) - (concat python-shell-interpreter " " python-shell-interpreter-args) - ;; For old python.el - (mapconcat 'identity (cons python-python-command python-python-command-args) " "))) - -(defun django-manage-get-commands () - "Return list of django commands." - (let ((help-output - (shell-command-to-string (concat python-shell-interpreter " " - (shell-quote-argument (django-manage-root)) "manage.py -h")))) - (setq dj-commands-str - (with-temp-buffer - (progn - (insert help-output) - (beginning-of-buffer) - (delete-region (point) (search-forward "Available subcommands:" nil nil nil)) - ;; cleanup [auth] and stuff - (beginning-of-buffer) - (save-excursion - (replace-regexp "\\[.*\\]" "")) - (buffer-string)))) - ;; get a list of commands from the output of manage.py -h - ;; What would be the pattern to optimize this ? - (setq dj-commands-str (s-split "\n" dj-commands-str)) - (setq dj-commands-str (-remove (lambda (x) (string= x "")) dj-commands-str)) - (setq dj-commands-str (mapcar (lambda (x) (s-trim x)) dj-commands-str)) - (sort dj-commands-str 'string-lessp))) - -(defun django-manage-command (command &optional no-prompt) - "Allow to run any `manage.py' command. -Argument COMMAND command for django to run. -Optional Argument NO-PROMPT if non-nil will *not* ask if you wish to pass extra arguments." - ;; nil nil: enable user to exit with any command. Still, he can not edit a completed choice. - (interactive (list (completing-read "Command: " (django-manage-get-commands) nil nil))) - (if (not no-prompt) - ;; Now ask to edit the command. How to do the two actions at once ? - (setq command (read-shell-command "Run command like this: " command))) - (compile (concat (django-manage-python-command) " " - (shell-quote-argument (django-manage-root)) "manage.py " command))) - -(defun django-manage-makemigrations (&optional app-name) - "Run \"makemigrations app-name\", will prompt for \"app-name\". -You can leave blank to simply run \"makemigrations\". -To choose arguments call `django-manage-command'. -Optional argument APP-NAME name of django app create migrations." - (interactive "sName: ") - (django-manage-command (concat "makemigrations " app-name) - (not django-manage-prompt-for-command))) - -(defun django-manage-flush () - "Run \"flush --noinput\". To choose arguments call `django-manage-command'." - (interactive) - (django-manage-command "flush --noinput" - (not django-manage-prompt-for-command))) - -(defun django-manage-runserver () - "Start the development server. To change what address and port to use, -customize `django-manage-server-ipaddr' and `django-manage-server-port' -If you want to pass arguments, then call `django-manage-command'" - (interactive) - (let ((parent-dir (file-name-base (substring (django-manage-root) 0 -1)))) - (compile (concat (django-manage-python-command) " " - (shell-quote-argument (django-manage-root)) "manage.py runserver " - django-manage-server-ipaddr ":" django-manage-server-port)) - (with-current-buffer "*compilation*" - (rename-buffer (format "*runserver[%s]*" parent-dir))))) - -(defun django-manage-migrate () - "Run \"migrate\". To choose arguments call `django-manage-command'." - (interactive) - (django-manage-command "migrate" - (not django-manage-prompt-for-command))) - -(defun django-manage-assets-rebuild () - "Run \"assets rebuild\". To choose arguments call `django-manage-command'." - (interactive) - (django-manage-command "assets rebuild" - (not django-manage-prompt-for-command))) - -(defun django-manage-startapp (name) - "Run \"startapp name\". Will prompt for name of app. -To choose arguments call `django-manage-command'. -Argument NAME name of app to create." - (interactive "sName:") - (django-manage-command (concat "startapp " name) - (not django-manage-prompt-for-command))) - -(defun django-manage-makemessages () - "Run \"makemessages --all --symlinks\". -To pass arguments call `django-manage-command'." - (interactive) - (django-manage-command "makemessages --all --symlinks" - (not django-manage-prompt-for-command))) - -(defun django-manage-compilemessages () - "Run \"compilemessages\". To pass arguments call `django-manage-command'." - (interactive) - (django-manage-command "compilemessages" - (not django-manage-prompt-for-command))) - -(defun django-manage-test (name) - "Run \"test name\". Will prompt for Django app name to test. -To pass arguments call `django-manage-command'. -Argument NAME name of django app to test." - (interactive "sTest app:") - (django-manage-command (concat "test " name) - (not django-manage-prompt-for-command))) - -(defun django-manage--prep-shell (pref-shell) - "Prepare the shell with users preference. -Argument PREF-SHELL users shell of choice" - ;; If a preexisting shell buffer exists return that one. If not create it - (let* ((parent-dir (file-name-base (substring (django-manage-root) 0 -1))) - (default-directory (django-manage-root)) - (buffer-shell-name - (format (if (string= pref-shell "shell") "*Django Shell[%s]*" "*Django DBshell[%s]*") parent-dir))) - ;; If it exists return it - (if (get-buffer buffer-shell-name) - (switch-to-buffer buffer-shell-name) - ;; Shell didn't exist, so let's create it - (if (eq 'term django-manage-shell-preference) - (term (concat (django-manage-python-command) " " - (shell-quote-argument (django-manage-root)) "manage.py " pref-shell))) - (if (eq 'eshell django-manage-shell-preference) - (progn - (unless (get-buffer eshell-buffer-name) - (eshell)) - (insert (concat (django-manage-python-command) " " - (shell-quote-argument (django-manage-root)) "manage.py " pref-shell)) - (eshell-send-input))) - (if (eq 'pyshell django-manage-shell-preference) - (let ((setup-code "os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"%s.settings\")") - (cmd ";from django.core.management import execute_from_command_line") - (exe (if (string= pref-shell "shell") - ";import django;django.setup()" - (format ";execute_from_command_line(['manage.py', '%s'])" pref-shell)))) - (run-python (python-shell-parse-command)) - (python-shell-send-string (concat (format setup-code parent-dir) cmd exe)) - (switch-to-buffer (python-shell-get-buffer)))) - (rename-buffer buffer-shell-name)))) - -(defun django-manage-shell () - "Start Python shell with Django already configured." - (interactive) - (django-manage--prep-shell "shell")) - -(defun django-manage-dbshell () - "Start Database shell." - (interactive) - (django-manage--prep-shell "dbshell")) - -(defun django-manage-insert-transpy (from to &optional buffer) - "Wraps highlighted region in _(...) for i18n. -Argument FROM start point TO wrap. -Optional argument BUFFER end point to wrap." - ;; From http://garage.pimentech.net/libcommonDjango_django_emacs/ - ;; Modified a little - (interactive "*r") - (save-excursion - (save-restriction - (narrow-to-region from to) - (goto-char from) - (iso-iso2sgml from to) - (insert "_(") - (goto-char (point-max)) - (insert ")") - (point-max)))) - -(defhydra django-manage-hydra (:color blue - :hint nil) - " - Manage.py --------------------------------------------------- - -_mm_: Enter manage.py commnand _r_: runserver _f_: Flush _t_: Run rest -_ma_: Makemigrations _sa_: Start new app _i_: Insert transpy -_mg_: Migrate _ss_: Run shell _a_: Rebuild Assets -_me_: Make messages _sd_: Run DB Shell _c_: Compile messages - -_q_: Cancel - -" - ("mm" django-manage-command) - ("ma" django-manage-makemigrations) - ("mg" django-manage-migrate) - ("me" django-manage-makemessages) - - ("r" django-manage-runserver "Start server") - ("sa" django-manage-startapp) - ("ss" django-manage-shell) - ("sd" django-manage-dbshell) - - ("f" django-manage-flush) - ("a" django-manage-assets-rebuild) - ("c" django-manage-compilemessages) - ("t" django-manage-test) - - ("i" django-manage-insert-transpy) - ("q" nil "cancel")) - -(defvar django-manage-map - (let ((map (make-keymap))) - (define-key map (kbd "C-c C-x") 'django-manage-hydra/body) - map)) - -(defun django-manage-setup () - "Determine whether to start minor mode or not." - (when (and (stringp buffer-file-name) - (locate-dominating-file default-directory "manage.py")) - (django-manage))) - -;;;###autoload -(define-minor-mode django-manage - "Minor mode for handling Django's manage.py" - :lighter " Manage" - :keymap django-manage-map) - -(easy-menu-define django-manage-menu django-manage-map "Django menu" - '("Django" - ["Start an app" django-manage-startapp t] - ["Run tests" django-manage-test t] - ["Make migrations" django-manage-makemigrations t] - ["Flush database" django-manage-flush t] - ["Runserver" django-manage-runserver t] - ["Run database migrations" django-manage-migrate t] - ["Rebuild assets" django-manage-assets-rebuild t] - ["Make translations" django-manage-makemessages t] - ["Compile translations" django-manage-compilemessages t] - ["Open Python shell" django-manage-shell t] - ["Open database shell" django-manage-dbshell t] - ["Run other command" django-manage-command t] - "-" - ["Insert translation mark" django-manage-insert-transpy t])) - -(easy-menu-add django-manage-menu django-manage-map) - -(provide 'django-manage) - -;;; django-manage.el ends here diff --git a/elpa/erlang-20161007.57/erlang-autoloads.el b/elpa/erlang-20161007.57/erlang-autoloads.el deleted file mode 100644 index 5663eea..0000000 --- a/elpa/erlang-20161007.57/erlang-autoloads.el +++ /dev/null @@ -1,159 +0,0 @@ -;;; erlang-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) - -;;;### (autoloads nil "erlang" "erlang.el" (22523 21259 84519 501000)) -;;; Generated autoloads from erlang.el - -(autoload 'erlang-mode "erlang" "\ -Major mode for editing Erlang source files in Emacs. -It knows about syntax and comment, it can indent code, it is capable -of fontifying the source file, the TAGS commands are aware of Erlang -modules, and the Erlang man pages can be accessed. - -Should this module, \"erlang.el\", be installed properly, Erlang mode -is activated whenever an Erlang source or header file is loaded into -Emacs. To indicate this, the mode line should contain the word -\"Erlang\". - -The main feature of Erlang mode is indentation, press TAB and the -current line will be indented correctly. - -Comments starting with only one `%' are indented to the column stored -in the variable `comment-column'. Comments starting with two `%':s -are indented with the same indentation as code. Comments starting -with at least three `%':s are indented to the first column. - -However, Erlang mode contains much more, this is a list of the most -useful commands: - TAB - Indent the line. - C-c C-q - Indent current function. - M-; - Create a comment at the end of the line. - M-q - Fill a comment, i.e. wrap lines so that they (hopefully) - will look better. - M-a - Goto the beginning of an Erlang clause. - M-C-a - Ditto for function. - M-e - Goto the end of an Erlang clause. - M-C-e - Ditto for function. - M-h - Mark current Erlang clause. - M-C-h - Ditto for function. - C-c C-z - Start, or switch to, an inferior Erlang shell. - C-c C-k - Compile current file. - C-x ` - Next error. - , - Electric comma. - ; - Electric semicolon. - -Erlang mode check the name of the file against the module name when -saving, whenever a mismatch occurs Erlang mode offers to modify the -source. - -The variable `erlang-electric-commands' controls the electric -commands. To deactivate all of them, set it to nil. - -There exists a large number of commands and variables in the Erlang -module. Please press `M-x apropos RET erlang RET' to see a complete -list. Press `C-h f name-of-function RET' and `C-h v name-of-variable -RET'to see the full description of functions and variables, -respectively. - -On entry to this mode the contents of the hook `erlang-mode-hook' is -executed. - -Please see the beginning of the file `erlang.el' for more information -and examples of hooks. - -Other commands: -\\{erlang-mode-map} - -\(fn)" t nil) - -(dolist (r '("\\.erl$" "\\.app\\.src$" "\\.escript" "\\.hrl$" "\\.xrl$" "\\.yrl" "/ebin/.+\\.app")) (add-to-list 'auto-mode-alist (cons r 'erlang-mode))) - -(autoload 'erlang-find-tag "erlang" "\ -Like `find-tag'. Capable of retrieving Erlang modules. - -Tags can be given on the forms `tag', `module:', `module:tag'. - -\(fn MODTAGNAME &optional NEXT-P REGEXP-P)" t nil) - -(autoload 'erlang-find-tag-other-window "erlang" "\ -Like `find-tag-other-window' but aware of Erlang modules. - -\(fn TAGNAME &optional NEXT-P REGEXP-P)" t nil) - -(autoload 'erlang-shell "erlang" "\ -Start a new Erlang shell. - -The variable `erlang-shell-function' decides which method to use, -default is to start a new Erlang host. It is possible that, in the -future, a new shell on an already running host will be started. - -\(fn)" t nil) - (autoload 'run-erlang "erlang" "Start a new Erlang shell." t) - -(autoload 'erlang-compile "erlang" "\ -Compile Erlang module in current buffer. - -\(fn)" t nil) - -(autoload 'inferior-erlang "erlang" "\ -Run an inferior Erlang. -With prefix command, prompt for command to start Erlang with. - -This is just like running Erlang in a normal shell, except that -an Emacs buffer is used for input and output. -\\ -The command line history can be accessed with \\[comint-previous-input] and \\[comint-next-input]. -The history is saved between sessions. - -Entry to this mode calls the functions in the variables -`comint-mode-hook' and `erlang-shell-mode-hook' with no arguments. - -The following commands imitate the usual Unix interrupt and -editing control characters: -\\{erlang-shell-mode-map} - -\(fn &optional COMMAND)" t nil) - -;;;*** - -;;;### (autoloads nil "erlang-edoc" "erlang-edoc.el" (22523 21259 -;;;;;; 104519 648000)) -;;; Generated autoloads from erlang-edoc.el - -(autoload 'erlang-edoc-mode "erlang-edoc" "\ -Toggle Erlang-Edoc mode on or off. -With a prefix argument ARG, enable Erlang-Edoc mode if ARG is -positive, and disable it otherwise. If called from Lisp, enable -the mode if ARG is omitted or nil, and toggle it if ARG is `toggle'. -\\{erlang-edoc-mode-map} - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "erlang-start" "erlang-start.el" (22523 21259 -;;;;;; 64519 353000)) -;;; Generated autoloads from erlang-start.el - -(let ((a '("\\.erl\\'" . erlang-mode)) (b '("\\.hrl\\'" . erlang-mode))) (or (assoc (car a) auto-mode-alist) (setq auto-mode-alist (cons a auto-mode-alist))) (or (assoc (car b) auto-mode-alist) (setq auto-mode-alist (cons b auto-mode-alist)))) - -(add-to-list 'interpreter-mode-alist (cons "escript" 'erlang-mode)) - -(let ((erl-ext '(".jam" ".vee" ".beam"))) (while erl-ext (let ((cie completion-ignored-extensions)) (while (and cie (not (string-equal (car cie) (car erl-ext)))) (setq cie (cdr cie))) (if (null cie) (setq completion-ignored-extensions (cons (car erl-ext) completion-ignored-extensions)))) (setq erl-ext (cdr erl-ext)))) - -;;;*** - -;;;### (autoloads nil nil ("erlang-eunit.el" "erlang-flymake.el" -;;;;;; "erlang-pkg.el" "erlang-skels-old.el" "erlang-skels.el" "erlang-test.el" -;;;;;; "erlang_appwiz.el") (22523 21259 100519 619000)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; erlang-autoloads.el ends here diff --git a/elpa/erlang-20161007.57/erlang-edoc.el b/elpa/erlang-20161007.57/erlang-edoc.el deleted file mode 100644 index 034036a..0000000 --- a/elpa/erlang-20161007.57/erlang-edoc.el +++ /dev/null @@ -1,172 +0,0 @@ -;;; erlang-edoc.el --- EDoc support for Erlang mode -*- lexical-binding: t; -*- - -;; %CopyrightBegin% -;; -;; Copyright Ericsson AB 1996-2016. All Rights Reserved. -;; -;; Licensed under the Apache License, Version 2.0 (the "License"); -;; you may not use this file except in compliance with the License. -;; You may obtain a copy of the License at -;; -;; http://www.apache.org/licenses/LICENSE-2.0 -;; -;; Unless required by applicable law or agreed to in writing, software -;; distributed under the License is distributed on an "AS IS" BASIS, -;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -;; See the License for the specific language governing permissions and -;; limitations under the License. -;; -;; %CopyrightEnd% - -;;; Commentary: - -;; Ref: http://www.erlang.org/doc/apps/edoc/users_guide.html -;; -;; To use: (add-hook 'erlang-mode-hook 'erlang-edoc-mode) - -;;; Code: - -(defcustom erlang-edoc-indent-level 2 - "Indentation level of xhtml in Erlang edoc." - :safe 'integerp - :group 'erlang) - -(defvar erlang-edoc-generic-tags - '("clear" "docfile" "end" "headerfile" "todo" "TODO" "type") - "Tags that can be used anywhere within a module.") - -(defvar erlang-edoc-overview-tags - '("author" "copyright" "reference" "see" "since" "title" "version") - "Tags that can be used in an overview file.") - -(defvar erlang-edoc-module-tags - '("author" "copyright" "deprecated" "doc" "hidden" "private" "reference" - "see" "since" "version") - "Tags that can be used before a module declaration.") - -(defvar erlang-edoc-function-tags - '("deprecated" "doc" "equiv" "hidden" "private" "see" "since" "spec" - "throws" "type") - "Tags that can be used before a function definition.") - -(defvar erlang-edoc-predefined-macros - '("date" "docRoot" "link" "module" "package" "section" "time" - "type" "version")) - -(defface erlang-edoc-tag '((t (:inherit font-lock-constant-face))) - "Face used to highlight edoc tags." - :group 'erlang) - -(defface erlang-edoc-macro '((t (:inherit font-lock-preprocessor-face))) - "Face used to highlight edoc macros." - :group 'erlang) - -(defface erlang-edoc-verbatim - '((t (:family "Monospace" :inherit font-lock-keyword-face))) - "Face used to highlight verbatim text." - :group 'erlang) - -(defface erlang-edoc-todo '((t (:inherit font-lock-warning-face))) - "Face used to highlight edoc macros." - :group 'erlang) - -(defface erlang-edoc-heading '((t (:inherit bold))) - "Face used to highlight edoc headings." - :group 'erlang) - -(defvar erlang-edoc-font-lock-keywords - '(("^%+\\s-*\\(@\\w+\\)\\_>" 1 'erlang-edoc-tag prepend) - ("^%+\\s-*" ("{\\(@\\w+\\)\\_>" nil nil (1 'erlang-edoc-macro prepend))) - ("^%+\\s-*" ("\\(?:@@\\)*\\(@[@{}]\\)" nil nil (1 'escape-glyph prepend))) - ("^%+\\s-*@\\(deprecated\\)\\_>" 1 font-lock-warning-face prepend) - ;; http://www.erlang.org/doc/apps/edoc/chapter.html#Wiki_notation - ("^%+\\s-*" ("[^`]`\\([^`]?\\|[^`].*?[^']\\)'" - (forward-char -1) nil (1 'erlang-edoc-verbatim prepend))) - ("^%+\\s-*" ("\\[\\(\\(?:https?\\|file\\|ftp\\)://[^][]+\\)\\]" - nil nil (1 'link prepend))) - ("^%+\\s-*\\(?:\\(?1:@todo\\|@TODO\\)\\_>\\|\\(?1:TODO\\):\\)" - 1 'erlang-edoc-todo prepend) - ("^%+\\s-*\\(\\(=\\{2,4\\}\\)[^=\n].*[^=\n]\\2\\)\\s-*$" - 1 'erlang-edoc-heading prepend))) - -(defun erlang-edoc-xml-context () - "Parse edoc x(ht)ml context at comment start of current line." - (eval-and-compile (require 'xmltok)) - (save-excursion - (beginning-of-line) - (when (looking-at "^%+\\s-*") - (let ((pt (match-end 0)) context) - (forward-comment (- (point))) - (while (< (point) pt) - (xmltok-forward) - (cond ((eq xmltok-type 'start-tag) - (push (cons xmltok-type xmltok-start) context)) - ((eq xmltok-type 'end-tag) - (pop context)))) - (goto-char pt) - (xmltok-forward) - (push (car (memq xmltok-type '(start-tag end-tag))) context) - context)))) - -(defun erlang-edoc-indent-line () - (let ((context (erlang-edoc-xml-context))) - (when context - (save-excursion - (beginning-of-line) - (re-search-forward "^%+\\s-*" (line-end-position)) - (when (or (car context) (cadr context)) - (let ((pad (when (cadr context) - (save-excursion - (goto-char (cdr (cadr context))) - (- (current-column) - (progn - (beginning-of-line) - (skip-chars-forward "%") - (current-column))))))) - (just-one-space (cond ((not pad) 1) - ((eq (car context) 'end-tag) pad) - (t (+ erlang-edoc-indent-level pad))))))) - (when (looking-back "^%*\\s-*" (line-beginning-position)) - (re-search-forward "\\=%*\\s-*"))))) - -(defun erlang-edoc-before-module-declaration-p () - (save-excursion - (beginning-of-line) - (forward-comment (point-max)) - (or (eobp) (re-search-forward "^-module\\s-*(" nil t)))) - -(defun erlang-edoc-completion-at-point () - (when (eq (syntax-ppss-context (syntax-ppss)) 'comment) - (save-excursion - (skip-syntax-backward "w_") - (when (= (preceding-char) ?@) - (let* ((is-tag (looking-back "^%+\\s-*@" (line-beginning-position))) - (beg (point)) - (end (progn (skip-syntax-forward "w_") (point))) - (table (cond - ((not is-tag) - erlang-edoc-predefined-macros) - ((erlang-edoc-before-module-declaration-p) - (append erlang-edoc-module-tags - erlang-edoc-generic-tags)) - (t (append erlang-edoc-function-tags - erlang-edoc-generic-tags))))) - (list beg end table)))))) - -;;;###autoload -(define-minor-mode erlang-edoc-mode nil - :lighter " EDoc" - (cond (erlang-edoc-mode - (add-hook 'erlang-indent-line-hook #'erlang-edoc-indent-line nil t) - (font-lock-add-keywords nil erlang-edoc-font-lock-keywords t) - (add-hook 'completion-at-point-functions - #'erlang-edoc-completion-at-point nil t)) - (t - (remove-hook 'erlang-indent-line-hook #'erlang-edoc-indent-line t) - (font-lock-remove-keywords nil erlang-edoc-font-lock-keywords) - (remove-hook 'completion-at-point-functions - #'erlang-edoc-completion-at-point t))) - (jit-lock-refontify)) - -(provide 'erlang-edoc) -;;; erlang-edoc.el ends here diff --git a/elpa/erlang-20161007.57/erlang-eunit.el b/elpa/erlang-20161007.57/erlang-eunit.el deleted file mode 100644 index 3b85e66..0000000 --- a/elpa/erlang-20161007.57/erlang-eunit.el +++ /dev/null @@ -1,453 +0,0 @@ -;; -;; %CopyrightBegin% -;; -;; Copyright Ericsson AB 2009-2016. All Rights Reserved. -;; -;; Licensed under the Apache License, Version 2.0 (the "License"); -;; you may not use this file except in compliance with the License. -;; You may obtain a copy of the License at -;; -;; http://www.apache.org/licenses/LICENSE-2.0 -;; -;; Unless required by applicable law or agreed to in writing, software -;; distributed under the License is distributed on an "AS IS" BASIS, -;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -;; See the License for the specific language governing permissions and -;; limitations under the License. -;; -;; %CopyrightEnd% -;;; -;;; Purpose: Provide EUnit utilities. -;;; -;;; Author: Klas Johansson - -(eval-when-compile - (require 'cl)) - -(defvar erlang-eunit-src-candidate-dirs '("../src" ".") - "*Name of directories which to search for source files matching -an EUnit test file. The first directory in the list will be used, -if there is no match.") - -(defvar erlang-eunit-test-candidate-dirs '("../test" ".") - "*Name of directories which to search for EUnit test files matching -a source file. The first directory in the list will be used, -if there is no match.") - -(defvar erlang-eunit-autosave nil - "*Set to non-nil to automtically save unsaved buffers before running tests. -This is useful, reducing the save-compile-load-test cycle to one keychord.") - -(defvar erlang-eunit-recent-info '((mode . nil) (module . nil) (test . nil) (cover . nil)) - "Info about the most recent running of an EUnit test representation.") - -(defvar erlang-error-regexp-alist - '(("^\\([^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)[:) \t]" . (1 2))) - "*Patterns for matching Erlang errors.") - -;;; -;;; Switch between src/EUnit test buffers -;;; -(defun erlang-eunit-toggle-src-and-test-file-other-window () - "Switch to the src file if the EUnit test file is the current -buffer and vice versa" - (interactive) - (if (erlang-eunit-test-file-p buffer-file-name) - (erlang-eunit-open-src-file-other-window buffer-file-name) - (erlang-eunit-open-test-file-other-window buffer-file-name))) - -;;; -;;; Open the EUnit test file which corresponds to a src file -;;; -(defun erlang-eunit-open-test-file-other-window (src-file-path) - "Open the EUnit test file which corresponds to a src file" - (find-file-other-window (erlang-eunit-test-filename src-file-path))) - -;;; -;;; Open the src file which corresponds to the an EUnit test file -;;; -(defun erlang-eunit-open-src-file-other-window (test-file-path) - "Open the src file which corresponds to the an EUnit test file" - (find-file-other-window (erlang-eunit-src-filename test-file-path))) - -;;; Return the name and path of the EUnit test file -;;, (input may be either the source filename itself or the EUnit test filename) -(defun erlang-eunit-test-filename (file-path) - (if (erlang-eunit-test-file-p file-path) - file-path - (erlang-eunit-rewrite-filename file-path erlang-eunit-test-candidate-dirs))) - -;;; Return the name and path of the source file -;;, (input may be either the source filename itself or the EUnit test filename) -(defun erlang-eunit-src-filename (file-path) - (if (erlang-eunit-src-file-p file-path) - file-path - (erlang-eunit-rewrite-filename file-path erlang-eunit-src-candidate-dirs))) - -;;; Rewrite a filename from the src or test filename to the other -(defun erlang-eunit-rewrite-filename (orig-file-path candidate-dirs) - (or (erlang-eunit-locate-buddy orig-file-path candidate-dirs) - (erlang-eunit-buddy-file-path orig-file-path (car candidate-dirs)))) - -;;; Search for a file's buddy file (a source file's EUnit test file, -;;; or an EUnit test file's source file) in a list of candidate -;;; directories. -(defun erlang-eunit-locate-buddy (orig-file-path candidate-dirs) - (when candidate-dirs - (let ((buddy-file-path (erlang-eunit-buddy-file-path - orig-file-path - (car candidate-dirs)))) - (if (file-readable-p buddy-file-path) - buddy-file-path - (erlang-eunit-locate-buddy orig-file-path (cdr candidate-dirs)))))) - -(defun erlang-eunit-buddy-file-path (orig-file-path buddy-dir-name) - (let* ((orig-dir-name (file-name-directory orig-file-path)) - (buddy-dir-name (file-truename - (filename-join orig-dir-name buddy-dir-name))) - (buddy-base-name (erlang-eunit-buddy-basename orig-file-path))) - (filename-join buddy-dir-name buddy-base-name))) - -;;; Return the basename of the buddy file: -;;; /tmp/foo/src/x.erl --> x_tests.erl -;;; /tmp/foo/test/x_tests.erl --> x.erl -(defun erlang-eunit-buddy-basename (file-path) - (let ((src-module-name (erlang-eunit-source-module-name file-path))) - (cond - ((erlang-eunit-src-file-p file-path) - (concat src-module-name "_tests.erl")) - ((erlang-eunit-test-file-p file-path) - (concat src-module-name ".erl"))))) - -;;; Checks whether a file is a source file or not -(defun erlang-eunit-src-file-p (file-path) - (not (erlang-eunit-test-file-p file-path))) - -;;; Checks whether a file is a EUnit test file or not -(defun erlang-eunit-test-file-p (file-path) - (erlang-eunit-string-match-p "^\\(.+\\)_tests.erl$" file-path)) - -;;; Return the module name of the source file -;;; /tmp/foo/src/x.erl --> x -;;; /tmp/foo/test/x_tests.erl --> x -(defun erlang-eunit-source-module-name (file-path) - (interactive) - (let ((module-name (erlang-eunit-module-name file-path))) - (if (string-match "^\\(.+\\)_tests$" module-name) - (substring module-name (match-beginning 1) (match-end 1)) - module-name))) - -;;; Return the module name of the file -;;; /tmp/foo/src/x.erl --> x -;;; /tmp/foo/test/x_tests.erl --> x_tests -(defun erlang-eunit-module-name (file-path) - (interactive) - (file-name-sans-extension (file-name-nondirectory file-path))) - -;;; Older emacsen don't have string-match-p. -(defun erlang-eunit-string-match-p (regexp string &optional start) - (if (fboundp 'string-match-p) ;; appeared in emacs 23 - (string-match-p regexp string start) - (save-match-data ;; fallback for earlier versions of emacs - (string-match regexp string start)))) - -;;; Join filenames -(defun filename-join (dir file) - (if (or (= (elt file 0) ?/) - (= (car (last (append dir nil))) ?/)) - (concat dir file) - (concat dir "/" file))) - -;;; Get info about the most recent running of EUnit -(defun erlang-eunit-recent (key) - (cdr (assq key erlang-eunit-recent-info))) - -;;; Record info about the most recent running of EUnit -;;; Known modes are 'module-mode and 'test-mode -(defun erlang-eunit-record-recent (mode module test) - (setcdr (assq 'mode erlang-eunit-recent-info) mode) - (setcdr (assq 'module erlang-eunit-recent-info) module) - (setcdr (assq 'test erlang-eunit-recent-info) test)) - -;;; Record whether the most recent running of EUnit included cover -;;; compilation -(defun erlang-eunit-record-recent-compile (under-cover) - (setcdr (assq 'cover erlang-eunit-recent-info) under-cover)) - -;;; Determine options for EUnit. -(defun erlang-eunit-opts () - (if current-prefix-arg ", [verbose]" "")) - -;;; Determine current test function -(defun erlang-eunit-current-test () - (save-excursion - (erlang-end-of-function 1) - (erlang-beginning-of-function 1) - (erlang-name-of-function))) - -(defun erlang-eunit-simple-test-p (test-name) - (if (erlang-eunit-string-match-p "^\\(.+\\)_test$" test-name) t nil)) - -(defun erlang-eunit-test-generator-p (test-name) - (if (erlang-eunit-string-match-p "^\\(.+\\)_test_$" test-name) t nil)) - -;;; Run one EUnit test -(defun erlang-eunit-run-test (module-name test-name) - (let ((command - (cond ((erlang-eunit-simple-test-p test-name) - (format "eunit:test({%s, %s}%s)." - module-name test-name (erlang-eunit-opts))) - ((erlang-eunit-test-generator-p test-name) - (format "eunit:test({generator, %s, %s}%s)." - module-name test-name (erlang-eunit-opts))) - (t (format "%% WARNING: '%s' is not a test function" test-name))))) - (erlang-eunit-record-recent 'test-mode module-name test-name) - (erlang-eunit-inferior-erlang-send-command command))) - -;;; Run EUnit tests for the current module -(defun erlang-eunit-run-module-tests (module-name) - (let ((command (format "eunit:test(%s%s)." module-name (erlang-eunit-opts)))) - (erlang-eunit-record-recent 'module-mode module-name nil) - (erlang-eunit-inferior-erlang-send-command command))) - -(defun erlang-eunit-compile-and-run-recent () - "Compile the source and test files and repeat the most recent EUnit test run. - -With prefix arg, compiles for debug and runs tests with the verbose flag set." - (interactive) - (case (erlang-eunit-recent 'mode) - ('test-mode - (erlang-eunit-compile-and-test - 'erlang-eunit-run-test (list (erlang-eunit-recent 'module) - (erlang-eunit-recent 'test)))) - ('module-mode - (erlang-eunit-compile-and-test - 'erlang-eunit-run-module-tests (list (erlang-eunit-recent 'module)) - (erlang-eunit-recent 'cover))) - (t (error "EUnit has not yet been run. Please run a test first.")))) - -(defun erlang-eunit-cover-compile () - "Cover compile current module." - (interactive) - (let* ((erlang-compile-extra-opts - (append (list 'debug_info) erlang-compile-extra-opts)) - (module-name - (erlang-add-quotes-if-needed - (erlang-eunit-module-name buffer-file-name))) - (compile-command - (format "cover:compile_beam(%s)." module-name))) - (erlang-compile) - (if (erlang-eunit-last-compilation-successful-p) - (erlang-eunit-inferior-erlang-send-command compile-command)))) - -(defun erlang-eunit-analyze-coverage () - "Analyze the data collected by cover tool for the module in the -current buffer. - -Assumes that the module has been cover compiled prior to this -call. This function will do two things: print the number of -covered and uncovered functions in the erlang shell and display a -new buffer called * coverage* which shows the source -code along with the coverage analysis results." - (interactive) - (let* ((module-name (erlang-add-quotes-if-needed - (erlang-eunit-module-name buffer-file-name))) - (tmp-filename (make-temp-file "cover")) - (analyze-command (format "cover:analyze_to_file(%s, \"%s\"). " - module-name tmp-filename)) - (buf-name (format "*%s coverage*" module-name))) - (erlang-eunit-inferior-erlang-send-command analyze-command) - ;; The purpose of the following snippet is to get the result of the - ;; analysis from a file into a new buffer (or an old, if one with - ;; the specified name already exists). Also we want the erlang-mode - ;; *and* view-mode to be enabled. - (save-excursion - (let ((buf (get-buffer-create (format "*%s coverage*" module-name)))) - (set-buffer buf) - (setq buffer-read-only nil) - (insert-file-contents tmp-filename nil nil nil t) - (if (= (buffer-size) 0) - (kill-buffer buf) - ;; FIXME: this would be a good place to enable (emacs-mode) - ;; to get some nice syntax highlighting in the - ;; coverage report, but it doesn't play well with - ;; flymake. Leave it off for now. - (view-buffer buf)))) - (delete-file tmp-filename))) - -(defun erlang-eunit-compile-and-run-current-test () - "Compile the source and test files and run the current EUnit test. - -With prefix arg, compiles for debug and runs tests with the verbose flag set." - (interactive) - (let ((module-name (erlang-add-quotes-if-needed - (erlang-eunit-module-name buffer-file-name))) - (test-name (erlang-eunit-current-test))) - (erlang-eunit-compile-and-test - 'erlang-eunit-run-test (list module-name test-name)))) - -(defun erlang-eunit-compile-and-run-module-tests () - "Compile the source and test files and run all EUnit tests in the module. - -With prefix arg, compiles for debug and runs tests with the verbose flag set." - (interactive) - (let ((module-name (erlang-add-quotes-if-needed - (erlang-eunit-source-module-name buffer-file-name)))) - (erlang-eunit-compile-and-test - 'erlang-eunit-run-module-tests (list module-name)))) - -;;; Compile source and EUnit test file and finally run EUnit tests for -;;; the current module -(defun erlang-eunit-compile-and-test (test-fun test-args &optional under-cover) - "Compile the source and test files and run the EUnit test suite. - -If under-cover is set to t, the module under test is compile for -code coverage analysis. If under-cover is left out or not set, -coverage analysis is disabled. The result of the code coverage -is both printed to the erlang shell (the number of covered vs -uncovered functions in a module) and written to a buffer called -* coverage* (which shows the source code for the module -and the number of times each line is covered). -With prefix arg, compiles for debug and runs tests with the verbose flag set." - (erlang-eunit-record-recent-compile under-cover) - (let ((src-filename (erlang-eunit-src-filename buffer-file-name)) - (test-filename (erlang-eunit-test-filename buffer-file-name))) - - ;; The purpose of out-maneuvering `save-some-buffers', as is done - ;; below, is to ask the question about saving buffers only once, - ;; instead of possibly several: one for each file to compile, - ;; for instance for both x.erl and x_tests.erl. - (save-some-buffers erlang-eunit-autosave) - (flet ((save-some-buffers (&optional any) nil)) - - ;; Compilation of the source file is mandatory (the file must - ;; exist, otherwise the procedure is aborted). Compilation of the - ;; test file on the other hand, is optional, since eunit tests may - ;; be placed in the source file instead. Any compilation error - ;; will prevent the subsequent steps to be run (hence the `and') - (and (erlang-eunit-compile-file src-filename under-cover) - (if (file-readable-p test-filename) - (erlang-eunit-compile-file test-filename) - t) - (apply test-fun test-args) - (if under-cover - (save-excursion - (set-buffer (find-file-noselect src-filename)) - (erlang-eunit-analyze-coverage))))))) - -(defun erlang-eunit-compile-and-run-module-tests-under-cover () - "Compile the source and test files and run the EUnit test suite and measure -code coverage. - -With prefix arg, compiles for debug and runs tests with the verbose flag set." - (interactive) - (let ((module-name (erlang-add-quotes-if-needed - (erlang-eunit-source-module-name buffer-file-name)))) - (erlang-eunit-compile-and-test - 'erlang-eunit-run-module-tests (list module-name) t))) - -(defun erlang-eunit-compile-file (file-path &optional under-cover) - (if (file-readable-p file-path) - (save-excursion - (set-buffer (find-file-noselect file-path)) - ;; In order to run a code coverage analysis on a - ;; module, we have two options: - ;; - ;; * either compile the module with cover:compile instead of the - ;; regular compiler - ;; - ;; * or first compile the module with the regular compiler (but - ;; *with* debug_info) and then compile it for coverage - ;; analysis using cover:compile_beam. - ;; - ;; We could accomplish the first by changing the - ;; erlang-compile-erlang-function to cover:compile, but there's - ;; a risk that that's used for other purposes. Therefore, a - ;; safer alternative (although with more steps) is to add - ;; debug_info to the list of compiler options and go for the - ;; second alternative. - (if under-cover - (erlang-eunit-cover-compile) - (erlang-compile)) - (erlang-eunit-last-compilation-successful-p)) - (let ((msg (format "Could not read %s" file-path))) - (erlang-eunit-inferior-erlang-send-command - (format "%% WARNING: %s" msg)) - (error msg)))) - -(defun erlang-eunit-last-compilation-successful-p () - (save-excursion - (set-buffer inferior-erlang-buffer) - (goto-char compilation-parsing-end) - (erlang-eunit-all-list-elems-fulfill-p - (lambda (re) (let ((continue t) - (result t)) - (while continue ; ignore warnings, stop at errors - (if (re-search-forward re (point-max) t) - (if (erlang-eunit-is-compilation-warning) - t - (setq result nil) - (setq continue nil)) - (setq result t) - (setq continue nil))) - result)) - (mapcar (lambda (e) (car e)) erlang-error-regexp-alist)))) - -(defun erlang-eunit-is-compilation-warning () - (erlang-eunit-string-match-p - "[0-9]+: Warning:" - (buffer-substring (line-beginning-position) (line-end-position)))) - -(defun erlang-eunit-all-list-elems-fulfill-p (pred list) - (let ((matches-p t)) - (while (and list matches-p) - (if (not (funcall pred (car list))) - (setq matches-p nil)) - (setq list (cdr list))) - matches-p)) - -;;; Evaluate a command in an erlang buffer -(defun erlang-eunit-inferior-erlang-send-command (command) - "Evaluate a command in an erlang buffer." - (interactive "P") - (inferior-erlang-prepare-for-input) - (inferior-erlang-send-command command) - (sit-for 0) ;; redisplay - (inferior-erlang-wait-prompt)) - - -;;;==================================================================== -;;; Key bindings -;;;==================================================================== - -(defconst erlang-eunit-key-bindings - '(("\C-c\C-et" erlang-eunit-toggle-src-and-test-file-other-window) - ("\C-c\C-ek" erlang-eunit-compile-and-run-module-tests) - ("\C-c\C-ej" erlang-eunit-compile-and-run-current-test) - ("\C-c\C-el" erlang-eunit-compile-and-run-recent) - ("\C-c\C-ec" erlang-eunit-compile-and-run-module-tests-under-cover) - ("\C-c\C-ev" erlang-eunit-cover-compile) - ("\C-c\C-ea" erlang-eunit-analyze-coverage))) - -(defun erlang-eunit-add-key-bindings () - (dolist (binding erlang-eunit-key-bindings) - (erlang-eunit-bind-key (car binding) (cadr binding)))) - -(defun erlang-eunit-bind-key (key function) - (erlang-eunit-ensure-keymap-for-key key) - (local-set-key key function)) - -(defun erlang-eunit-ensure-keymap-for-key (key-seq) - (let ((prefix-keys (butlast (append key-seq nil))) - (prefix-seq "")) - (while prefix-keys - (setq prefix-seq (concat prefix-seq (make-string 1 (car prefix-keys)))) - (setq prefix-keys (cdr prefix-keys)) - (if (not (keymapp (lookup-key (current-local-map) prefix-seq))) - (local-set-key prefix-seq (make-sparse-keymap)))))) - -(add-hook 'erlang-mode-hook 'erlang-eunit-add-key-bindings) - - -(provide 'erlang-eunit) -;; erlang-eunit ends here diff --git a/elpa/erlang-20161007.57/erlang-flymake.el b/elpa/erlang-20161007.57/erlang-flymake.el deleted file mode 100644 index 2e447b5..0000000 --- a/elpa/erlang-20161007.57/erlang-flymake.el +++ /dev/null @@ -1,103 +0,0 @@ -;; erlang-flymake.el -;; -;; Syntax check erlang source code on the fly (integrates with flymake). -;; -;; Start using flymake with erlang by putting the following somewhere -;; in your .emacs file: -;; -;; (require 'erlang-flymake) -;; -;; Flymake is rather eager and does its syntax checks frequently by -;; default and if you are bothered by this, you might want to put the -;; following in your .emacs as well: -;; -;; (erlang-flymake-only-on-save) -;; -;; There are a couple of variables which control the compilation options: -;; * erlang-flymake-get-code-path-dirs-function -;; * erlang-flymake-get-include-dirs-function -;; * erlang-flymake-extra-opts -;; -;; This code is inspired by http://www.emacswiki.org/emacs/FlymakeErlang. - -(require 'flymake) -(eval-when-compile - (require 'cl)) - -(defvar erlang-flymake-command - "erlc" - "The command that will be used to perform the syntax check") - -(defvar erlang-flymake-get-code-path-dirs-function - 'erlang-flymake-get-code-path-dirs - "Return a list of ebin directories to add to the code path.") - -(defvar erlang-flymake-get-include-dirs-function - 'erlang-flymake-get-include-dirs - "Return a list of include directories to add to the compiler options.") - -(defvar erlang-flymake-extra-opts - (list "+warn_obsolete_guard" - "+warn_unused_import" - "+warn_shadow_vars" - "+warn_export_vars" - "+strong_validation" - "+report") - "A list of options that will be passed to the compiler") - -(defun erlang-flymake-only-on-save () - "Trigger flymake only when the buffer is saved (disables syntax -check on newline and when there are no changes)." - (interactive) - ;; There doesn't seem to be a way of disabling this; set to the - ;; largest int available as a workaround (most-positive-fixnum - ;; equates to 8.5 years on my machine, so it ought to be enough ;-) ) - (setq flymake-no-changes-timeout most-positive-fixnum) - (setq flymake-start-syntax-check-on-newline nil)) - - -(defun erlang-flymake-get-code-path-dirs () - (list (concat (erlang-flymake-get-app-dir) "ebin"))) - -(defun erlang-flymake-get-include-dirs () - (list (concat (erlang-flymake-get-app-dir) "include") - (concat (erlang-flymake-get-app-dir) "deps"))) - -(defun erlang-flymake-get-app-dir () - (let ((src-path (file-name-directory (buffer-file-name)))) - (file-name-directory (directory-file-name src-path)))) - -(defun erlang-flymake-init () - (let* ((temp-file - (flet ((flymake-get-temp-dir () (erlang-flymake-temp-dir))) - (flymake-init-create-temp-buffer-copy - 'flymake-create-temp-with-folder-structure))) - (code-dir-opts - (erlang-flymake-flatten - (mapcar (lambda (dir) (list "-pa" dir)) - (funcall erlang-flymake-get-code-path-dirs-function)))) - (inc-dir-opts - (erlang-flymake-flatten - (mapcar (lambda (dir) (list "-I" dir)) - (funcall erlang-flymake-get-include-dirs-function)))) - (compile-opts - (append inc-dir-opts - code-dir-opts - erlang-flymake-extra-opts))) - (list erlang-flymake-command (append compile-opts (list temp-file))))) - -(defun erlang-flymake-temp-dir () - ;; Squeeze the user's name in there in order to make sure that files - ;; for two users who are working on the same computer (like a linux - ;; box) don't collide - (format "%s/flymake-%s" temporary-file-directory user-login-name)) - -(defun erlang-flymake-flatten (list) - (apply #'append list)) - -(add-to-list 'flymake-allowed-file-name-masks - '("\\.erl\\'" erlang-flymake-init)) -(add-hook 'erlang-mode-hook 'flymake-mode) - -(provide 'erlang-flymake) -;; erlang-flymake ends here diff --git a/elpa/erlang-20161007.57/erlang-pkg.el b/elpa/erlang-20161007.57/erlang-pkg.el deleted file mode 100644 index 30b21c7..0000000 --- a/elpa/erlang-20161007.57/erlang-pkg.el +++ /dev/null @@ -1,4 +0,0 @@ -(define-package "erlang" "20161007.57" "Erlang major mode" 'nil) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/erlang-20161007.57/erlang-skels-old.el b/elpa/erlang-20161007.57/erlang-skels-old.el deleted file mode 100644 index 4087bc3..0000000 --- a/elpa/erlang-20161007.57/erlang-skels-old.el +++ /dev/null @@ -1,1268 +0,0 @@ -;; -;; %CopyrightBegin% -;; -;; Copyright Ericsson AB 2010-2016. All Rights Reserved. -;; -;; Licensed under the Apache License, Version 2.0 (the "License"); -;; you may not use this file except in compliance with the License. -;; You may obtain a copy of the License at -;; -;; http://www.apache.org/licenses/LICENSE-2.0 -;; -;; Unless required by applicable law or agreed to in writing, software -;; distributed under the License is distributed on an "AS IS" BASIS, -;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -;; See the License for the specific language governing permissions and -;; limitations under the License. -;; -;; %CopyrightEnd% -;;; -;;; Purpose: Provide Erlang code skeletons. -;;; See 'erlang-skel-file' variable. - -(defvar erlang-tempo-tags nil - "Tempo tags for erlang mode") - -(defvar erlang-skel - '(("If" "if" erlang-skel-if) - ("Case" "case" erlang-skel-case) - ("Receive" "receive" erlang-skel-receive) - ("Receive After" "after" erlang-skel-receive-after) - ("Receive Loop" "loop" erlang-skel-receive-loop) - ("Module" "module" erlang-skel-module) - ("Author" "author" erlang-skel-author) - () - ("Small Header" "small-header" - erlang-skel-small-header erlang-skel-header) - ("Normal Header" "normal-header" - erlang-skel-normal-header erlang-skel-header) - ("Large Header" "large-header" - erlang-skel-large-header erlang-skel-header) - () - ("Small Server" "small-server" - erlang-skel-small-server erlang-skel-header) - () - ("Application" "application" - erlang-skel-application erlang-skel-header) - ("Supervisor" "supervisor" - erlang-skel-supervisor erlang-skel-header) - ("supervisor_bridge" "supervisor-bridge" - erlang-skel-supervisor-bridge erlang-skel-header) - ("gen_server" "generic-server" - erlang-skel-generic-server erlang-skel-header) - ("gen_event" "gen-event" - erlang-skel-gen-event erlang-skel-header) - ("gen_fsm" "gen-fsm" - erlang-skel-gen-fsm erlang-skel-header) - ("Library module" "gen-lib" - erlang-skel-lib erlang-skel-header) - ("Corba callback" "gen-corba-cb" - erlang-skel-corba-callback erlang-skel-header) - ("Small Common Test suite" "ct-test-suite-s" - erlang-skel-ct-test-suite-s erlang-skel-header) - ("Large Common Test suite" "ct-test-suite-l" - erlang-skel-ct-test-suite-l erlang-skel-header) - ("Erlang TS test suite" "ts-test-suite" - erlang-skel-ts-test-suite erlang-skel-header) - ) - "*Description of all skeleton templates. -Both functions and menu entries will be created. - -Each entry in `erlang-skel' should be a list with three or four -elements, or the empty list. - -The first element is the name which shows up in the menu. The second -is the `tempo' identifier (The string \"erlang-\" will be added in -front of it). The third is the skeleton descriptor, a variable -containing `tempo' attributes as described in the function -`tempo-define-template'. The optional fourth elements denotes a -function which should be called when the menu is selected. - -Functions corresponding to every template will be created. The name -of the function will be `tempo-template-erlang-X' where `X' is the -tempo identifier as specified in the second argument of the elements -in this list. - -A list with zero elements means that the a horizontal line should -be placed in the menu.") - -;; In XEmacs `user-mail-address' returns "x@y.z (Foo Bar)" ARGH! -;; What's wrong with that? RFC 822 says it's legal. [sverkerw] -;; This needs to use the customized value. If that's not sane, things like -;; add-log will lose anyhow. Avoid it if there _is_ a paren. -(defvar erlang-skel-mail-address - (if (or (not user-mail-address) (string-match "(" user-mail-address)) - (concat (user-login-name) "@" - (or (and (boundp 'mail-host-address) - mail-host-address) - (system-name))) - user-mail-address) - "Mail address of the user.") - -;; Expression templates: -(defvar erlang-skel-case - '((erlang-skel-skip-blank) o > - "case " p " of" n> p "_ ->" n> p "ok" n> "end" p) - "*The skeleton of a `case' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-if - '((erlang-skel-skip-blank) o > - "if" n> p " ->" n> p "ok" n> "end" p) - "The skeleton of an `if' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive - '((erlang-skel-skip-blank) o > - "receive" n> p "_ ->" n> p "ok" n> "end" p) - "*The skeleton of a `receive' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive-after - '((erlang-skel-skip-blank) o > - "receive" n> p "_ ->" n> p "ok" n> "after " p "T ->" n> - p "ok" n> "end" p) - "*The skeleton of a `receive' expression with an `after' clause. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive-loop - '(& o "loop(" p ") ->" n> "receive" n> p "_ ->" n> - "loop(" p ")" n> "end.") - "*The skeleton of a simple `receive' loop. -Please see the function `tempo-define-template'.") - - -;; Attribute templates - -(defvar erlang-skel-module - '(& "-module(" - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) - ")." n) - "*The skeleton of a `module' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-author - '(& "-author('" erlang-skel-mail-address "')." n) - "*The skeleton of a `author' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-vc nil - "*The skeleton template to generate a version control attribute. -The default is to insert nothing. Example of usage: - - (setq erlang-skel-vc '(& \"-rcs(\\\"$\Id: $ \\\").\") n) - -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-export - '(& "-export([" n> "])." n) - "*The skeleton of an `export' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-import - '(& "%%-import(Module, [Function/Arity, ...])." n) - "*The skeleton of an `import' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-compile nil - ;; '(& "%%-compile(export_all)." n) - "*The skeleton of a `compile' attribute. -Please see the function `tempo-define-template'.") - - -;; Comment templates. - -(defvar erlang-skel-date-function 'erlang-skel-dd-mmm-yyyy - "*Function which returns date string. -Look in the module `time-stamp' for a battery of functions.") - -(defvar erlang-skel-copyright-comment '() - "*The template for a copyright line in the header, normally empty. -This variable should be bound to a `tempo' template, for example: - '(& \"%%% Copyright (C) 2000, Yoyodyne, Inc.\" n) - -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-created-comment - '(& "%%% Created : " (funcall erlang-skel-date-function) " by " - (user-full-name) " <" erlang-skel-mail-address ">" n) - "*The template for the \"Created:\" comment line.") - -(defvar erlang-skel-author-comment - '(& "%%% Author : " (user-full-name) " <" erlang-skel-mail-address ">" n) - "*The template for creating the \"Author:\" line in the header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-file-comment - '(& "%%% File : " (file-name-nondirectory buffer-file-name) n) -"*The template for creating the \"Module:\" line in the header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-small-header - '(o (erlang-skel-include erlang-skel-module) - ;; erlang-skel-author) - n - (erlang-skel-include erlang-skel-compile - ;; erlang-skel-export - erlang-skel-vc)) - "*The template of a small header without any comments. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-normal-header - '(o (erlang-skel-include erlang-skel-copyright-comment - erlang-skel-file-comment - erlang-skel-author-comment) - "%%% Description : " p n - (erlang-skel-include erlang-skel-created-comment) n - (erlang-skel-include erlang-skel-small-header) n) - "*The template of a normal header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-large-header - '(o (erlang-skel-separator) - (erlang-skel-include erlang-skel-copyright-comment - erlang-skel-file-comment - erlang-skel-author-comment) - "%%% Description : " p n - "%%%" n - (erlang-skel-include erlang-skel-created-comment) - (erlang-skel-separator) - (erlang-skel-include erlang-skel-small-header) ) - "*The template of a large header. -Please see the function `tempo-define-template'.") - - -;; Server templates. - -(defvar erlang-skel-small-server - '((erlang-skel-include erlang-skel-large-header) - "-export([start/0,init/1])." n n n - "start() ->" n> "spawn(" (erlang-get-module-from-file-name) - ", init, [self()])." n n - "init(From) ->" n> - "loop(From)." n n - "loop(From) ->" n> - "receive" n> - p "_ ->" n> - "loop(From)" n> - "end." - ) - "*Template of a small server. -Please see the function `tempo-define-template'.") - -;; Behaviour templates. - -(defvar erlang-skel-application - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(application)." n n - "%% Application callbacks" n - "-export([start/2, stop/1])." n n - (erlang-skel-double-separator 2) - "%% Application callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start(Type, StartArgs) -> {ok, Pid} |" n - "%% {ok, Pid, State} |" n - "%% {error, Reason}" n - "%% Description: This function is called whenever an application " n - "%% is started using application:start/1,2, and should start the processes" n - "%% of the application. If the application is structured according to the" n - "%% OTP design principles as a supervision tree, this means starting the" n - "%% top supervisor of the tree." n - (erlang-skel-separator 2) - "start(_Type, StartArgs) ->" n> - "case 'TopSupervisor':start_link(StartArgs) of" n> - "{ok, Pid} -> " n> - "{ok, Pid};" n> - "Error ->" n> - "Error" n> - "end." n - n - (erlang-skel-separator 2) - "%% Function: stop(State) -> void()" n - "%% Description: This function is called whenever an application" n - "%% has stopped. It is intended to be the opposite of Module:start/2 and" n - "%% should do any necessary cleaning up. The return value is ignored. "n - (erlang-skel-separator 2) - "stop(_State) ->" n> - "ok." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of an application behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-supervisor - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(supervisor)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% Supervisor callbacks" n - "-export([init/1])." n n - - "-define(SERVER, ?MODULE)." n n - - (erlang-skel-double-separator 2) - "%% API functions" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n - "%% Description: Starts the supervisor" n - (erlang-skel-separator 2) - "start_link() ->" n> - "supervisor:start_link({local, ?SERVER}, ?MODULE, [])." n - n - (erlang-skel-double-separator 2) - "%% Supervisor callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Func: init(Args) -> {ok, {SupFlags, [ChildSpec]}} |" n - "%% ignore |" n - "%% {error, Reason}" n - "%% Description: Whenever a supervisor is started using "n - "%% supervisor:start_link/[2,3], this function is called by the new process "n - "%% to find out about restart strategy, maximum restart frequency and child "n - "%% specifications." n - (erlang-skel-separator 2) - "init([]) ->" n> - "AChild = {'AName',{'AModule',start_link,[]}," n> - "permanent,2000,worker,['AModule']}," n> - "{ok,{{one_for_all,0,1}, [AChild]}}." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of an supervisor behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-supervisor-bridge - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(supervisor_bridge)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% supervisor_bridge callbacks" n - "-export([init/1, terminate/2])." n n - - "-define(SERVER, ?MODULE)." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator 2) - "%% API" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n - "%% Description: Starts the supervisor bridge" n - (erlang-skel-separator 2) - "start_link() ->" n> - "supervisor_bridge:start_link({local, ?SERVER}, ?MODULE, [])." n - n - (erlang-skel-double-separator 2) - "%% supervisor_bridge callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Funcion: init(Args) -> {ok, Pid, State} |" n - "%% ignore |" n - "%% {error, Reason} " n - "%% Description:Creates a supervisor_bridge process, linked to the calling" n - "%% process, which calls Module:init/1 to start the subsystem. To ensure a" n - "%% synchronized start-up procedure, this function does not return until" n - "%% Module:init/1 has returned. " n - (erlang-skel-separator 2) - "init([]) ->" n> - "case 'AModule':start_link() of" n> - "{ok, Pid} ->" n> - "{ok, Pid, #state{}};" n> - "Error ->" n> - "Error" n> - "end." n - n - (erlang-skel-separator 2) - "%% Func: terminate(Reason, State) -> void()" n - "%% Description:This function is called by the supervisor_bridge when it is"n - "%% about to terminate. It should be the opposite of Module:init/1 and stop"n - "%% the subsystem and do any necessary cleaning up.The return value is ignored." - (erlang-skel-separator 2) - "terminate(Reason, State) ->" n> - "'AModule':stop()," n> - "ok." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of an supervisor_bridge behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-generic-server - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_server)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% gen_server callbacks" n - "-export([init/1, handle_call/3, handle_cast/2, " - "handle_info/2," n> - "terminate/2, code_change/3])." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator 2) - "%% API" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link() -> {ok,Pid} | ignore | {error,Error}" n - "%% Description: Starts the server" n - (erlang-skel-separator 2) - "start_link() ->" n> - "gen_server:start_link({local, ?SERVER}, ?MODULE, [], [])." n - n - (erlang-skel-double-separator 2) - "%% gen_server callbacks" n - (erlang-skel-double-separator 2) - n - (erlang-skel-separator 2) - "%% Function: init(Args) -> {ok, State} |" n - "%% {ok, State, Timeout} |" n - "%% ignore |" n - "%% {stop, Reason}" n - "%% Description: Initializes the server" n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Function: " - "%% handle_call(Request, From, State) -> {reply, Reply, State} |" n - "%% {reply, Reply, State, Timeout} |" n - "%% {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, Reply, State} |" n - "%% {stop, Reason, State}" n - "%% Description: Handling call messages" n - (erlang-skel-separator 2) - "handle_call(_Request, _From, State) ->" n> - "Reply = ok," n> - "{reply, Reply, State}." n - n - (erlang-skel-separator 2) - "%% Function: handle_cast(Msg, State) -> {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State}" n - "%% Description: Handling cast messages" n - - (erlang-skel-separator 2) - "handle_cast(_Msg, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator 2) - "%% Function: handle_info(Info, State) -> {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State}" n - "%% Description: Handling all non call/cast messages" n - (erlang-skel-separator 2) - "handle_info(_Info, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator 2) - "%% Function: terminate(Reason, State) -> void()" n - "%% Description: This function is called by a gen_server when it is about to"n - "%% terminate. It should be the opposite of Module:init/1 and do any necessary"n - "%% cleaning up. When it returns, the gen_server terminates with Reason." n - "%% The return value is ignored." n - - (erlang-skel-separator 2) - "terminate(_Reason, _State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Func: code_change(OldVsn, State, Extra) -> {ok, NewState}" n - "%% Description: Convert process state when code is changed" n - (erlang-skel-separator 2) - "code_change(_OldVsn, State, _Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%%% Internal functions" n - (erlang-skel-separator 2) - ) - "*The template of a generic server. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-gen-event - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_event)." n - - "%% API" n - "-export([start_link/0, add_handler/0])." n n - - "%% gen_event callbacks" n - "-export([init/1, handle_event/2, handle_call/2, " n> - "handle_info/2, terminate/2, code_change/3])." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator 2) - "%% gen_event callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link() -> {ok,Pid} | {error,Error} " n - "%% Description: Creates an event manager." n - (erlang-skel-separator 2) - "start_link() ->" n> - "gen_event:start_link({local, ?SERVER}). " n - n - (erlang-skel-separator 2) - "%% Function: add_handler() -> ok | {'EXIT',Reason} | term()" n - "%% Description: Adds an event handler" n - (erlang-skel-separator 2) - "add_handler() ->" n> - "gen_event:add_handler(?SERVER, ?MODULE, [])." n - n - (erlang-skel-double-separator 2) - "%% gen_event callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: init(Args) -> {ok, State}" n - "%% Description: Whenever a new event handler is added to an event manager,"n - "%% this function is called to initialize the event handler." n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Function: "n - "%% handle_event(Event, State) -> {ok, State} |" n - "%% {swap_handler, Args1, State1, Mod2, Args2} |"n - "%% remove_handler" n - "%% Description:Whenever an event manager receives an event sent using"n - "%% gen_event:notify/2 or gen_event:sync_notify/2, this function is called for"n - "%% each installed event handler to handle the event. "n - (erlang-skel-separator 2) - "handle_event(_Event, State) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%% Function: " n - "%% handle_call(Request, State) -> {ok, Reply, State} |" n - "%% {swap_handler, Reply, Args1, State1, "n - "%% Mod2, Args2} |" n - "%% {remove_handler, Reply}" n - "%% Description: Whenever an event manager receives a request sent using"n - "%% gen_event:call/3,4, this function is called for the specified event "n - "%% handler to handle the request."n - (erlang-skel-separator 2) - "handle_call(_Request, State) ->" n> - "Reply = ok," n> - "{ok, Reply, State}." n - n - (erlang-skel-separator 2) - "%% Function: " n - "%% handle_info(Info, State) -> {ok, State} |" n - "%% {swap_handler, Args1, State1, Mod2, Args2} |" n - "%% remove_handler" n - "%% Description: This function is called for each installed event handler when"n - "%% an event manager receives any other message than an event or a synchronous"n - "%% request (or a system message)."n - (erlang-skel-separator 2) - "handle_info(_Info, State) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%% Function: terminate(Reason, State) -> void()" n - "%% Description:Whenever an event handler is deleted from an event manager,"n - "%% this function is called. It should be the opposite of Module:init/1 and "n - "%% do any necessary cleaning up. " n - (erlang-skel-separator 2) - "terminate(_Reason, _State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Function: code_change(OldVsn, State, Extra) -> {ok, NewState} " n - "%% Description: Convert process state when code is changed" n - (erlang-skel-separator 2) - "code_change(_OldVsn, State, _Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%%% Internal functions" n - (erlang-skel-separator 2) - ) - "*The template of a gen_event. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-gen-fsm - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_fsm)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% gen_fsm callbacks" n - "-export([init/1, state_name/2, state_name/3, handle_event/3," n> - "handle_sync_event/4, handle_info/3, terminate/3, code_change/4])." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator 2) - "%% API" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: start_link() -> ok,Pid} | ignore | {error,Error}" n - "%% Description:Creates a gen_fsm process which calls Module:init/1 to"n - "%% initialize. To ensure a synchronized start-up procedure, this function" n - "%% does not return until Module:init/1 has returned. " n - (erlang-skel-separator 2) - "start_link() ->" n> - "gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], [])." n - n - (erlang-skel-double-separator 2) - "%% gen_fsm callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: init(Args) -> {ok, StateName, State} |" n - "%% {ok, StateName, State, Timeout} |" n - "%% ignore |" n - "%% {stop, StopReason} " n - "%% Description:Whenever a gen_fsm is started using gen_fsm:start/[3,4] or"n - "%% gen_fsm:start_link/3,4, this function is called by the new process to "n - "%% initialize. " n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, state_name, #state{}}." n - n - (erlang-skel-separator 2) - "%% Function: "n - "%% state_name(Event, State) -> {next_state, NextStateName, NextState}|" n - "%% {next_state, NextStateName, " n - "%% NextState, Timeout} |" n - "%% {stop, Reason, NewState}" n - "%% Description:There should be one instance of this function for each possible"n - "%% state name. Whenever a gen_fsm receives an event sent using" n - "%% gen_fsm:send_event/2, the instance of this function with the same name as"n - "%% the current state name StateName is called to handle the event. It is also "n - "%% called if a timeout occurs. " n - (erlang-skel-separator 2) - "state_name(_Event, State) ->" n> - "{next_state, state_name, State}." n - n - (erlang-skel-separator 2) - "%% Function:" n - "%% state_name(Event, From, State) -> {next_state, NextStateName, NextState} |"n - "%% {next_state, NextStateName, " n - "%% NextState, Timeout} |" n - "%% {reply, Reply, NextStateName, NextState}|"n - "%% {reply, Reply, NextStateName, " n - "%% NextState, Timeout} |" n - "%% {stop, Reason, NewState}|" n - "%% {stop, Reason, Reply, NewState}" n - "%% Description: There should be one instance of this function for each" n - "%% possible state name. Whenever a gen_fsm receives an event sent using" n - "%% gen_fsm:sync_send_event/2,3, the instance of this function with the same"n - "%% name as the current state name StateName is called to handle the event." n - (erlang-skel-separator 2) - "state_name(_Event, _From, State) ->" n> - "Reply = ok," n> - "{reply, Reply, state_name, State}." n - n - (erlang-skel-separator 2) - "%% Function: " n - "%% handle_event(Event, StateName, State) -> {next_state, NextStateName, "n - "%% NextState} |" n - "%% {next_state, NextStateName, "n - "%% NextState, Timeout} |" n - "%% {stop, Reason, NewState}" n - "%% Description: Whenever a gen_fsm receives an event sent using"n - "%% gen_fsm:send_all_state_event/2, this function is called to handle"n - "%% the event." n - (erlang-skel-separator 2) - "handle_event(_Event, StateName, State) ->" n> - "{next_state, StateName, State}." n - n - (erlang-skel-separator 2) - "%% Function: " n - "%% handle_sync_event(Event, From, StateName, "n - "%% State) -> {next_state, NextStateName, NextState} |" n - "%% {next_state, NextStateName, NextState, " n - "%% Timeout} |" n - "%% {reply, Reply, NextStateName, NextState}|" n - "%% {reply, Reply, NextStateName, NextState, " n - "%% Timeout} |" n - "%% {stop, Reason, NewState} |" n - "%% {stop, Reason, Reply, NewState}" n - "%% Description: Whenever a gen_fsm receives an event sent using"n - "%% gen_fsm:sync_send_all_state_event/2,3, this function is called to handle"n - "%% the event."n - (erlang-skel-separator 2) - "handle_sync_event(Event, From, StateName, State) ->" n> - "Reply = ok," n> - "{reply, Reply, StateName, State}." n - n - (erlang-skel-separator 2) - "%% Function: " n - "%% handle_info(Info,StateName,State)-> {next_state, NextStateName, NextState}|" n - "%% {next_state, NextStateName, NextState, "n - "%% Timeout} |" n - "%% {stop, Reason, NewState}" n - "%% Description: This function is called by a gen_fsm when it receives any"n - "%% other message than a synchronous or asynchronous event"n - "%% (or a system message)." n - (erlang-skel-separator 2) - "handle_info(_Info, StateName, State) ->" n> - "{next_state, StateName, State}." n - n - (erlang-skel-separator 2) - "%% Function: terminate(Reason, StateName, State) -> void()" n - "%% Description:This function is called by a gen_fsm when it is about"n - "%% to terminate. It should be the opposite of Module:init/1 and do any"n - "%% necessary cleaning up. When it returns, the gen_fsm terminates with"n - "%% Reason. The return value is ignored." n - (erlang-skel-separator 2) - "terminate(_Reason, _StateName, _State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Function:" n - "%% code_change(OldVsn, StateName, State, Extra) -> {ok, StateName, NewState}" n - "%% Description: Convert process state when code is changed" n - (erlang-skel-separator 2) - "code_change(_OldVsn, StateName, State, _Extra) ->" n> - "{ok, StateName, State}." n - n - (erlang-skel-separator 2) - "%%% Internal functions" n - (erlang-skel-separator 2) - ) - "*The template of a gen_fsm. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-lib - '((erlang-skel-include erlang-skel-large-header) - - "%% API" n - "-export([])." n n - - (erlang-skel-double-separator 2) - "%% API" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: " n - "%% Description:" n - (erlang-skel-separator 2) - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-corba-callback - '((erlang-skel-include erlang-skel-large-header) - "%% Include files" n n - - "%% API" n - "-export([])." n n - - "%% Corba callbacks" n - "-export([init/1, terminate/2, code_change/3])." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator 2) - "%% Corba callbacks" n - (erlang-skel-double-separator 2) - (erlang-skel-separator 2) - "%% Function: init(Args) -> {ok, State} |" n - "%% {ok, State, Timeout} |" n - "%% ignore |" n - "%% {stop, Reason}" n - "%% Description: Initializes the server" n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Function: terminate(Reason, State) -> void()" n - "%% Description: Shutdown the server" n - (erlang-skel-separator 2) - "terminate(_Reason, _State) ->" n> - "ok." n - n - (erlang-skel-separator 2) - "%% Function: code_change(OldVsn, State, Extra) -> {ok, NewState} " n - "%% Description: Convert process state when code is changed" n - (erlang-skel-separator 2) - "code_change(_OldVsn, State, _Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-double-separator 2) - "%% Internal functions" n - (erlang-skel-double-separator 2) - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-ts-test-suite - '((erlang-skel-include erlang-skel-large-header) - "%% Note: This directive should only be used in test suites." n - "-compile(export_all)." n n - - "-include_lib(\"common_test/include/ct.hrl\")." n n - - (erlang-skel-separator 2) - "%% TEST SERVER CALLBACK FUNCTIONS" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% Function: init_per_suite(Config0) -> Config1 | {skip,Reason}" n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the suite." n - "%%" n - "%% Description: Initialization before the suite." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - (erlang-skel-separator 2) - "init_per_suite(Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_suite(Config) -> term()" n - "%%" n - "%% Config = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%%" n - "%% Description: Cleanup after the suite." n - (erlang-skel-separator 2) - "end_per_suite(_Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: init_per_testcase(TestCase, Config0) -> Config1 |" n - "%% {skip,Reason}" n - "%% TestCase = atom()" n - "%% Name of the test case that is about to run." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%%" n - "%% Description: Initialization before each test case." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - (erlang-skel-separator 2) - "init_per_testcase(_TestCase, Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_testcase(TestCase, Config) -> term()" n - "%%" n - "%% TestCase = atom()" n - "%% Name of the test case that is finished." n - "%% Config = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%%" n - "%% Description: Cleanup after each test case." n - (erlang-skel-separator 2) - "end_per_testcase(_TestCase, _Config) ->" n > - "ok."n n - - (erlang-skel-separator 2) - "%% Function: all(Clause) -> Descr | Spec | {skip,Reason}" n - "%%" n - "%% Clause = doc | suite" n - "%% Indicates expected return value." n - "%% Descr = [string()] | []" n - "%% String that describes the test suite." n - "%% Spec = [TestCase]" n - "%% A test specification." n - "%% TestCase = ConfCase | atom()" n - "%% Configuration case, or the name of a test case function." n - "%% ConfCase = {conf,Init,Spec,End} |" n - "%% {conf,Properties,Init,Spec,End}" n - "%% Init = End = {Mod,Func} | Func" n - "%% Initialization and cleanup function." n - "%% Mod = Func = atom()" n - "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n - "%% Execution properties of the test cases (may be combined)." n - "%% Shuffle = shuffle | {shuffle,Seed}" n - "%% To get cases executed in random order." n - "%% Seed = {integer(),integer(),integer()}" n - "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n - "%% repeat_until_any_ok | repeat_until_any_fail" n - "%% To get execution of cases repeated." n - "%% N = integer() | forever" n - "%% Reason = term()" n - "%% The reason for skipping the test suite." n - "%%" n - "%% Description: Returns a description of the test suite when" n - "%% Clause == doc, and a test specification (list" n - "%% of the conf and test cases in the suite) when" n - "%% Clause == suite." n - (erlang-skel-separator 2) - "all(doc) -> " n > - "[\"Describe the main purpose of this suite\"];" n n - "all(suite) -> " n > - "[a_test_case]." n n - n - (erlang-skel-separator 2) - "%% TEST CASES" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% Function: TestCase(Arg) -> Descr | Spec | ok | exit() | {skip,Reason}" n - "%%" n - "%% Arg = doc | suite | Config" n - "%% Indicates expected behaviour and return value." n - "%% Config = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Descr = [string()] | []" n - "%% String that describes the test case." n - "%% Spec = [tuple()] | []" n - "%% A test specification, see all/1." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%%" n - "%% Description: Test case function. Returns a description of the test" n - "%% case (doc), then returns a test specification (suite)," n - "%% or performs the actual test (Config)." n - (erlang-skel-separator 2) - "a_test_case(doc) -> " n > - "[\"Describe the main purpose of this test case\"];" n n - "a_test_case(suite) -> " n > - "[];" n n - "a_test_case(Config) when is_list(Config) -> " n > - "ok." n - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-ct-test-suite-l - '((erlang-skel-include erlang-skel-large-header) - "%% Note: This directive should only be used in test suites." n - "-compile(export_all)." n n - - "-include_lib(\"common_test/include/ct.hrl\")." n n - - (erlang-skel-separator 2) - "%% COMMON TEST CALLBACK FUNCTIONS" n - (erlang-skel-separator 2) - n - (erlang-skel-separator 2) - "%% Function: suite() -> Info" n - "%%" n - "%% Info = [tuple()]" n - "%% List of key/value pairs." n - "%%" n - "%% Description: Returns list of tuples to set default properties" n - "%% for the suite." n - "%%" n - "%% Note: The suite/0 function is only meant to be used to return" n - "%% default data values, not perform any other operations." n - (erlang-skel-separator 2) - "suite() ->" n > - "[{timetrap,{minutes,10}}]." n n - - (erlang-skel-separator 2) - "%% Function: init_per_suite(Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the suite." n - "%%" n - "%% Description: Initialization before the suite." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - (erlang-skel-separator 2) - "init_per_suite(Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_suite(Config0) -> term() | {save_config,Config1}" n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%%" n - "%% Description: Cleanup after the suite." n - (erlang-skel-separator 2) - "end_per_suite(_Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: init_per_group(GroupName, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%%" n - "%% GroupName = atom()" n - "%% Name of the test case group that is about to run." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding configuration data for the group." n - "%% Reason = term()" n - "%% The reason for skipping all test cases and subgroups in the group." n - "%%" n - "%% Description: Initialization before each test case group." n - (erlang-skel-separator 2) - "init_per_group(_GroupName, Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_group(GroupName, Config0) ->" n - "%% term() | {save_config,Config1}" n - "%%" n - "%% GroupName = atom()" n - "%% Name of the test case group that is finished." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding configuration data for the group." n - "%%" n - "%% Description: Cleanup after each test case group." n - (erlang-skel-separator 2) - "end_per_group(_GroupName, _Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: init_per_testcase(TestCase, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%%" n - "%% TestCase = atom()" n - "%% Name of the test case that is about to run." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%%" n - "%% Description: Initialization before each test case." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - (erlang-skel-separator 2) - "init_per_testcase(_TestCase, Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_testcase(TestCase, Config0) ->" n - "%% term() | {save_config,Config1} | {fail,Reason}" n - "%%" n - "%% TestCase = atom()" n - "%% Name of the test case that is finished." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for failing the test case." n - "%%" n - "%% Description: Cleanup after each test case." n - (erlang-skel-separator 2) - "end_per_testcase(_TestCase, _Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: groups() -> [Group]" n - "%%" n - "%% Group = {GroupName,Properties,GroupsAndTestCases}" n - "%% GroupName = atom()" n - "%% The name of the group." n - "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n - "%% Group properties that may be combined." n - "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n - "%% TestCase = atom()" n - "%% The name of a test case." n - "%% Shuffle = shuffle | {shuffle,Seed}" n - "%% To get cases executed in random order." n - "%% Seed = {integer(),integer(),integer()}" n - "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n - "%% repeat_until_any_ok | repeat_until_any_fail" n - "%% To get execution of cases repeated." n - "%% N = integer() | forever" n - "%%" n - "%% Description: Returns a list of test case group definitions." n - (erlang-skel-separator 2) - "groups() ->" n > - "[]." n n - - (erlang-skel-separator 2) - "%% Function: all() -> GroupsAndTestCases | {skip,Reason}" n - "%%" n - "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n - "%% GroupName = atom()" n - "%% Name of a test case group." n - "%% TestCase = atom()" n - "%% Name of a test case." n - "%% Reason = term()" n - "%% The reason for skipping all groups and test cases." n - "%%" n - "%% Description: Returns the list of groups and test cases that" n - "%% are to be executed." n - (erlang-skel-separator 2) - "all() -> " n > - "[my_test_case]." n n - - n - (erlang-skel-separator 2) - "%% TEST CASES" n - (erlang-skel-separator 2) - n - - (erlang-skel-separator 2) - "%% Function: TestCase() -> Info" n - "%%" n - "%% Info = [tuple()]" n - "%% List of key/value pairs." n - "%%" n - "%% Description: Test case info function - returns list of tuples to set" n - "%% properties for the test case." n - "%%" n - "%% Note: This function is only meant to be used to return a list of" n - "%% values, not perform any other operations." n - (erlang-skel-separator 2) - "my_test_case() -> " n > - "[]." n n - - (erlang-skel-separator 2) - "%% Function: TestCase(Config0) ->" n - "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n - "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%% Comment = term()" n - "%% A comment about the test case that will be printed in the html log." n - "%%" n - "%% Description: Test case function. (The name of it must be specified in" n - "%% the all/0 list or in a test case group for the test case" n - "%% to be executed)." n - (erlang-skel-separator 2) - "my_test_case(_Config) -> " n > - "ok." n - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-ct-test-suite-s - '((erlang-skel-include erlang-skel-large-header) - "-compile(export_all)." n n - - "-include_lib(\"common_test/include/ct.hrl\")." n n - - (erlang-skel-separator 2) - "%% Function: suite() -> Info" n - "%% Info = [tuple()]" n - (erlang-skel-separator 2) - "suite() ->" n > - "[{timetrap,{seconds,30}}]." n n - - (erlang-skel-separator 2) - "%% Function: init_per_suite(Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator 2) - "init_per_suite(Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_suite(Config0) -> term() | {save_config,Config1}" n - "%% Config0 = Config1 = [tuple()]" n - (erlang-skel-separator 2) - "end_per_suite(_Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: init_per_group(GroupName, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%% GroupName = atom()" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator 2) - "init_per_group(_GroupName, Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_group(GroupName, Config0) ->" n - "%% term() | {save_config,Config1}" n - "%% GroupName = atom()" n - "%% Config0 = Config1 = [tuple()]" n - (erlang-skel-separator 2) - "end_per_group(_GroupName, _Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: init_per_testcase(TestCase, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%% TestCase = atom()" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator 2) - "init_per_testcase(_TestCase, Config) ->" n > - "Config." n n - - (erlang-skel-separator 2) - "%% Function: end_per_testcase(TestCase, Config0) ->" n - "%% term() | {save_config,Config1} | {fail,Reason}" n - "%% TestCase = atom()" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator 2) - "end_per_testcase(_TestCase, _Config) ->" n > - "ok." n n - - (erlang-skel-separator 2) - "%% Function: groups() -> [Group]" n - "%% Group = {GroupName,Properties,GroupsAndTestCases}" n - "%% GroupName = atom()" n - "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n - "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n - "%% TestCase = atom()" n - "%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}" n - "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n - "%% repeat_until_any_ok | repeat_until_any_fail" n - "%% N = integer() | forever" n - (erlang-skel-separator 2) - "groups() ->" n > - "[]." n n - - (erlang-skel-separator 2) - "%% Function: all() -> GroupsAndTestCases | {skip,Reason}" n - "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n - "%% GroupName = atom()" n - "%% TestCase = atom()" n - "%% Reason = term()" n - (erlang-skel-separator 2) - "all() -> " n > - "[my_test_case]." n n - - (erlang-skel-separator 2) - "%% Function: TestCase() -> Info" n - "%% Info = [tuple()]" n - (erlang-skel-separator 2) - "my_test_case() -> " n > - "[]." n n - - (erlang-skel-separator 2) - "%% Function: TestCase(Config0) ->" n - "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n - "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - "%% Comment = term()" n - (erlang-skel-separator 2) - "my_test_case(_Config) -> " n > - "ok." n - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") diff --git a/elpa/erlang-20161007.57/erlang-skels.el b/elpa/erlang-20161007.57/erlang-skels.el deleted file mode 100644 index 0284c9d..0000000 --- a/elpa/erlang-20161007.57/erlang-skels.el +++ /dev/null @@ -1,1926 +0,0 @@ -;; -;; %CopyrightBegin% -;; -;; Copyright Ericsson AB 2010-2016. All Rights Reserved. -;; -;; Licensed under the Apache License, Version 2.0 (the "License"); -;; you may not use this file except in compliance with the License. -;; You may obtain a copy of the License at -;; -;; http://www.apache.org/licenses/LICENSE-2.0 -;; -;; Unless required by applicable law or agreed to in writing, software -;; distributed under the License is distributed on an "AS IS" BASIS, -;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -;; See the License for the specific language governing permissions and -;; limitations under the License. -;; -;; %CopyrightEnd% -;;; -;;; Purpose: Provide Erlang code skeletons. -;;; See 'erlang-skel-file' variable. - -(defvar erlang-tempo-tags nil - "Tempo tags for erlang mode") - -(defvar erlang-skel - '(("If" "if" erlang-skel-if) - ("Case" "case" erlang-skel-case) - ("Receive" "receive" erlang-skel-receive) - ("Receive After" "after" erlang-skel-receive-after) - ("Receive Loop" "loop" erlang-skel-receive-loop) - ("Module" "module" erlang-skel-module) - ("Author" "author" erlang-skel-author) - ("Function" "function" erlang-skel-function) - ("Spec" "spec" erlang-skel-spec) - () - ("Small Header" "small-header" - erlang-skel-small-header erlang-skel-header) - ("Normal Header" "normal-header" - erlang-skel-normal-header erlang-skel-header) - ("Large Header" "large-header" - erlang-skel-large-header erlang-skel-header) - () - ("Small Server" "small-server" - erlang-skel-small-server erlang-skel-header) - () - ("Application" "application" - erlang-skel-application erlang-skel-header) - ("Supervisor" "supervisor" - erlang-skel-supervisor erlang-skel-header) - ("supervisor_bridge" "supervisor-bridge" - erlang-skel-supervisor-bridge erlang-skel-header) - ("gen_server" "generic-server" - erlang-skel-generic-server erlang-skel-header) - ("gen_event" "gen-event" - erlang-skel-gen-event erlang-skel-header) - ("gen_fsm" "gen-fsm" - erlang-skel-gen-fsm erlang-skel-header) - ("gen_statem (StateName/3)" "gen-statem-StateName" - erlang-skel-gen-statem-StateName erlang-skel-header) - ("gen_statem (handle_event/4)" "gen-statem-handle-event" - erlang-skel-gen-statem-handle-event erlang-skel-header) - ("wx_object" "wx-object" - erlang-skel-wx-object erlang-skel-header) - ("Library module" "gen-lib" - erlang-skel-lib erlang-skel-header) - ("Corba callback" "gen-corba-cb" - erlang-skel-corba-callback erlang-skel-header) - ("Small Common Test suite" "ct-test-suite-s" - erlang-skel-ct-test-suite-s erlang-skel-header) - ("Large Common Test suite" "ct-test-suite-l" - erlang-skel-ct-test-suite-l erlang-skel-header) - ("Erlang TS test suite" "ts-test-suite" - erlang-skel-ts-test-suite erlang-skel-header) - ) - "*Description of all skeleton templates. -Both functions and menu entries will be created. - -Each entry in `erlang-skel' should be a list with three or four -elements, or the empty list. - -The first element is the name which shows up in the menu. The second -is the `tempo' identifier (The string \"erlang-\" will be added in -front of it). The third is the skeleton descriptor, a variable -containing `tempo' attributes as described in the function -`tempo-define-template'. The optional fourth elements denotes a -function which should be called when the menu is selected. - -Functions corresponding to every template will be created. The name -of the function will be `tempo-template-erlang-X' where `X' is the -tempo identifier as specified in the second argument of the elements -in this list. - -A list with zero elements means that the a horizontal line should -be placed in the menu.") - -(defvar erlang-skel-use-separators t - "A boolean than determines whether the skeletons include horizontal -separators. - -Should this variable be nil, the documentation for functions will not -include separators of the form %%--...") - -;; In XEmacs `user-mail-address' returns "x@y.z (Foo Bar)" ARGH! -;; What's wrong with that? RFC 822 says it's legal. [sverkerw] -;; This needs to use the customized value. If that's not sane, things like -;; add-log will lose anyhow. Avoid it if there _is_ a paren. -(defvar erlang-skel-mail-address - (if (or (not user-mail-address) (string-match "(" user-mail-address)) - (concat (user-login-name) "@" - (or (and (boundp 'mail-host-address) - mail-host-address) - (system-name))) - user-mail-address) - "Mail address of the user.") - -;; Expression templates: -(defvar erlang-skel-case - '((erlang-skel-skip-blank) o > - "case " p " of" n> p "_ ->" n> p "ok" n "end" > p) - "*The skeleton of a `case' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-if - '((erlang-skel-skip-blank) o > - "if" n> p " ->" n> p "ok" n "end" > p) - "The skeleton of an `if' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive - '((erlang-skel-skip-blank) o > - "receive" n> p "_ ->" n> p "ok" n "end" > p) - "*The skeleton of a `receive' expression. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive-after - '((erlang-skel-skip-blank) o > - "receive" n> p "_ ->" n> p "ok" n "after " > p "T ->" n> - p "ok" n "end" > p) - "*The skeleton of a `receive' expression with an `after' clause. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-receive-loop - '(& o "loop(" p ") ->" n> "receive" n> p "_ ->" n> - "loop(" p ")" n "end." >) - "*The skeleton of a simple `receive' loop. -Please see the function `tempo-define-template'.") - - -(defvar erlang-skel-function - '((erlang-skel-separator-start 2) - "%% @doc" n - "%% @spec" n - (erlang-skel-separator-end 2)) - "*The template of a function skeleton. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-spec - '("-spec " (erlang-skel-get-function-name) "(" (erlang-skel-get-function-args) ") -> undefined.") - "*The template of a -spec for the function following point. -Please see the function `tempo-define-template'.") - -;; Attribute templates - -(defvar erlang-skel-module - '(& "-module(" - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) - ")." n) - "*The skeleton of a `module' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-author - '(& "-author('" erlang-skel-mail-address "')." n) - "*The skeleton of a `author' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-vc nil - "*The skeleton template to generate a version control attribute. -The default is to insert nothing. Example of usage: - - (setq erlang-skel-vc '(& \"-rcs(\\\"$\Id: $ \\\").\") n) - -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-export - '(& "-export([" n> "])." n) - "*The skeleton of an `export' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-import - '(& "%%-import(Module, [Function/Arity, ...])." n) - "*The skeleton of an `import' attribute. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-compile nil - ;; '(& "%%-compile(export_all)." n) - "*The skeleton of a `compile' attribute. -Please see the function `tempo-define-template'.") - - -;; Comment templates. - -(defvar erlang-skel-date-function 'erlang-skel-dd-mmm-yyyy - "*Function which returns date string. -Look in the module `time-stamp' for a battery of functions.") - -(defvar erlang-skel-copyright-comment - (if (boundp '*copyright-organization*) - '(& "%%% @copyright (C) " (format-time-string "%Y") ", " - *copyright-organization* n) - '(& "%%% @copyright (C) " (format-time-string "%Y") ", " - (user-full-name) n)) - "*The template for a copyright line in the header, normally empty. -This variable should be bound to a `tempo' template, for example: - '(& \"%%% Copyright (C) 2000, Yoyodyne, Inc.\" n) -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-created-comment - '(& "%%% Created : " (funcall erlang-skel-date-function) " by " - (user-full-name) " <" erlang-skel-mail-address ">" n) - "*The template for the \"Created:\" comment line.") - -(defvar erlang-skel-author-comment - '(& "%%% @author " (user-full-name) " <" erlang-skel-mail-address ">" n) - "*The template for creating the \"Author:\" line in the header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-small-header - '(o (erlang-skel-include erlang-skel-module) - n - (erlang-skel-include erlang-skel-compile erlang-skel-vc)) - "*The template of a small header without any comments. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-normal-header - '(o (erlang-skel-include erlang-skel-author-comment) - (erlang-skel-include erlang-skel-copyright-comment) - "%%% @doc" n - "%%%" p n - "%%% @end" n - (erlang-skel-include erlang-skel-created-comment) n - (erlang-skel-include erlang-skel-small-header) n) - "*The template of a normal header. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-large-header - '(o (erlang-skel-separator) - (erlang-skel-include erlang-skel-author-comment) - (erlang-skel-include erlang-skel-copyright-comment) - "%%% @doc" n - "%%%" p n - "%%% @end" n - (erlang-skel-include erlang-skel-created-comment) - (erlang-skel-separator) - (erlang-skel-include erlang-skel-small-header) ) - "*The template of a large header. -Please see the function `tempo-define-template'.") - - - ;; Server templates. -(defvar erlang-skel-small-server - '((erlang-skel-include erlang-skel-large-header) - "-export([start/0, init/1])." n n n - "start() ->" n> "spawn(" (erlang-get-module-from-file-name) - ", init, [self()])." n n - "init(From) ->" n> - "loop(From)." n n - "loop(From) ->" n> - "receive" n> - p "_ ->" n> - "loop(From)" n - "end." > n - ) - "*Template of a small server. -Please see the function `tempo-define-template'.") - -;; Behaviour templates. -(defvar erlang-skel-application - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(application)." n n - "%% Application callbacks" n - "-export([start/2, stop/1])." n n - (erlang-skel-double-separator-start 3) - "%%% Application callbacks" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called whenever an application is started using" n - "%% application:start/[1,2], and should start the processes of the" n - "%% application. If the application is structured according to the OTP" n - "%% design principles as a supervision tree, this means starting the" n - "%% top supervisor of the tree." n - "%%" n - "%% @spec start(StartType, StartArgs) -> {ok, Pid} |" n - "%% {ok, Pid, State} |" n - "%% {error, Reason}" n - "%% StartType = normal | {takeover, Node} | {failover, Node}" n - "%% StartArgs = term()" n - (erlang-skel-separator-end 2) - "start(_StartType, _StartArgs) ->" n> - "case 'TopSupervisor':start_link() of" n> - "{ok, Pid} ->" n> - "{ok, Pid};" n> - "Error ->" n> - "Error" n - "end." > n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called whenever an application has stopped. It" n - "%% is intended to be the opposite of Module:start/2 and should do" n - "%% any necessary cleaning up. The return value is ignored." n - "%%" n - "%% @spec stop(State) -> void()" n - (erlang-skel-separator-end 2) - "stop(_State) ->" n> - "ok." n - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of an application behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-supervisor - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(supervisor)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% Supervisor callbacks" n - "-export([init/1])." n n - - "-define(SERVER, ?MODULE)." n n - - (erlang-skel-double-separator-start 3) - "%%% API functions" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Starts the supervisor" n - "%%" n - "%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}" n - (erlang-skel-separator-end 2) - "start_link() ->" n> - "supervisor:start_link({local, ?SERVER}, ?MODULE, [])." n - n - (erlang-skel-double-separator-start 3) - "%%% Supervisor callbacks" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Whenever a supervisor is started using supervisor:start_link/[2,3]," n - "%% this function is called by the new process to find out about" n - "%% restart strategy, maximum restart intensity, and child" n - "%% specifications." n - "%%" n - "%% @spec init(Args) -> {ok, {SupFlags, [ChildSpec]}} |" n - "%% ignore |" n - "%% {error, Reason}" n - (erlang-skel-separator-end 2) - "init([]) ->" n - "" n> - "SupFlags = #{strategy => one_for_one," n> - "intensity => 1," n> - "period => 5}," n - "" n> - "AChild = #{id => 'AName'," n> - "start => {'AModule', start_link, []}," n> - "restart => permanent," n> - "shutdown => 5000," n> - "type => worker," n> - "modules => ['AModule']}," n - "" n> - "{ok, {SupFlags, [AChild]}}." n - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of a supervisor behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-supervisor-bridge - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(supervisor_bridge)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% supervisor_bridge callbacks" n - "-export([init/1, terminate/2])." n n - - "-define(SERVER, ?MODULE)." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator-start 3) - "%%% API" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Starts the supervisor bridge" n - "%%" n - "%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}" n - (erlang-skel-separator-end 2) - "start_link() ->" n> - "supervisor_bridge:start_link({local, ?SERVER}, ?MODULE, [])." n - n - (erlang-skel-double-separator-start 3) - "%%% supervisor_bridge callbacks" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Creates a supervisor_bridge process, linked to the calling process," n - "%% which calls Module:init/1 to start the subsystem. To ensure a" n - "%% synchronized start-up procedure, this function does not return" n - "%% until Module:init/1 has returned." n - "%%" n - "%% @spec init(Args) -> {ok, Pid, State} |" n - "%% ignore |" n - "%% {error, Reason}" n - (erlang-skel-separator-end 2) - "init([]) ->" n> - "case 'AModule':start_link() of" n> - "{ok, Pid} ->" n> - "{ok, Pid, #state{}};" n> - "Error ->" n> - "Error" n - "end." > n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called by the supervisor_bridge when it is about" n - "%% to terminate. It should be the opposite of Module:init/1 and stop" n - "%% the subsystem and do any necessary cleaning up.The return value is" n - "%% ignored." n - "%%" n - "%% @spec terminate(Reason, State) -> void()" n - (erlang-skel-separator-end 2) - "terminate(Reason, State) ->" n> - "'AModule':stop()," n> - "ok." n - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of a supervisor_bridge behaviour. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-generic-server - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_server)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% gen_server callbacks" n - "-export([init/1, handle_call/3, handle_cast/2, " - "handle_info/2," n> - "terminate/2, code_change/3])." n n - - "-define(SERVER, ?MODULE)." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator-start 3) - "%%% API" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Starts the server" n - "%%" n - "%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}" n - (erlang-skel-separator-end 2) - "start_link() ->" n> - "gen_server:start_link({local, ?SERVER}, ?MODULE, [], [])." n - n - (erlang-skel-double-separator-start 3) - "%%% gen_server callbacks" n - (erlang-skel-double-separator-end 3) - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Initializes the server" n - "%%" n - "%% @spec init(Args) -> {ok, State} |" n - "%% {ok, State, Timeout} |" n - "%% ignore |" n - "%% {stop, Reason}" n - (erlang-skel-separator-end 2) - "init([]) ->" n> - "process_flag(trap_exit, true)," n> - "{ok, #state{}}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Handling call messages" n - "%%" n - "%% @spec handle_call(Request, From, State) ->" n - "%% {reply, Reply, State} |" n - "%% {reply, Reply, State, Timeout} |" n - "%% {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, Reply, State} |" n - "%% {stop, Reason, State}" n - (erlang-skel-separator-end 2) - "handle_call(_Request, _From, State) ->" n> - "Reply = ok," n> - "{reply, Reply, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Handling cast messages" n - "%%" n - "%% @spec handle_cast(Msg, State) -> {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State}" n - (erlang-skel-separator-end 2) - "handle_cast(_Msg, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Handling all non call/cast messages" n - "%%" n - "%% @spec handle_info(Info, State) -> {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State}" n - (erlang-skel-separator-end 2) - "handle_info(_Info, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called by a gen_server when it is about to" n - "%% terminate. It should be the opposite of Module:init/1 and do any" n - "%% necessary cleaning up. When it returns, the gen_server terminates" n - "%% with Reason. The return value is ignored." n - "%%" n - "%% @spec terminate(Reason, State) -> void()" n - (erlang-skel-separator-end 2) - "terminate(_Reason, _State) ->" n> - "ok." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Convert process state when code is changed" n - "%%" n - "%% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}" n - (erlang-skel-separator-end 2) - "code_change(_OldVsn, State, _Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of a generic server. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-gen-event - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_event)." n n - - "%% API" n - "-export([start_link/0, add_handler/0])." n n - - "%% gen_event callbacks" n - "-export([init/1, handle_event/2, handle_call/2, " n> - "handle_info/2, terminate/2, code_change/3])." n n - - "-define(SERVER, ?MODULE)." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator-start 3) - "%%% API" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Creates an event manager" n - "%%" n - "%% @spec start_link() -> {ok, Pid} | {error, Error}" n - (erlang-skel-separator-end 2) - "start_link() ->" n> - "gen_event:start_link({local, ?SERVER})." n - n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Adds an event handler" n - "%%" n - "%% @spec add_handler() -> ok | {'EXIT', Reason} | term()" n - (erlang-skel-separator-end 2) - "add_handler() ->" n> - "gen_event:add_handler(?SERVER, ?MODULE, [])." n - n - (erlang-skel-double-separator-start 3) - "%%% gen_event callbacks" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Whenever a new event handler is added to an event manager," n - "%% this function is called to initialize the event handler." n - "%%" n - "%% @spec init(Args) -> {ok, State}" n - (erlang-skel-separator-end 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Whenever an event manager receives an event sent using" n - "%% gen_event:notify/2 or gen_event:sync_notify/2, this function is" n - "%% called for each installed event handler to handle the event." n - "%%" n - "%% @spec handle_event(Event, State) ->" n - "%% {ok, State} |" n - "%% {swap_handler, Args1, State1, Mod2, Args2} |"n - "%% remove_handler" n - (erlang-skel-separator-end 2) - "handle_event(_Event, State) ->" n> - "{ok, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Whenever an event manager receives a request sent using" n - "%% gen_event:call/3,4, this function is called for the specified" n - "%% event handler to handle the request." n - "%%" n - "%% @spec handle_call(Request, State) ->" n - "%% {ok, Reply, State} |" n - "%% {swap_handler, Reply, Args1, State1, Mod2, Args2} |" n - "%% {remove_handler, Reply}" n - (erlang-skel-separator-end 2) - "handle_call(_Request, State) ->" n> - "Reply = ok," n> - "{ok, Reply, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called for each installed event handler when" n - "%% an event manager receives any other message than an event or a" n - "%% synchronous request (or a system message)." n - "%%" n - "%% @spec handle_info(Info, State) ->" n - "%% {ok, State} |" n - "%% {swap_handler, Args1, State1, Mod2, Args2} |" n - "%% remove_handler" n - (erlang-skel-separator-end 2) - "handle_info(_Info, State) ->" n> - "{ok, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Whenever an event handler is deleted from an event manager, this" n - "%% function is called. It should be the opposite of Module:init/1 and" n - "%% do any necessary cleaning up." n - "%%" n - "%% @spec terminate(Reason, State) -> void()" n - (erlang-skel-separator-end 2) - "terminate(_Reason, _State) ->" n> - "ok." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Convert process state when code is changed" n - "%%" n - "%% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}" n - (erlang-skel-separator-end 2) - "code_change(_OldVsn, State, _Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of a gen_event. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-gen-fsm - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_fsm)." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% gen_fsm callbacks" n - "-export([init/1, state_name/2, state_name/3, handle_event/3," n> - "handle_sync_event/4, handle_info/3, terminate/3, code_change/4])." n n - - "-define(SERVER, ?MODULE)." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator-start 3) - "%%% API" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Creates a gen_fsm process which calls Module:init/1 to" n - "%% initialize. To ensure a synchronized start-up procedure, this" n - "%% function does not return until Module:init/1 has returned." n - "%%" n - "%% @spec start_link() -> {ok, Pid} | ignore | {error, Error}" n - (erlang-skel-separator-end 2) - "start_link() ->" n> - "gen_fsm:start_link({local, ?SERVER}, ?MODULE, [], [])." n - n - (erlang-skel-double-separator-start 3) - "%%% gen_fsm callbacks" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Whenever a gen_fsm is started using gen_fsm:start/[3,4] or" n - "%% gen_fsm:start_link/[3,4], this function is called by the new" n - "%% process to initialize." n - "%%" n - "%% @spec init(Args) -> {ok, StateName, State} |" n - "%% {ok, StateName, State, Timeout} |" n - "%% ignore |" n - "%% {stop, StopReason}" n - (erlang-skel-separator-end 2) - "init([]) ->" n> - "process_flag(trap_exit, true)," n> - "{ok, state_name, #state{}}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% There should be one instance of this function for each possible" n - "%% state name. Whenever a gen_fsm receives an event sent using" n - "%% gen_fsm:send_event/2, the instance of this function with the same" n - "%% name as the current state name StateName is called to handle" n - "%% the event. It is also called if a timeout occurs." n - "%%" n - "%% @spec state_name(Event, State) ->" n - "%% {next_state, NextStateName, NextState} |" n - "%% {next_state, NextStateName, NextState, Timeout} |" n - "%% {stop, Reason, NewState}" n - (erlang-skel-separator-end 2) - "state_name(_Event, State) ->" n> - "{next_state, state_name, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% There should be one instance of this function for each possible" n - "%% state name. Whenever a gen_fsm receives an event sent using" n - "%% gen_fsm:sync_send_event/[2,3], the instance of this function with" n - "%% the same name as the current state name StateName is called to" n - "%% handle the event." n - "%%" n - "%% @spec state_name(Event, From, State) ->" n - "%% {next_state, NextStateName, NextState} |"n - "%% {next_state, NextStateName, NextState, Timeout} |" n - "%% {reply, Reply, NextStateName, NextState} |" n - "%% {reply, Reply, NextStateName, NextState, Timeout} |" n - "%% {stop, Reason, NewState} |" n - "%% {stop, Reason, Reply, NewState}" n - (erlang-skel-separator-end 2) - "state_name(_Event, _From, State) ->" n> - "Reply = ok," n> - "{reply, Reply, state_name, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Whenever a gen_fsm receives an event sent using" n - "%% gen_fsm:send_all_state_event/2, this function is called to handle" n - "%% the event." n - "%%" n - "%% @spec handle_event(Event, StateName, State) ->" n - "%% {next_state, NextStateName, NextState} |" n - "%% {next_state, NextStateName, NextState, Timeout} |" n - "%% {stop, Reason, NewState}" n - (erlang-skel-separator-end 2) - "handle_event(_Event, StateName, State) ->" n> - "{next_state, StateName, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Whenever a gen_fsm receives an event sent using" n - "%% gen_fsm:sync_send_all_state_event/[2,3], this function is called" n - "%% to handle the event." n - "%%" n - "%% @spec handle_sync_event(Event, From, StateName, State) ->" n - "%% {next_state, NextStateName, NextState} |" n - "%% {next_state, NextStateName, NextState, Timeout} |" n - "%% {reply, Reply, NextStateName, NextState} |" n - "%% {reply, Reply, NextStateName, NextState, Timeout} |" n - "%% {stop, Reason, NewState} |" n - "%% {stop, Reason, Reply, NewState}" n - (erlang-skel-separator-end 2) - "handle_sync_event(_Event, _From, StateName, State) ->" n> - "Reply = ok," n> - "{reply, Reply, StateName, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called by a gen_fsm when it receives any" n - "%% message other than a synchronous or asynchronous event" n - "%% (or a system message)." n - "%%" n - "%% @spec handle_info(Info,StateName,State)->" n - "%% {next_state, NextStateName, NextState} |" n - "%% {next_state, NextStateName, NextState, Timeout} |" n - "%% {stop, Reason, NewState}" n - (erlang-skel-separator-end 2) - "handle_info(_Info, StateName, State) ->" n> - "{next_state, StateName, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called by a gen_fsm when it is about to" n - "%% terminate. It should be the opposite of Module:init/1 and do any" n - "%% necessary cleaning up. When it returns, the gen_fsm terminates with" n - "%% Reason. The return value is ignored." n - "%%" n - "%% @spec terminate(Reason, StateName, State) -> void()" n - (erlang-skel-separator-end 2) - "terminate(_Reason, _StateName, _State) ->" n> - "ok." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Convert process state when code is changed" n - "%%" n - "%% @spec code_change(OldVsn, StateName, State, Extra) ->" n - "%% {ok, StateName, NewState}" n - (erlang-skel-separator-end 2) - "code_change(_OldVsn, StateName, State, _Extra) ->" n> - "{ok, StateName, State}." n - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of a gen_fsm. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-gen-statem-StateName - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_statem)." n n - - "%% API" n - "-export([start_link/0])." n - n - "%% gen_statem callbacks" n - "-export([callback_mode/0, init/1, terminate/3, code_change/4])." n - "-export([state_name/3])." n - n - "-define(SERVER, ?MODULE)." n - n - "-record(data, {})." n - n - (erlang-skel-double-separator-start 3) - "%%% API" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Creates a gen_statem process which calls Module:init/1 to" n - "%% initialize. To ensure a synchronized start-up procedure, this" n - "%% function does not return until Module:init/1 has returned." n - "%%" n - (erlang-skel-separator-end 2) - "-spec start_link() ->" n> - "{ok, Pid :: pid()} |" n> - "ignore |" n> - "{error, Error :: term()}." n - "start_link() ->" n> - "gen_statem:start_link({local, ?SERVER}, ?MODULE, [], [])." n - n - (erlang-skel-double-separator-start 3) - "%%% gen_statem callbacks" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Define the callback_mode() for this callback module." n - (erlang-skel-separator-end 2) - "-spec callback_mode() -> gen_statem:callback_mode()." n - "callback_mode() -> state_functions." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Whenever a gen_statem is started using gen_statem:start/[3,4] or" n - "%% gen_statem:start_link/[3,4], this function is called by the new" n - "%% process to initialize." n - (erlang-skel-separator-end 2) - "-spec init(Args :: term()) ->" n> - "{ok, State :: term(), Data :: term()} |" n> - "{ok, State :: term(), Data :: term()," n> - "[gen_statem:action()] | gen_statem:action()} |" n> - "ignore |" n> - "{stop, Reason :: term()}." n - "init([]) ->" n> - "process_flag(trap_exit, true)," n> - "{ok, state_name, #data{}}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% There should be one function like this for each state name." n - "%% Whenever a gen_statem receives an event, the function " n - "%% with the name of the current state (StateName) " n - "%% is called to handle the event." n - "%%" n - "%% NOTE: If there is an exported function handle_event/4, it is called" n - "%% instead of StateName/3 functions like this!" n - (erlang-skel-separator-end 2) - "-spec state_name(" n> - "gen_statem:event_type(), Msg :: term()," n> - "Data :: term()) ->" n> - "gen_statem:state_function_result()." n - "state_name({call,Caller}, _Msg, Data) ->" n> - "{next_state, state_name, Data, [{reply,Caller,ok}]}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called by a gen_statem when it is about to" n - "%% terminate. It should be the opposite of Module:init/1 and do any" n - "%% necessary cleaning up. When it returns, the gen_statem terminates with" n - "%% Reason. The return value is ignored." n - (erlang-skel-separator-end 2) - "-spec terminate(Reason :: term(), State :: term(), Data :: term()) ->" n> - "any()." n - "terminate(_Reason, _State, _Data) ->" n> - "void." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Convert process state when code is changed" n - (erlang-skel-separator-end 2) - "-spec code_change(" n> - "OldVsn :: term() | {down,term()}," n> - "State :: term(), Data :: term(), Extra :: term()) ->" n> - "{ok, NewState :: term(), NewData :: term()} |" n> - "(Reason :: term())." n - "code_change(_OldVsn, State, Data, _Extra) ->" n> - "{ok, State, Data}." n - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of a gen_statem (StateName/3). -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-gen-statem-handle-event - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_statem)." n n - - "%% API" n - "-export([start_link/0])." n - n - "%% gen_statem callbacks" n - "-export([callback_mode/0, init/1, terminate/3, code_change/4])." n - "-export([handle_event/4])." n - n - "-define(SERVER, ?MODULE)." n - n - "-record(data, {})." n - n - (erlang-skel-double-separator-start 3) - "%%% API" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Creates a gen_statem process which calls Module:init/1 to" n - "%% initialize. To ensure a synchronized start-up procedure, this" n - "%% function does not return until Module:init/1 has returned." n - "%%" n - (erlang-skel-separator-end 2) - "-spec start_link() ->" n> - "{ok, Pid :: pid()} |" n> - "ignore |" n> - "{error, Error :: term()}." n - "start_link() ->" n> - "gen_statem:start_link({local, ?SERVER}, ?MODULE, [], [])." n - n - (erlang-skel-double-separator-start 3) - "%%% gen_statem callbacks" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Define the callback_mode() for this callback module." n - (erlang-skel-separator-end 2) - "-spec callback_mode() -> gen_statem:callback_mode()." n - "callback_mode() -> handle_event_function." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Whenever a gen_statem is started using gen_statem:start/[3,4] or" n - "%% gen_statem:start_link/[3,4], this function is called by the new" n - "%% process to initialize." n - (erlang-skel-separator-end 2) - "-spec init(Args :: term()) ->" n> - "{ok, State :: term(), Data :: term()} |" n> - "{ok, State :: term(), Data :: term()," n> - "[gen_statem:action()] | gen_statem:action()} |" n> - "ignore |" n> - "{stop, Reason :: term()}." n - "init([]) ->" n> - "process_flag(trap_exit, true)," n> - "{ok, state_name, #data{}}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called for every event a gen_statem receives." n - "%%" n - "%% NOTE: If there is no exported function handle_event/4," n - "%% StateName/3 functions are called instead!" n - (erlang-skel-separator-end 2) - "-spec handle_event(" n> - "gen_statem:event_type(), Msg :: term()," n> - "State :: term(), Data :: term()) ->" n> - "gen_statem:handle_event_result()." n - "handle_event({call,From}, _Msg, State, Data) ->" n> - "{next_state, State, Data, [{reply,From,ok}]}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called by a gen_statem when it is about to" n - "%% terminate. It should be the opposite of Module:init/1 and do any" n - "%% necessary cleaning up. When it returns, the gen_statem terminates with" n - "%% Reason. The return value is ignored." n - (erlang-skel-separator-end 2) - "-spec terminate(Reason :: term(), State :: term(), Data :: term()) ->" n> - "any()." n - "terminate(_Reason, _State, _Data) ->" n> - "void." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Convert process state when code is changed" n - (erlang-skel-separator-end 2) - "-spec code_change(" n> - "OldVsn :: term() | {down,term()}," n> - "State :: term(), Data :: term(), Extra :: term()) ->" n> - "{ok, NewState :: term(), NewData :: term()} |" n> - "(Reason :: term())." n - "code_change(_OldVsn, State, Data, _Extra) ->" n> - "{ok, State, Data}." n - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of a gen_statem (handle_event/4). -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-wx-object - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(wx_object)." n n - - "-include_lib(\"wx/include/wx.hrl\")." n n - - "%% API" n - "-export([start_link/0])." n n - - "%% wx_object callbacks" n - "-export([init/1, handle_call/3, handle_cast/2, " - "handle_info/2," n> - "handle_event/2, terminate/2, code_change/3])." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator-start 3) - "%%% API" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Starts the server" n - "%%" n - "%% @spec start_link() -> wxWindow()" n - (erlang-skel-separator-end 2) - "start_link() ->" n> - "wx_object:start_link(?MODULE, [], [])." n - n - (erlang-skel-double-separator-start 3) - "%%% wx_object callbacks" n - (erlang-skel-double-separator-end 3) - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Initializes the server" n - "%%" n - "%% @spec init(Args) -> {wxWindow(), State} |" n - "%% {wxWindow(), State, Timeout} |" n - "%% ignore |" n - "%% {stop, Reason}" n - (erlang-skel-separator-end 2) - "init([]) ->" n> - "wx:new()," n> - "Frame = wxFrame:new()," n> - "{Frame, #state{}}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Handling events" n - "%%" n - "%% @spec handle_event(wx{}, State) ->" n - "%% {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State}" n - (erlang-skel-separator-end 2) - "handle_event(#wx{}, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Handling call messages" n - "%%" n - "%% @spec handle_call(Request, From, State) ->" n - "%% {reply, Reply, State} |" n - "%% {reply, Reply, State, Timeout} |" n - "%% {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, Reply, State} |" n - "%% {stop, Reason, State}" n - (erlang-skel-separator-end 2) - "handle_call(_Request, _From, State) ->" n> - "Reply = ok," n> - "{reply, Reply, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Handling cast messages" n - "%%" n - "%% @spec handle_cast(Msg, State) -> {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State}" n - (erlang-skel-separator-end 2) - "handle_cast(_Msg, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Handling all non call/cast messages" n - "%%" n - "%% @spec handle_info(Info, State) -> {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State}" n - (erlang-skel-separator-end 2) - "handle_info(_Info, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% This function is called by a wx_object when it is about to" n - "%% terminate. It should be the opposite of Module:init/1 and do any" n - "%% necessary cleaning up. When it returns, the wx_object terminates" n - "%% with Reason. The return value is ignored." n - "%%" n - "%% @spec terminate(Reason, State) -> void()" n - (erlang-skel-separator-end 2) - "terminate(_Reason, _State) ->" n> - "ok." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Convert process state when code is changed" n - "%%" n - "%% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}" n - (erlang-skel-separator-end 2) - "code_change(_OldVsn, State, _Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of a generic server. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-lib - '((erlang-skel-include erlang-skel-large-header) - - "%% API" n - "-export([])." n n - - (erlang-skel-double-separator-start 3) - "%%% API" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% @spec" n - (erlang-skel-separator-end 2) - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-corba-callback - '((erlang-skel-include erlang-skel-large-header) - "%% Include files" n n - - "%% API" n - "-export([])." n n - - "%% Corba callbacks" n - "-export([init/1, terminate/2, code_change/3])." n n - - "-record(state, {})." n n - - (erlang-skel-double-separator-start 3) - "%%% Corba callbacks" n - (erlang-skel-double-separator-end 3) n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Initializes the server" n - "%%" n - "%% @spec init(Args) -> {ok, State} |" n - "%% {ok, State, Timeout} |" n - "%% ignore |" n - "%% {stop, Reason}" n - (erlang-skel-separator-end 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Shutdown the server" n - "%%" n - "%% @spec terminate(Reason, State) -> void()" n - (erlang-skel-separator-end 2) - "terminate(_Reason, _State) ->" n> - "ok." n - n - (erlang-skel-separator-start 2) - "%% @private" n - "%% @doc" n - "%% Convert process state when code is changed" n - "%%" n - "%% @spec code_change(OldVsn, State, Extra) -> {ok, NewState}" n - (erlang-skel-separator-end 2) - "code_change(_OldVsn, State, _Extra) ->" n> - "{ok, State}." n - n - (erlang-skel-double-separator-start 3) - "%%% Internal functions" n - (erlang-skel-double-separator-end 3) - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-ts-test-suite - '((erlang-skel-include erlang-skel-large-header) - "%% Note: This directive should only be used in test suites." n - "-compile(export_all)." n n - - "-include_lib(\"common_test/include/ct.hrl\")." n n - - (erlang-skel-separator-start 2) - "%% TEST SERVER CALLBACK FUNCTIONS" n - (erlang-skel-separator 2) - n - (erlang-skel-separator-start 2) - "%%" n - "%% @doc" n - "%% Initialization before the suite." n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the suite." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - "%%" n - "%% @spec init_per_suite(Config) -> Config" n - (erlang-skel-separator-end 2) - "init_per_suite(Config) ->" n > - "Config." n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Cleanup after the suite." n - "%% Config - [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%%" n - "%% @spec end_per_suite(Config) -> _" n - (erlang-skel-separator-end 2) - "end_per_suite(_Config) ->" n > - "ok." n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Initialization before each test case" n - "%%" n - "%% TestCase - atom()" n - "%% Name of the test case that is about to be run." n - "%% Config - [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - "%%" n - "%% @spec init_per_testcase(TestCase, Config) -> Config" n - (erlang-skel-separator-end 2) - "init_per_testcase(_TestCase, Config) ->" n > - "Config." n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Cleanup after each test case" n - "%%" n - "%% TestCase = atom()" n - "%% Name of the test case that is finished." n - "%% Config = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%%" n - "%% @spec end_per_testcase(TestCase, Config) -> _" n - (erlang-skel-separator-end 2) - "end_per_testcase(_TestCase, _Config) ->" n > - "ok."n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Returns a description of the test suite when" n - "%% Clause == doc, and a test specification (list" n - "%% of the conf and test cases in the suite) when" n - "%% Clause == suite." n - "%% Returns a list of all test cases in this test suite" n - "%%" n - "%% Clause = doc | suite" n - "%% Indicates expected return value." n - "%% Descr = [string()] | []" n - "%% String that describes the test suite." n - "%% Spec = [TestCase]" n - "%% A test specification." n - "%% TestCase = ConfCase | atom()" n - "%% Configuration case, or the name of a test case function." n - "%% ConfCase = {conf,Init,Spec,End} |" n - "%% {conf,Properties,Init,Spec,End}" n - "%% Init = End = {Mod,Func} | Func" n - "%% Initialization and cleanup function." n - "%% Mod = Func = atom()" n - "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n - "%% Execution properties of the test cases (may be combined)." n - "%% Shuffle = shuffle | {shuffle,Seed}" n - "%% To get cases executed in random order." n - "%% Seed = {integer(),integer(),integer()}" n - "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n - "%% repeat_until_any_ok | repeat_until_any_fail" n - "%% To get execution of cases repeated." n - "%% N = integer() | forever" n - "%% Reason = term()" n - "%% The reason for skipping the test suite." n - "%%" n - "%% @spec all(Clause) -> TestCases" n - (erlang-skel-separator-end 2) - "all(doc) ->" n > - "[\"Describe the main purpose of this suite\"];" n n - "all(suite) -> " n > - "[a_test_case]." n n - n - (erlang-skel-separator-start 2) - "%% TEST CASES" n - (erlang-skel-separator 2) - n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Test case function. Returns a description of the test" n - "%% case (doc), then returns a test specification (suite)," n - "%% or performs the actual test (Config)." n - "%%" n - "%% Arg = doc | suite | Config" n - "%% Indicates expected behaviour and return value." n - "%% Config = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Descr = [string()] | []" n - "%% String that describes the test case." n - "%% Spec = [tuple()] | []" n - "%% A test specification, see all/1." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%%" n - "%% @spec TestCase(Arg) -> Descr | Spec | ok | exit() | {skip,Reason}" n - - (erlang-skel-separator-end 2) - "a_test_case(doc) -> " n > - "[\"Describe the main purpose of this test case\"];" n n - "a_test_case(suite) -> " n > - "[];" n n - "a_test_case(Config) when is_list(Config) -> " n > - "ok." n - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - -(defvar erlang-skel-ct-test-suite-s - '((erlang-skel-include erlang-skel-large-header) - "-compile(export_all)." n n - - "-include_lib(\"common_test/include/ct.hrl\")." n n - - (erlang-skel-separator-start 2) - "%% @spec suite() -> Info" n - "%% Info = [tuple()]" n - (erlang-skel-separator-end 2) - "suite() ->" n > - "[{timetrap,{seconds,30}}]." n n - - (erlang-skel-separator-start 2) - "%% @spec init_per_suite(Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator-end 2) - "init_per_suite(Config) ->" n > - "Config." n n - - (erlang-skel-separator-start 2) - "%% @spec end_per_suite(Config0) -> term() | {save_config,Config1}" n - "%% Config0 = Config1 = [tuple()]" n - (erlang-skel-separator-end 2) - "end_per_suite(_Config) ->" n > - "ok." n n - - (erlang-skel-separator-start 2) - "%% @spec init_per_group(GroupName, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%% GroupName = atom()" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator-end 2) - "init_per_group(_GroupName, Config) ->" n > - "Config." n n - - (erlang-skel-separator-start 2) - "%% @spec end_per_group(GroupName, Config0) ->" n - "%% term() | {save_config,Config1}" n - "%% GroupName = atom()" n - "%% Config0 = Config1 = [tuple()]" n - (erlang-skel-separator-end 2) - "end_per_group(_GroupName, _Config) ->" n > - "ok." n n - - (erlang-skel-separator-start 2) - "%% @spec init_per_testcase(TestCase, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - "%% TestCase = atom()" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator-end 2) - "init_per_testcase(_TestCase, Config) ->" n > - "Config." n n - - (erlang-skel-separator-start 2) - "%% @spec end_per_testcase(TestCase, Config0) ->" n - "%% term() | {save_config,Config1} | {fail,Reason}" n - "%% TestCase = atom()" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - (erlang-skel-separator-end 2) - "end_per_testcase(_TestCase, _Config) ->" n > - "ok." n n - - (erlang-skel-separator-start 2) - "%% @spec groups() -> [Group]" n - "%% Group = {GroupName,Properties,GroupsAndTestCases}" n - "%% GroupName = atom()" n - "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n - "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n - "%% TestCase = atom()" n - "%% Shuffle = shuffle | {shuffle,{integer(),integer(),integer()}}" n - "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n - "%% repeat_until_any_ok | repeat_until_any_fail" n - "%% N = integer() | forever" n - (erlang-skel-separator-end 2) - "groups() ->" n > - "[]." n n - - (erlang-skel-separator-start 2) - "%% @spec all() -> GroupsAndTestCases | {skip,Reason}" n - "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n - "%% GroupName = atom()" n - "%% TestCase = atom()" n - "%% Reason = term()" n - (erlang-skel-separator-end 2) - "all() -> " n > - "[my_test_case]." n n - - (erlang-skel-separator-start 2) - "%% @spec TestCase() -> Info" n - "%% Info = [tuple()]" n - (erlang-skel-separator-end 2) - "my_test_case() -> " n > - "[]." n n - - (erlang-skel-separator-start 2) - "%% @spec TestCase(Config0) ->" n - "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n - "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n - "%% Config0 = Config1 = [tuple()]" n - "%% Reason = term()" n - "%% Comment = term()" n - (erlang-skel-separator-end 2) - "my_test_case(_Config) -> " n > - "ok." n - ) - "*The template of a library module. -Please see the function `tempo-define-template'.") - - -(defvar erlang-skel-ct-test-suite-l - '((erlang-skel-include erlang-skel-large-header) - "%% Note: This directive should only be used in test suites." n - "-compile(export_all)." n n - - "-include_lib(\"common_test/include/ct.hrl\")." n n - - (erlang-skel-separator-start 2) - "%% COMMON TEST CALLBACK FUNCTIONS" n - (erlang-skel-separator 2) - n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Returns list of tuples to set default properties" n - "%% for the suite." n - "%%" n - "%% Function: suite() -> Info" n - "%%" n - "%% Info = [tuple()]" n - "%% List of key/value pairs." n - "%%" n - "%% Note: The suite/0 function is only meant to be used to return" n - "%% default data values, not perform any other operations." n - "%%" n - "%% @spec suite() -> Info" n - (erlang-skel-separator-end 2) - "suite() ->" n > - "[{timetrap,{minutes,10}}]." n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Initialization before the whole suite" n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the suite." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - "%%" n - "%% @spec init_per_suite(Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - (erlang-skel-separator-end 2) - "init_per_suite(Config) ->" n > - "Config." n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Cleanup after the whole suite" n - "%%" n - "%% Config - [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%%" n - "%% @spec end_per_suite(Config) -> _" n - (erlang-skel-separator-end 2) - "end_per_suite(_Config) ->" n > - "ok." n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Initialization before each test case group." n - "%%" n - "%% GroupName = atom()" n - "%% Name of the test case group that is about to run." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding configuration data for the group." n - "%% Reason = term()" n - "%% The reason for skipping all test cases and subgroups in the group." n - "%%" n - "%% @spec init_per_group(GroupName, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - (erlang-skel-separator-end 2) - "init_per_group(_GroupName, Config) ->" n > - "Config." n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Cleanup after each test case group." n - "%%" n - "%% GroupName = atom()" n - "%% Name of the test case group that is finished." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding configuration data for the group." n - "%%" n - "%% @spec end_per_group(GroupName, Config0) ->" n - "%% term() | {save_config,Config1}" n - (erlang-skel-separator-end 2) - "end_per_group(_GroupName, _Config) ->" n > - "ok." n n - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Initialization before each test case" n - "%%" n - "%% TestCase - atom()" n - "%% Name of the test case that is about to be run." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%%" n - "%% Note: This function is free to add any key/value pairs to the Config" n - "%% variable, but should NOT alter/remove any existing entries." n - "%%" n - "%% @spec init_per_testcase(TestCase, Config0) ->" n - "%% Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}" n - (erlang-skel-separator-end 2) - "init_per_testcase(_TestCase, Config) ->" n > - "Config." n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Cleanup after each test case" n - "%%" n - "%% TestCase - atom()" n - "%% Name of the test case that is finished." n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%%" n - "%% @spec end_per_testcase(TestCase, Config0) ->" n - "%% term() | {save_config,Config1} | {fail,Reason}" n - (erlang-skel-separator-end 2) - "end_per_testcase(_TestCase, _Config) ->" n > - "ok." n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Returns a list of test case group definitions." n - "%%" n - "%% Group = {GroupName,Properties,GroupsAndTestCases}" n - "%% GroupName = atom()" n - "%% The name of the group." n - "%% Properties = [parallel | sequence | Shuffle | {RepeatType,N}]" n - "%% Group properties that may be combined." n - "%% GroupsAndTestCases = [Group | {group,GroupName} | TestCase]" n - "%% TestCase = atom()" n - "%% The name of a test case." n - "%% Shuffle = shuffle | {shuffle,Seed}" n - "%% To get cases executed in random order." n - "%% Seed = {integer(),integer(),integer()}" n - "%% RepeatType = repeat | repeat_until_all_ok | repeat_until_all_fail |" n - "%% repeat_until_any_ok | repeat_until_any_fail" n - "%% To get execution of cases repeated." n - "%% N = integer() | forever" n - "%%" n - "%% @spec: groups() -> [Group]" n - (erlang-skel-separator-end 2) - "groups() ->" n > - "[]." n n - - (erlang-skel-separator-start 2) - "%% @doc" n - "%% Returns the list of groups and test cases that" n - "%% are to be executed." n - "%%" n - "%% GroupsAndTestCases = [{group,GroupName} | TestCase]" n - "%% GroupName = atom()" n - "%% Name of a test case group." n - "%% TestCase = atom()" n - "%% Name of a test case." n - "%% Reason = term()" n - "%% The reason for skipping all groups and test cases." n - "%%" n - "%% @spec all() -> GroupsAndTestCases | {skip,Reason}" n - (erlang-skel-separator-end 2) - "all() -> " n > - "[my_test_case]." n n - - n - (erlang-skel-separator-start 2) - "%% TEST CASES" n - (erlang-skel-separator 2) - n - - (erlang-skel-separator-start 2) - "%% @doc " n - "%% Test case info function - returns list of tuples to set" n - "%% properties for the test case." n - "%%" n - "%% Info = [tuple()]" n - "%% List of key/value pairs." n - "%%" n - "%% Note: This function is only meant to be used to return a list of" n - "%% values, not perform any other operations." n - "%%" n - "%% @spec TestCase() -> Info " n - (erlang-skel-separator-end 2) - "my_test_case() -> " n > - "[]." n n - - (erlang-skel-separator 2) - "%% @doc Test case function. (The name of it must be specified in" n - "%% the all/0 list or in a test case group for the test case" n - "%% to be executed)." n - "%%" n - "%% Config0 = Config1 = [tuple()]" n - "%% A list of key/value pairs, holding the test case configuration." n - "%% Reason = term()" n - "%% The reason for skipping the test case." n - "%% Comment = term()" n - "%% A comment about the test case that will be printed in the html log." n - "%%" n - "%% @spec TestCase(Config0) ->" n - "%% ok | exit() | {skip,Reason} | {comment,Comment} |" n - "%% {save_config,Config1} | {skip_and_save,Reason,Config1}" n - (erlang-skel-separator-end 2) - "my_test_case(_Config) -> " n > - "ok." n - - ) - "*The template of a library module. - Please see the function `tempo-define-template'.") - -;; Skeleton code: - -;; This code is based on the package `tempo' which is part of modern -;; Emacsen. (GNU Emacs 19.25 (?) and XEmacs 19.14.) - -(defun erlang-skel-init () - "Generate the skeleton functions and menu items. -The variable `erlang-skel' contains the name and descriptions of -all skeletons. - -The skeleton routines are based on the `tempo' package. Should this -package not be present, this function does nothing." - (interactive) - (condition-case nil - (require 'tempo) - (error t)) - (if (featurep 'tempo) - (let ((skel erlang-skel) - (menu '())) - (while skel - (cond ((null (car skel)) - (setq menu (cons nil menu))) - (t - (funcall (symbol-function 'tempo-define-template) - (concat "erlang-" (nth 1 (car skel))) - ;; The tempo template used contains an `include' - ;; function call only, hence changes to the - ;; variables describing the templates take effect - ;; immdiately. - (list (list 'erlang-skel-include (nth 2 (car skel)))) - (nth 1 (car skel))) - (setq menu (cons (erlang-skel-make-menu-item - (car skel)) menu)))) - (setq skel (cdr skel))) - (setq erlang-menu-skel-items - (list nil (list "Skeletons" (nreverse menu)))) - (setq erlang-menu-items - (erlang-menu-add-above 'erlang-menu-skel-items - 'erlang-menu-version-items - erlang-menu-items)) - (erlang-menu-init)))) - -(defun erlang-skel-make-menu-item (skel) - (let ((func (intern (concat "tempo-template-erlang-" (nth 1 skel))))) - (cond ((null (nth 3 skel)) - (list (car skel) func)) - (t - (list (car skel) - (list 'lambda '() - '(interactive) - (list 'funcall - (list 'quote (nth 3 skel)) - (list 'quote func)))))))) - -;; Functions designed to be added to the skeleton menu. -;; (Not normally used) -(defun erlang-skel-insert (func) - "Insert skeleton generated by FUNC and goto first tempo mark." - (save-excursion (funcall func)) - (funcall (symbol-function 'tempo-forward-mark))) - -(defun erlang-skel-header (func) - "Insert the header generated by FUNC at the beginning of the buffer." - (goto-char (point-min)) - (save-excursion (funcall func)) - (funcall (symbol-function 'tempo-forward-mark))) - - -;; Functions used inside the skeleton descriptions. -(defun erlang-skel-skip-blank () - (skip-chars-backward " \t") - nil) - -(defun erlang-skel-include (&rest args) - "Include a template inside another template. - -Example of use, assuming that `erlang-skel-func' is defined: - - (defvar foo-skeleton '(\"%%% New function:\" - (erlang-skel-include erlang-skel-func))) - -Technically, this function returns the `tempo' attribute`(l ...)' which -can contain other `tempo' attributes. Please see the function -`tempo-define-template' for a description of the `(l ...)' attribute." - (let ((res '()) - entry) - (while args - (setq entry (car args)) - (while entry - (setq res (cons (car entry) res)) - (setq entry (cdr entry))) - (setq args (cdr args))) - (cons 'l (nreverse res)))) - -(defun erlang-skel-separator (&optional percent) - "Return a comment separator." - (let ((percent (or percent 3))) - (concat (make-string percent ?%) - (make-string (- 70 percent) ?-) - "\n"))) - -(defun erlang-skel-separator-start (&optional percent) - "Return a comment separator or an empty string if separators -are configured off." - (if erlang-skel-use-separators - (erlang-skel-separator percent) - "")) - -(defun erlang-skel-separator-end (&optional percent) - "Return a comment separator to end a function comment block or an -empty string if separators are configured off." - (if erlang-skel-use-separators - (concat "%% @end\n" (erlang-skel-separator percent)) - "")) - -(defun erlang-skel-double-separator (&optional percent) - "Return a double line (equals sign) comment separator." - (let ((percent (or percent 3))) - (concat (make-string percent ?%) - (make-string (- 70 percent) ?=) - "\n"))) - -(defun erlang-skel-double-separator-start (&optional percent) - "Return a double separator or a newline if separators are configured off." - (if erlang-skel-use-separators - (erlang-skel-double-separator percent) - "\n")) - -(defun erlang-skel-double-separator-end (&optional percent) - "Return a double separator or an empty string if separators are -configured off." - (if erlang-skel-use-separators - (erlang-skel-double-separator percent) - "")) - -(defun erlang-skel-dd-mmm-yyyy () - "Return the current date as a string in \"DD Mon YYYY\" form. -The first character of DD is space if the value is less than 10." - (let ((date (current-time-string))) - (format "%2d %s %s" - (string-to-int (substring date 8 10)) - (substring date 4 7) - (substring date -4)))) - -(defun erlang-skel-get-function-name () - (save-excursion - (erlang-beginning-of-function -1) - (erlang-get-function-name))) - -(defun erlang-skel-get-function-args () - (save-excursion - (erlang-beginning-of-function -1) - (erlang-get-function-arguments))) - -;; Local variables: -;; coding: iso-8859-1 -;; End: - -;;; erlang-skels.el ends here diff --git a/elpa/erlang-20161007.57/erlang-start.el b/elpa/erlang-20161007.57/erlang-start.el deleted file mode 100644 index f9a6d24..0000000 --- a/elpa/erlang-20161007.57/erlang-start.el +++ /dev/null @@ -1,125 +0,0 @@ -;; erlang-start.el --- Load this file to initialize the Erlang package. - -;; Copyright (C) 1998 Ericsson Telecom AB - -;; Author: Anders Lindgren -;; Version: 2.3 -;; Keywords: erlang, languages, processes -;; Created: 1996-09-18 -;; Date: 1998-03-16 - -;;; Commentary: - -;; Introduction: -;; ------------ -;; -;; This package provides support for the programming language Erlang. -;; The package provides an editing mode with lots of bells and -;; whistles, compilation support, and it makes it possible for the -;; user to start Erlang shells that run inside Emacs. -;; -;; See the Erlang distribution for full documentation of this package. - -;; Installation: -;; ------------ -;; -;; Place this file in Emacs load path, byte-compile it, and add the -;; following line to the appropriate init file: -;; -;; (require 'erlang-start) -;; -;; The full documentation contains much more extensive description of -;; the installation procedure. - -;; Reporting Bugs: -;; -------------- -;; -;; Please send bug reports to the following email address: -;; support@erlang.ericsson.se -;; -;; Please state as exactly as possible: -;; - Version number of Erlang Mode (see the menu), Emacs, Erlang, -;; and of any other relevant software. -;; - What the expected result was. -;; - What you did, preferably in a repeatable step-by-step form. -;; - A description of the unexpected result. -;; - Relevant pieces of Erlang code causing the problem. -;; - Personal Emacs customisations, if any. -;; -;; Should the Emacs generate an error, please set the emacs variable -;; `debug-on-error' to `t'. Repeat the error and enclose the debug -;; information in your bug-report. -;; -;; To set the variable you can use the following command: -;; M-x set-variable RET debug-on-error RET t RET - -;;; Code: - -;; -;; Declare functions in "erlang.el". -;; - -(autoload 'erlang-mode "erlang" "Major mode for editing Erlang code." t) -(autoload 'erlang-version "erlang" - "Return the current version of Erlang mode." t) -(autoload 'erlang-shell "erlang" "Start a new Erlang shell." t) -(autoload 'run-erlang "erlang" "Start a new Erlang shell." t) - -(autoload 'erlang-compile "erlang" - "Compile Erlang module in current buffer." t) - -(autoload 'erlang-man-module "erlang" - "Find manual page for MODULE." t) -(autoload 'erlang-man-function "erlang" - "Find manual page for NAME, where NAME is module:function." t) - -(autoload 'erlang-find-tag "erlang" - "Like `find-tag'. Capable of retreiving Erlang modules.") -(autoload 'erlang-find-tag-other-window "erlang" - "Like `find-tag-other-window'. Capable of retreiving Erlang modules.") - -(autoload 'erlang-edoc-mode "erlang-edoc" "Toggle Erlang-Edoc mode on or off." t) - -;; -;; Associate files extensions ".erl" and ".hrl" with Erlang mode. -;; - -;;;###autoload -(let ((a '("\\.erl\\'" . erlang-mode)) - (b '("\\.hrl\\'" . erlang-mode))) - (or (assoc (car a) auto-mode-alist) - (setq auto-mode-alist (cons a auto-mode-alist))) - (or (assoc (car b) auto-mode-alist) - (setq auto-mode-alist (cons b auto-mode-alist)))) - -;; -;; Associate files using interpreter "escript" with Erlang mode. -;; - -;;;###autoload -(add-to-list 'interpreter-mode-alist (cons "escript" 'erlang-mode)) - -;; -;; Ignore files ending in ".jam", ".vee", and ".beam" when performing -;; file completion. -;; - -;;;###autoload -(let ((erl-ext '(".jam" ".vee" ".beam"))) - (while erl-ext - (let ((cie completion-ignored-extensions)) - (while (and cie (not (string-equal (car cie) (car erl-ext)))) - (setq cie (cdr cie))) - (if (null cie) - (setq completion-ignored-extensions - (cons (car erl-ext) completion-ignored-extensions)))) - (setq erl-ext (cdr erl-ext)))) - - -;; -;; The end. -;; - -(provide 'erlang-start) - -;; erlang-start.el ends here. diff --git a/elpa/erlang-20161007.57/erlang-test.el b/elpa/erlang-20161007.57/erlang-test.el deleted file mode 100644 index ba6190d..0000000 --- a/elpa/erlang-20161007.57/erlang-test.el +++ /dev/null @@ -1,184 +0,0 @@ -;;; erlang-test.el -*- lexical-binding: t; coding: utf-8-unix -*- - -;;; Unit tests for erlang.el. - -;; Author: Johan Claesson -;; Created: 2016-05-07 -;; Keywords: erlang, languages - -;; %CopyrightBegin% -;; -;; Copyright Ericsson AB 2016. All Rights Reserved. -;; -;; Licensed under the Apache License, Version 2.0 (the "License"); -;; you may not use this file except in compliance with the License. -;; You may obtain a copy of the License at -;; -;; http://www.apache.org/licenses/LICENSE-2.0 -;; -;; Unless required by applicable law or agreed to in writing, software -;; distributed under the License is distributed on an "AS IS" BASIS, -;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -;; See the License for the specific language governing permissions and -;; limitations under the License. -;; -;; %CopyrightEnd% - - -;;; Commentary: - -;; This library require GNU Emacs 25 or later. - -;;; Code: - -(require 'ert) -(require 'cl-lib) -(require 'erlang) - -(defvar erlang-test-code - '((nil . "-module(erlang_test).") - (nil . "-import(lists, [map/2]).") - (nil . "-compile(export_all).") - ("SYMBOL" . "-define(SYMBOL, value).") - ("MACRO" . "-define(MACRO(X), X + X).") - ("struct" . "-record(struct, {until,maps,are,everywhere}).") - ("function". "function() -> #struct{}.")) - "Alist of erlang test code. -Each entry have the format (TAGNAME . ERLANG_CODE). If TAGNAME -is nil there is no definitions in the ERLANG_CODE. The -ERLANG_CODE is a single line of erlang code. These lines will be -concatenated to form an erlang file to test on.") - - -(ert-deftest erlang-test-tags () - (let* ((dir (make-temp-file "erlang-test" t)) - (erlang-file (expand-file-name "erlang_test.erl" dir)) - (tags-file (expand-file-name "TAGS" dir)) - (old-tags-file-name (default-value 'tags-file-name)) - (old-tags-table-list (default-value 'tags-table-list)) - tags-file-name - tags-table-list - tags-table-set-list - erlang-buffer - erlang-mode-hook - prog-mode-hook - erlang-shell-mode-hook - tags-add-tables) - (unwind-protect - (progn - (setq-default tags-file-name nil) - (setq-default tags-table-list nil) - (erlang-test-create-erlang-file erlang-file) - (erlang-test-compile-tags erlang-file tags-file) - (setq erlang-buffer (find-file-noselect erlang-file)) - (with-current-buffer erlang-buffer - (setq-local tags-file-name tags-file)) - ;; Setting global tags-file-name is a workaround for - ;; GNU Emacs bug#23164. - (setq tags-file-name tags-file) - (erlang-test-complete-at-point tags-file) - (erlang-test-completion-table) - (erlang-test-xref-find-definitions erlang-file erlang-buffer)) - (when (buffer-live-p erlang-buffer) - (kill-buffer erlang-buffer)) - (let ((tags-buffer (find-buffer-visiting tags-file))) - (when (buffer-live-p tags-buffer) - (kill-buffer tags-buffer))) - (when (file-exists-p dir) - (delete-directory dir t)) - (setq-default tags-file-name old-tags-file-name) - (setq-default tags-table-list old-tags-table-list)))) - -(defun erlang-test-create-erlang-file (erlang-file) - (with-temp-file erlang-file - (cl-loop for (_ . code) in erlang-test-code - do (insert code "\n")))) - -(defun erlang-test-compile-tags (erlang-file tags-file) - (should (zerop (call-process "etags" nil nil nil - "-o" tags-file - erlang-file)))) - -(defun erlang-test-completion-table () - (let ((erlang-replace-etags-tags-completion-table t)) - (setq tags-completion-table nil) - (tags-completion-table)) - (should (equal (sort tags-completion-table #'string-lessp) - (sort (erlang-expected-completion-table) #'string-lessp)))) - -(defun erlang-expected-completion-table () - (append (cl-loop for (symbol . _) in erlang-test-code - when (stringp symbol) - append (list symbol (concat "erlang_test:" symbol))) - (list "erlang_test:" "erlang_test:module_info"))) - -(defun erlang-test-xref-find-definitions (erlang-file erlang-buffer) - (cl-loop for (tagname . code) in erlang-test-code - for line = 1 then (1+ line) - do (when tagname - (switch-to-buffer erlang-buffer) - (xref-find-definitions tagname) - (erlang-test-verify-pos erlang-file line) - (xref-find-definitions (concat "erlang_test:" tagname)) - (erlang-test-verify-pos erlang-file line))) - (xref-find-definitions "erlang_test:") - (erlang-test-verify-pos erlang-file 1)) - -(defun erlang-test-verify-pos (expected-file expected-line) - (should (string-equal (file-truename expected-file) - (file-truename (buffer-file-name)))) - (should (eq expected-line (line-number-at-pos))) - (should (= (point-at-bol) (point)))) - -(defun erlang-test-complete-at-point (tags-file) - (with-temp-buffer - (erlang-mode) - (setq-local tags-file-name tags-file) - (insert "\nerlang_test:fun") - (erlang-complete-tag) - (should (looking-back "erlang_test:function")) - (insert "\nfun") - (erlang-complete-tag) - (should (looking-back "function")) - (insert "\nerlang_") - (erlang-complete-tag) - (should (looking-back "erlang_test:")))) - - -(ert-deftest erlang-test-compile-options () - (erlang-test-format-opt t - "t") - (erlang-test-format-opt nil - "nil") - (erlang-test-format-opt (cons 1 2) - "{1, 2}") - (erlang-test-format-opt (list 1) - "[1]") - (erlang-test-format-opt (list 1 2) - "[1, 2]") - (erlang-test-format-opt (list 1 2 3) - "[1, 2, 3]") - (erlang-test-format-opt 'symbol - "symbol") - (erlang-test-format-opt "string" - "\"string\"") - (erlang-test-format-opt [] - "{}") - (erlang-test-format-opt [1] - "{1}") - (erlang-test-format-opt [1 2] - "{1, 2}") - (erlang-test-format-opt [1 2 (3 [4 5 6] 7)] - "{1, 2, [3, {4, 5, 6}, 7]}")) - -(defun erlang-test-format-opt (elisp &optional expected-erlang) - (let ((erlang (inferior-erlang-format-opt elisp))) - (message "%s -> %s" elisp erlang) - (when expected-erlang - (should (equal erlang expected-erlang))) - erlang)) - - -(provide 'erlang-test) - -;;; erlang-test.el ends here diff --git a/elpa/erlang-20161007.57/erlang.el b/elpa/erlang-20161007.57/erlang.el deleted file mode 100644 index 67e88ba..0000000 --- a/elpa/erlang-20161007.57/erlang.el +++ /dev/null @@ -1,5941 +0,0 @@ -;;; erlang.el --- Major modes for editing and running Erlang - -;; Copyright (C) 2004 Free Software Foundation, Inc. -;; Author: Anders Lindgren -;; Keywords: erlang, languages, processes -;; Date: 2011-12-11 - -;; %CopyrightBegin% -;; -;; Copyright Ericsson AB 1996-2016. All Rights Reserved. -;; -;; Licensed under the Apache License, Version 2.0 (the "License"); -;; you may not use this file except in compliance with the License. -;; You may obtain a copy of the License at -;; -;; http://www.apache.org/licenses/LICENSE-2.0 -;; -;; Unless required by applicable law or agreed to in writing, software -;; distributed under the License is distributed on an "AS IS" BASIS, -;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -;; See the License for the specific language governing permissions and -;; limitations under the License. -;; -;; %CopyrightEnd% -;; - -;; Lars Thorsén's modifications of 2000-06-07 included. -;; The original version of this package was written by Robert Virding. -;; -;;; Commentary: - -;; Introduction: -;; ------------ -;; -;; This package provides support for the programming language Erlang. -;; The package provides an editing mode with lots of bells and -;; whistles, compilation support, and it makes it possible for the -;; user to start Erlang shells that run inside Emacs. -;; -;; See the Erlang distribution for full documentation of this package. - -;; Installation: -;; ------------ -;; -;; Place this file in Emacs load path, byte-compile it, and add the -;; following line to the appropriate init file: -;; -;; (require 'erlang-start) -;; -;; The full documentation contains much more extensive description of -;; the installation procedure. - -;; Reporting Bugs: -;; -------------- -;; -;; Please send bug reports to the following email address: -;; erlang-bugs@erlang.org -;; or if you have a patch suggestion to: -;; erlang-patches@erlang.org -;; Please state as exactly as possible: -;; - Version number of Erlang Mode (see the menu), Emacs, Erlang, -;; and of any other relevant software. -;; - What the expected result was. -;; - What you did, preferably in a repeatable step-by-step form. -;; - A description of the unexpected result. -;; - Relevant pieces of Erlang code causing the problem. -;; - Personal Emacs customisations, if any. -;; -;; Should the Emacs generate an error, please set the Emacs variable -;; `debug-on-error' to `t'. Repeat the error and enclose the debug -;; information in your bug-report. -;; -;; To toggle the variable you can use the following command: -;; M-x toggle-debug-on-error RET -;;; Code: - -(eval-when-compile (require 'cl)) - -;; Variables: - -(defgroup erlang nil - "The Erlang programming language." - :group 'languages) - -(defconst erlang-version "2.7" - "The version number of Erlang mode.") - -(defvar erlang-root-dir nil - "The directory where the Erlang system is installed. -The name should not contain the trailing slash. - -Should this variable be nil, no manual pages will show up in the -Erlang mode menu.") - -(eval-and-compile - (defconst erlang-emacs-major-version - (if (boundp 'emacs-major-version) - emacs-major-version - (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version) - (erlang-string-to-int (substring emacs-version - (match-beginning 1) (match-end 1)))) - "Major version number of Emacs.")) - -(eval-and-compile - (defconst erlang-emacs-minor-version - (if (boundp 'emacs-minor-version) - emacs-minor-version - (string-match "\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version) - (erlang-string-to-int (substring emacs-version - (match-beginning 2) (match-end 2)))) - "Minor version number of Emacs.")) - -(defconst erlang-xemacs-p (string-match "Lucid\\|XEmacs" emacs-version) - "Non-nil when running under XEmacs or Lucid Emacs.") - -(defvar erlang-xemacs-popup-menu '("Erlang Mode Commands" . nil) - "Common popup menu for all buffers in Erlang mode. - -This variable is destructively modified every time the Erlang menu -is modified. The effect is that all changes take effect in all -buffers in Erlang mode, just like under GNU Emacs. - -Never EVER set this variable!") - -(defvar erlang-menu-items '(erlang-menu-base-items - erlang-menu-skel-items - erlang-menu-shell-items - erlang-menu-compile-items - erlang-menu-man-items - erlang-menu-personal-items - erlang-menu-version-items) - "*List of menu item list to combine to create Erlang mode menu. - -External programs which temporarily add menu items to the Erlang mode -menu may use this variable. Please use the function `add-hook' to add -items. - -Please call the function `erlang-menu-init' after every change to this -variable.") - -(defvar erlang-menu-base-items - '(("Indent" - (("Indent Line" erlang-indent-command) - ("Indent Region " erlang-indent-region - (if erlang-xemacs-p (mark) mark-active)) - ("Indent Clause" erlang-indent-clause) - ("Indent Function" erlang-indent-function) - ("Indent Buffer" erlang-indent-current-buffer))) - ("Edit" - (("Fill Comment" erlang-fill-paragraph) - ("Comment Region" comment-region - (if erlang-xemacs-p (mark) mark-active)) - ("Uncomment Region" erlang-uncomment-region - (if erlang-xemacs-p (mark) mark-active)) - nil - ("Beginning of Function" erlang-beginning-of-function) - ("End of Function" erlang-end-of-function) - ("Mark Function" erlang-mark-function) - nil - ("Beginning of Clause" erlang-beginning-of-clause) - ("End of Clause" erlang-end-of-clause) - ("Mark Clause" erlang-mark-clause) - nil - ("New Clause" erlang-generate-new-clause) - ("Clone Arguments" erlang-clone-arguments) - nil - ("Align Arrows" erlang-align-arrows))) - ("Syntax Highlighting" - (("Level 4" erlang-font-lock-level-4) - ("Level 3" erlang-font-lock-level-3) - ("Level 2" erlang-font-lock-level-2) - ("Level 1" erlang-font-lock-level-1) - ("Off" erlang-font-lock-level-0))) - ("TAGS" - (("Find Tag" find-tag) - ("Find Next Tag" erlang-find-next-tag) - ;("Find Regexp" find-tag-regexp) - ("Complete Word" erlang-complete-tag) - ("Tags Apropos" tags-apropos) - ("Search Files" tags-search)))) - "Description of menu used in Erlang mode. - -This variable must be a list. The elements are either nil representing -a horizontal line or a list with two or three elements. The first is -the name of the menu item, the second is the function to call, or a -submenu, on the same same form as ITEMS. The third optional argument -is an expression which is evaluated every time the menu is displayed. -Should the expression evaluate to nil the menu item is ghosted. - -Example: - '((\"Func1\" function-one) - (\"SubItem\" - ((\"Yellow\" function-yellow) - (\"Blue\" function-blue))) - nil - (\"Region Function\" spook-function midnight-variable)) - -Call the function `erlang-menu-init' after modifying this variable.") - -(defvar erlang-menu-shell-items - '(nil - ("Shell" - (("Start New Shell" erlang-shell) - ("Display Shell" erlang-shell-display)))) - "Description of the Shell menu used by Erlang mode. - -Please see the documentation of `erlang-menu-base-items'.") - -(defvar erlang-menu-compile-items - '(("Compile" - (("Compile Buffer" erlang-compile) - ("Display Result" erlang-compile-display) - ("Next Error" erlang-next-error)))) - "Description of the Compile menu used by Erlang mode. - -Please see the documentation of `erlang-menu-base-items'.") - -(defvar erlang-menu-version-items - '(nil - ("Version" erlang-version)) - "Description of the version menu used in Erlang mode.") - -(defvar erlang-menu-personal-items nil - "Description of personal menu items used in Erlang mode. - -Please see the variable `erlang-menu-base-items' for a description -of the format.") - -(defvar erlang-menu-man-items nil - "The menu containing man pages. - -The format of the menu should be compatible with `erlang-menu-base-items'. -This variable is added to the list of Erlang menus stored in -`erlang-menu-items'.") - -(defvar erlang-menu-skel-items '() - "Description of the menu containing the skeleton entries. -The menu is in the form described by the variable `erlang-menu-base-items'.") - -(defvar erlang-mode-hook nil - "*Functions to run when Erlang mode is activated. - -This hook is used to change the behaviour of Erlang mode. It is -normally used by the user to personalise the programming environment. -When used in a site init file, it could be used to customise Erlang -mode for all users on the system. - -The functions added to this hook are run every time Erlang mode is -started. See also `erlang-load-hook', a hook which is run once, -when Erlang mode is loaded into Emacs, and `erlang-shell-mode-hook' -which is run every time a new inferior Erlang shell is started. - -To use a hook, create an Emacs lisp function to perform your actions -and add the function to the hook by calling `add-hook'. - -The following example binds the key sequence C-c C-c to the command -`erlang-compile' (normally bound to C-c C-k). The example also -activates Font Lock mode to fontify the buffer and adds a menu -containing all functions defined in the current buffer. - -To use the example, copy the following lines to your `~/.emacs' file: - - (add-hook 'erlang-mode-hook 'my-erlang-mode-hook) - - (defun my-erlang-mode-hook () - (local-set-key \"\\C-c\\C-c\" 'erlang-compile) - (if window-system - (progn - (setq font-lock-maximum-decoration t) - (font-lock-mode 1))) - (if (and window-system (fboundp 'imenu-add-to-menubar)) - (imenu-add-to-menubar \"Imenu\")))") - -(defvar erlang-load-hook nil - "*Functions to run when Erlang mode is loaded. - -This hook is used to change the behaviour of Erlang mode. It is -normally used by the user to personalise the programming environment. -When used in a site init file, it could be used to customize Erlang -mode for all users on the system. - -The difference between this hook and `erlang-mode-hook' and -`erlang-shell-mode-hook' is that the functions in this hook -is only called once, when the Erlang mode is loaded into Emacs -the first time. - -Natural actions for the functions added to this hook are actions which -only should be performed once, and actions which should be performed -before starting Erlang mode. For example, a number of variables are -used by Erlang mode before `erlang-mode-hook' is run. - -The following example sets the variable `erlang-root-dir' so that the -manual pages can be retrieved (note that you must set the value of -`erlang-root-dir' to match the location of Erlang on your system): - - (add-hook 'erlang-load-hook 'my-erlang-load-hook) - - (defun my-erlang-load-hook () - (setq erlang-root-dir \"/usr/local/erlang\"))") - -(defvar erlang-new-file-hook nil - "Functions to run when a new Erlang source file is being edited. - -A useful function is `tempo-template-erlang-normal-header'. -\(This function only exists when the `tempo' package is available.)") - -(defvar erlang-check-module-name 'ask - "*Non-nil means check that module name and file name agrees when saving. - -If the value of this variable is the atom `ask', the user is -prompted. If the value is t the source is silently changed.") - -(defvar erlang-electric-commands - '(erlang-electric-comma - erlang-electric-semicolon - erlang-electric-gt) - "*List of activated electric commands. - -The list should contain the electric commands which should be active. -Currently, the available electric commands are: - `erlang-electric-comma' - `erlang-electric-semicolon' - `erlang-electric-gt' - `erlang-electric-newline' - -Should the variable be bound to t, all electric commands -are activated. - -To deactivate all electric commands, set this variable to nil.") - -(defvar erlang-electric-newline-inhibit t - "*Set to non-nil to inhibit newline after electric command. - -This is useful since a lot of people press return after executing an -electric command. - -In order to work, the command must also be in the -list `erlang-electric-newline-inhibit-list'. - -Note that commands in this list are required to set the variable -`erlang-electric-newline-inhibit' to nil when the newline shouldn't be -inhibited.") - -(defvar erlang-electric-newline-inhibit-list - '(erlang-electric-semicolon - erlang-electric-comma - erlang-electric-gt) - "*Commands which can inhibit the next newline.") - -(defvar erlang-electric-semicolon-insert-blank-lines nil - "*Number of blank lines inserted before header, or nil. - -This variable controls the behaviour of `erlang-electric-semicolon' -when a new function header is generated. When nil, no blank line is -inserted between the current line and the new header. When bound to a -number it represents the number of blank lines which should be -inserted.") - -(defvar erlang-electric-semicolon-criteria - '(erlang-next-lines-empty-p - erlang-at-keyword-end-p - erlang-at-end-of-function-p) - "*List of functions controlling `erlang-electric-semicolon'. -The functions in this list are called, in order, whenever a semicolon -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- insert prototype, and stop checking - -If every function in the list is called with no determination made, -then no prototype is inserted. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-electric-comma-criteria - '(erlang-stop-when-inside-argument-list - erlang-stop-when-at-guard - erlang-next-lines-empty-p - erlang-at-keyword-end-p - erlang-at-end-of-clause-p - erlang-at-end-of-function-p) - "*List of functions controlling `erlang-electric-comma'. -The functions in this list are called, in order, whenever a comma -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- insert prototype, and stop checking - -If every function in the list is called with no determination made, -then no prototype is inserted. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-electric-arrow-criteria - '(erlang-stop-when-in-type-spec - erlang-next-lines-empty-p - erlang-at-end-of-function-p) - "*List of functions controlling the arrow aspect of `erlang-electric-gt'. -The functions in this list are called, in order, whenever a `>' -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- insert prototype, and stop checking - -If every function in the list is called with no determination made, -then no prototype is inserted. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-electric-newline-criteria - '(t) - "*List of functions controlling `erlang-electric-newline'. - -The electric newline commands indents the next line. Should the -current line begin with a comment the comment start is copied to -the newly created line. - -The functions in this list are called, in order, whenever a comma -is typed. Each function in the list is called with no arguments, -and should return one of the following values: - - nil -- no determination made, continue checking - 'stop -- do not create prototype for next line - (anything else) -- trigger the electric command. - -If every function in the list is called with no determination made, -then no prototype is inserted. Should the atom t be a member of the -list, it is treated as a function triggering the electric command. - -The test is performed by the function `erlang-test-criteria-list'.") - -(defvar erlang-next-lines-empty-threshold 2 - "*Number of blank lines required to activate an electric command. - -Actually, this value controls the behaviour of the function -`erlang-next-lines-empty-p' which normally is a member of the -criteria lists controlling the electric commands. (Please see -the variables `erlang-electric-semicolon-criteria' and -`erlang-electric-comma-criteria'.) - -The variable is bound to a threshold value, a number, representing the -number of lines which must be empty. - -Setting this variable to zero, electric commands will always be -triggered by `erlang-next-lines-empty-p', unless inhibited by other -rules. - -Should this variable be nil, `erlang-next-lines-empty-p' will never -trigger an electric command. The same effect would be reached if the -function `erlang-next-lines-empty-p' would be removed from the criteria -lists. - -Note that even if `erlang-next-lines-empty-p' should not trigger an -electric command, other functions in the criteria list could.") - -(defvar erlang-new-clause-with-arguments nil - "*Non-nil means that the arguments are cloned when a clause is generated. - -A new function header can be generated by calls to the function -`erlang-generate-new-clause' and by use of the electric semicolon.") - -(defvar erlang-compile-use-outdir t - "*When nil, go to the directory containing source file when compiling. - -This is a workaround for a bug in the `outdir' option of compile. If the -outdir is not in the current load path, Erlang doesn't load the object -module after it has been compiled. - -To activate the workaround, place the following in your `~/.emacs' file: - (setq erlang-compile-use-outdir nil)") - -(defvar erlang-indent-level 4 - "*Indentation of Erlang calls/clauses within blocks.") -(put 'erlang-indent-level 'safe-local-variable 'integerp) - -(defvar erlang-indent-guard 2 - "*Indentation of Erlang guards.") -(put 'erlang-indent-guard 'safe-local-variable 'integerp) - -(defvar erlang-argument-indent 2 - "*Indentation of the first argument in a function call. -When nil, indent to the column after the `(' of the -function.") -(put 'erlang-argument-indent 'safe-local-variable '(lambda (val) (or (null val) (integerp val)))) - -(defvar erlang-tab-always-indent t - "*Non-nil means TAB in Erlang mode should always re-indent the current line, -regardless of where in the line point is when the TAB command is used.") - -(defvar erlang-man-inhibit (eq system-type 'windows-nt) - "Inhibit the creation of the Erlang Manual Pages menu. - -The Windows distribution of Erlang does not include man pages, hence -there is no attempt to create the menu.") - -(defvar erlang-man-dirs - '(("Man - Commands" "/man/man1" t) - ("Man - Modules" "/man/man3" t) - ("Man - Files" "/man/man4" t) - ("Man - Applications" "/man/man6" t)) - "*The man directories displayed in the Erlang menu. - -Each item in the list should be a list with three elements, the first -the name of the menu, the second the directory, and the last a flag. -Should the flag the nil, the directory is absolute, should it be non-nil -the directory is relative to the variable `erlang-root-dir'.") - -(defvar erlang-man-max-menu-size 35 - "*The maximum number of menu items in one menu allowed.") - -(defvar erlang-man-display-function 'erlang-man-display - "*Function used to display man page. - -The function is called with one argument, the name of the file -containing the man page. Use this variable when the default -function, `erlang-man-display', does not work on your system.") - -(defvar erlang-compile-extra-opts '() - "*Additional options to the compilation command. -This is an elisp list of options. Each option can be either: -- an atom -- a dotted pair -- a string -Example: '(bin_opt_info (i . \"/path1/include\") (i . \"/path2/include\"))") - -(defvar erlang-compile-command-function-alist - '((".erl\\'" . inferior-erlang-compute-erl-compile-command) - (".xrl\\'" . inferior-erlang-compute-leex-compile-command) - (".yrl\\'" . inferior-erlang-compute-yecc-compile-command) - ("." . inferior-erlang-compute-erl-compile-command)) - "*Alist of filename patterns vs corresponding compilation functions. -Each element looks like (REGEXP . FUNCTION). Compiling a file whose name -matches REGEXP specifies FUNCTION to use to compute the compilation -command. The FUNCTION will be called with two arguments: module name and -default compilation options, like output directory. The FUNCTION -is expected to return a string.") - -(defvar erlang-leex-compile-opts '() - "*Options to pass to leex when compiling xrl files. -This is an elisp list of options. Each option can be either: -- an atom -- a dotted pair -- a string") - -(defvar erlang-yecc-compile-opts '() - "*Options to pass to yecc when compiling yrl files. -This is an elisp list of options. Each option can be either: -- an atom -- a dotted pair -- a string") - -(eval-and-compile - (defvar erlang-regexp-modern-p - (if (> erlang-emacs-major-version 21) t nil) - "Non-nil when this version of Emacs uses a modern version of regexp. -Supporting \_< and \_> This is determined by checking the version of Emacs used.")) - -(eval-and-compile - (defconst erlang-atom-quoted-regexp - "'\\(?:[^\\']\\|\\(?:\\\\.\\)\\)*'" - "Regexp describing a single-quoted atom")) - -(eval-and-compile - (defconst erlang-atom-regular-regexp - (if erlang-regexp-modern-p - "\\_<[[:lower:]]\\(?:\\sw\\|\\s_\\)*\\_>" - "\\<[[:lower:]]\\(?:\\sw\\|\\s_\\)*\\>") - "Regexp describing a regular (non-quoted) atom")) - -(eval-and-compile - (defconst erlang-atom-regexp - (concat "\\(" erlang-atom-quoted-regexp "\\|" - erlang-atom-regular-regexp "\\)") - "Regexp describing an Erlang atom.")) - -(eval-and-compile - (defconst erlang-atom-regexp-matches 1 - "Number of regexp parenthesis pairs in `erlang-atom-regexp'. - -This is used to determine parenthesis matches in complex regexps which -contains `erlang-atom-regexp'.")) - - -(eval-and-compile - (defconst erlang-variable-regexp - (if erlang-regexp-modern-p - "\\_<\\([[:upper:]_]\\(?:\\sw\\|\\s_\\)*\\)\\_>" - "\\<\\([[:upper:]_]\\(?:\\sw\\|\\s_\\)*\\)\\>") - "Regexp which should match an Erlang variable. - -The regexp must be surrounded with a pair of regexp parentheses.")) - -(eval-and-compile - (defconst erlang-variable-regexp-matches 1 - "Number of regexp parenthesis pairs in `erlang-variable-regexp'. - -This is used to determine matches in complex regexps which contains -`erlang-variable-regexp'.")) - - -(eval-and-compile - (defun erlang-regexp-opt (strings &optional paren) - "Like `regexp-opt', except if PAREN is `symbols', then the -resulting regexp is surrounded by \\_< and \\_>." - (if (eq paren 'symbols) - (if erlang-regexp-modern-p - (concat "\\_<" (regexp-opt strings t) "\\_>") - (concat "\\<" (regexp-opt strings t) "\\>")) - (regexp-opt strings paren)))) - - -(eval-and-compile - (defvar erlang-keywords - '("after" - "begin" - "catch" - "case" - "cond" - "end" - "fun" - "if" - "let" - "of" - "receive" - "try" - "when") - "Erlang reserved keywords")) - -(eval-and-compile - (defconst erlang-keywords-regexp (erlang-regexp-opt erlang-keywords 'symbols))) - -(eval-and-compile - (defvar erlang-operators - '("and" - "andalso" - "band" - "bnot" - "bor" - "bsl" - "bsr" - "bxor" - "div" - "not" - "or" - "orelse" - "rem" - "xor") - "Erlang operators")) -;; What about these? -;; '+' '-' '*' '/' '>', '>=', '<', '=<', '=:=', '==', '=/=', '/=' - -(eval-and-compile - (defconst erlang-operators-regexp (erlang-regexp-opt erlang-operators 'symbols))) - - -(eval-and-compile - (defvar erlang-guards - '("is_atom" - "is_binary" - "is_bitstring" - "is_boolean" - "is_float" - "is_function" - "is_integer" - "is_list" - "is_map" - "is_number" - "is_pid" - "is_port" - "is_record" - "is_reference" - "is_tuple" - "atom" - "binary" - "bitstring" - "boolean" - ;;"float" ; Not included to avoid clashes with the bif float/1 - "function" - "integer" - "list" - "number" - "pid" - "port" - "record" - "reference" - "tuple") - "Erlang guards")) - -(eval-and-compile - (defconst erlang-guards-regexp (erlang-regexp-opt erlang-guards 'symbols))) - -(eval-and-compile - (defvar erlang-predefined-types - '("any" - "arity" - "boolean" - "byte" - "char" - "cons" - "deep_string" - "iodata" - "iolist" - "maybe_improper_list" - "module" - "mfa" - "nil" - "neg_integer" - "none" - "non_neg_integer" - "nonempty_list" - "nonempty_improper_list" - "nonempty_maybe_improper_list" - "nonempty_string" - "no_return" - "pos_integer" - "string" - "term" - "timeout" - "map") - "Erlang type specs types")) - -(eval-and-compile - (defconst erlang-predefined-types-regexp - (erlang-regexp-opt erlang-predefined-types 'symbols))) - - -(eval-and-compile - (defvar erlang-int-bifs - '("abs" - "apply" - "atom_to_binary" - "atom_to_list" - "binary_to_atom" - "binary_to_existing_atom" - "binary_to_float" - "binary_to_integer" - "binary_to_list" - "binary_to_term" - "binary_part" - "bit_size" - "bitsize" - "bitstring_to_list" - "byte_size" - "check_old_code" - "check_process_code" - "date" - "delete_module" - "demonitor" - "disconnect_node" - "element" - "erase" - "error" - "exit" - "float" - "float_to_binary" - "float_to_list" - "garbage_collect" - "get" - "get_keys" - "group_leader" - "halt" - "hd" - "integer_to_list" - "integer_to_binary" - "iolist_size" - "iolist_to_binary" - "is_alive" - "is_atom" - "is_binary" - "is_bitstring" - "is_boolean" - "is_float" - "is_function" - "is_integer" - "is_list" - "is_map" - "is_number" - "is_pid" - "is_port" - "is_process_alive" - "is_record" - "is_reference" - "is_tuple" - "length" - "link" - "list_to_atom" - "list_to_binary" - "list_to_bitstring" - "list_to_existing_atom" - "list_to_float" - "list_to_integer" - "list_to_pid" - "list_to_tuple" - "load_module" - "make_ref" - "map_size" - "max" - "min" - "module_loaded" - "monitor" - "monitor_node" - "node" - "nodes" - "now" - "open_port" - "pid_to_list" - "port_close" - "port_command" - "port_connect" - "port_control" - "pre_loaded" - "process_flag" - "process_info" - "processes" - "purge_module" - "put" - "register" - "registered" - "round" - "self" - "setelement" - "size" - "spawn" - "spawn_link" - "spawn_monitor" - "spawn_opt" - "split_binary" - "statistics" - "term_to_binary" - "time" - "throw" - "tl" - "trunc" - "tuple_size" - "tuple_to_list" - "unlink" - "unregister" - "whereis") - "Erlang built-in functions (BIFs)")) - -(eval-and-compile - (defconst erlang-int-bif-regexp (erlang-regexp-opt erlang-int-bifs 'symbols))) - - -(eval-and-compile - (defvar erlang-ext-bifs - '("adler32" - "adler32_combine" - "alloc_info" - "alloc_sizes" - "append" - "append_element" - "await_proc_exit" - "await_sched_wall_time_modifications" - "bump_reductions" - "call_on_load_function" - "cancel_timer" - "crasher" - "crc32" - "crc32_combine" - "decode_packet" - "delay_trap" - "delete_element" - "dexit" - "dgroup_leader" - "display" - "display_nl" - "display_string" - "dist_exit" - "dlink" - "dmonitor_node" - "dmonitor_p" - "dsend" - "dt_append_vm_tag_data" - "dt_get_tag" - "dt_get_tag_data" - "dt_prepend_vm_tag_data" - "dt_put_tag" - "dt_restore_tag" - "dt_spread_tag" - "dunlink" - "convert_time_unit" - "external_size" - "finish_after_on_load" - "finish_loading" - "format_cpu_topology" - "fun_info" - "fun_info_mfa" - "fun_to_list" - "function_exported" - "garbage_collect_message_area" - "gather_gc_info_result" - "gather_sched_wall_time_result" - "get_cookie" - "get_module_info" - "get_stacktrace" - "hash" - "has_prepared_code_on_load" - "hibernate" - "insert_element" - "is_builtin" - "load_nif" - "loaded" - "localtime" - "localtime_to_universaltime" - "make_fun" - "make_tuple" - "match_spec_test" - "md5" - "md5_final" - "md5_init" - "md5_update" - "memory" - "module_info" - "monitor_node" - "monotonic_time" - "nif_error" - "phash" - "phash2" - "port_call" - "port_get_data" - "port_info" - "port_set_data" - "port_to_list" - "ports" - "posixtime_to_universaltime" - "prepare_loading" - "process_display" - "raise" - "read_timer" - "ref_to_list" - "resume_process" - "send" - "send_after" - "send_nosuspend" - "seq_trace" - "seq_trace_info" - "seq_trace_print" - "set_cookie" - "set_cpu_topology" - "setnode" - "spawn_opt" - "start_timer" - "subtract" - "suspend_process" - "system_flag" - "system_info" - "system_monitor" - "system_profile" - "system_time" - "trace" - "trace_delivered" - "trace_info" - "trace_pattern" - "time_offset" - "timestamp" - "universaltime" - "universaltime_to_localtime" - "universaltime_to_posixtime" - "unique_integer" - "yield") - "Erlang built-in functions (BIFs) that needs erlang: prefix")) - -(eval-and-compile - (defconst erlang-ext-bif-regexp - (erlang-regexp-opt (append erlang-int-bifs erlang-ext-bifs) 'symbols))) - - -(defvar erlang-defun-prompt-regexp (concat "^" erlang-atom-regexp "\\s *(") - "Regexp which should match beginning of a clause.") - -(defvar erlang-file-name-extension-regexp "\\.erl$" - "*Regexp which should match an Erlang file name. - -This regexp is used when an Erlang module name is extracted from the -name of an Erlang source file. - -The regexp should only match the section of the file name which should -be excluded from the module name. - -To match all files set this variable to \"\\\\(\\\\..*\\\\|\\\\)$\". -The matches all except the extension. This is useful if the Erlang -tags system should interpret tags on the form `module:tag' for -files written in other languages than Erlang.") - -(defvar erlang-inferior-shell-split-window t - "*If non-nil, when starting an inferior shell, split windows. -If nil, the inferior shell replaces the window. This is the traditional -behaviour.") - -(defconst inferior-erlang-use-cmm (boundp 'minor-mode-overriding-map-alist) - "Non-nil means use `compilation-minor-mode' in Erlang shell.") - -(defvar erlang-mode-map - (let ((map (make-sparse-keymap))) - (unless (boundp 'indent-line-function) - (define-key map "\t" 'erlang-indent-command)) - (define-key map ";" 'erlang-electric-semicolon) - (define-key map "," 'erlang-electric-comma) - (define-key map "<" 'erlang-electric-lt) - (define-key map ">" 'erlang-electric-gt) - (define-key map "\C-m" 'erlang-electric-newline) - (if (not (boundp 'delete-key-deletes-forward)) - (define-key map "\177" 'backward-delete-char-untabify) - (define-key map [(backspace)] 'backward-delete-char-untabify)) - ;;(unless (boundp 'fill-paragraph-function) - (define-key map "\M-q" 'erlang-fill-paragraph) - (unless (boundp 'beginning-of-defun-function) - (define-key map "\M-\C-a" 'erlang-beginning-of-function) - (define-key map "\M-\C-e" 'erlang-end-of-function) - (define-key map '(meta control h) 'erlang-mark-function)) ; Xemacs - (define-key map "\M-\t" 'erlang-complete-tag) - (define-key map "\C-c\M-\t" 'tempo-complete-tag) - (define-key map "\M-+" 'erlang-find-next-tag) - (define-key map "\C-c\M-a" 'erlang-beginning-of-clause) - (define-key map "\C-c\M-b" 'tempo-backward-mark) - (define-key map "\C-c\M-e" 'erlang-end-of-clause) - (define-key map "\C-c\M-f" 'tempo-forward-mark) - (define-key map "\C-c\M-h" 'erlang-mark-clause) - (define-key map "\C-c\C-c" 'comment-region) - (define-key map "\C-c\C-j" 'erlang-generate-new-clause) - (define-key map "\C-c\C-k" 'erlang-compile) - (define-key map "\C-c\C-l" 'erlang-compile-display) - (define-key map "\C-c\C-s" 'erlang-show-syntactic-information) - (define-key map "\C-c\C-q" 'erlang-indent-function) - (define-key map "\C-c\C-u" 'erlang-uncomment-region) - (define-key map "\C-c\C-y" 'erlang-clone-arguments) - (define-key map "\C-c\C-a" 'erlang-align-arrows) - (define-key map "\C-c\C-z" 'erlang-shell-display) - (unless inferior-erlang-use-cmm - (define-key map "\C-x`" 'erlang-next-error)) - map) - "*Keymap used in Erlang mode.") -(defvar erlang-mode-abbrev-table nil - "Abbrev table in use in Erlang-mode buffers.") -(defvar erlang-mode-syntax-table nil - "Syntax table in use in Erlang-mode buffers.") - - - -(defvar erlang-skel-file "erlang-skels" - "The type of erlang-skeletons that should be used, default - uses edoc type, for the old type, standard comments, - set \"erlang-skels-old\" in your .emacs and restart. - - Or define your own and set the variable to that file.") - -;; Tempo skeleton templates: -(load erlang-skel-file) - -;; Font-lock variables - -;; The next few variables define different Erlang font-lock patterns. -;; They could be appended to form a custom font-lock appearance. -;; -;; The function `erlang-font-lock-set-face' could be used to change -;; the face of a pattern. -;; -;; Note that Erlang strings and atoms are highlighted with using -;; syntactic analysis. - -(defvar erlang-font-lock-keywords-function-header - (list - (list (concat "^" erlang-atom-regexp "\\s-*(") - 1 'font-lock-function-name-face t)) - "Font lock keyword highlighting a function header.") - -(defface erlang-font-lock-exported-function-name-face - (if (featurep 'xemacs) - (progn - (require 'font-lock) - `((t (:foreground ,(face-foreground 'font-lock-function-name-face)) - (:background ,(face-background 'font-lock-function-name-face))))) - '((default (:inherit font-lock-function-name-face)))) - "Face used for highlighting exported functions." - :group 'erlang) - -(defvar erlang-font-lock-exported-function-name-face - 'erlang-font-lock-exported-function-name-face) - -(defvar erlang-inhibit-exported-function-name-face nil - "Inhibit separate face for exported functions") - -(defvar erlang-font-lock-keywords-exported-function-header - (list - (list #'erlang-match-next-exported-function - 1 'erlang-font-lock-exported-function-name-face t)) - "Font lock keyword highlighting an exported function header.") - -(defvar erlang-font-lock-keywords-int-bifs - (list - (list (concat erlang-int-bif-regexp "\\s-*(") - 1 'font-lock-builtin-face)) - "Font lock keyword highlighting built in functions.") - -(defvar erlang-font-lock-keywords-ext-bifs - (list - (list (concat "\\<\\(erlang\\)\\s-*:\\s-*" erlang-ext-bif-regexp "\\s-*(") - '(1 'font-lock-builtin-face) - '(2 'font-lock-builtin-face))) - "Font lock keyword highlighting built in functions.") - -(defvar erlang-font-lock-keywords-int-function-calls - (list - (list (concat erlang-atom-regexp "\\s-*(") - 1 'font-lock-type-face)) - "Font lock keyword highlighting an internal function call.") - -(defvar erlang-font-lock-keywords-ext-function-calls - (list - (list (concat erlang-atom-regexp "\\s-*:\\s-*" - erlang-atom-regexp "\\s-*(") - '(1 'font-lock-type-face) - '(2 'font-lock-type-face))) - "Font lock keyword highlighting an external function call.") - -(defvar erlang-font-lock-keywords-fun-n - (list - (list (concat "\\(" erlang-atom-regexp "/[0-9]+\\)") - 1 'font-lock-type-face)) - "Font lock keyword highlighting a fun descriptor in F/N format.") - -(defvar erlang-font-lock-keywords-operators - (list - (list erlang-operators-regexp - 1 'font-lock-builtin-face)) - "Font lock keyword highlighting Erlang operators.") - -(defvar erlang-font-lock-keywords-dollar - (list - (list "\\(\\$\\([^\\]\\|\\\\\\([^0-7^\n]\\|[0-7]+\\|\\^[a-zA-Z]\\)\\)\\)" - 1 'font-lock-constant-face)) - "Font lock keyword highlighting numbers in ASCII form (e.g. $A).") - -(defvar erlang-font-lock-keywords-arrow - (list - (list "->\\(\\s \\|$\\)" 1 'font-lock-function-name-face)) - "Font lock keyword highlighting clause arrow.") - -(defvar erlang-font-lock-keywords-lc - (list - (list "\\(<-\\|<=\\|||\\)\\(\\s \\|$\\)" 1 'font-lock-keyword-face)) - "Font lock keyword highlighting list comprehension operators.") - -(defvar erlang-font-lock-keywords-keywords - (list - (list erlang-keywords-regexp 1 'font-lock-keyword-face)) - "Font lock keyword highlighting Erlang keywords.") - -(defvar erlang-font-lock-keywords-attr - (list - (list (concat "^\\(-" erlang-atom-regexp "\\)\\(\\s-\\|\\.\\|(\\)") - 1 (if (boundp 'font-lock-preprocessor-face) - 'font-lock-preprocessor-face - 'font-lock-constant-face))) - "Font lock keyword highlighting attributes.") - -(defvar erlang-font-lock-keywords-quotes - (list - (list "`\\([-+a-zA-Z0-9_:*][-+a-zA-Z0-9_:*]+\\)'" - 1 - 'font-lock-keyword-face - t)) - "Font lock keyword highlighting words in single quotes in comments. - -This is not the highlighting of Erlang strings and atoms, which -are highlighted by syntactic analysis.") - -(defvar erlang-font-lock-keywords-guards - (list - (list (concat "[^:]" erlang-guards-regexp "\\s-*(") - 1 'font-lock-builtin-face)) - "Font lock keyword highlighting guards.") - -(defvar erlang-font-lock-keywords-predefined-types - (list - (list (concat "[^:]" erlang-predefined-types-regexp "\\s-*(") - 1 'font-lock-builtin-face)) - "Font lock keyword highlighting predefined types.") - - -(defvar erlang-font-lock-keywords-macros - (list - (list (concat "?\\s-*\\(" erlang-atom-regexp - "\\|" erlang-variable-regexp "\\)") - 1 'font-lock-constant-face) - (list (concat "^\\(-\\(?:define\\|ifn?def\\)\\)\\s-*(\\s-*\\(" erlang-atom-regexp - "\\|" erlang-variable-regexp "\\)") - (if (boundp 'font-lock-preprocessor-face) - (list 1 'font-lock-preprocessor-face t) - (list 1 'font-lock-constant-face t)) - (list 3 'font-lock-type-face t t)) - (list "^-e\\(lse\\|ndif\\)\\>" 0 'font-lock-preprocessor-face t)) - "Font lock keyword highlighting macros. -This must be placed in front of `erlang-font-lock-keywords-vars'.") - -(defvar erlang-font-lock-keywords-records - (list - (list (concat "#\\s *" erlang-atom-regexp) - 1 'font-lock-type-face) - ;; Don't highlight numerical constants. - (list (if erlang-regexp-modern-p - "\\_<[0-9]+#\\([0-9a-zA-Z]+\\)" - "\\<[0-9]+#\\([0-9a-zA-Z]+\\)") - 1 nil t) - (list (concat "^-record\\s-*(\\s-*" erlang-atom-regexp) - 1 'font-lock-type-face)) - "Font lock keyword highlighting Erlang records. -This must be placed in front of `erlang-font-lock-keywords-vars'.") - -(defvar erlang-font-lock-keywords-vars - (list - (list (concat "[^#]" erlang-variable-regexp) ; no numerical constants - 1 'font-lock-variable-name-face)) - "Font lock keyword highlighting Erlang variables. -Must be preceded by `erlang-font-lock-keywords-macros' to work properly.") - -(defvar erlang-font-lock-descr-string - "Font-lock keywords used by Erlang Mode. - -There exists three levels of Font Lock keywords for Erlang: - `erlang-font-lock-keywords-1' - Function headers and reserved keywords. - `erlang-font-lock-keywords-2' - Bifs, guards and `single quotes'. - `erlang-font-lock-keywords-3' - Variables, macros and records. - `erlang-font-lock-keywords-4' - Exported functions, Function names, - Funs, LCs (not Atoms). - -To use a specific level, please set the variable -`font-lock-maximum-decoration' to the appropriate level. Note that the -variable must be set before Erlang mode is activated. - -Example: - (setq font-lock-maximum-decoration 2)") - -(defvar erlang-font-lock-keywords-1 - (append erlang-font-lock-keywords-function-header - erlang-font-lock-keywords-dollar - erlang-font-lock-keywords-arrow - erlang-font-lock-keywords-keywords - ) - ;; DocStringOrig: erlang-font-lock-keywords - erlang-font-lock-descr-string) - -(defvar erlang-font-lock-keywords-2 - (append erlang-font-lock-keywords-1 - erlang-font-lock-keywords-int-bifs - erlang-font-lock-keywords-ext-bifs - erlang-font-lock-keywords-attr - erlang-font-lock-keywords-quotes - erlang-font-lock-keywords-guards - ) - ;; DocStringCopy: erlang-font-lock-keywords - erlang-font-lock-descr-string) - -(defvar erlang-font-lock-keywords-3 - (append erlang-font-lock-keywords-2 - erlang-font-lock-keywords-operators - erlang-font-lock-keywords-macros - erlang-font-lock-keywords-records - erlang-font-lock-keywords-vars - erlang-font-lock-keywords-predefined-types - ) - ;; DocStringCopy: erlang-font-lock-keywords - erlang-font-lock-descr-string) - -(defvar erlang-font-lock-keywords-4 - (append erlang-font-lock-keywords-3 - erlang-font-lock-keywords-exported-function-header - erlang-font-lock-keywords-int-function-calls - erlang-font-lock-keywords-ext-function-calls - erlang-font-lock-keywords-fun-n - erlang-font-lock-keywords-lc - ) - ;; DocStringCopy: erlang-font-lock-keywords - erlang-font-lock-descr-string) - -(defvar erlang-font-lock-keywords erlang-font-lock-keywords-4 - ;; DocStringCopy: erlang-font-lock-keywords - erlang-font-lock-descr-string) - -(defvar erlang-font-lock-syntax-table nil - "Syntax table used by Font Lock mode. - -The difference between this and the standard Erlang Mode -syntax table is that `_' is treated as part of words by -this syntax table. - -Unfortunately, XEmacs hasn't got support for a special Font -Lock syntax table. The effect is that `apply' in the atom -`foo_apply' will be highlighted as a bif.") - -(defvar erlang-replace-etags-tags-completion-table nil - "Internal flag used by advice `erlang-replace-tags-table'. -This is non-nil when `etags-tags-completion-table' should be -replaced by `erlang-etags-tags-completion-table'.") - - -;;; Avoid errors while compiling this file. - -;; `eval-when-compile' is not defined in Emacs 18. We define it as a -;; no-op. -(or (fboundp 'eval-when-compile) - (defmacro eval-when-compile (&rest rest) nil)) - -;; These umm...functions are new in Emacs 20. And, yes, until version -;; 19.27 Emacs backquotes were this ugly. - -(or (fboundp 'unless) - (defmacro unless (condition &rest body) - "(unless CONDITION BODY...): If CONDITION is false, do BODY, else return nil." - `((if (, condition) nil ,@body)))) - -(or (fboundp 'when) - (defmacro when (condition &rest body) - "(when CONDITION BODY...): If CONDITION is true, do BODY, else return nil." - `((if (, condition) (progn ,@body) nil)))) - -(or (fboundp 'char-before) - (defmacro char-before (&optional pos) - "Return the character in the current buffer just before POS." - `( (char-after (1- (or ,pos (point))))))) - -;; defvar some obsolete variables, which we still support for -;; backwards compatibility reasons. -(eval-when-compile - (defvar comment-indent-hook) - (defvar dabbrev-case-fold-search) - (defvar tempo-match-finder) - (defvar compilation-menu-map) - (defvar next-error-last-buffer)) - -(eval-when-compile - (if (or (featurep 'bytecomp) - (featurep 'byte-compile)) - (progn - (cond ((string-match "Lucid\\|XEmacs" emacs-version) - (put 'comment-indent-hook 'byte-obsolete-variable nil) - ;; Do not warn for unused variables - ;; when compiling under XEmacs. - (setq byte-compile-warnings - '(free-vars unresolved callargs redefine)))) - (require 'comint) - (require 'tempo) - (require 'compile)))) - - -(defun erlang-version () - "Return the current version of Erlang mode." - (interactive) - (if (erlang-interactive-p) - (message "Erlang mode version %s, written by Anders Lindgren" - erlang-version)) - erlang-version) - -(defun erlang-interactive-p () - (if (fboundp 'called-interactively-p) - (called-interactively-p 'interactive) - (funcall (symbol-function 'interactive-p)))) - -(unless (fboundp 'prog-mode) - (defun prog-mode () - (use-local-map (make-keymap)))) - -;;;###autoload -(define-derived-mode erlang-mode prog-mode "Erlang" - "Major mode for editing Erlang source files in Emacs. -It knows about syntax and comment, it can indent code, it is capable -of fontifying the source file, the TAGS commands are aware of Erlang -modules, and the Erlang man pages can be accessed. - -Should this module, \"erlang.el\", be installed properly, Erlang mode -is activated whenever an Erlang source or header file is loaded into -Emacs. To indicate this, the mode line should contain the word -\"Erlang\". - -The main feature of Erlang mode is indentation, press TAB and the -current line will be indented correctly. - -Comments starting with only one `%' are indented to the column stored -in the variable `comment-column'. Comments starting with two `%':s -are indented with the same indentation as code. Comments starting -with at least three `%':s are indented to the first column. - -However, Erlang mode contains much more, this is a list of the most -useful commands: - TAB - Indent the line. - C-c C-q - Indent current function. - M-; - Create a comment at the end of the line. - M-q - Fill a comment, i.e. wrap lines so that they (hopefully) - will look better. - M-a - Goto the beginning of an Erlang clause. - M-C-a - Ditto for function. - M-e - Goto the end of an Erlang clause. - M-C-e - Ditto for function. - M-h - Mark current Erlang clause. - M-C-h - Ditto for function. - C-c C-z - Start, or switch to, an inferior Erlang shell. - C-c C-k - Compile current file. - C-x ` - Next error. - , - Electric comma. - ; - Electric semicolon. - -Erlang mode check the name of the file against the module name when -saving, whenever a mismatch occurs Erlang mode offers to modify the -source. - -The variable `erlang-electric-commands' controls the electric -commands. To deactivate all of them, set it to nil. - -There exists a large number of commands and variables in the Erlang -module. Please press `M-x apropos RET erlang RET' to see a complete -list. Press `C-h f name-of-function RET' and `C-h v name-of-variable -RET'to see the full description of functions and variables, -respectively. - -On entry to this mode the contents of the hook `erlang-mode-hook' is -executed. - -Please see the beginning of the file `erlang.el' for more information -and examples of hooks. - -Other commands: -\\{erlang-mode-map}" - ;; Use our own syntax table function - :syntax-table nil - (erlang-syntax-table-init) - (erlang-electric-init) - (erlang-menu-init) - (erlang-mode-variables) - (erlang-check-module-name-init) - (erlang-man-init) - (erlang-tags-init) - (erlang-font-lock-init) - (erlang-skel-init) - (when (fboundp 'tempo-use-tag-list) - (tempo-use-tag-list 'erlang-tempo-tags)) - (run-hooks 'erlang-mode-hook) - (if (zerop (buffer-size)) - (run-hooks 'erlang-new-file-hook))) - -;;;###autoload -(dolist (r '("\\.erl$" "\\.app\\.src$" "\\.escript" - "\\.hrl$" "\\.xrl$" "\\.yrl" "/ebin/.+\\.app")) - (add-to-list 'auto-mode-alist (cons r 'erlang-mode))) - -(defun erlang-syntax-table-init () - (if (null erlang-mode-syntax-table) - (let ((table (make-syntax-table))) - (modify-syntax-entry ?\n ">" table) - (modify-syntax-entry ?\" "\"" table) - (modify-syntax-entry ?# "." table) -;; (modify-syntax-entry ?$ "\\" table) ;; Creates problems with indention afterwards -;; (modify-syntax-entry ?$ "'" table) ;; Creates syntax highlighting and indention problems - (modify-syntax-entry ?$ "/" table) ;; Misses the corner case "string that ends with $" - ;; we have to live with that for now..it is the best alternative - ;; that can be worked around with "string hat ends with \$" - (modify-syntax-entry ?% "<" table) - (modify-syntax-entry ?& "." table) - (modify-syntax-entry ?\' "\"" table) - (modify-syntax-entry ?* "." table) - (modify-syntax-entry ?+ "." table) - (modify-syntax-entry ?- "." table) - (modify-syntax-entry ?/ "." table) - (modify-syntax-entry ?: "." table) - (modify-syntax-entry ?< "." table) - (modify-syntax-entry ?= "." table) - (modify-syntax-entry ?> "." table) - (modify-syntax-entry ?\\ "\\" table) - (modify-syntax-entry ?_ "_" table) - (modify-syntax-entry ?| "." table) - (modify-syntax-entry ?^ "'" table) - - ;; Pseudo bit-syntax: Latin1 double angle quotes as parens. - ;;(modify-syntax-entry ?\253 "(?\273" table) - ;;(modify-syntax-entry ?\273 ")?\253" table) - - (setq erlang-mode-syntax-table table))) - - (set-syntax-table erlang-mode-syntax-table)) - - -(defun erlang-electric-init () - ;; Set up electric character functions to work with - ;; delsel/pending-del mode. Also, set up text properties for bit - ;; syntax handling. - (mapc #'(lambda (cmd) - (put cmd 'delete-selection t) ;for delsel (Emacs) - (put cmd 'pending-delete t)) ;for pending-del (XEmacs) - '(erlang-electric-semicolon - erlang-electric-comma - erlang-electric-gt)) - - (put 'bitsyntax-open-outer 'syntax-table '(4 . ?>)) - (put 'bitsyntax-open-outer 'rear-nonsticky '(category)) - (put 'bitsyntax-open-inner 'rear-nonsticky '(category)) - (put 'bitsyntax-close-inner 'rear-nonsticky '(category)) - (put 'bitsyntax-close-outer 'syntax-table '(5 . ?<)) - (put 'bitsyntax-close-outer 'rear-nonsticky '(category)) - (make-local-variable 'parse-sexp-lookup-properties) - (setq parse-sexp-lookup-properties 't)) - - -(defun erlang-mode-variables () - (or erlang-mode-abbrev-table - (define-abbrev-table 'erlang-mode-abbrev-table ())) - (setq local-abbrev-table erlang-mode-abbrev-table) - (make-local-variable 'paragraph-start) - (setq paragraph-start (concat "^$\\|" page-delimiter)) - (make-local-variable 'paragraph-separate) - (setq paragraph-separate paragraph-start) - (make-local-variable 'paragraph-ignore-fill-prefix) - (setq paragraph-ignore-fill-prefix t) - (make-local-variable 'defun-prompt-regexp) - (setq defun-prompt-regexp erlang-defun-prompt-regexp) - (make-local-variable 'comment-start) - (setq comment-start "%") - (make-local-variable 'comment-start-skip) - (setq comment-start-skip "%+\\s *") - (make-local-variable 'comment-column) - (setq comment-column 48) - (make-local-variable 'indent-line-function) - (setq indent-line-function 'erlang-indent-command) - (make-local-variable 'indent-region-function) - (setq indent-region-function 'erlang-indent-region) - (set (make-local-variable 'comment-indent-function) 'erlang-comment-indent) - (if (<= erlang-emacs-major-version 18) - (set (make-local-variable 'comment-indent-hook) 'erlang-comment-indent)) - (set (make-local-variable 'parse-sexp-ignore-comments) t) - (set (make-local-variable 'dabbrev-case-fold-search) nil) - (set (make-local-variable 'imenu-prev-index-position-function) - 'erlang-beginning-of-function) - (set (make-local-variable 'imenu-extract-index-name-function) - 'erlang-get-function-name-and-arity) - (set (make-local-variable 'tempo-match-finder) - "[^-a-zA-Z0-9_]\\([-a-zA-Z0-9_]*\\)\\=") - (set (make-local-variable 'beginning-of-defun-function) - 'erlang-beginning-of-function) - (set (make-local-variable 'end-of-defun-function) 'erlang-end-of-function) - (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil) - (set (make-local-variable 'fill-paragraph-function) 'erlang-fill-paragraph) - (set (make-local-variable 'comment-add) 1) - (set (make-local-variable 'outline-regexp) "[[:lower:]0-9_]+ *(.*) *-> *$") - (set (make-local-variable 'outline-level) (lambda () 1)) - (set (make-local-variable 'add-log-current-defun-function) - 'erlang-current-defun)) - -(defun erlang-font-lock-init () - "Initialize Font Lock for Erlang mode." - (or erlang-font-lock-syntax-table - (setq erlang-font-lock-syntax-table - (let ((table (copy-syntax-table erlang-mode-syntax-table))) - (modify-syntax-entry ?_ "w" table) - table))) - (set (make-local-variable 'font-lock-syntax-table) - erlang-font-lock-syntax-table) - (set (make-local-variable (if (boundp 'syntax-begin-function) - 'syntax-begin-function - 'font-lock-beginning-of-syntax-function)) - 'erlang-beginning-of-clause) - (make-local-variable 'font-lock-keywords) - (let ((level (cond ((boundp 'font-lock-maximum-decoration) - (symbol-value 'font-lock-maximum-decoration)) - ((boundp 'font-lock-use-maximal-decoration) - (symbol-value 'font-lock-use-maximal-decoration)) - (t nil)))) - (if (consp level) - (setq level (cdr-safe (or (assq 'erlang-mode level) - (assq t level))))) - ;; `level' can here be: - ;; A number - The fontification level - ;; nil - Use the default - ;; t - Use maximum - (cond ((eq level nil) - (set 'font-lock-keywords erlang-font-lock-keywords)) - ((eq level 1) - (set 'font-lock-keywords erlang-font-lock-keywords-1)) - ((eq level 2) - (set 'font-lock-keywords erlang-font-lock-keywords-2)) - ((eq level 3) - (set 'font-lock-keywords erlang-font-lock-keywords-3)) - (t - (set 'font-lock-keywords erlang-font-lock-keywords-4)))) - - ;; Modern font-locks can handle the above much more elegantly: - (set (make-local-variable 'font-lock-defaults) - '((erlang-font-lock-keywords erlang-font-lock-keywords-1 - erlang-font-lock-keywords-2 - erlang-font-lock-keywords-3 - erlang-font-lock-keywords-4) - nil nil ((?_ . "w")) erlang-beginning-of-clause - (font-lock-mark-block-function . erlang-mark-clause) - (font-lock-syntactic-keywords - ;; A dollar sign right before the double quote that ends a - ;; string is not a character escape. - ;; - ;; And a "string" consists of a double quote not escaped by a - ;; dollar sign, any number of non-backslash non-newline - ;; characters or escaped backslashes, a dollar sign - ;; (otherwise we wouldn't care) and a double quote. This - ;; doesn't match multi-line strings, but this is probably - ;; the best we can get, since while font-locking we don't - ;; know whether matching started inside a string: limiting - ;; search to a single line keeps things sane. - . (("\\(?:^\\|[^$]\\)\"\\(?:[^\"\n]\\|\\\\\"\\)*\\(\\$\\)\"" 1 "w") - ;; Likewise for atoms - ("\\(?:^\\|[^$]\\)'\\(?:[^'\n]\\|\\\\'\\)*\\(\\$\\)'" 1 "w") - ;; And the dollar sign in $\" or $\' escapes two - ;; characters, not just one. - ("\\(\\$\\)\\\\[\"']" 1 "'")))))) - - - -;; Useful when defining your own keywords. -(defun erlang-font-lock-set-face (ks &rest faces) - "Replace the face components in a list of keywords. - -The first argument, KS, is a list of keywords. The rest of the -arguments are expressions to replace the face information with. The -first expression replaces the face of the first keyword, the second -expression the second keyword etc. - -Should an expression be nil, the face of the corresponding keyword is -not changed. - -Should fewer expressions than keywords be given, the last expression -is used for all remaining keywords. - -Normally, the expressions are just atoms representing the new face. -They could however be more complex, returning different faces in -different situations. - -This function only handles keywords with elements on the forms: - (REGEXP NUMBER FACE) - (REGEXP NUMBER FACE OVERWRITE) - -This could be used when defining your own special font-lock setup, e.g: - -\(setq my-font-lock-keywords - (append erlang-font-lock-keywords-function-header - erlang-font-lock-keywords-dollar - (erlang-font-lock-set-face - erlang-font-lock-keywords-macros 'my-neon-green-face) - (erlang-font-lock-set-face - erlang-font-lock-keywords-lc 'my-deep-red 'my-light-red) - erlang-font-lock-keywords-attr)) - -For a more elaborate example, please see the beginning of the file -`erlang.el'." - (let ((res '())) - (while ks - (let* ((regexp (car (car ks))) - (number (car (cdr (car ks)))) - (new-face (if (and faces (car faces)) - (car faces) - (car (cdr (cdr (car ks)))))) - (overwrite (car (cdr (cdr (cdr (car ks)))))) - (new-keyword (list regexp number new-face))) - (if overwrite (nconc new-keyword (list overwrite))) - (setq res (cons new-keyword res)) - (setq ks (cdr ks)) - (if (and faces (cdr faces)) - (setq faces (cdr faces))))) - (nreverse res))) - - -(defun erlang-font-lock-level-0 () - ;; DocStringOrig: font-cmd - "Unfontify current buffer." - (interactive) - (font-lock-mode 0)) - - -(defun erlang-font-lock-level-1 () - ;; DocStringCopy: font-cmd - "Fontify current buffer at level 1. -This highlights function headers, reserved keywords, strings and comments." - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-1) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - - -(defun erlang-font-lock-level-2 () - ;; DocStringCopy: font-cmd - "Fontify current buffer at level 2. -This highlights level 1 features (see `erlang-font-lock-level-1') -plus bifs, guards and `single quotes'." - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-2) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - - -(defun erlang-font-lock-level-3 () - ;; DocStringCopy: font-cmd - "Fontify current buffer at level 3. -This highlights level 2 features (see `erlang-font-lock-level-2') -plus variables, macros and records." - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-3) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - -(defun erlang-font-lock-level-4 () - ;; DocStringCopy: font-cmd - "Fontify current buffer at level 4. -This highlights level 3 features (see `erlang-font-lock-level-2') -plus variables, macros and records." - (interactive) - (require 'font-lock) - (set 'font-lock-keywords erlang-font-lock-keywords-4) - (font-lock-mode 1) - (funcall (symbol-function 'font-lock-fontify-buffer))) - - -(defun erlang-menu-init () - "Init menus for Erlang mode. - -The variable `erlang-menu-items' contain a description of the Erlang -mode menu. Normally, the list contains atoms, representing variables -bound to pieces of the menu. - -Personal extensions could be added to `erlang-menu-personal-items'. - -This function should be called if any variable describing the -menu configuration is changed." - (erlang-menu-install "Erlang" erlang-menu-items erlang-mode-map t)) - - -(defun erlang-menu-install (name items keymap &optional popup) - "Install a menu in Emacs or XEmacs based on an abstract description. - -NAME is the name of the menu. - -ITEMS is a list. The elements are either nil representing a horizontal -line or a list with two or three elements. The first is the name of -the menu item, the second the function to call, or a submenu, on the -same same form as ITEMS. The third optional element is an expression -which is evaluated every time the menu is displayed. Should the -expression evaluate to nil the menu item is ghosted. - -KEYMAP is the keymap to add to menu to. (When using XEmacs, the menu -will only be visible when this menu is the global, the local, or an -activate minor mode keymap.) - -If POPUP is non-nil, the menu is bound to the XEmacs `mode-popup-menu' -variable, i.e. it will popup when pressing the right mouse button. - -Please see the variable `erlang-menu-base-items'." - (cond (erlang-xemacs-p - (let ((menu (erlang-menu-xemacs name items keymap))) - ;; We add the menu to the global menubar. - ;;(funcall (symbol-function 'set-buffer-menubar) - ;; (symbol-value 'current-menubar)) - (funcall (symbol-function 'add-submenu) nil menu) - (setcdr erlang-xemacs-popup-menu (cdr menu)) - (if (and popup (boundp 'mode-popup-menu)) - (funcall (symbol-function 'set) - 'mode-popup-menu erlang-xemacs-popup-menu)))) - ((>= erlang-emacs-major-version 19) - (define-key keymap (vector 'menu-bar (intern name)) - (erlang-menu-make-keymap name items))) - (t nil))) - - -(defun erlang-menu-make-keymap (name items) - "Build a menu for Emacs 19." - (let ((menumap (funcall (symbol-function 'make-sparse-keymap) - name)) - (count 0) - id def first second third) - (setq items (reverse items)) - (while items - ;; Replace any occurrence of atoms by their value. - (while (and items (atom (car items)) (not (null (car items)))) - (if (and (boundp (car items)) - (listp (symbol-value (car items)))) - (setq items (append (reverse (symbol-value (car items))) - (cdr items))) - (setq items (cdr items)))) - (setq first (car-safe (car items))) - (setq second (car-safe (cdr-safe (car items)))) - (setq third (car-safe (cdr-safe (cdr-safe (car items))))) - (cond ((null first) - (setq count (+ count 1)) - (setq id (intern (format "separator-%d" count))) - (setq def '("--" . nil))) - ((and (consp second) (eq (car second) 'lambda)) - (setq count (+ count 1)) - (setq id (intern (format "lambda-%d" count))) - (setq def (cons first second))) - ((symbolp second) - (setq id second) - (setq def (cons first second))) - (t - (setq count (+ count 1)) - (setq id (intern (format "submenu-%d" count))) - (setq def (erlang-menu-make-keymap first second)))) - (define-key menumap (vector id) def) - (if third - (put id 'menu-enable third)) - (setq items (cdr items))) - (cons name menumap))) - - -(defun erlang-menu-xemacs (name items &optional keymap) - "Build a menu for XEmacs." - (let ((res '()) - first second third entry) - (while items - ;; Replace any occurrence of atoms by their value. - (while (and items (atom (car items)) (not (null (car items)))) - (if (and (boundp (car items)) - (listp (symbol-value (car items)))) - (setq items (append (reverse (symbol-value (car items))) - (cdr items))) - (setq items (cdr items)))) - (setq first (car-safe (car items))) - (setq second (car-safe (cdr-safe (car items)))) - (setq third (car-safe (cdr-safe (cdr-safe (car items))))) - (cond ((null first) - (setq res (cons "------" res))) - ((symbolp second) - (setq res (cons (vector first second (or third t)) res))) - ((and (consp second) (eq (car second) 'lambda)) - (setq res (cons (vector first (list 'call-interactively second) - (or third t)) res))) - (t - (setq res (cons (cons first - (cdr (erlang-menu-xemacs - first second))) - res)))) - (setq items (cdr items))) - (setq res (reverse res)) - ;; When adding a menu to a minor-mode keymap under Emacs, - ;; it disappears when the mode is disabled. The expression - ;; generated below imitates this behaviour. - ;; (This could be expressed much clearer using backquotes, - ;; but I don't want to pull in every package.) - (if keymap - (let ((expr (list 'or - (list 'eq keymap 'global-map) - (list 'eq keymap (list 'current-local-map)) - (list 'symbol-value - (list 'car-safe - (list 'rassq - keymap - 'minor-mode-map-alist)))))) - (setq res (cons ':included (cons expr res))))) - (cons name res))) - - -(defun erlang-menu-substitute (items alist) - "Substitute functions in menu described by ITEMS. - -The menu ITEMS is updated destructively. - -ALIST is list of pairs where the car is the old function and cdr the new." - (let (first second pair) - (while items - (setq first (car-safe (car items))) - (setq second (car-safe (cdr-safe (car items)))) - (cond ((null first)) - ((symbolp second) - (setq pair (and second (assq second alist))) - (if pair - (setcar (cdr (car items)) (cdr pair)))) - ((and (consp second) (eq (car second) 'lambda))) - (t - (erlang-menu-substitute second alist))) - (setq items (cdr items))))) - - -(defun erlang-menu-add-above (entry above items) - "Add menu ENTRY above menu entry ABOVE in menu ITEMS. -Do nothing if the items already should be in the menu. -Should ABOVE not be in the list, the entry is added at -the bottom of the menu. - -The new menu is returned. No guarantee is given that the original -menu is left unchanged. - -The equality test is performed by `eq'. - -Example: (erlang-menu-add-above 'my-erlang-menu-items - 'erlang-menu-man-items)" - (erlang-menu-add-below entry above items t)) - - -(defun erlang-menu-add-below (entry below items &optional above-p) - "Add menu ENTRY below menu items BELOW in the Erlang menu. -Do nothing if the items already should be in the menu. -Should BELOW not be in the list, items is added at the bottom -of the menu. - -The new menu is returned. No guarantee is given that the original -menu is left unchanged. - -The equality test is performed by `eq'. - -Example: - -\(setq erlang-menu-items - (erlang-menu-add-below 'my-erlang-menu-items - 'erlang-menu-base-items - erlang-menu-items))" - (if (memq entry items) - items ; Return the original menu. - (let ((head '()) - (done nil) - res) - (while (not done) - (cond ((null items) - (setq res (append head (list entry))) - (setq done t)) - ((eq below (car items)) - (setq res - (if above-p - (append head (cons entry items)) - (append head (cons (car items) - (cons entry (cdr items)))))) - (setq done t)) - (t - (setq head (append head (list (car items)))) - (setq items (cdr items))))) - res))) - -(defun erlang-menu-delete (entry items) - "Delete ENTRY from menu ITEMS. - -The new menu is returned. No guarantee is given that the original -menu is left unchanged." - (delq entry items)) - -;; Man code: - -(defun erlang-man-init () - "Add menus containing the manual pages of the Erlang. - -The variable `erlang-man-dirs' contains entries describing -the location of the manual pages." - (interactive) - (if erlang-man-inhibit - () - (setq erlang-menu-man-items - '(nil - ("Man - Function" erlang-man-function))) - (if erlang-man-dirs - (setq erlang-menu-man-items - (append erlang-menu-man-items - (erlang-man-make-top-menu erlang-man-dirs)))) - (setq erlang-menu-items - (erlang-menu-add-above 'erlang-menu-man-items - 'erlang-menu-version-items - erlang-menu-items)) - (erlang-menu-init))) - - -(defun erlang-man-uninstall () - "Remove the man pages from the Erlang mode." - (interactive) - (setq erlang-menu-items - (erlang-menu-delete 'erlang-menu-man-items erlang-menu-items)) - (erlang-menu-init)) - - -;; The man menu is a hierarchal structure, with the manual sections -;; at the top, described by `erlang-man-dirs'. The next level could -;; either be the manual pages if not to many, otherwise it is an index -;; menu whose submenus will contain up to `erlang-man-max-menu-size' -;; manual pages. - -(defun erlang-man-make-top-menu (dir-list) - "Create one menu entry per element of DIR-LIST. -The format is described in the documentation of `erlang-man-dirs'." - (let ((menu '()) - dir) - (while dir-list - (setq dir (cond ((nth 2 (car dir-list)) - ;; Relative to `erlang-root-dir'. - (and (stringp erlang-root-dir) - (concat erlang-root-dir (nth 1 (car dir-list))))) - (t - ;; Absolute - (nth 1 (car dir-list))))) - (if (and dir - (file-readable-p dir)) - (setq menu (cons (list (car (car dir-list)) - (erlang-man-make-middle-menu - (erlang-man-get-files dir))) - menu))) - (setq dir-list (cdr dir-list))) - ;; Should no menus be found, generate a menu item which - ;; will display a help text, when selected. - (if menu - (nreverse menu) - '(("Man Pages" - (("Error! Why?" erlang-man-describe-error))))))) - - -;; Should the menu be to long, let's split it into a number of -;; smaller menus. Warning, this code contains beautiful -;; destructive operations! -(defun erlang-man-make-middle-menu (filelist) - "Create the second level menu from FILELIST. - -Should the list be longer than `erlang-man-max-menu-size', a tree of -menus is created." - (if (<= (length filelist) erlang-man-max-menu-size) - (erlang-man-make-menu filelist) - (let ((menu '()) - (filelist (copy-sequence filelist)) - segment submenu pair) - (while filelist - (setq pair (nthcdr (- erlang-man-max-menu-size 1) filelist)) - (setq segment filelist) - (if (null pair) - (setq filelist nil) - (setq filelist (cdr pair)) - (setcdr pair nil)) - (setq submenu (erlang-man-make-menu segment)) - (setq menu (cons (list (concat (car (car submenu)) - " -- " - (car (car (reverse submenu)))) - submenu) - menu))) - (nreverse menu)))) - - -(defun erlang-man-make-menu (filelist) - "Make a leaf menu based on FILELIST." - (let ((menu '()) - item) - (while filelist - (setq item (erlang-man-make-menu-item (car filelist))) - (if item - (setq menu (cons item menu))) - (setq filelist (cdr filelist))) - (nreverse menu))) - - -(defun erlang-man-make-menu-item (file) - "Create a menu item containing the name of the man page." - (and (string-match ".+/\\([^/]+\\)\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$" file) - (let ((page (substring file (match-beginning 1) (match-end 1)))) - (list (capitalize page) - (list 'lambda '() - '(interactive) - (list 'funcall 'erlang-man-display-function - file)))))) - - -(defun erlang-man-get-files (dir) - "Return files in directory DIR." - (directory-files dir t ".+\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?\\'")) - - -(defun erlang-man-module (&optional module) - "Find manual page for MODULE, defaults to module of function under point. -This function is aware of imported functions." - (interactive - (list (let* ((mod (car-safe (erlang-get-function-under-point))) - (input (read-string - (format "Manual entry for module%s: " - (if (or (null mod) (string= mod "")) - "" - (format " (default %s)" mod)))))) - (if (string= input "") - mod - input)))) - (or module (setq module (car (erlang-get-function-under-point)))) - (if (or (null module) (string= module "")) - (error "No Erlang module name given")) - (let ((dir-list erlang-man-dirs) - (pat (concat "/" (regexp-quote module) "\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$")) - (file nil) - file-list) - (while (and dir-list (null file)) - (setq file-list (erlang-man-get-files - (if (nth 2 (car dir-list)) - (concat erlang-root-dir (nth 1 (car dir-list))) - (nth 1 (car dir-list))))) - (while (and file-list (null file)) - (if (string-match pat (car file-list)) - (setq file (car file-list))) - (setq file-list (cdr file-list))) - (setq dir-list (cdr dir-list))) - (if file - (funcall erlang-man-display-function file) - (error "No manual page for module %s found" module)))) - - -;; Warning, the function `erlang-man-function' is a hack! -;; It links itself into the man code in a non-clean way. I have -;; chosen to keep it since it provides a very useful functionality -;; which is not possible to achieve using a clean approach. -;; / AndersL - -(defvar erlang-man-function-name nil - "Name of function for last `erlang-man-function' call. -Used for communication between `erlang-man-function' and the -patch to `Man-notify-when-ready'.") - -(defun erlang-man-function (&optional name) - "Find manual page for NAME, where NAME is module:function. -The entry for `function' is displayed. - -This function is aware of imported functions." - (interactive - (list (let* ((mod-func (erlang-get-function-under-point)) - (mod (car-safe mod-func)) - (func (nth 1 mod-func)) - (input (read-string - (format - "Manual entry for `module:func' or `module'%s: " - (if (or (null mod) (string= mod "")) - "" - (format " (default %s:%s)" mod func)))))) - (if (string= input "") - (if (and mod func) - (concat mod ":" func) - mod) - input)))) - ;; Emacs 18 doesn't provide `man'... - (condition-case nil - (require 'man) - (error nil)) - (let ((modname nil) - (funcname nil)) - (cond ((null name) - (let ((mod-func (erlang-get-function-under-point))) - (setq modname (car-safe mod-func)) - (setq funcname (nth 1 mod-func)))) - ((string-match ":" name) - (setq modname (substring name 0 (match-beginning 0))) - (setq funcname (substring name (match-end 0) nil))) - ((stringp name) - (setq modname name))) - (if (or (null modname) (string= modname "")) - (error "No Erlang module name given")) - (cond ((fboundp 'Man-notify-when-ready) - ;; Emacs 19: The man command could possibly start an - ;; asynchronous process, i.e. we must hook ourselves into - ;; the system to be activated when the man-process - ;; terminates. - (if (null funcname) - () - (erlang-man-patch-notify) - (setq erlang-man-function-name funcname)) - (condition-case nil - (erlang-man-module modname) - (error (setq erlang-man-function-name nil)))) - (t - (erlang-man-module modname) - (if funcname - (erlang-man-find-function - (or (get-buffer "*Manual Entry*") ; Emacs 18 - (current-buffer)) ; XEmacs - funcname)))))) - - -;; Should the defadvice be at the top level, the package `advice' would -;; be required. Now it is only required when this functionality -;; is used. (Emacs 19 specific.) -(defun erlang-man-patch-notify () - "Patch the function `Man-notify-when-ready' to search for function. -The variable `erlang-man-function-name' is assumed to be bound to -the function name, or to nil. - -The reason for patching a function is that under Emacs 19, the man -command is executed asynchronously." - (condition-case nil - (require 'advice) - ;; This should never happened since this is only called when - ;; running under Emacs 19. - (error (error (concat "This command needs the package `advice', " - "please upgrade your Emacs.")))) - (require 'man) - (defadvice Man-notify-when-ready - (after erlang-Man-notify-when-ready activate) - "Set point at the documentation of the function name in -`erlang-man-function-name' when the man page is displayed." - (if erlang-man-function-name - (erlang-man-find-function (ad-get-arg 0) erlang-man-function-name)) - (setq erlang-man-function-name nil))) - - -(defun erlang-man-find-function (buf func) - "Find manual page for function in `erlang-man-function-name' in buffer BUF." - (if func - (let ((win (get-buffer-window buf))) - (if win - (progn - (set-buffer buf) - (goto-char (point-min)) - (if (re-search-forward - (concat "^[ \t]+" func " ?(") - (point-max) t) - (progn - (forward-word -1) - (set-window-point win (point))) - (message "Could not find function `%s'" func))))))) - - -(defun erlang-man-display (file) - "Display FILE as a `man' file. -This is the default manual page display function. -The variables `erlang-man-display-function' contains the function -to be used." - ;; Emacs 18 doesn't `provide' man. - (condition-case nil - (require 'man) - (error nil)) - (if file - (let ((process-environment (copy-sequence process-environment))) - (if (string-match "\\(.*\\)/man[^/]*/\\([^.]+\\)\\.\\([124-9]\\|3\\(erl\\)?\\)\\(\\.gz\\)?$" file) - (let ((dir (substring file (match-beginning 1) (match-end 1))) - (page (substring file (match-beginning 2) (match-end 2)))) - (if (fboundp 'setenv) - (setenv "MANPATH" dir) - ;; Emacs 18 - (setq process-environment (cons (concat "MANPATH=" dir) - process-environment))) - (cond ((not (and (not erlang-xemacs-p) - (= erlang-emacs-major-version 19) - (< erlang-emacs-minor-version 29))) - (manual-entry page)) - (t - ;; Emacs 19.28 and earlier versions of 19: - ;; The manual-entry command unconditionally prompts - ;; the user :-( - (funcall (symbol-function 'Man-getpage-in-background) - page)))) - (error "Can't find man page for %s\n" file))))) - - -(defun erlang-man-describe-error () - "Describe why the manual pages weren't found." - (interactive) - (with-output-to-temp-buffer "*Erlang Man Error*" - (princ "Normally, this menu should contain Erlang manual pages. - -In order to find the manual pages, the variable `erlang-root-dir' -should be bound to the name of the directory containing the Erlang -installation. The name should not include the final slash. - -Practically, you should add a line on the following form to -your ~/.emacs, or ask your system administrator to add it to -the site init file: - (setq erlang-root-dir \"/the/erlang/root/dir/goes/here\") - -For example: - (setq erlang-root-dir \"/usr/local/erlang\") - -After installing the line, kill and restart Emacs, or restart Erlang -mode with the command `M-x erlang-mode RET'."))) - -;; Skeleton code: - -;; This code is based on the package `tempo' which is part of modern -;; Emacsen. (GNU Emacs 19.25 (?) and XEmacs 19.14.) - -(defvar erlang-skel) -(defun erlang-skel-init () - "Generate the skeleton functions and menu items. -The variable `erlang-skel' contains the name and descriptions of -all skeletons. - -The skeleton routines are based on the `tempo' package. Should this -package not be present, this function does nothing." - (interactive) - (condition-case nil - (require 'tempo) - (error t)) - (if (featurep 'tempo) - (let ((skel erlang-skel) - (menu '())) - (while skel - (cond ((null (car skel)) - (setq menu (cons nil menu))) - (t - (funcall (symbol-function 'tempo-define-template) - (concat "erlang-" (nth 1 (car skel))) - ;; The tempo template used contains an `include' - ;; function call only, hence changes to the - ;; variables describing the templates take effect - ;; immdiately. - (list (list 'erlang-skel-include (nth 2 (car skel)))) - (nth 1 (car skel)) - (car (car skel)) - 'erlang-tempo-tags) - (setq menu (cons (erlang-skel-make-menu-item - (car skel)) menu)))) - (setq skel (cdr skel))) - (setq erlang-menu-skel-items - (list nil (list "Skeletons" (nreverse menu)))) - (setq erlang-menu-items - (erlang-menu-add-above 'erlang-menu-skel-items - 'erlang-menu-version-items - erlang-menu-items)) - (erlang-menu-init)))) - -(defun erlang-skel-make-menu-item (skel) - (let ((func (intern (concat "tempo-template-erlang-" (nth 1 skel))))) - (cond ((null (nth 3 skel)) - (list (car skel) func)) - (t - (list (car skel) - (list 'lambda '() - '(interactive) - (list 'funcall - (list 'quote (nth 3 skel)) - (list 'quote func)))))))) - -;; Functions designed to be added to the skeleton menu. -;; (Not normally used) -(defun erlang-skel-insert (func) - "Insert skeleton generated by FUNC and goto first tempo mark." - (save-excursion (funcall func)) - (funcall (symbol-function 'tempo-forward-mark))) - -(defun erlang-skel-header (func) - "Insert the header generated by FUNC at the beginning of the buffer." - (goto-char (point-min)) - (save-excursion (funcall func)) - (funcall (symbol-function 'tempo-forward-mark))) - - -;; Functions used inside the skeleton descriptions. -(defun erlang-skel-skip-blank () - (skip-chars-backward " \t") - nil) - -(defun erlang-skel-include (&rest args) - "Include a template inside another template. - -Example of use, assuming that `erlang-skel-func' is defined: - - (defvar foo-skeleton '(\"%%% New function:\" - (erlang-skel-include erlang-skel-func))) - -Technically, this function returns the `tempo' attribute`(l ...)' which -can contain other `tempo' attributes. Please see the function -`tempo-define-template' for a description of the `(l ...)' attribute." - (let ((res '()) - entry) - (while args - (setq entry (car args)) - (while entry - (setq res (cons (car entry) res)) - (setq entry (cdr entry))) - (setq args (cdr args))) - (cons 'l (nreverse res)))) - -(defvar erlang-skel-separator-length 70) - -(defun erlang-skel-separator (&optional percent) - "Return a comment separator." - (let ((percent (or percent 3))) - (concat (make-string percent ?%) - (make-string (- erlang-skel-separator-length percent) ?-) - "\n"))) - -(defun erlang-skel-double-separator (&optional percent) - "Return a comment separator." - (let ((percent (or percent 3))) - (concat (make-string percent ?%) - (make-string (- erlang-skel-separator-length percent) ?=) - "\n"))) - -(defun erlang-skel-dd-mmm-yyyy () - "Return the current date as a string in \"DD Mon YYYY\" form. -The first character of DD is space if the value is less than 10." - (let ((date (current-time-string))) - (format "%2d %s %s" - (erlang-string-to-int (substring date 8 10)) - (substring date 4 7) - (substring date -4)))) - -;; Indentation code: - -(defun erlang-indent-command (&optional whole-exp) - "Indent current line as Erlang code. -With argument, indent any additional lines of the same clause -rigidly along with this one." - (interactive "P") - (if whole-exp - ;; If arg, always indent this line as Erlang - ;; and shift remaining lines of clause the same amount. - (let ((shift-amt (erlang-indent-line)) - beg end) - (save-excursion - (if erlang-tab-always-indent - (beginning-of-line)) - (setq beg (point)) - (erlang-end-of-clause 1) - (setq end (point)) - (goto-char beg) - (forward-line 1) - (setq beg (point))) - (if (> end beg) - (indent-code-rigidly beg end shift-amt "\n"))) - (if (and (not erlang-tab-always-indent) - (save-excursion - (skip-chars-backward " \t") - (not (bolp)))) - (insert-tab) - (erlang-indent-line)))) - - -(defun erlang-indent-line () - "Indent current line as Erlang code. -Return the amount the indentation changed by." - (let ((pos (- (point-max) (point))) - indent beg - shift-amt) - (beginning-of-line 1) - (setq beg (point)) - (skip-chars-forward " \t") - (cond ((looking-at "%") - (setq indent (funcall comment-indent-function)) - (setq shift-amt (- indent (current-column)))) - (t - (setq indent (erlang-calculate-indent)) - (cond ((null indent) - (setq indent (current-indentation))) - ((eq indent t) - ;; This should never occur here. - (error "Erlang mode error")) - ;;((= (char-syntax (following-char)) ?\)) - ;; (setq indent (1- indent))) - ) - (setq shift-amt (- indent (current-column))))) - (if (zerop shift-amt) - nil - (delete-region beg (point)) - (indent-to indent)) - ;; If initial point was within line's indentation, position - ;; after the indentation. Else stay at same point in text. - (if (> (- (point-max) pos) (point)) - (goto-char (- (point-max) pos))) - (run-hooks 'erlang-indent-line-hook) - shift-amt)) - - -(defun erlang-indent-region (beg end) - "Indent region of Erlang code. - -This is automagically called by the user level function `indent-region'." - (interactive "r") - (save-excursion - (let ((case-fold-search nil) - (continue t) - (from-end (- (point-max) end)) - indent-point;; The beginning of the current line - indent;; The indent amount - state) - (goto-char beg) - (beginning-of-line) - (setq indent-point (point)) - (erlang-beginning-of-clause) - ;; Parse the Erlang code from the beginning of the clause to - ;; the beginning of the region. - (while (< (point) indent-point) - (let ((pt (point))) - (setq state (erlang-partial-parse pt indent-point state)) - (if (= pt (point)) - (error "Illegal syntax")))) - ;; Indent every line in the region - (while continue - (goto-char indent-point) - (skip-chars-forward " \t") - (cond ((looking-at "%") - ;; Do not use our stack to help the user to customize - ;; comment indentation. - (setq indent (funcall comment-indent-function))) - ((looking-at "$") - ;; Don't indent empty lines. - (setq indent 0)) - (t - (setq indent - (save-excursion - (erlang-calculate-stack-indent (point) state))) - (cond ((null indent) - (setq indent (current-indentation))) - ((eq indent t) - ;; This should never occur here. - (error "Erlang mode error")) - ;;((= (char-syntax (following-char)) ?\)) - ;; (setq indent (1- indent))) - ))) - (if (zerop (- indent (current-column))) - nil - (delete-region indent-point (point)) - (indent-to indent)) - ;; Find the next line in the region - (goto-char indent-point) - (save-excursion - (forward-line 1) - (setq indent-point (point))) - (if (>= from-end (- (point-max) indent-point)) - (setq continue nil) - (while (< (point) indent-point) - (let ((pt (point))) - (setq state (erlang-partial-parse - pt indent-point state)) - (if (= pt (point)) - (error "Illegal syntax"))))))))) - - -(defun erlang-indent-current-buffer () - "Indent current buffer as Erlang code." - (interactive) - (save-excursion - (save-restriction - (widen) - (erlang-indent-region (point-min) (point-max))))) - - -(defun erlang-indent-function () - "Indent current Erlang function." - (interactive) - (save-excursion - (let ((end (progn (erlang-end-of-function 1) (point))) - (beg (progn (erlang-beginning-of-function 1) (point)))) - (erlang-indent-region beg end)))) - - -(defun erlang-indent-clause () - "Indent current Erlang clause." - (interactive) - (save-excursion - (let ((end (progn (erlang-end-of-clause 1) (point))) - (beg (progn (erlang-beginning-of-clause 1) (point)))) - (erlang-indent-region beg end)))) - - -(defmacro erlang-push (x stack) (list 'setq stack (list 'cons x stack))) -(defmacro erlang-pop (stack) (list 'setq stack (list 'cdr stack))) -;; Would much prefer to make caddr a macro but this clashes. -(defun erlang-caddr (x) (car (cdr (cdr x)))) - - -(defun erlang-calculate-indent (&optional parse-start) - "Compute appropriate indentation for current line as Erlang code. -Return nil if line starts inside string, t if in a comment." - (save-excursion - (let ((indent-point (point)) - (case-fold-search nil) - (state nil)) - (if parse-start - (goto-char parse-start) - (erlang-beginning-of-clause)) - (while (< (point) indent-point) - (let ((pt (point))) - (setq state (erlang-partial-parse pt indent-point state)) - (if (= pt (point)) - (error "Illegal syntax")))) - (erlang-calculate-stack-indent indent-point state)))) - -(defun erlang-show-syntactic-information () - "Show syntactic information for current line." - - (interactive) - - (save-excursion - (let ((starting-point (point)) - (case-fold-search nil) - (state nil)) - (erlang-beginning-of-clause) - (while (< (point) starting-point) - (setq state (erlang-partial-parse (point) starting-point state))) - (message "%S" state)))) - - -(defun erlang-partial-parse (from to &optional state) - "Parse Erlang syntax starting at FROM until TO, with an optional STATE. -Value is list (stack token-start token-type in-what)." - (goto-char from) ; Start at the beginning - (erlang-skip-blank to) - (let ((cs (char-syntax (following-char))) - (stack (car state)) - (token (point)) - in-what) - (cond - - ;; Done: Return previous state. - ((>= token to) - (setq token (nth 1 state)) - (setq cs (nth 2 state)) - (setq in-what (nth 3 state))) - - ;; Word constituent: check and handle keywords. - ((= cs ?w) - (cond ((looking-at "\\(end\\|after\\)[^_a-zA-Z0-9]") - ;; Must pop top icr layer, `after' will push a new - ;; layer next. - (progn - (while (and stack (eq (car (car stack)) '->)) - (erlang-pop stack)) - (if (and stack (memq (car (car stack)) '(icr begin fun try))) - (erlang-pop stack)))) - ((looking-at "catch\\b.*of") - t) - ((looking-at "catch\\b\\s *\\($\\|%\\|.*->\\)") - ;; Must pop top icr layer, `catch' in try/catch - ;;will push a new layer next. - (progn - (while (and stack (eq (car (car stack)) '->)) - (erlang-pop stack)) - (if (and stack (memq (car (car stack)) '(icr begin try))) - (erlang-pop stack)))) - ) - (cond ((looking-at "\\(if\\|case\\|receive\\)[^_a-zA-Z0-9]") - ;; Must push a new icr (if/case/receive) layer. - (erlang-push (list 'icr token (current-column)) stack)) - ((looking-at "\\(try\\|after\\)[^_a-zA-Z0-9]") - ;; Must handle separately, try catch or try X of -> catch - ;; same for `after', it could be - ;; receive after Time -> X end, or - ;; try after X end - (erlang-push (list 'try token (current-column)) stack)) - ((looking-at "\\(of\\)[^_a-zA-Z0-9]") - ;; Must handle separately, try X of -> catch - (if (and stack (eq (car (car stack)) 'try)) - (let ((try-column (nth 2 (car stack))) - (try-pos (nth 1 (car stack)))) - (erlang-pop stack) - (erlang-push (list 'icr try-pos try-column) stack)))) - - ((looking-at "\\(fun\\)[^_a-zA-Z0-9]") - ;; Push a new layer if we are defining a `fun' - ;; expression, not when we are refering an existing - ;; function. 'fun's defines are only indented one level now. - (if (save-excursion - (goto-char (match-end 1)) - (erlang-skip-blank to) - ;; Use erlang-variable-regexp here to look for an - ;; optional variable name to match EEP37 named funs. - (if (looking-at erlang-variable-regexp) - (progn - (goto-char (match-end 0)) - (erlang-skip-blank to))) - (eq (following-char) ?\()) - (erlang-push (list 'fun token (current-column)) stack))) - ((looking-at "\\(begin\\)[^_a-zA-Z0-9]") - (erlang-push (list 'begin token (current-column)) stack)) - ;; Normal when case - ;;((looking-at "when\\s ") - ;;((looking-at "when\\s *\\($\\|%\\)") - ((looking-at "when[^_a-zA-Z0-9]") - (erlang-push (list 'when token (current-column)) stack)) - ((looking-at "catch\\b.*of") - t) - ((looking-at "catch\\b\\s *\\($\\|%\\|.*->\\)") - (erlang-push (list 'icr token (current-column)) stack)) - ;;(erlang-push (list '-> token (current-column)) stack)) - ;;((looking-at "^of$") - ;; (erlang-push (list 'icr token (current-column)) stack) - ;;(erlang-push (list '-> token (current-column)) stack)) - ) - (forward-sexp 1)) - ;; String: Try to skip over it. (Catch error if not complete.) - ((= cs ?\") - (condition-case nil - (progn - (forward-sexp 1) - (if (> (point) to) - (progn - (setq in-what 'string) - (goto-char to)))) - (error - (setq in-what 'string) - (goto-char to)))) - - ;; Expression prefix e.i. $ or ^ (Note ^ can be in the character - ;; literal $^ or part of string and $ outside of a string denotes - ;; a character literal) - ((= cs ?') - (cond - ((= (following-char) ?\") ;; $ or ^ was the last char in a string - (forward-char 1)) - (t - ;; Maybe a character literal, quote the next char to avoid - ;; situations as $" being seen as the begining of a string. - ;; Note the quoting something in the middle of a string is harmless. - (quote (following-char)) - (forward-char 1)))) - - ;; Symbol constituent or punctuation - - ((memq cs '(?. ?_)) - (cond - - ;; Clause end - ((= (following-char) ?\;) - (if (eq (car (car (last stack))) 'spec) - (while (memq (car (car stack)) '(when ::)) - (erlang-pop stack))) - (if (and stack (eq (car (car stack)) '->)) - (erlang-pop stack)) - (forward-char 1)) - - ;; Parameter separator - ((looking-at ",") - (forward-char 1) - (if (and stack (eq (car (car stack)) '::)) - ;; Type or spec - (erlang-pop stack))) - - ;; Function end - ((looking-at "\\.\\(\\s \\|\n\\|\\s<\\)") - (setq stack nil) - (forward-char 1)) - - ;; Function head - ((looking-at "->") - (if (and stack (eq (car (car stack)) 'when)) - (erlang-pop stack)) - (erlang-push (list '-> token (current-column)) stack) - (forward-char 2)) - - ;; List-comprehension divider - ((looking-at "||") - (erlang-push (list '|| token (current-column)) stack) - (forward-char 2)) - - ;; Bit-syntax open. Note that map syntax allows "<<" to follow ":=" - ;; or "=>" without intervening whitespace, so handle that case here - ((looking-at "\\(:=\\|=>\\)?<<") - (erlang-push (list '<< token (current-column)) stack) - (forward-char (- (match-end 0) (match-beginning 0)))) - - ;; Bit-syntax close - ((looking-at ">>") - (while (memq (car (car stack)) '(|| ->)) - (erlang-pop stack)) - (cond ((eq (car (car stack)) '<<) - (erlang-pop stack)) - ((memq (car (car stack)) '(icr begin fun)) - (error "Missing `end'")) - (t - (error "Unbalanced parentheses"))) - (forward-char 2)) - - ;; Macro - ((= (following-char) ??) - ;; Skip over the ? - (forward-char 1) - ) - - ;; Type spec's - ((looking-at "-type\\s \\|-opaque\\s ") - (if stack - (forward-char 1) - (erlang-push (list 'icr token (current-column)) stack) - (forward-char 6))) - ((looking-at "-spec\\s ") - (if stack - (forward-char 1) - (forward-char 6) - (skip-chars-forward "^(\n") - (erlang-push (list 'spec (point) (current-column)) stack) - )) - - ;; Type spec delimiter - ((looking-at "::") - (erlang-push (list ':: token (current-column)) stack) - (forward-char 2)) - - ;; Don't follow through in the clause below - ;; '|' don't need spaces around it - ((looking-at "|") - (forward-char 1)) - - ;; Other punctuation: Skip over it and any following punctuation - ((= cs ?.) - ;; Skip over all characters in the operand. - (skip-syntax-forward ".")) - - ;; Other char: Skip over it. - (t - (forward-char 1)))) - - ;; Open parenthesis - ((= cs ?\() - (erlang-push (list '\( token (current-column)) stack) - (forward-char 1)) - - ;; Close parenthesis - ((= cs ?\)) - (while (memq (car (car stack)) '(|| -> :: when)) - (erlang-pop stack)) - (cond ((eq (car (car stack)) '\() - (erlang-pop stack) - (if (and (eq (car (car stack)) 'fun) - (or (eq (car (car (last stack))) 'spec) - (eq (car (car (cdr stack))) '::))) ;; -type() - ;; Inside fun type def ') closes fun definition - (erlang-pop stack))) - ((eq (car (car stack)) 'icr) - (erlang-pop stack) - ;; Normal catch not try-catch might have caused icr - ;; and then incr should be removed and is not an error. - (if (eq (car (car stack)) '\() - (erlang-pop stack) - (error "Missing `end'") - )) - ((eq (car (car stack)) 'begin) - (error "Missing `end'")) - (t - (error "Unbalanced parenthesis")) - ) - (forward-char 1)) - - ;; Character quote: Skip it and the quoted char. - ((= cs ?/) - (forward-char 2)) - - ;; Character escape: Skip it and the escape sequence. - ((= cs ?\\) - (forward-char 1) - (skip-syntax-forward "w")) - - ;; Everything else - (t - (forward-char 1))) - (list stack token cs in-what))) - -(defun erlang-calculate-stack-indent (indent-point state) - "From the given last position and state (stack) calculate indentation. -Return nil if inside string, t if in a comment." - (let* ((stack (and state (car state))) - (token (nth 1 state)) - (stack-top (and stack (car stack)))) - (cond ((null state) ;No state - 0) - ((nth 3 state) - ;; Return nil or t. - (eq (nth 3 state) 'comment)) - ((null stack) - (if (looking-at "when[^_a-zA-Z0-9]") - erlang-indent-guard - 0)) - ((eq (car stack-top) '\() - ;; Element of list, tuple or part of an expression, - (cond ((null erlang-argument-indent) - ;; indent to next column. - (1+ (nth 2 stack-top))) - ((= (char-syntax (following-char)) ?\)) - (goto-char (nth 1 stack-top)) - (cond ((looking-at "[({]\\s *\\($\\|%\\)") - ;; Line ends with parenthesis. - (let ((previous (erlang-indent-find-preceding-expr)) - (stack-pos (nth 2 stack-top))) - (if (>= previous stack-pos) stack-pos - (- (+ previous erlang-argument-indent) 1)))) - (t - (nth 2 stack-top)))) - ((= (following-char) ?,) - ;; a comma at the start of the line: line up with opening parenthesis. - (nth 2 stack-top)) - (t - (goto-char (nth 1 stack-top)) - (let ((base (cond ((looking-at "[({]\\s *\\($\\|%\\)") - ;; Line ends with parenthesis. - (erlang-indent-parenthesis (nth 2 stack-top))) - (t - ;; Indent to the same column as the first - ;; argument. - (goto-char (1+ (nth 1 stack-top))) - (skip-chars-forward " \t") - (current-column))))) - (erlang-indent-standard indent-point token base 't))))) - ;; - ((eq (car stack-top) '<<) - ;; Element of binary (possible comprehension) expression, - (cond ((null erlang-argument-indent) - ;; indent to next column. - (+ 2 (nth 2 stack-top))) - ((looking-at "\\(>>\\)[^_a-zA-Z0-9]") - (nth 2 stack-top)) - (t - (goto-char (nth 1 stack-top)) - ;; Indent to the same column as the first - ;; argument. - (goto-char (+ 2 (nth 1 stack-top))) - (skip-chars-forward " \t") - (current-column)))) - - ((memq (car stack-top) '(icr fun spec)) - ;; The default indentation is the column of the option - ;; directly following the keyword. (This does not apply to - ;; `case'.) Should no option be on the same line, the - ;; indentation is the indentation of the keyword + - ;; `erlang-indent-level'. - ;; - ;; `after' should be indented to the same level as the - ;; corresponding receive. - (cond ((looking-at "\\(after\\|of\\)\\($\\|[^_a-zA-Z0-9]\\)") - (nth 2 stack-top)) - ((looking-at "when[^_a-zA-Z0-9]") - ;; Handling one when part - (+ (nth 2 stack-top) erlang-indent-level erlang-indent-guard)) - (t - (save-excursion - (goto-char (nth 1 stack-top)) - (if (looking-at "case[^_a-zA-Z0-9]") - (+ (nth 2 stack-top) erlang-indent-level) - (skip-chars-forward "a-z") - (skip-chars-forward " \t") - (if (memq (following-char) '(?% ?\n)) - (+ (nth 2 stack-top) erlang-indent-level) - (current-column)))))) - ) - ((and (eq (car stack-top) '||) (looking-at "\\(]\\|>>\\)[^_a-zA-Z0-9]")) - (nth 2 (car (cdr stack)))) - ;; Real indentation, where operators create extra indentation etc. - ((memq (car stack-top) '(-> || try begin)) - (if (looking-at "\\(of\\)[^_a-zA-Z0-9]") - (nth 2 stack-top) - (goto-char (nth 1 stack-top)) - ;; Check if there is more code after the '->' on the - ;; same line. If so use this indentation as base, else - ;; use parent indentation + 2 * level as base. - (let ((off erlang-indent-level) - (skip 2)) - (cond ((null (cdr stack))) ; Top level in function. - ((eq (car stack-top) 'begin) - (setq skip 5)) - ((eq (car stack-top) 'try) - (setq skip 5)) - ((eq (car stack-top) '->) - ;; If in fun definition use standard indent level not double - ;;(if (not (eq (car (car (cdr stack))) 'fun)) - ;; Removed it made multi clause fun's look to bad - (setq off (* 2 erlang-indent-level)))) ;; ) - (let ((base (erlang-indent-find-base stack indent-point off skip))) - ;; Special cases - (goto-char indent-point) - (cond ((looking-at "\\(end\\|after\\)\\($\\|[^_a-zA-Z0-9]\\)") - (if (eq (car stack-top) '->) - (erlang-pop stack)) - (if stack - (erlang-caddr (car stack)) - 0)) - ((looking-at "catch\\b\\($\\|[^_a-zA-Z0-9]\\)") - ;; Are we in a try - (let ((start (if (eq (car stack-top) '->) - (car (cdr stack)) - stack-top))) - (if (null start) nil - (goto-char (nth 1 start))) - (cond ((looking-at "try\\($\\|[^_a-zA-Z0-9]\\)") - (progn - (if (eq (car stack-top) '->) - (erlang-pop stack)) - (if stack - (erlang-caddr (car stack)) - 0))) - (t (erlang-indent-standard indent-point token base 'nil))))) ;; old catch - (t - (erlang-indent-standard indent-point token base 'nil) - )))) - )) - ((eq (car stack-top) 'when) - (goto-char (nth 1 stack-top)) - (if (looking-at "when\\s *\\($\\|%\\)") - (progn - (erlang-pop stack) - (if (and stack (memq (nth 0 (car stack)) '(icr fun))) - (progn - (goto-char (nth 1 (car stack))) - (+ (nth 2 (car stack)) erlang-indent-guard - ;; receive XYZ or receive - ;; XYZ - ;; This if thing does not seem to be needed - ;;(if (looking-at "[a-z]+\\s *\\($\\|%\\)") - ;; erlang-indent-level - ;; (* 2 erlang-indent-level)))) - (* 2 erlang-indent-level))) - ;;erlang-indent-level)) - (+ erlang-indent-level erlang-indent-guard))) - ;; "when" is followed by code, let's indent to the same - ;; column. - (forward-char 4) ; Skip "when" - (skip-chars-forward " \t") - (current-column))) - ;; Type and Spec indentation - ((eq (car stack-top) '::) - (if (looking-at "[},)]") - ;; Closing function spec, record definition with types, - ;; or a comma at the start of the line - ;; pop stack and recurse - (erlang-calculate-stack-indent indent-point - (cons (erlang-pop stack) (cdr state))) - (cond ((null erlang-argument-indent) - ;; indent to next column. - (+ 2 (nth 2 stack-top))) - ((looking-at "::[^_a-zA-Z0-9]") - (nth 2 stack-top)) - (t - (let ((start-alternativ (if (looking-at "|") 2 0))) - (goto-char (nth 1 stack-top)) - (- (cond ((looking-at "::\\s *\\($\\|%\\)") - ;; Line ends with :: - (if (eq (car (car (last stack))) 'spec) - (+ (erlang-indent-find-preceding-expr 1) - erlang-argument-indent) - (+ (erlang-indent-find-preceding-expr 2) - erlang-argument-indent))) - (t - ;; Indent to the same column as the first - ;; argument. - (goto-char (+ 2 (nth 1 stack-top))) - (skip-chars-forward " \t") - (current-column))) start-alternativ)))))) - ))) - -(defun erlang-indent-standard (indent-point token base inside-parenthesis) - "Standard indent when in blocks or tuple or arguments. - Look at last thing to see in what state we are, move relative to the base." - (goto-char token) - (cond ((looking-at "||\\|,\\|->\\||") - base) - ((erlang-at-keyword) - (+ (current-column) erlang-indent-level)) - ((or (= (char-syntax (following-char)) ?.) - (erlang-at-operator)) - (+ base erlang-indent-level)) - (t - (goto-char indent-point) - (cond ((memq (following-char) '(?\( )) - ;; Function application. - (+ (erlang-indent-find-preceding-expr) - erlang-argument-indent)) - ;; Empty line, or end; treat it as the end of - ;; the block. (Here we have a choice: should - ;; the user be forced to reindent continued - ;; lines, or should the "end" be reindented?) - - ;; Avoid treating comments a continued line. - ((= (following-char) ?%) - base) - ;; Continued line (e.g. line beginning - ;; with an operator.) - (t - (if (or (erlang-at-operator) (not inside-parenthesis)) - (+ base erlang-indent-level) - base)))))) - -(defun erlang-indent-find-base (stack indent-point &optional offset skip) - "Find the base column for current stack." - (or skip (setq skip 2)) - (or offset (setq offset erlang-indent-level)) - (save-excursion - (let* ((stack-top (car stack))) - (goto-char (nth 1 stack-top)) - (if (< skip (- (point-max) (point))) - (progn - (forward-char skip) - (if (looking-at "\\s *\\($\\|%\\)") - (progn - (if (memq (car stack-top) '(-> ||)) - (erlang-pop stack)) - ;; Take parent identation + offset, - ;; else just erlang-indent-level if no parent - (if stack - (+ (erlang-caddr (car stack)) - offset) - erlang-indent-level)) - (erlang-skip-blank indent-point) - (current-column))) - (+ (current-column) skip))))) - - -;; Does not handle `begin' .. `end'. -(defun erlang-indent-find-preceding-expr (&optional arg) - "Return the first column of the preceding expression. -This assumes that the preceding expression is either simple -\(i.e. an atom) or parenthesized." - (save-excursion - (or arg (setq arg 1)) - (ignore-errors (forward-sexp (- arg))) - (let ((col (current-column))) - (skip-chars-backward " \t") - ;; Special hack to handle: (note line break) - ;; [#myrecord{ - ;; foo = foo}] - ;; where the call (forward-sexp -1) will fail when point is at the `#'. - (or - (ignore-errors - ;; Needed to match the colon in "'foo':'bar'". - (cond ((eq (preceding-char) ?:) - (backward-char 1) - (forward-sexp -1) - (current-column)) - ((eq (preceding-char) ?#) - ;; We may now be at: - ;; - either a construction of a new record - ;; - or update of a record, in which case we want - ;; the column of the expression to be updated. - ;; - ;; To see which of the two cases we are at, we first - ;; move an expression backwards, check for keywords, - ;; then immediately an expression forwards. Moving - ;; backwards skips past tokens like `,' or `->', but - ;; when moving forwards again, we won't skip past such - ;; tokens. We use this: if, after having moved - ;; forwards, we're back where we started, then it was - ;; a record update. - ;; The check for keywords is to detect cases like: - ;; case Something of #record_construction{...} - (backward-char 1) - (let ((record-start (point)) - (record-start-col (current-column))) - (forward-sexp -1) - (let ((preceding-expr-col (current-column)) - ;; white space definition according to erl_scan - (white-space "\000-\040\200-\240")) - (if (erlang-at-keyword) - ;; The (forward-sexp -1) call moved past a keyword - (1+ record-start-col) - (forward-sexp 1) - (skip-chars-forward white-space record-start) - ;; Are we back where we started? If so, it was an update. - (if (= (point) record-start) - preceding-expr-col - (goto-char record-start) - (1+ (current-column))))))) - (t col))) - col)))) - -(defun erlang-indent-parenthesis (stack-position) - (let ((previous (erlang-indent-find-preceding-expr))) - (if (> previous stack-position) - (+ stack-position erlang-argument-indent) - (+ previous erlang-argument-indent)))) - -(defun erlang-skip-blank (&optional lim) - "Skip over whitespace and comments until limit reached." - (or lim (setq lim (point-max))) - (let (stop) - (while (and (not stop) (< (point) lim)) - (cond ((= (following-char) ?%) - (skip-chars-forward "^\n" lim)) - ((= (following-char) ?\n) - (skip-chars-forward "\n" lim)) - ((looking-at "\\s ") - (if (re-search-forward "\\S " lim 'move) - (forward-char -1))) - (t - (setq stop t)))) - stop)) - -(defun erlang-at-keyword () - "Are we looking at an Erlang keyword which will increase indentation?" - (looking-at (concat "\\(when\\|if\\|fun\\|case\\|begin\\|" - "of\\|receive\\|after\\|catch\\|try\\)\\b"))) - -(defun erlang-at-operator () - "Are we looking at an Erlang operator?" - (looking-at - "\\(bnot\\|div\\|mod\\|band\\|bor\\|bxor\\|bsl\\|bsr\\)\\b")) - -(defun erlang-comment-indent () - "Compute Erlang comment indentation. - -Used both by `indent-for-comment' and the Erlang specific indentation -commands." - (cond ((looking-at "%%%") 0) - ((looking-at "%%") - (or (erlang-calculate-indent) - (current-indentation))) - (t - (save-excursion - (skip-chars-backward " \t") - (max (if (bolp) 0 (1+ (current-column))) - comment-column))))) - -;;; Erlang movement commands - -;; All commands below work as movement commands. I.e. if the point is -;; at the end of the clause, and the command `erlang-end-of-clause' is -;; executed, the point is moved to the end of the NEXT clause. (This -;; mimics the behaviour of `end-of-defun'.) -;; -;; Personally I would like to rewrite them to be "pure", and add a set -;; of movement functions, like `erlang-next-clause', -;; `erlang-previous-clause', and the same for functions. -;; -;; The current implementation makes it hopeless to use the functions as -;; subroutines in more complex commands. /andersl - -(defun erlang-beginning-of-clause (&optional arg) - "Move backward to previous start of clause. -With argument, do this that many times. -Return t unless search stops due to end of buffer." - (interactive "p") - (or arg (setq arg 1)) - (if (< arg 0) - ;; Step back to the end of the previous line, unless we are at - ;; the beginning of the buffer. The reason for this move is - ;; that the regexp below includes the last character of the - ;; previous line. - (if (bobp) - (or (looking-at "\n") - (forward-char 1)) - (forward-char -1) - (if (looking-at "\\`\n") - (forward-char 1)))) - ;; The regexp matches a function header that isn't - ;; included in a string. - (and (re-search-forward "\\(\\`\\|\\`\n\\|[^\\]\n\\)\\(-?[a-z]\\|'\\|-\\)" - nil 'move (- arg)) - (let ((beg (match-beginning 2))) - (and beg (goto-char beg)) - t))) - -(defun erlang-end-of-clause (&optional arg) - "Move to the end of the current clause. -With argument, do this that many times." - (interactive "p") - (or arg (setq arg 1)) - (while (and (looking-at "[ \t]*[%\n]") - (zerop (forward-line 1)))) - ;; Move to the next clause. - (erlang-beginning-of-clause (- arg)) - (beginning-of-line);; Just to be sure... - (let ((continue t)) - (while (and (not (bobp)) continue) - (forward-line -1) - (unless (looking-at "[ \t]*[%\n]") - (end-of-line) - (setq continue nil))))) - -(defun erlang-mark-clause () - "Put mark at end of clause, point at beginning." - (interactive) - (push-mark (point)) - (erlang-end-of-clause 1) - ;; Sets the region. In Emacs 19 and XEmacs, we want to activate - ;; the region. - (condition-case nil - (push-mark (point) nil t) - (error (push-mark (point)))) - (erlang-beginning-of-clause 1) - ;; The above function deactivates the mark. - (if (boundp 'deactivate-mark) - (funcall (symbol-function 'set) 'deactivate-mark nil))) - -(defun erlang-beginning-of-function (&optional arg) - "Move backward to previous start of function. -With positive argument, do this that many times. -With negative argument, search forward. - -Return t unless search stops due to end of buffer." - (interactive "p") - (or arg (setq arg 1)) - (cond - ;; Search backward - ((> arg 0) - (while (and (> arg 0) - (and (erlang-beginning-of-clause 1) - (let ((start (point)) - (name (erlang-name-of-function)) - (arity (erlang-get-function-arity))) - ;; Note: "arity" is nil for e.g. "-import", hence - ;; two "-import" clauses are not considered to - ;; be part of the same function. - (while (and (erlang-beginning-of-clause 1) - (string-equal name - (erlang-name-of-function)) - arity - (equal arity - (erlang-get-function-arity))) - (setq start (point))) - (goto-char start) - t))) - (setq arg (1- arg)))) - ;; Search forward - ((< arg 0) - (end-of-line) - (erlang-beginning-of-clause 1) - ;; Step -arg functions forward. - (while (and (< arg 0) - ;; Step one function forward, or stop if the end of - ;; the buffer was reached. Return t if we found the - ;; function. - (let ((name (erlang-name-of-function)) - (arity (erlang-get-function-arity)) - (found (erlang-beginning-of-clause -1))) - (while (and found - (string-equal name (erlang-name-of-function)) - arity - (equal arity - (erlang-get-function-arity))) - (setq found (erlang-beginning-of-clause -1))) - found)) - (setq arg (1+ arg))))) - (zerop arg)) - - -(defun erlang-end-of-function (&optional arg) - "Move forward to next end of function. - -With argument, do this that many times. -With negative argument go towards the beginning of the buffer." - (interactive "p") - (or arg (setq arg 1)) - (let ((first t)) - ;; Forward - (while (and (> arg 0) (< (point) (point-max))) - (let ((pos (point))) - (while (progn - (if (and first - (progn - (forward-char 1) - (erlang-beginning-of-clause 1))) - nil - (or (bobp) (forward-char -1)) - (erlang-beginning-of-clause -1)) - (setq first nil) - (erlang-pass-over-function) - (skip-chars-forward " \t") - (if (looking-at "[%\n]") - (forward-line 1)) - (<= (point) pos)))) - (setq arg (1- arg))) - ;; Backward - (while (< arg 0) - (let ((pos (point))) - (erlang-beginning-of-clause 1) - (erlang-pass-over-function) - (forward-line 1) - (if (>= (point) pos) - (if (erlang-beginning-of-function 2) - (progn - (erlang-pass-over-function) - (skip-chars-forward " \t") - (if (looking-at "[%\n]") - (forward-line 1))) - (goto-char (point-min))))) - (setq arg (1+ arg))))) - -(eval-and-compile - (if (default-boundp 'beginning-of-defun-function) - (defalias 'erlang-mark-function 'mark-defun) - (defun erlang-mark-function () - "Put mark at end of function, point at beginning." - (interactive) - (push-mark (point)) - (erlang-end-of-function 1) - ;; Sets the region. In Emacs 19 and XEmacs, we want to activate - ;; the region. - (condition-case nil - (push-mark (point) nil t) - (error (push-mark (point)))) - (erlang-beginning-of-function 1) - ;; The above function deactivates the mark. - (if (boundp 'deactivate-mark) - (funcall (symbol-function 'set) 'deactivate-mark nil))))) - -(defun erlang-pass-over-function () - (while (progn - (erlang-skip-blank) - (and (not (looking-at "\\.\\(\\s \\|\n\\|\\s<\\)")) - (not (eobp)))) - (forward-sexp 1)) - (if (not (eobp)) - (forward-char 1))) - -(defun erlang-name-of-function () - (save-excursion - ;; Skip over attribute leader. - (if (looking-at "-[ \t]*") - (re-search-forward "-[ \t]*" nil 'move)) - (let ((start (point))) - (forward-sexp 1) - (buffer-substring start (point))))) - - -;;; Miscellaneous - -(defun erlang-fill-paragraph (&optional justify) - "Like \\[fill-paragraph], but handle Erlang comments. -If any of the current line is a comment, fill the comment or the -paragraph of it that point is in, preserving the comment's indentation -and initial `%':s." - (interactive "P") - (let ((has-comment nil) - ;; If has-comment, the appropriate fill-prefix for the comment. - comment-fill-prefix) - ;; Figure out what kind of comment we are looking at. - (save-excursion - (beginning-of-line) - (cond - ;; Find the command prefix. - ((looking-at (concat "\\s *" comment-start-skip)) - (setq has-comment t) - (setq comment-fill-prefix (buffer-substring (match-beginning 0) - (match-end 0)))) - ;; A line with some code, followed by a comment? Remember that the - ;; % which starts the comment shouldn't be part of a string or - ;; character. - ((progn - (while (not (looking-at "%\\|$")) - (skip-chars-forward "^%\n\"\\\\") - (cond - ((eq (char-after (point)) ?\\) (forward-char 2)) - ((eq (char-after (point)) ?\") (forward-sexp 1)))) - (looking-at comment-start-skip)) - (setq has-comment t) - (setq comment-fill-prefix - (concat (make-string (current-column) ? ) - (buffer-substring (match-beginning 0) (match-end 0))))))) - (if (not has-comment) - (fill-paragraph justify) - ;; Narrow to include only the comment, and then fill the region. - (save-restriction - (narrow-to-region - ;; Find the first line we should include in the region to fill. - (save-excursion - (while (and (zerop (forward-line -1)) - (looking-at "^\\s *%"))) - ;; We may have gone to far. Go forward again. - (or (looking-at "^\\s *%") - (forward-line 1)) - (point)) - ;; Find the beginning of the first line past the region to fill. - (save-excursion - (while (progn (forward-line 1) - (looking-at "^\\s *%"))) - (point))) - ;; Lines with only % on them can be paragraph boundaries. - (let ((paragraph-start (concat paragraph-start "\\|^[ \t%]*$")) - (paragraph-separate (concat paragraph-start "\\|^[ \t%]*$")) - (fill-prefix comment-fill-prefix)) - (fill-paragraph justify)))))) - - -(defun erlang-uncomment-region (beg end) - "Uncomment all commented lines in the region." - (interactive "r") - (uncomment-region beg end)) - - -(defun erlang-generate-new-clause () - "Create additional Erlang clause header. - -Parses the source file for the name of the current Erlang function. -Create the header containing the name, A pair of parentheses, -and an arrow. The space between the function name and the -first parenthesis is preserved. The point is placed between -the parentheses." - (interactive) - (let ((name (save-excursion - (and (erlang-beginning-of-clause) - (erlang-get-function-name t)))) - (arrow (save-excursion - (and (erlang-beginning-of-clause) - (erlang-get-function-arrow))))) - (if (or (null arrow) (null name)) - (error "Can't find name of current Erlang function")) - (if (and (bolp) (eolp)) - nil - (end-of-line) - (newline)) - (insert name) - (save-excursion - (insert ") " arrow)) - (if erlang-new-clause-with-arguments - (erlang-clone-arguments)))) - - -(defun erlang-clone-arguments () - "Insert, at the point, the argument list of the previous clause. - -The mark is set at the beginning of the inserted text, the point -at the end." - (interactive) - (let ((args (save-excursion - (beginning-of-line) - (and (erlang-beginning-of-clause) - (erlang-get-function-arguments)))) - (p (point))) - (if (null args) - (error "Can't clone argument list")) - (insert args) - (set-mark p))) - -;;; Information retrieval functions. - -(defun erlang-buffer-substring (beg end) - "Like `buffer-substring-no-properties'. -Although, this function works on all versions of Emacs." - (if (fboundp 'buffer-substring-no-properties) - (funcall (symbol-function 'buffer-substring-no-properties) beg end) - (buffer-substring beg end))) - - -(defun erlang-get-module () - "Return the name of the module as specified by `-module'. - -Return nil if file contains no `-module' attribute." - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (let ((md (match-data))) - (unwind-protect - (if (re-search-forward - (eval-when-compile - (concat "^-module\\s *(\\s *\\(\\(" - erlang-atom-regexp - "\\)?\\)\\s *)\\s *\\.")) - (point-max) t) - (erlang-remove-quotes - (erlang-buffer-substring (match-beginning 1) - (match-end 1))) - nil) - (store-match-data md)))))) - - -(defun erlang-get-module-from-file-name (&optional file) - "Extract the module name from a file name. - -First, the directory part is removed. Second, the part of the file name -matching `erlang-file-name-extension-regexp' is removed. - -Should the match fail, nil is returned. - -By modifying `erlang-file-name-extension-regexp' to match files other -than Erlang source files, Erlang specific functions could be applied on -non-Erlang files. Most notably; the support for Erlang modules in the -tags system could be used by files written in other languages." - (or file (setq file buffer-file-name)) - (if (null file) - nil - (setq file (file-name-nondirectory file)) - (if (string-match erlang-file-name-extension-regexp file) - (substring file 0 (match-beginning 0)) - nil))) - - -;; Used by `erlang-get-export' and `erlang-get-import'. - -(defun erlang-get-function-arity-list () - "Parse list of `function/arity' as used by `-import' and `-export'. - -Point must be before the opening bracket. When the -function returns the point will be placed after the closing bracket. - -The function does not return an error if the list is incorrectly -formatted. - -Return list of (function . arity). The order of the returned list -corresponds to the order of the parsed Erlang list." - (let ((res '())) - (erlang-skip-blank) - (forward-char 1) - (if (not (eq (preceding-char) ?\[)) - '() ; Not looking at an Erlang list. - (while ; Note: `while' has no body. - (progn - (erlang-skip-blank) - (and (looking-at (eval-when-compile - (concat erlang-atom-regexp "/\\([0-9]+\\)\\>"))) - (progn - (setq res (cons - (cons - (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 1) (match-end 1))) - (erlang-string-to-int - (erlang-buffer-substring - (match-beginning - (+ 1 erlang-atom-regexp-matches)) - (match-end - (+ 1 erlang-atom-regexp-matches))))) - res)) - (goto-char (match-end 0)) - (erlang-skip-blank) - (forward-char 1) - ;; Test if there are more exported functions. - (eq (preceding-char) ?,)))))) - (nreverse res))) - - -;;; Note that `-export' and the open parenthesis must be written on -;;; the same line. - -(defun erlang-get-export () - "Return a list of `(function . arity)' as specified by `-export'." - (save-excursion - (goto-char (point-min)) - (let ((md (match-data)) - (res '())) - (unwind-protect - (progn - (while (re-search-forward "^-export\\s *(" (point-max) t) - (erlang-skip-blank) - (setq res (nconc res (erlang-get-function-arity-list)))) - res) - (store-match-data md))))) - - -(defun erlang-get-import () - "Parse an Erlang source file for imported functions. - -Return an alist with module name as car part and list of conses containing -function and arity as cdr part." - (save-excursion - (goto-char (point-min)) - (let ((md (match-data)) - (res '())) - (unwind-protect - (progn - (while (re-search-forward "^-import\\s *(" (point-max) t) - (erlang-skip-blank) - (if (looking-at erlang-atom-regexp) - (let ((module (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 0) - (match-end 0))))) - (goto-char (match-end 0)) - (erlang-skip-blank) - (if (eq (following-char) ?,) - (progn - (forward-char 1) - (erlang-skip-blank) - (let ((funcs (erlang-get-function-arity-list)) - (pair (assoc module res))) - (if pair - (setcdr pair (nconc (cdr pair) funcs)) - (setq res (cons (cons module funcs) - res))))))))) - (nreverse res)) - (store-match-data md))))) - - -(defun erlang-get-function-name (&optional arg) - "Return name of current function, or nil. - -If optional argument is non-nil, everything up to and including -the first `(' is returned. - -Normally used in conjunction with `erlang-beginning-of-clause', e.g.: - (save-excursion - (if (not (eobp)) (forward-char 1)) - (and (erlang-beginning-of-clause) - (erlang-get-function-name t)))" - (let ((n (if arg 0 1))) - (and (looking-at (eval-when-compile - (concat "^" erlang-atom-regexp "\\s *("))) - (erlang-buffer-substring (match-beginning n) (match-end n))))) - - -(defun erlang-get-function-arrow () - "Return arrow of current function, could be \"->\" or nil. - -Normally used in conjunction with `erlang-beginning-of-clause', e.g.: - (save-excursion - (if (not (eobp)) (forward-char 1)) - (and (erlang-beginning-of-clause) - (erlang-get-function-arrow)))" - (and - (save-excursion - (re-search-forward "->" (point-max) t) - (erlang-buffer-substring (- (point) 2) (+ (point) 1))))) - -(defun erlang-get-function-arity () - "Return the number of arguments of function at point, or nil." - (and (looking-at (eval-when-compile - (concat "^" erlang-atom-regexp "\\s *("))) - (save-excursion - (goto-char (match-end 0)) - (condition-case nil - (let ((res 0) - (cont t)) - (while cont - (cond ((eobp) - (setq res nil) - (setq cont nil)) - ((looking-at "\\s *)") - (setq cont nil)) - ((looking-at "\\s *\\($\\|%\\)") - (forward-line 1)) - ((looking-at "\\s *<<[^>]*?>>") - (when (zerop res) - (setq res (+ 1 res))) - (goto-char (match-end 0))) - ((looking-at "\\s *,") - (setq res (+ 1 res)) - (goto-char (match-end 0))) - (t - (when (zerop res) - (setq res (+ 1 res))) - (forward-sexp 1)))) - res) - (error nil))))) - -(defun erlang-get-function-name-and-arity () - "Return the name and arity of the function at point, or nil. -The return value is a string of the form \"foo/1\"." - (let ((name (erlang-get-function-name)) - (arity (erlang-get-function-arity))) - (and name arity (format "%s/%d" name arity)))) - -(defun erlang-get-function-arguments () - "Return arguments of current function, or nil." - (if (not (looking-at (eval-when-compile - (concat "^" erlang-atom-regexp "\\s *(")))) - nil - (save-excursion - (condition-case nil - (let ((start (match-end 0))) - (goto-char (- start 1)) - (forward-sexp) - (erlang-buffer-substring start (- (point) 1))) - (error nil))))) - - -(defun erlang-get-function-under-point () - "Return the module and function under the point, or nil. - -Should no explicit module name be present at the point, the -list of imported functions is searched. - -The following could be returned: - (\"module\" \"function\") -- Both module and function name found. - (nil \"function\") -- No module name was found. - nil -- No function name found - -In the future the list may contain more elements." - (save-excursion - (let ((md (match-data)) - (res nil)) - (if (eq (char-syntax (following-char)) ? ) - (skip-chars-backward " \t")) - (skip-chars-backward "a-zA-Z0-9_:'") - (cond ((looking-at (eval-when-compile - (concat erlang-atom-regexp ":" erlang-atom-regexp))) - (setq res (list - (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 1) (match-end 1))) - (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning (1+ erlang-atom-regexp-matches)) - (match-end (1+ erlang-atom-regexp-matches))))))) - ((looking-at erlang-atom-regexp) - (let ((fk (erlang-remove-quotes - (erlang-buffer-substring - (match-beginning 0) (match-end 0)))) - (mod nil) - (imports (erlang-get-import))) - (while (and imports (null mod)) - (if (assoc fk (cdr (car imports))) - (setq mod (car (car imports))) - (setq imports (cdr imports)))) - (cond ((eq (preceding-char) ?#) - (setq fk (concat "-record(" fk))) - ((eq (preceding-char) ??) - (setq fk (concat "-define(" fk))) - ((and (null mod) (not (member fk erlang-int-bifs))) - (setq mod (erlang-get-module)))) - (setq res (list mod fk))))) - (store-match-data md) - res))) - - -;; TODO: Escape single quotes inside the string without -;; replace-regexp-in-string. -(defun erlang-add-quotes-if-needed (str) - "Return STR, possibly with quotes." - (let ((case-fold-search nil)) ; force string matching to be case sensitive - (if (and (stringp str) - (not (string-match (eval-when-compile - (concat "\\`" erlang-atom-regexp "\\'")) str))) - (progn (if (fboundp 'replace-regexp-in-string) - (setq str (replace-regexp-in-string "'" "\\'" str t t ))) - (concat "'" str "'")) - str))) - - -(defun erlang-remove-quotes (str) - "Return STR without quotes, if present." - (let ((md (match-data))) - (prog1 - (if (string-match "\\`'\\(.*\\)'\\'" str) - (substring str 1 -1) - str) - (store-match-data md)))) - -(defun erlang-match-next-exported-function (max) - "Returns non-nil if there is an exported function in the current -buffer between point and MAX." - (block nil - (while (and (not erlang-inhibit-exported-function-name-face) - (erlang-match-next-function max)) - (when (erlang-last-match-exported-p) - (return (match-data)))))) - -(defun erlang-match-next-function (max) - "Searches forward in current buffer for the next erlang function, -bounded by position MAX." - (re-search-forward erlang-defun-prompt-regexp max 'move-point)) - -(defun erlang-last-match-exported-p () - "Returns non-nil if match-data describes the name and arity of an -exported function." - (save-excursion - (save-match-data - (goto-char (match-beginning 1)) - (erlang-function-exported-p - (erlang-remove-quotes (erlang-get-function-name)) - (erlang-get-function-arity))))) - -(defun erlang-function-exported-p (name arity) - "Returns non-nil if function of name and arity is exported in current buffer." - (save-excursion - (let* ((old-match-data (match-data)) - (exports (erlang-get-export))) - (store-match-data old-match-data) - (member (cons name arity) exports)))) - - -;;; Check module name - -;; The function `write-file', bound to C-x C-w, calls -;; `set-visited-file-name' which clears the hook. :-( -;; To make sure that the hook always is present, we advise -;; `set-visited-file-name'. -(defun erlang-check-module-name-init () - "Initialize the functionality to compare file and module names. - -Unless we have `before-save-hook', we advice the function -`set-visited-file-name' since it clears the variable -`local-write-file-hooks'." - (if (boundp 'before-save-hook) - (add-hook 'before-save-hook 'erlang-check-module-name nil t) - (require 'advice) - (when (fboundp 'ad-advised-definition-p) - (unless (ad-advised-definition-p 'set-visited-file-name) - (defadvice set-visited-file-name (after erlang-set-visited-file-name - activate) - (if (eq major-mode 'erlang-mode) - (add-hook 'local-write-file-hooks 'erlang-check-module-name)))) - (add-hook 'local-write-file-hooks 'erlang-check-module-name)))) - - -(defun erlang-check-module-name () - "If the module name doesn't match file name, ask for permission to change. - -The variable `erlang-check-module-name' controls the behaviour of this -function. It it is nil, this function does nothing. If it is t, the -source is silently changed. If it is set to the atom `ask', the user -is prompted. - -This function is normally placed in the hook `local-write-file-hooks'." - (if erlang-check-module-name - (let ((mn (erlang-add-quotes-if-needed - (erlang-get-module))) - (fn (erlang-add-quotes-if-needed - (erlang-get-module-from-file-name (buffer-file-name))))) - (if (and (stringp mn) (stringp fn)) - (or (string-equal mn fn) - (if (or (eq erlang-check-module-name t) - (y-or-n-p - "Module does not match file name. Modify source? ")) - (save-excursion - (save-restriction - (widen) - (goto-char (point-min)) - (if (re-search-forward - (eval-when-compile - (concat "^-module\\s *(\\s *\\(\\(" - erlang-atom-regexp - "\\)?\\)\\s *)\\s *\\.")) - (point-max) t) - (progn - (goto-char (match-beginning 1)) - (delete-region (match-beginning 1) - (match-end 1)) - (insert fn)))))))))) - ;; Must return nil since it is added to `local-write-file-hook'. - nil) - - -;;; Electric functions. - -(defun erlang-electric-semicolon (&optional arg) - "Insert a semicolon character and possibly a prototype for the next line. - -The variable `erlang-electric-semicolon-criteria' states a criterion, -when fulfilled a newline is inserted, the next line is indented and a -prototype for the next line is inserted. Normally the prototype -consists of \" ->\". Should the semicolon end the clause a new clause -header is generated. - -The variable `erlang-electric-semicolon-insert-blank-lines' controls -the number of blank lines inserted between the current line and new -function header. - -Behaves just like the normal semicolon when supplied with a -numerical arg, point is inside string or comment, or when there are -non-whitespace characters following the point on the current line." - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - (if (or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-semicolon - erlang-electric-commands))) - (erlang-in-literal) - (not (looking-at "\\s *\\(%.*\\)?$")) - (null (erlang-test-criteria-list - erlang-electric-semicolon-criteria))) - (setq erlang-electric-newline-inhibit nil) - (setq erlang-electric-newline-inhibit t) - (undo-boundary) - (erlang-indent-line) - (end-of-line) - (newline) - (if (condition-case nil - (progn (erlang-indent-line) t) - (error (if (bolp) (delete-char -1)))) - (if (not (bolp)) - (save-excursion - (insert " ->")) - (condition-case nil - (progn - (erlang-generate-new-clause) - (if erlang-electric-semicolon-insert-blank-lines - (save-excursion - (beginning-of-line) - (newline - erlang-electric-semicolon-insert-blank-lines)))) - (error (if (bolp) (delete-char -1)))))))) - - -(defun erlang-electric-comma (&optional arg) - "Insert a comma character and possibly a new indented line. -The variable `erlang-electric-comma-criteria' states a criterion, -when fulfilled a newline is inserted and the next line is indented. - -Behaves just like the normal comma when supplied with a -numerical arg, point is inside string or comment, or when there are -non-whitespace characters following the point on the current line." - (interactive "P") - - (self-insert-command (prefix-numeric-value arg)) - - (if (or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-comma erlang-electric-commands))) - (erlang-in-literal) - (not (looking-at "\\s *\\(%.*\\)?$")) - (null (erlang-test-criteria-list - erlang-electric-comma-criteria))) - (setq erlang-electric-newline-inhibit nil) - (setq erlang-electric-newline-inhibit t) - (undo-boundary) - (erlang-indent-line) - (end-of-line) - (newline) - (condition-case nil - (erlang-indent-line) - (error (if (bolp) (delete-char -1)))))) - -(defun erlang-electric-lt (&optional arg) - "Insert a less-than sign, and optionally mark it as an open paren." - - (interactive "p") - - (self-insert-command arg) - - ;; Was this the second char in bit-syntax open (`<<')? - (unless (<= (point) 2) - (save-excursion - (backward-char 2) - (when (and (eq (char-after (point)) ?<) - (not (eq (get-text-property (point) 'category) - 'bitsyntax-open-inner))) - ;; Then mark the two chars... - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-open-outer) - (forward-char 1) - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-open-inner) - ;;...and unmark any subsequent less-than chars. - (forward-char 1) - (while (eq (char-after (point)) ?<) - (remove-text-properties (point) (1+ (point)) - '(category nil)) - (forward-char 1)))))) - -(defun erlang-after-bitsyntax-close () - "Return t if point is immediately after a bit-syntax close parenthesis (`>>')." - (and (>= (point) 3) - (save-excursion - (backward-char 2) - (and (eq (char-after (point)) ?>) - (not (eq (get-text-property (point) 'category) - 'bitsyntax-close-outer)))))) - -(defun erlang-after-arrow () - "Return true if point is immediately after a function arrow (`->')." - (and (>= (point) 2) - (and - (save-excursion - (backward-char) - (eq (char-before (point)) ?-)) - (or (not (listp erlang-electric-commands)) - (memq 'erlang-electric-gt - erlang-electric-commands)) - (not (erlang-in-literal)) - (looking-at "\\s *\\(%.*\\)?$") - (erlang-test-criteria-list erlang-electric-arrow-criteria)))) - - -(defun erlang-electric-gt (&optional arg) - "Insert a greater-than sign, and optionally mark it as a close paren." - - (interactive "p") - - (self-insert-command arg) - - (cond - ;; Did we just write a bit-syntax close (`>>')? - ((erlang-after-bitsyntax-close) - (save-excursion - ;; Then mark the two chars... - (backward-char 2) - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-close-inner) - (forward-char) - (put-text-property (point) (1+ (point)) - 'category 'bitsyntax-close-outer) - ;;...and unmark any subsequent greater-than chars. - (forward-char) - (while (eq (char-after (point)) ?>) - (remove-text-properties (point) (1+ (point)) - '(category nil)) - (forward-char)))) - - ;; Did we just write a function arrow (`->')? - ((erlang-after-arrow) - (let ((erlang-electric-newline-inhibit t)) - (undo-boundary) - (end-of-line) - (newline) - (condition-case nil - (erlang-indent-line) - (error (if (bolp) (delete-char -1)))))) - - ;; Then it's just a plain greater-than. - (t - nil))) - - -(defun erlang-electric-arrow\ off (&optional arg) - "Insert a '>'-sign and possibly a new indented line. - -This command is only `electric' when the `>' is part of an `->' arrow. -The variable `erlang-electric-arrow-criteria' states a sequence of -criteria, which decides when a newline should be inserted and the next -line indented. - -It behaves just like the normal greater than sign when supplied with a -numerical arg, point is inside string or comment, or when there are -non-whitespace characters following the point on the current line. - -After being split/merged into `erlang-after-arrow' and -`erlang-electric-gt', it is now unused and disabled." - (interactive "P") - (let ((prec (preceding-char))) - (self-insert-command (prefix-numeric-value arg)) - (if (or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-arrow - erlang-electric-commands))) - (not (eq prec ?-)) - (erlang-in-literal) - (not (looking-at "\\s *\\(%.*\\)?$")) - (null (erlang-test-criteria-list - erlang-electric-arrow-criteria))) - (setq erlang-electric-newline-inhibit nil) - (setq erlang-electric-newline-inhibit t) - (undo-boundary) - (end-of-line) - (newline) - (condition-case nil - (erlang-indent-line) - (error (if (bolp) (delete-char -1))))))) - - -(defun erlang-electric-newline (&optional arg) - "Break line at point and indent, continuing comment if within one. -The variable `erlang-electric-newline-criteria' states a criterion, -when fulfilled a newline is inserted and the next line is indented. - -Should the current line begin with a comment, and the variable -`comment-multi-line' be non-nil, a new comment start is inserted. - -Should the previous command be another electric command we assume that -the user pressed newline out of old habit, hence we will do nothing." - (interactive "P") - (cond ((and (not arg) - erlang-electric-newline-inhibit - (memq last-command erlang-electric-newline-inhibit-list)) - ()) ; Do nothing! - ((or arg - (and (listp erlang-electric-commands) - (not (memq 'erlang-electric-newline - erlang-electric-commands))) - (null (erlang-test-criteria-list - erlang-electric-newline-criteria))) - (newline (prefix-numeric-value arg))) - (t - (if (and comment-multi-line - (save-excursion - (beginning-of-line) - (looking-at (concat "\\s *" comment-start-skip)))) - (let ((str (buffer-substring - (or (match-end 1) (match-beginning 0)) - (min (match-end 0) (point))))) - (newline) - (undo-boundary) - (insert str)) - (newline) - (undo-boundary) - (indent-according-to-mode))))) - - -(defun erlang-test-criteria-list (criteria) - "Given a list of criterion functions, test if criteria are fulfilled. - -Each element in the criteria list can a function returning nil, t or -the atom `stop'. t means that the criterion is fulfilled, `stop' means -that it isn't fulfilled and that the search should stop, -and nil means continue searching. - -Should the list contain the atom t the criterion is assumed to be -fulfilled, unless preceded by a function returning `stop', of course. - -Should the argument be the atom t instead of a list, the criterion is -assumed to be trivially true. - -Should all functions return nil, the criteria are assumed not to be -fulfilled. - -Return t if criteria fulfilled, nil otherwise." - (if (eq criteria t) - t - (save-excursion - (let ((answer nil)) - (while (and criteria (null answer)) - (if (eq (car criteria) t) - (setq answer t) - (setq answer (funcall (car criteria)))) - (setq criteria (cdr criteria))) - (if (and answer (not (eq answer 'stop))) - t - nil))))) - - -(defun erlang-in-literal (&optional lim) - "Test if point is in string, quoted atom or comment. - -Return one of the three atoms `atom', `string', and `comment'. -Should the point be inside none of the above mentioned types of -context, nil is returned." - (save-excursion - (let* ((lim (or lim (save-excursion - (erlang-beginning-of-clause) - (point)))) - (state (if (fboundp 'syntax-ppss) ; post Emacs 21.3 - (funcall (symbol-function 'syntax-ppss)) - (parse-partial-sexp lim (point))))) - (cond - ((eq (nth 3 state) ?') 'atom) - ((nth 3 state) 'string) - ((nth 4 state) 'comment) - (t nil))))) - - -(defun erlang-at-end-of-function-p () - "Test if point is at end of an Erlang function. - -This function is designed to be a member of a criteria list." - (eq (save-excursion (erlang-skip-blank) (point)) - (save-excursion - (erlang-beginning-of-function -1) (point)))) - - -(defun erlang-at-end-of-clause-p () - "Test if point is at end of an Erlang clause. - -This function is designed to be a member of a criteria list." - (eq (save-excursion (erlang-skip-blank) (point)) - (save-excursion - (erlang-beginning-of-clause -1) (point)))) - - -(defun erlang-stop-when-inside-argument-list () - "Return `stop' if inside parenthesis list, nil otherwise. - -Knows about the list comprehension syntax. When the point is -after `||', `stop' is not returned. - -This function is designed to be a member of a criteria list." - (save-excursion - (condition-case nil - (let ((orig-point (point)) - (state nil)) - (up-list -1) - (if (not (eq (following-char) ?\[)) - 'stop - ;; Do not return `stop' when inside a list comprehension - ;; construction. (The point must be after `||'). - (while (< (point) orig-point) - (let ((pt (point))) - (setq state (erlang-partial-parse pt orig-point state)) - (if (= pt (point)) - (error "Illegal syntax")))) - (if (and (car state) (eq (car (car (car state))) '||)) - nil - 'stop))) - (error - nil)))) - - -(defun erlang-stop-when-at-guard () - "Return `stop' when at function guards. - -This function is designed to be a member of a criteria list." - (save-excursion - (beginning-of-line) - (if (and (looking-at (eval-when-compile - (concat "^" erlang-atom-regexp "\\s *("))) - (not (looking-at - (eval-when-compile - (concat "^" erlang-atom-regexp ".*->"))))) - 'stop - nil))) - - -(defun erlang-stop-when-in-type-spec () - "Return `stop' when in a type spec line. - -This function is designed to be a member of a criteria list." - (save-excursion - (beginning-of-line) - (when (save-match-data (looking-at "-\\(spec\\|type\\|callback\\)")) - 'stop))) - - -(defun erlang-next-lines-empty-p () - "Return non-nil if next lines are empty. - -The variable `erlang-next-lines-empty-threshold' contains the number -of lines required to be empty. - -A line containing only spaces and tabs is considered empty. - -This function is designed to be a member of a criteria list." - (and erlang-next-lines-empty-threshold - (save-excursion - (let ((left erlang-next-lines-empty-threshold) - (cont t)) - (while (and cont (> left 0)) - (forward-line 1) - (setq cont (looking-at "\\s *$")) - (setq left (- left 1))) - cont)))) - - -(defun erlang-at-keyword-end-p () - "Test if next readable token is the keyword end. - -This function is designed to be a member of a criteria list." - (save-excursion - (erlang-skip-blank) - (looking-at "end[^_a-zA-Z0-9]"))) - - -;; Erlang tags support which is aware of erlang modules. -;; -;; Not yet implemented under XEmacs. (Hint: The Emacs 19 etags -;; package works under XEmacs.) - -(eval-when-compile - (if (or (featurep 'bytecomp) - (featurep 'byte-compile)) - (progn - (require 'etags)))) - - -;; Variables: - -(defvar erlang-tags-function-alist - '((find-tag . erlang-find-tag) - (find-tag-other-window . erlang-find-tag-other-window) - (find-tag-regexp . erlang-find-tag-regexp) - (find-tag-other-frame . erlang-find-tag-other-frame)) - "Alist of old tags commands and the replacement functions.") - -(defvar erlang-tags-installed nil - "Non-nil when the Erlang tags system is installed.") -(defvar erlang-tags-file-list '() - "List of files in tag list. Used when finding tag on form `module:'.") -(defvar erlang-tags-completion-table nil - "Like `tags-completion-table', this table contains `tag' and `module:tag'.") -(defvar erlang-tags-buffer-installed-p nil - "Non-nil when Erlang module recognising functions installed.") -(defvar erlang-tags-buffer-list '() - "Temporary list of buffers.") -(defvar erlang-tags-orig-completion-table nil - "Temporary storage for `tags-completion-table'.") -(defvar erlang-tags-orig-tag-order nil - "Temporary storage for `find-tag-tag-order'.") -(defvar erlang-tags-orig-regexp-tag-order nil - "Temporary storage for `find-tag-regexp-tag-order'.") -(defvar erlang-tags-orig-search-function nil - "Temporary storage for `find-tag-search-function'.") -(defvar erlang-tags-orig-regexp-search-function nil - "Temporary storage for `find-tag-regexp-search-function'.") -(defvar erlang-tags-orig-format-hooks nil - "Temporary storage for `tags-table-format-hooks'.") ;v19 -(defvar erlang-tags-orig-format-functions nil - "Temporary storage for `tags-table-format-functions'.") ;v > 19 - -(defun erlang-tags-init () - "Install an alternate version of tags, aware of Erlang modules. - -After calling this function, the tags functions are aware of -Erlang modules. Tags can be entered on the for `module:tag' as well -as on the old form `tag'. - -In the completion list, `module:tag' and `module:' shows up. - -This function only works under Emacs 18 and Emacs 19. Currently, It -is not implemented under XEmacs. (Hint: The Emacs 19 etags module -works under XEmacs.)" - (interactive) - (cond ((= erlang-emacs-major-version 18) - (require 'tags) - (erlang-tags-define-keys (current-local-map)) - (setq erlang-tags-installed t)) - (t - (require 'etags) - (set (make-local-variable 'find-tag-default-function) - 'erlang-find-tag-for-completion) - (if (>= emacs-major-version 25) - (add-hook 'xref-backend-functions - #'erlang-etags--xref-backend nil t) - ;; Test on a function available in the Emacs 19 version - ;; of tags but not in the XEmacs version. - (when (fboundp 'find-tag-noselect) - (erlang-tags-define-keys (current-local-map)) - (setq erlang-tags-installed t)))))) - - - -;; Set all keys bound to `find-tag' et.al. in the global map and the -;; menu to `erlang-find-tag' et.al. in `map'. -;; -;; The function `substitute-key-definition' does not work properly -;; in all version of Emacs. - -(defun erlang-tags-define-keys (map) - "Bind tags commands to keymap MAP aware of Erlang modules." - (let ((alist erlang-tags-function-alist)) - (while alist - (let* ((old (car (car alist))) - (new (cdr (car alist))) - (keys (append (where-is-internal old global-map)))) - (while keys - (define-key map (car keys) new) - (setq keys (cdr keys)))) - (setq alist (cdr alist)))) - ;; Update the menu. - (erlang-menu-substitute erlang-menu-base-items erlang-tags-function-alist) - (erlang-menu-init)) - - -(defun erlang-find-tag-default () - "Return the default tag. -Search `-import' list of imported functions. -Single quotes are been stripped away." - (let ((mod-func (erlang-get-function-under-point))) - (cond ((null mod-func) - nil) - ((null (car mod-func)) - (nth 1 mod-func)) - (t - (concat (car mod-func) ":" (nth 1 mod-func)))))) - - -;; Return `t' since it is used inside `tags-loop-form'. -;;;###autoload -(defun erlang-find-tag (modtagname &optional next-p regexp-p) - "Like `find-tag'. Capable of retrieving Erlang modules. - -Tags can be given on the forms `tag', `module:', `module:tag'." - (interactive (erlang-tag-interactive "Find `module:tag' or `tag': ")) - (switch-to-buffer (erlang-find-tag-noselect modtagname next-p regexp-p)) - t) - - -;; Code mainly from `find-tag-other-window' in `etags.el'. -;;;###autoload -(defun erlang-find-tag-other-window (tagname &optional next-p regexp-p) - "Like `find-tag-other-window' but aware of Erlang modules." - (interactive (erlang-tag-interactive - "Find `module:tag' or `tag' other window: ")) - - ;; This is to deal with the case where the tag is found in the - ;; selected window's buffer; without this, point is moved in both - ;; windows. To prevent this, we save the selected window's point - ;; before doing find-tag-noselect, and restore it afterwards. - (let* ((window-point (window-point (selected-window))) - (tagbuf (erlang-find-tag-noselect tagname next-p regexp-p)) - (tagpoint (progn (set-buffer tagbuf) (point)))) - (set-window-point (prog1 - (selected-window) - (switch-to-buffer-other-window tagbuf) - ;; We have to set this new window's point; it - ;; might already have been displaying a - ;; different portion of tagbuf, in which case - ;; switch-to-buffer-other-window doesn't set - ;; the window's point from the buffer. - (set-window-point (selected-window) tagpoint)) - window-point))) - - -(defun erlang-find-tag-other-frame (tagname &optional next-p) - "Like `find-tag-other-frame' but aware of Erlang modules." - (interactive (erlang-tag-interactive - "Find `module:tag' or `tag' other frame: ")) - (let ((pop-up-frames t)) - (erlang-find-tag-other-window tagname next-p))) - - -(defun erlang-find-tag-regexp (regexp &optional next-p other-window) - "Like `find-tag-regexp' but aware of Erlang modules." - (interactive (if (fboundp 'find-tag-regexp) - (erlang-tag-interactive - "Find `module:regexp' or `regexp': ") - (error "This version of Emacs can't find tags by regexps"))) - (funcall (if other-window - 'erlang-find-tag-other-window - 'erlang-find-tag) - regexp next-p t)) - - -;; Just like C-u M-. This could be added to the menu. -(defun erlang-find-next-tag () - "Find next tag, like \\[find-tag] with prefix arg." - (interactive) - (let ((current-prefix-arg '(4))) - (if erlang-tags-installed - (call-interactively 'erlang-find-tag) - (call-interactively 'find-tag)))) - - -;; Mimics `find-tag-noselect' found in `etags.el', but uses `find-tag' to -;; be compatible with `tags.el'. -;; -;; Handles three cases: -;; * `module:' Loop over all possible file names. Stop if a file-name -;; without extension and directory matches the module. -;; -;; * `module:tag' -;; Emacs 19: Replace test functions with functions aware of -;; Erlang modules. Tricky because the etags system wasn't -;; built for these kind of operations... -;; -;; Emacs 18: We loop over `find-tag' until we find a file -;; whose module matches the requested module. The -;; drawback is that a lot of files could be loaded into -;; Emacs. -;; -;; * `tag' Just give it to `find-tag'. - -(defun erlang-find-tag-noselect (modtagname &optional next-p regexp-p) - "Like `find-tag-noselect' but aware of Erlang modules." - (interactive (erlang-tag-interactive "Find `module:tag' or `tag': ")) - (or modtagname - (setq modtagname (symbol-value 'last-tag))) - (funcall (symbol-function 'set) 'last-tag modtagname) - ;; `tags.el' uses this variable to record how M-, would - ;; know where to restart a tags command. - (if (boundp 'tags-loop-form) - (funcall (symbol-function 'set) - 'tags-loop-form '(erlang-find-tag nil t))) - (save-window-excursion - (cond - ((string-match ":$" modtagname) - ;; Only the module name was given. Read all files whose file name - ;; match. - (let ((modname (substring modtagname 0 (match-beginning 0))) - (file nil)) - (if (not next-p) - (save-excursion - (visit-tags-table-buffer) - (setq erlang-tags-file-list - (funcall (symbol-function 'tags-table-files))))) - (while (null file) - (or erlang-tags-file-list - (save-excursion - (if (and (featurep 'etags) - (funcall - (symbol-function 'visit-tags-table-buffer) 'same) - (funcall - (symbol-function 'visit-tags-table-buffer) t)) - (setq erlang-tags-file-list - (funcall (symbol-function 'tags-table-files))) - (error "No %stags containing %s" (if next-p "more " "") - modtagname)))) - (if erlang-tags-file-list - (let ((this-module (erlang-get-module-from-file-name - (car erlang-tags-file-list)))) - (if (and (stringp this-module) - (string= modname this-module)) - (setq file (car erlang-tags-file-list))) - (setq erlang-tags-file-list (cdr erlang-tags-file-list))))) - (set-buffer (or (get-file-buffer file) - (find-file-noselect file))))) - - ((string-match ":" modtagname) - (if (boundp 'find-tag-tag-order) - ;; Method one: Add module-recognising functions to the - ;; list of order functions. However, the tags system - ;; from Emacs 18, and derives thereof (read: XEmacs) - ;; hasn't got this feature. - (progn - (erlang-tags-install-module-check) - (unwind-protect - (funcall (symbol-function 'find-tag) - modtagname next-p regexp-p) - (erlang-tags-remove-module-check))) - ;; Method two: Call the tags system until a file matching - ;; the module is found. This could result in that many - ;; files are read. (e.g. The tag "foo:file" will take a - ;; while to process.) - (let* ((modname (substring modtagname 0 (match-beginning 0))) - (tagname (substring modtagname (match-end 0) nil)) - (last-tag tagname) - file) - (while - (progn - (funcall (symbol-function 'find-tag) tagname next-p regexp-p) - (setq next-p t) - ;; Determine the module form the file name. (The - ;; alternative, to check `-module', would make this - ;; code useless for non-Erlang programs.) - (setq file (erlang-get-module-from-file-name buffer-file-name)) - (not (and (stringp file) - (string= modname file)))))))) - (t - (funcall (symbol-function 'find-tag) modtagname next-p regexp-p))) - (current-buffer))) ; Return the new buffer. - - - - - - - -;; Process interactive arguments for erlang-find-tag-*. -;; -;; Negative arguments work only for `etags', not `tags'. This is not -;; a problem since negative arguments means step back into the -;; history list, a feature not implemented in `tags'. - -(defun erlang-tag-interactive (prompt) - (condition-case nil - (require 'etags) - (error - (require 'tags))) - (if current-prefix-arg - (list nil (if (< (prefix-numeric-value current-prefix-arg) 0) - '- - t)) - (let* ((default (erlang-find-tag-default)) - (prompt (if default - (format "%s(default %s) " prompt default) - prompt)) - (spec (if (featurep 'etags) - (completing-read prompt 'erlang-tags-complete-tag) - (read-string prompt)))) - (list (if (equal spec "") - (or default (error "There is no default tag")) - spec))))) - - -;; Search tag functions which are aware of Erlang modules. The tactic -;; is to store new search functions into the local variables of the -;; TAGS buffers. The variables are restored directly after the -;; search. The situation is complicated by the fact that new TAGS -;; files can be loaded during the search. -;; - -(defun erlang-tags-install-module-check () - "Install our own tag search functions." - ;; Make sure our functions are installed in TAGS files loaded - ;; into Emacs while searching. - (cond - ((>= erlang-emacs-major-version 20) - (setq erlang-tags-orig-format-functions - (symbol-value 'tags-table-format-functions)) - (funcall (symbol-function 'set) 'tags-table-format-functions - (cons 'erlang-tags-recognize-tags-table - erlang-tags-orig-format-functions)) - (setq erlang-tags-buffer-list '()) - ) - (t - (setq erlang-tags-orig-format-hooks - (symbol-value 'tags-table-format-hooks)) - (funcall (symbol-function 'set) 'tags-table-format-hooks - (cons 'erlang-tags-recognize-tags-table - erlang-tags-orig-format-hooks)) - (setq erlang-tags-buffer-list '()) - )) - - ;; Install our functions in the TAGS files already resident. - (save-excursion - (let ((files (symbol-value 'tags-table-computed-list))) - (while files - (if (stringp (car files)) - (if (get-file-buffer (car files)) - (progn - (set-buffer (get-file-buffer (car files))) - (erlang-tags-install-local)))) - (setq files (cdr files)))))) - - -(defun erlang-tags-install-local () - "Install our tag search functions in current buffer." - (if erlang-tags-buffer-installed-p - () - ;; Mark this buffer as "installed" and record. - (set (make-local-variable 'erlang-tags-buffer-installed-p) t) - (setq erlang-tags-buffer-list - (cons (current-buffer) erlang-tags-buffer-list)) - - ;; Save the original values. - (set (make-local-variable 'erlang-tags-orig-tag-order) - (symbol-value 'find-tag-tag-order)) - (set (make-local-variable 'erlang-tags-orig-regexp-tag-order) - (symbol-value 'find-tag-regexp-tag-order)) - (set (make-local-variable 'erlang-tags-orig-search-function) - (symbol-value 'find-tag-search-function)) - (set (make-local-variable 'erlang-tags-orig-regexp-search-function) - (symbol-value 'find-tag-regexp-search-function)) - - ;; Install our own functions. - (set (make-local-variable 'find-tag-search-function) - 'erlang-tags-search-forward) - (set (make-local-variable 'find-tag-regexp-search-function) - 'erlang-tags-regexp-search-forward) - (set (make-local-variable 'find-tag-tag-order) - (mapcar #'erlang-make-order-function-aware-of-modules - erlang-tags-orig-tag-order)) - (set (make-local-variable 'find-tag-regexp-tag-order) - (mapcar #'erlang-make-order-function-aware-of-modules - erlang-tags-orig-regexp-tag-order)))) - -(defun erlang-make-order-function-aware-of-modules (f) - `(lambda (tag) - (let (mod) - (when (string-match ":" tag) - (setq mod (substring tag 0 (match-beginning 0))) - (setq tag (substring tag (match-end 0) nil))) - (and (funcall ',f tag) - (or (null mod) - (erlang-tag-at-point-match-module-p mod)))))) - -(defun erlang-tag-at-point-match-module-p (mod) - (string-equal mod (erlang-get-module-from-file-name - (funcall (symbol-function 'file-of-tag))))) - - -(defun erlang-tags-remove-module-check () - "Remove our own tags search functions." - (cond - ((>= erlang-emacs-major-version 20) - (funcall (symbol-function 'set) - 'tags-table-format-functions - erlang-tags-orig-format-functions) - ) - (t - (funcall (symbol-function 'set) - 'tags-table-format-hooks - erlang-tags-orig-format-hooks) - )) - - ;; Remove our functions from the TAGS files. (Note that - ;; `tags-table-computed-list' need not be the same list as when - ;; the search was started.) - (save-excursion - (let ((buffers erlang-tags-buffer-list)) - (while buffers - (if (buffer-name (car buffers)) - (progn - (set-buffer (car buffers)) - (erlang-tags-remove-local))) - (setq buffers (cdr buffers)))))) - - -(defun erlang-tags-remove-local () - "Remove our tag search functions from current buffer." - (if (null erlang-tags-buffer-installed-p) - () - (funcall (symbol-function 'set) 'erlang-tags-buffer-installed-p nil) - (funcall (symbol-function 'set) - 'find-tag-tag-order erlang-tags-orig-tag-order) - (funcall (symbol-function 'set) - 'find-tag-regexp-tag-order erlang-tags-orig-regexp-tag-order) - (funcall (symbol-function 'set) - 'find-tag-search-function erlang-tags-orig-search-function) - (funcall (symbol-function 'set) - 'find-tag-regexp-search-function - erlang-tags-orig-regexp-search-function))) - - -(defun erlang-tags-recognize-tags-table () - "Install our functions in all loaded TAGS files. - -This function is added to `tags-table-format-hooks/functions' when searching -for a tag on the form `module:tag'." - (if (null (funcall (symbol-function 'etags-recognize-tags-table))) - nil - (erlang-tags-install-local) - t)) - - -(defun erlang-tags-search-forward (tag &optional bound noerror count) - "Forward search function, aware of Erlang module prefix." - (if (string-match ":" tag) - (setq tag (substring tag (match-end 0) nil))) - ;; Avoid unintended recursion. - (if (eq erlang-tags-orig-search-function 'erlang-tags-search-forward) - (search-forward tag bound noerror count) - (funcall erlang-tags-orig-search-function tag bound noerror count))) - - -(defun erlang-tags-regexp-search-forward (tag &optional bound noerror count) - "Forward regexp search function, aware of Erlang module prefix." - (if (string-match ":" tag) - (setq tag (substring tag (match-end 0) nil))) - (if (eq erlang-tags-orig-regexp-search-function - 'erlang-tags-regexp-search-forward) - (re-search-forward tag bound noerror count) - (funcall erlang-tags-orig-regexp-search-function - tag bound noerror count))) - -;;; Tags completion, Emacs 19 `etags' specific. -;;; -;;; The basic idea is to create a second completion table `erlang-tags- -;;; completion-table' containing all normal tags plus tags on the form -;;; `module:tag' and `module:'. - -(when (and (locate-library "etags") - (require 'etags) - (fboundp 'etags-tags-completion-table) - (fboundp 'tags-lazy-completion-table)) ; Emacs 23.1+ - (if (fboundp 'advice-add) - ;; Emacs 24.4+ - (advice-add 'etags-tags-completion-table :around - #'erlang-etags-tags-completion-table-advice) - ;; Emacs 23.1-24.3 - (defadvice etags-tags-completion-table (around - erlang-replace-tags-table - activate) - (if erlang-replace-etags-tags-completion-table - (setq ad-return-value (erlang-etags-tags-completion-table)) - ad-do-it)))) - -(defun erlang-etags-tags-completion-table-advice (oldfun) - (if erlang-replace-etags-tags-completion-table - (erlang-etags-tags-completion-table) - (funcall oldfun))) - -(defun erlang-complete-tag () - "Perform tags completion on the text around point. -Completes to the set of names listed in the current tags table. - -Should the Erlang tags system be installed this command knows -about Erlang modules." - (interactive) - (condition-case nil - (require 'etags) - (error nil)) - (cond ((and (fboundp 'etags-tags-completion-table) - (fboundp 'tags-lazy-completion-table)) ; Emacs 23.1+ - (let ((erlang-replace-etags-tags-completion-table t)) - (complete-tag))) - ((and erlang-tags-installed - (fboundp 'complete-tag) - (fboundp 'tags-complete-tag)) ; Emacs 19-22 - (let ((orig-tags-complete-tag (symbol-function 'tags-complete-tag))) - (fset 'tags-complete-tag - (symbol-function 'erlang-tags-complete-tag)) - (unwind-protect - (complete-tag) - (fset 'tags-complete-tag orig-tags-complete-tag)))) - ((fboundp 'complete-tag) ; Emacs 19 - (complete-tag)) - ((fboundp 'tag-complete-symbol) ; XEmacs - (funcall (symbol-function 'tag-complete-symbol))) - (t - (error "This version of Emacs can't complete tags")))) - - -(defun erlang-find-tag-for-completion () - (let ((start (save-excursion - (skip-chars-backward "[:word:][:digit:]_:'") - (point)))) - (unless (eq start (point)) - (buffer-substring-no-properties start (point))))) - - -;; Based on `tags-complete-tag', but this one uses -;; `erlang-tags-completion-table' instead of `tags-completion-table'. -;; -;; This is the entry-point called by system function `completing-read'. -;; -;; Used for minibuffer completion in Emacs 19-24 and completion in -;; erlang buffers in Emacs 19-22. -(defun erlang-tags-complete-tag (string predicate what) - (with-current-buffer (window-buffer (minibuffer-selected-window)) - (save-excursion - ;; If we need to ask for the tag table, allow that. - (let ((enable-recursive-minibuffers t)) - (visit-tags-table-buffer)) - (if (eq what t) - (all-completions string (erlang-tags-completion-table) predicate) - (try-completion string (erlang-tags-completion-table) predicate))))) - - -;; `tags-completion-table' calls itself recursively, make it -;; call our own wedge instead. Note that the recursive call -;; is very rare; it only occurs when a tags-file contains -;; `include'-statements. -(defun erlang-tags-completion-table () - "Build completion table. Tags on the form `tag' or `module:tag'." - (setq erlang-tags-orig-completion-table - (symbol-function 'tags-completion-table)) - (fset 'tags-completion-table - (symbol-function 'erlang-tags-completion-table-1)) - (unwind-protect - (erlang-tags-completion-table-1) - (fset 'tags-completion-table - erlang-tags-orig-completion-table))) - -(defun erlang-tags-completion-table-1 () - (make-local-variable 'erlang-tags-completion-table) - (or erlang-tags-completion-table - (let ((tags-completion-table nil) - (tags-completion-table-function - 'erlang-etags-tags-completion-table)) - (funcall erlang-tags-orig-completion-table) - (setq erlang-tags-completion-table tags-completion-table)))) - - - -;; Emacs 25 expects this function to return a list (and it is ok for -;; it to include duplicates). Older emacsen expects an obarray. -(defun erlang-etags-tags-completion-table () - (if (>= emacs-major-version 25) - (erlang-etags-tags-completion-table-list) - (let ((obarray (make-vector 511 0))) - (dolist (tag (erlang-etags-tags-completion-table-list)) - (intern tag obarray)) - obarray))) - -;; Based on `etags-tags-completion-table'. The difference is that we -;; add three strings to the list, the tag, module: and module:tag. -;; The module is extracted from the file name of a tag. (This one -;; only works if we are looking at an `etags' file. However, this is -;; the only format supported by Emacs, so far.) -(defun erlang-etags-tags-completion-table-list () - (let ((progress-reporter - (make-progress-reporter - (format "Making tags completion table for %s..." buffer-file-name) - (point-min) (point-max))) - table module) - (save-excursion - (goto-char (point-min)) - (while (progn - (while (and (eq (following-char) ?\f) - (looking-at "\f\n\\([^,\n]*\\),.*\n")) - (let ((file (buffer-substring (match-beginning 1) - (match-end 1)))) - (setq module (erlang-get-module-from-file-name file)) - (when module - (push (concat module ":") table) - (push (concat module ":module_info") table)) - (forward-line 2))) - ;; This regexp matches an explicit tag name or the - ;; place where it would start. - (re-search-forward - "[\f\t\n\r()=,; ]?\177\\\(?:\\([^\n\001]+\\)\001\\)?" - nil t)) - (let ((tag (if (match-beginning 1) - ;; There is an explicit tag name. - (buffer-substring (match-beginning 1) (match-end 1)) - ;; No explicit tag name. Backtrack a little, - ;; and look for the implicit one. - (goto-char (match-beginning 0)) - (skip-chars-backward "^\f\t\n\r()=,; ") - (buffer-substring (point) (match-beginning 0))))) - (forward-line 1) - (push tag table) - (when (stringp module) - (push (concat module ":" tag) table)) - (progress-reporter-update progress-reporter (point))))) - table)) - - - - -;;; Xref backend erlang-etags - -;; In GNU Emacs 25 xref was introduced. It is a framework for cross -;; referencing commands, in particular commands for finding -;; definitions. It does not replace etags. It rather resides on top -;; of it and provides user-friendly commands. The idea is that the -;; user commands should be the same regardless of what backend does -;; the actual finding of definitions. - -;; The backend below is a wrapper around the built-in etags backend. -;; It adds awareness of the module:tag syntax in a similar way that is -;; done above for the old etags commands. - - -(defun erlang-etags--xref-backend () 'erlang-etags) - -(defun erlang-soft-require (feature) - (when (locate-library (symbol-name feature)) - (require feature))) - -(and (erlang-soft-require 'xref) - (erlang-soft-require 'cl-generic) - ;; The purpose of using eval here is to avoid compilation - ;; warnings in emacsen without cl-defmethod. - (eval - '(progn - (cl-defmethod xref-backend-identifier-at-point - ((_backend (eql erlang-etags))) - (erlang-find-tag-default)) - - (cl-defmethod xref-backend-definitions - ((_backend (eql erlang-etags)) identifier) - (erlang-xref-find-definitions identifier)) - - (cl-defmethod xref-backend-apropos - ((_backend (eql erlang-etags)) identifier) - (erlang-xref-find-definitions identifier t)) - - (cl-defmethod xref-backend-identifier-completion-table - ((_backend (eql erlang-etags))) - (let ((erlang-replace-etags-tags-completion-table t)) - (tags-completion-table)))))) - - - - -(defun erlang-xref-find-definitions (identifier &optional is-regexp) - (let ((id-list (split-string identifier ":"))) - (cond - ;; Handle "tag" - ((null (cdr id-list)) - (erlang-xref-find-definitions-tag identifier is-regexp)) - ;; Handle "module:" - ((string-equal (cadr id-list) "") - (erlang-xref-find-definitions-module (car id-list))) - ;; Handle "module:tag" - (t - (erlang-xref-find-definitions-module-tag (car id-list) - (cadr id-list) - is-regexp))))) - -(defun erlang-xref-find-definitions-tag (tag is-regexp) - "Find all definitions of TAG and reorder them so that -definitions in the currently visited file comes first." - (when (fboundp 'etags--xref-find-definitions) - (let* ((current-file (and (buffer-file-name) - (file-truename (buffer-file-name)))) - (xrefs (etags--xref-find-definitions tag is-regexp)) - local-xrefs non-local-xrefs) - (while xrefs - (if (string-equal (erlang-xref-truename-file (car xrefs)) - current-file) - (push (car xrefs) local-xrefs) - (push (car xrefs) non-local-xrefs)) - (setq xrefs (cdr xrefs))) - (append (reverse local-xrefs) - (reverse non-local-xrefs))))) - -(defun erlang-xref-find-definitions-module (module) - (and (fboundp 'xref-make) - (fboundp 'xref-make-file-location) - (let* ((first-time t) - xrefs matching-files) - (save-excursion - (while (visit-tags-table-buffer (not first-time)) - (setq first-time nil) - (let ((files (tags-table-files))) - (while files - (let* ((file (car files)) - (m (erlang-get-module-from-file-name file))) - (when (and m (string-equal m module)) - (unless (member file matching-files) - (push file - matching-files) - (push (xref-make file - (xref-make-file-location file 1 0)) - xrefs)))) - (setq files (cdr files)))))) - (nreverse xrefs)))) - -(defun erlang-xref-find-definitions-module-tag (module tag is-regexp) - "Find all definitions of TAG and filter away definitions -outside of MODULE." - (when (fboundp 'etags--xref-find-definitions) - (let ((xrefs (etags--xref-find-definitions tag is-regexp)) - xrefs-in-module) - (while xrefs - (when (string-equal module (erlang-xref-module (car xrefs))) - (push (car xrefs) xrefs-in-module)) - (setq xrefs (cdr xrefs))) - xrefs-in-module))) - -(defun erlang-xref-module (xref) - (erlang-get-module-from-file-name (erlang-xref-file xref))) - -(defun erlang-xref-truename-file (xref) - (let ((file (erlang-xref-file xref))) - (and file - (file-truename file)))) - -(defun erlang-xref-file (xref) - (and (fboundp 'xref-location-group) - (fboundp 'xref-item-location) - (xref-location-group (xref-item-location xref)))) - - - -;;; -;;; Prepare for other methods to run an Erlang slave process. -;;; - -(defvar erlang-shell-function 'inferior-erlang - "Command to execute start a new Erlang shell. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-shell-display-function 'inferior-erlang-run-or-select - "Command to execute to display Erlang shell. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-compile-function 'inferior-erlang-compile - "Command to execute to compile current buffer. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-compile-erlang-function "c" - "Erlang function to call to compile an erlang file.") - -(defvar erlang-compile-display-function 'inferior-erlang-run-or-select - "Command to execute to view last compilation. - -Change this variable to use your favorite -Erlang compilation package.") - -(defvar erlang-next-error-function 'inferior-erlang-next-error - "Command to execute to go to the next error. - -Change this variable to use your favorite Erlang compilation -package. Not used in Emacs 21.") - - -;;;###autoload -(defun erlang-shell () - "Start a new Erlang shell. - -The variable `erlang-shell-function' decides which method to use, -default is to start a new Erlang host. It is possible that, in the -future, a new shell on an already running host will be started." - (interactive) - (call-interactively erlang-shell-function)) - - -;;;###autoload (autoload 'run-erlang "erlang" "Start a new Erlang shell." t) - -;; It is customary for Emacs packages to supply a function on this -;; form, even though it violates the `erlang-*' name convention. -(defalias 'run-erlang 'erlang-shell) - - -(defun erlang-shell-display () - "Display an Erlang shell, or start a new." - (interactive) - (call-interactively erlang-shell-display-function)) - - -;;;###autoload -(defun erlang-compile () - "Compile Erlang module in current buffer." - (interactive) - (call-interactively erlang-compile-function)) - - -(defun erlang-compile-display () - "Display compilation output." - (interactive) - (call-interactively erlang-compile-display-function)) - - -(defun erlang-next-error () - "Display next error message from the latest compilation." - (interactive) - (call-interactively erlang-next-error-function)) - - - -;;; -;;; Erlang Shell Mode -- Major mode used for Erlang shells. -;;; - -;; This mode is designed to be implementation independent, -;; e.g. it does not assume that we are running an inferior -;; Erlang, there exists a lot of other possibilities. - - -(defvar erlang-shell-buffer-name "*erlang*" - "The name of the Erlang link shell buffer.") - -(defvar erlang-shell-mode-map nil - "Keymap used by Erlang shells.") - - -(defvar erlang-shell-mode-hook nil - "*User functions to run when an Erlang shell is started. - -This hook is used to change the behaviour of Erlang mode. It is -normally used by the user to personalise the programming environment. -When used in a site init file, it could be used to customise Erlang -mode for all users on the system. - -The function added to this hook is run every time a new Erlang -shell is started. - -See also `erlang-load-hook', a hook which is run once, when Erlang -mode is loaded, and `erlang-mode-hook' which is run every time a new -Erlang source file is loaded into Emacs.") - - -(defvar erlang-input-ring-file-name "~/.erlang_history" - "*When non-nil, file name used to store Erlang shell history information.") - - -(defun erlang-shell-mode () - "Major mode for interacting with an Erlang shell. - -We assume that we already are in Comint mode. - -The following special commands are available: -\\{erlang-shell-mode-map}" - (interactive) - (setq major-mode 'erlang-shell-mode) - (setq mode-name "Erlang Shell") - (erlang-mode-variables) - (if erlang-shell-mode-map - nil - (setq erlang-shell-mode-map (copy-keymap comint-mode-map)) - (erlang-shell-mode-commands erlang-shell-mode-map)) - (use-local-map erlang-shell-mode-map) - (unless inferior-erlang-use-cmm - ;; This was originally not a marker, but it needs to be, at least - ;; in Emacs 21, and should be backwards-compatible. Otherwise, - ;; would need to test whether compilation-parsing-end is a marker - ;; after requiring `compile'. - (set (make-local-variable 'compilation-parsing-end) (copy-marker 1)) - (set (make-local-variable 'compilation-error-list) nil) - (set (make-local-variable 'compilation-old-error-list) nil)) - ;; Needed when compiling directly from the Erlang shell. - (setq compilation-last-buffer (current-buffer)) - (setq comint-prompt-regexp "^[^>=]*> *") - (setq comint-eol-on-send t) - (setq comint-input-ignoredups t) - (setq comint-scroll-show-maximum-output t) - (setq comint-scroll-to-bottom-on-output t) - (add-hook 'comint-output-filter-functions - 'inferior-erlang-strip-delete nil t) - (add-hook 'comint-output-filter-functions - 'inferior-erlang-strip-ctrl-m nil t) - ;; Some older versions of comint don't have an input ring. - (if (fboundp 'comint-read-input-ring) - (progn - (setq comint-input-ring-file-name erlang-input-ring-file-name) - (comint-read-input-ring t) - (make-local-variable 'kill-buffer-hook) - (add-hook 'kill-buffer-hook 'comint-write-input-ring))) - ;; At least in Emacs 21, we need to be in `compilation-minor-mode' - ;; for `next-error' to work. We can avoid it clobbering the shell - ;; keys thus. - (when inferior-erlang-use-cmm - (compilation-minor-mode 1) - (set (make-local-variable 'minor-mode-overriding-map-alist) - `((compilation-minor-mode - . ,(let ((map (make-sparse-keymap))) - ;; It would be useful to put keymap properties on the - ;; error lines so that we could use RET and mouse-2 - ;; on them directly. - (when (boundp 'compilation-skip-threshold) ; new compile.el - (define-key map [mouse-2] #'erlang-mouse-2-command) - (define-key map "\C-m" #'erlang-RET-command)) - (if (boundp 'compilation-menu-map) - (define-key map [menu-bar compilation] - (cons "Errors" compilation-menu-map))) - map))))) - (erlang-tags-init) - (run-hooks 'erlang-shell-mode-hook)) - - -(defun erlang-mouse-2-command (event) - "Command bound to `mouse-2' in inferior Erlang buffer. -Selects Comint or Compilation mode command as appropriate." - (interactive "e") - (if (save-window-excursion - (save-excursion - (mouse-set-point event) - (consp (get-text-property (line-beginning-position) 'message)))) - (call-interactively (lookup-key compilation-mode-map [mouse-2])) - (call-interactively (lookup-key comint-mode-map [mouse-2])))) - -(defun erlang-RET-command () - "Command bound to `RET' in inferior Erlang buffer. -Selects Comint or Compilation mode command as appropriate." - (interactive) - (if (consp (get-text-property (line-beginning-position) 'message)) - (call-interactively (lookup-key compilation-mode-map "\C-m")) - (call-interactively (lookup-key comint-mode-map "\C-m")))) - -(defun erlang-shell-mode-commands (map) - (define-key map "\M-\t" 'erlang-complete-tag) - (define-key map "\C-a" 'comint-bol) ; Normally the other way around. - (define-key map "\C-c\C-a" 'beginning-of-line) - (define-key map "\C-d" nil) ; Was `comint-delchar-or-maybe-eof' - (define-key map "\M-\C-m" 'compile-goto-error) - (unless inferior-erlang-use-cmm - (define-key map "\C-x`" 'erlang-next-error))) - -;;; -;;; Inferior Erlang -- Run an Erlang shell as a subprocess. -;;; - -(defvar inferior-erlang-display-buffer-any-frame nil - "*When nil, `inferior-erlang-display-buffer' use only selected frame. -When t, all frames are searched. When 'raise, the frame is raised.") - -(defvar inferior-erlang-shell-type 'newshell - "The type of Erlang shell to use. - -When this variable is set to the atom `oldshell', the old shell is used. -When set to `newshell' the new shell is used. Should the variable be -nil, the default shell is used. - -This variable influence the setting of other variables.") - -(defvar inferior-erlang-machine "erl" - "*The name of the Erlang shell.") - -(defvar inferior-erlang-machine-options '() - "*The options used when activating the Erlang shell. - -This must be a list of strings.") - -(defvar inferior-erlang-process-name "inferior-erlang" - "The name of the inferior Erlang process.") - -(defvar inferior-erlang-buffer-name erlang-shell-buffer-name - "The name of the inferior Erlang buffer.") - -(defvar inferior-erlang-prompt-timeout 60 - "*Number of seconds before `inferior-erlang-wait-prompt' timeouts. - -The time specified is waited after every output made by the inferior -Erlang shell. When this variable is t, we assume that we always have -a prompt. When nil, we will wait forever, or until \\[keyboard-quit].") - -(defvar inferior-erlang-process nil - "Process of last invoked inferior Erlang, or nil.") - -(defvar inferior-erlang-buffer nil - "Buffer of last invoked inferior Erlang, or nil.") - -;; Enable uniquifying Erlang shell buffers based on directory name. -(eval-after-load "uniquify" - '(add-to-list 'uniquify-list-buffers-directory-modes 'erlang-shell-mode)) - -;;;###autoload -(defun inferior-erlang (&optional command) - "Run an inferior Erlang. -With prefix command, prompt for command to start Erlang with. - -This is just like running Erlang in a normal shell, except that -an Emacs buffer is used for input and output. -\\ -The command line history can be accessed with \\[comint-previous-input] and \\[comint-next-input]. -The history is saved between sessions. - -Entry to this mode calls the functions in the variables -`comint-mode-hook' and `erlang-shell-mode-hook' with no arguments. - -The following commands imitate the usual Unix interrupt and -editing control characters: -\\{erlang-shell-mode-map}" - (interactive - (when current-prefix-arg - (list (if (fboundp 'read-shell-command) - ;; `read-shell-command' is a new function in Emacs 23. - (read-shell-command "Erlang command: ") - (read-string "Erlang command: "))))) - (require 'comint) - (let (cmd opts) - (if command - (setq cmd "sh" - opts (list "-c" command)) - (setq cmd inferior-erlang-machine - opts inferior-erlang-machine-options) - (cond ((eq inferior-erlang-shell-type 'oldshell) - (setq opts (cons "-oldshell" opts))) - ((eq inferior-erlang-shell-type 'newshell) - (setq opts (append '("-newshell" "-env" "TERM" "vt100") opts))))) - - ;; Using create-file-buffer and list-buffers-directory in this way - ;; makes uniquify give each buffer a unique name based on the - ;; directory. - (let ((fake-file-name (expand-file-name inferior-erlang-buffer-name default-directory))) - (setq inferior-erlang-buffer (create-file-buffer fake-file-name)) - (apply 'make-comint-in-buffer - inferior-erlang-process-name - inferior-erlang-buffer - cmd - nil opts) - (with-current-buffer inferior-erlang-buffer - (setq list-buffers-directory fake-file-name)))) - - (setq inferior-erlang-process - (get-buffer-process inferior-erlang-buffer)) - (if (> 21 erlang-emacs-major-version) ; funcalls to avoid compiler warnings - (funcall (symbol-function 'set-process-query-on-exit-flag) - inferior-erlang-process nil) - (funcall (symbol-function 'process-kill-without-query) inferior-erlang-process)) - (if erlang-inferior-shell-split-window - (switch-to-buffer-other-window inferior-erlang-buffer) - (switch-to-buffer inferior-erlang-buffer)) - (if (and (not (eq system-type 'windows-nt)) - (eq inferior-erlang-shell-type 'newshell)) - (setq comint-process-echoes t)) - (erlang-shell-mode)) - - -(defun inferior-erlang-run-or-select () - "Switch to an inferior Erlang buffer, possibly starting new process." - (interactive) - (if (null (inferior-erlang-running-p)) - (inferior-erlang) - (inferior-erlang-display-buffer t))) - - -(defun inferior-erlang-display-buffer (&optional select) - "Make the inferior Erlang process visible. -The window is returned. - -Should `inferior-erlang-display-buffer-any-frame' be nil the buffer is -displayed in the current frame. Should it be non-nil, and the buffer -already is visible in any other frame, no new window will be created. -Should it be the atom 'raise, the frame containing the window will -be raised. - -Should the optional argument SELECT be non-nil, the window is -selected. Should the window be in another frame, that frame is raised. - -Note, should the mouse pointer be places outside the raised frame, that -frame will become deselected before the next command." - (interactive) - (or (inferior-erlang-running-p) - (error "No inferior Erlang process is running")) - (let ((win (inferior-erlang-window - inferior-erlang-display-buffer-any-frame)) - (frames-p (fboundp 'selected-frame))) - (if (null win) - (let ((old-win (selected-window))) - (save-excursion - (switch-to-buffer-other-window inferior-erlang-buffer) - (setq win (selected-window))) - (select-window old-win)) - (if (and window-system - frames-p - (or select - (eq inferior-erlang-display-buffer-any-frame 'raise)) - (not (eq (selected-frame) (window-frame win)))) - (raise-frame (window-frame win)))) - (if select - (select-window win)) - (sit-for 0) - win)) - - -(defun inferior-erlang-running-p () - "Non-nil when an inferior Erlang is running." - (and inferior-erlang-process - (memq (process-status inferior-erlang-process) '(run open)) - inferior-erlang-buffer - (buffer-name inferior-erlang-buffer))) - - -(defun inferior-erlang-window (&optional all-frames) - "Return the window containing the inferior Erlang, or nil." - (and (inferior-erlang-running-p) - (if (and all-frames (>= erlang-emacs-major-version 19)) - (get-buffer-window inferior-erlang-buffer t) - (get-buffer-window inferior-erlang-buffer)))) - - -(defun inferior-erlang-wait-prompt () - "Wait until the inferior Erlang shell prompt appears." - (if (eq inferior-erlang-prompt-timeout t) - () - (or (inferior-erlang-running-p) - (error "No inferior Erlang shell is running")) - (with-current-buffer inferior-erlang-buffer - (let ((msg nil)) - (while (save-excursion - (goto-char (process-mark inferior-erlang-process)) - (forward-line 0) - (not (looking-at comint-prompt-regexp))) - (if msg - () - (setq msg t) - (message "Waiting for Erlang shell prompt (press C-g to abort).")) - (or (accept-process-output inferior-erlang-process - inferior-erlang-prompt-timeout) - (error "No Erlang shell prompt before timeout"))) - (if msg (message "")))))) - -(defun inferior-erlang-send-empty-cmd-unless-already-at-prompt () - "If not already at a prompt, try to send an empty cmd to get a prompt. -The empty command resembles hitting RET. This is useful in some -situations, for instance if a crash or error report from sasl -has been printed after the last prompt." - (with-current-buffer inferior-erlang-buffer - (if (> (point-max) 1) - ;; make sure we get a prompt if buffer contains data - (if (save-excursion - (goto-char (process-mark inferior-erlang-process)) - (forward-line 0) - (not (looking-at comint-prompt-regexp))) - (inferior-erlang-send-command ""))))) - -(autoload 'comint-send-input "comint") - -(defun inferior-erlang-send-command (cmd &optional hist) - "Send command CMD to the inferior Erlang. - -The contents of the current command line (if any) will -be placed at the next prompt. - -If optional second argument is non-nil the command is inserted into -the history list. - -Return the position after the newly inserted command." - (or (inferior-erlang-running-p) - (error "No inferior Erlang process is running")) - (let ((old-buffer (current-buffer)) - (insert-point (marker-position (process-mark inferior-erlang-process))) - (insert-length (if comint-process-echoes - 0 - (1+ (length cmd))))) - (set-buffer inferior-erlang-buffer) - (goto-char insert-point) - (insert cmd) - ;; Strange things happened if `comint-eol-on-send' is declared - ;; in the `let' expression above, but setq:d here. The - ;; `set-buffer' statement obviously makes the buffer local - ;; instance of `comint-eol-on-send' shadow this one. - ;; I'm considering this a bug in Elisp. - ;; - ;; This was previously cautioned against in the Lisp manual. It - ;; has been sorted out in Emacs 21. -- fx - (let ((comint-eol-on-send nil) - (comint-input-filter (if hist comint-input-filter 'ignore))) - (if (and (not erlang-xemacs-p) - (>= emacs-major-version 22)) - (comint-send-input nil t) - (comint-send-input))) - ;; Adjust all windows whose points are incorrect. - (if (null comint-process-echoes) - (walk-windows - (function - (lambda (window) - (if (and (eq (window-buffer window) inferior-erlang-buffer) - (= (window-point window) insert-point)) - (set-window-point window - (+ insert-point insert-length))))) - nil t)) - (set-buffer old-buffer) - (+ insert-point insert-length))) - - -(defun inferior-erlang-strip-delete (&optional s) - "Remove `^H' (delete) and the characters it was supposed to remove." - (interactive) - (if (and (boundp 'comint-last-input-end) - (boundp 'comint-last-output-start)) - (save-excursion - (goto-char - (if (erlang-interactive-p) - (symbol-value 'comint-last-input-end) - (symbol-value 'comint-last-output-start))) - (while (progn (skip-chars-forward "^\C-h") - (not (eq (point) (point-max)))) - (delete-char 1) - (or (bolp) - (backward-delete-char 1)))))) - - -;; Basically `comint-strip-ctrl-m', with a few extra checks. -(defun inferior-erlang-strip-ctrl-m (&optional string) - "Strip trailing `^M' characters from the current output group." - (interactive) - (if (and (boundp 'comint-last-input-end) - (boundp 'comint-last-output-start)) - (let ((pmark (process-mark (get-buffer-process (current-buffer))))) - (save-excursion - (goto-char - (if (erlang-interactive-p) - (symbol-value 'comint-last-input-end) - (symbol-value 'comint-last-output-start))) - (while (re-search-forward "\r+$" pmark t) - (replace-match "" t t)))))) - - -(defun inferior-erlang-compile (arg) - "Compile the file in the current buffer. - -With prefix arg, compiles for debug. - -Should Erlang return `{error, nofile}' it could not load the object -module after completing the compilation. This is due to a bug in the -compile command `c' when using the option `outdir'. - -There exists two workarounds for this bug: - - 1) Place the directory in the Erlang load path. - - 2) Set the Emacs variable `erlang-compile-use-outdir' to nil. - To do so, place the following line in your `~/.emacs'-file: - (setq erlang-compile-use-outdir nil)" - (interactive "P") - (save-some-buffers) - (inferior-erlang-prepare-for-input) - (let* ((dir (inferior-erlang-compile-outdir)) - (noext (substring (erlang-local-buffer-file-name) 0 -4)) - (opts (append (list (cons 'outdir dir)) - (if current-prefix-arg - (list 'debug_info 'export_all)) - erlang-compile-extra-opts)) - end) - (with-current-buffer inferior-erlang-buffer - (when (fboundp 'compilation-forget-errors) - (compilation-forget-errors))) - (setq end (inferior-erlang-send-command - (inferior-erlang-compute-compile-command noext opts) - nil)) - (sit-for 0) - (inferior-erlang-wait-prompt) - (with-current-buffer inferior-erlang-buffer - (setq compilation-error-list nil) - (set-marker compilation-parsing-end end)) - (setq compilation-last-buffer inferior-erlang-buffer))) - -(defun inferior-erlang-prepare-for-input (&optional no-display) - "Create an inferior erlang buffer if needed and ready it for input. -The buffer is displayed, according to `inferior-erlang-display-buffer' -unless the optional NO-DISPLAY is non-nil." - (or (inferior-erlang-running-p) - (save-excursion - (inferior-erlang))) - (or (inferior-erlang-running-p) - (error "Error starting inferior Erlang shell")) - (if (not no-display) - (inferior-erlang-display-buffer)) - (inferior-erlang-send-empty-cmd-unless-already-at-prompt) - (sit-for 0) - (inferior-erlang-wait-prompt)) - -(defun inferior-erlang-compile-outdir () - "Return the directory to compile the current buffer into." - (let* ((buffer-dir (directory-file-name - (file-name-directory (erlang-local-buffer-file-name)))) - (parent-dir (directory-file-name - (file-name-directory buffer-dir))) - (ebin-dir (concat (file-name-as-directory parent-dir) "ebin")) - (buffer-dir-base-name (file-name-nondirectory - (expand-file-name - (concat (file-name-as-directory buffer-dir) - "."))))) - (if (and (string= buffer-dir-base-name "src") - (file-directory-p ebin-dir)) - (file-name-as-directory ebin-dir) - (file-name-as-directory buffer-dir)))) - -(defun inferior-erlang-compute-compile-command (module-name opts) - (let ((ccfn erlang-compile-command-function-alist) - (res (inferior-erlang-compute-erl-compile-command module-name opts)) - ccfn-entry - done - result) - (if (not (null (erlang-local-buffer-file-name))) - (while (and (not done) (not (null ccfn))) - (setq ccfn-entry (car ccfn)) - (setq ccfn (cdr ccfn)) - (if (string-match (car ccfn-entry) (erlang-local-buffer-file-name)) - (let ((c-fn (cdr ccfn-entry))) - (setq done t) - (if (not (null c-fn)) - (setq result (funcall c-fn module-name opts))))))) - result)) - -(defun inferior-erlang-compute-erl-compile-command (module-name opts) - (let* ((out-dir-opt (assoc 'outdir opts)) - (out-dir (cdr out-dir-opt))) - (if erlang-compile-use-outdir - (format "%s(\"%s\"%s)." - erlang-compile-erlang-function - module-name - (inferior-erlang-format-comma-opts opts)) - (let (;; Hopefully, noone else will ever use these... - (tmpvar "Tmp7236") - (tmpvar2 "Tmp8742")) - (format - (concat - "f(%s), {ok, %s} = file:get_cwd(), " - "file:set_cwd(\"%s\"), " - "%s = %s(\"%s\"%s), file:set_cwd(%s), f(%s), %s.") - tmpvar2 tmpvar - out-dir - tmpvar2 - erlang-compile-erlang-function - module-name (inferior-erlang-format-comma-opts - (remq out-dir-opt opts)) - tmpvar tmpvar tmpvar2))))) - -(defun inferior-erlang-compute-leex-compile-command (module-name opts) - (let ((file-name (erlang-local-buffer-file-name)) - (erl-compile-expr (inferior-erlang-remove-any-trailing-dot - (inferior-erlang-compute-erl-compile-command - module-name opts)))) - (format (concat "f(LErr1__), f(LErr2__), " - "case case leex:file(\"%s\", [%s]) of" - " ok -> ok;" - " {ok,_} -> ok;" - " {ok,_,_} -> ok;" - " LErr1__ -> LErr1__ " - "end of" - " ok -> %s;" - " LErr2__ -> LErr2__ " - "end.") - file-name - (inferior-erlang-format-comma-opts erlang-leex-compile-opts) - erl-compile-expr))) - -(defun inferior-erlang-compute-yecc-compile-command (module-name opts) - (let ((file-name (erlang-local-buffer-file-name)) - (erl-compile-expr (inferior-erlang-remove-any-trailing-dot - (inferior-erlang-compute-erl-compile-command - module-name opts)))) - (format (concat "f(YErr1__), f(YErr2__), " - "case case yecc:file(\"%s\", [%s]) of" - " {ok,_} -> ok;" - " {ok,_,_} -> ok;" - " YErr1__ -> YErr1__ " - "end of" - " ok -> %s;" - " YErr2__ -> YErr2__ " - "end.") - file-name - (inferior-erlang-format-comma-opts erlang-yecc-compile-opts) - erl-compile-expr))) - -(defun inferior-erlang-remove-any-trailing-dot (str) - (if (string= (substring str -1) ".") - (substring str 0 (1- (length str))) - str)) - -(defun inferior-erlang-format-comma-opts (opts) - (if (null opts) - "" - (concat ", " (inferior-erlang-format-opt opts)))) - -(defun inferior-erlang-format-opt (opt) - (cond ((stringp opt) (concat "\"" opt "\"")) - ((vectorp opt) (inferior-erlang-tuple (append opt nil))) - ((atom opt) (format "%s" opt)) - ((consp opt) (if (listp (cdr opt)) - (inferior-erlang-list opt) - (inferior-erlang-tuple (list (car opt) (cdr opt))))) - (t (error "Unexpected erlang compile option %s" opt)))) - -(defun inferior-erlang-tuple (opts) - (concat "{" (mapconcat 'inferior-erlang-format-opt - opts - ", ") - "}")) - -(defun inferior-erlang-list (opts) - (concat "[" (mapconcat 'inferior-erlang-format-opt - opts - ", ") - "]")) - - -(defun erlang-local-buffer-file-name () - ;; When editing a file remotely via tramp, - ;; the buffer's file name may be for example - ;; "/ssh:host.example.com:/some/path/x.erl" - ;; - ;; If I try to compile such a file using C-c C-k, an - ;; erlang shell on the remote host is automatically - ;; started if needed, but for it to successfully compile - ;; the file, the c(...) command that is sent must contain - ;; the file name "/some/path/x.erl" without the - ;; tramp-prefix "/ssh:host.example.com:". - (cond ((null (buffer-file-name)) - nil) - ((erlang-tramp-remote-file-p) - (erlang-tramp-get-localname)) - (t - (buffer-file-name)))) - -(defun erlang-tramp-remote-file-p () - (and (fboundp 'tramp-tramp-file-p) - (tramp-tramp-file-p (buffer-file-name)))) - -(defun erlang-tramp-get-localname () - (when (fboundp 'tramp-dissect-file-name) - (let ((tramp-info (tramp-dissect-file-name (buffer-file-name)))) - (if (fboundp 'tramp-file-name-localname) - (tramp-file-name-localname tramp-info) - ;; In old versions of tramp, it was `tramp-file-name-path' - ;; instead of the newer `tramp-file-name-localname' - (when (fboundp 'tramp-file-name-path) - (tramp-file-name-path tramp-info)))))) - -;; `next-error' only accepts buffers with major mode `compilation-mode' -;; or with the minor mode `compilation-minor-mode' activated. -;; (To activate the minor mode is out of the question, since it will -;; ruin the inferior Erlang keymap.) -;; This is done differently in Emacs 21. -(defun inferior-erlang-next-error (&optional argp) - "Just like `next-error'. -Capable of finding error messages in an inferior Erlang buffer." - (interactive "P") - (let ((done nil) - (buf (or (and (boundp 'next-error-last-buffer) - next-error-last-buffer) - (and (boundp 'compilation-last-buffer) - compilation-last-buffer)))) - (if (and (bufferp buf) - (with-current-buffer buf - (and (eq major-mode 'erlang-shell-mode) - (setq major-mode 'compilation-mode)))) - (unwind-protect - (progn - (setq done t) - (next-error argp)) - (with-current-buffer buf - (setq major-mode 'erlang-shell-mode)))) - (or done - (next-error argp)))) - - -(defun inferior-erlang-change-directory (&optional dir) - "Make the inferior Erlang change directory. -The default is to go to the directory of the current buffer." - (interactive) - (or dir (setq dir (file-name-directory (erlang-local-buffer-file-name)))) - (or (inferior-erlang-running-p) - (error "No inferior Erlang is running")) - (inferior-erlang-display-buffer) - (inferior-erlang-send-empty-cmd-unless-already-at-prompt) - (inferior-erlang-wait-prompt) - (inferior-erlang-send-command (format "cd('%s')." dir) nil)) - -(defun erlang-align-arrows (start end) - "Align arrows (\"->\") in function clauses from START to END. -When called interactively, aligns arrows after function clauses inside -the region. - -With a prefix argument, aligns all arrows, not just those in function -clauses. - -Example: - -sum(L) -> sum(L, 0). -sum([H|T], Sum) -> sum(T, Sum + H); -sum([], Sum) -> Sum. - -becomes: - -sum(L) -> sum(L, 0). -sum([H|T], Sum) -> sum(T, Sum + H); -sum([], Sum) -> Sum." - (interactive "r") - (save-excursion - (let (;; regexp for matching arrows. without a prefix argument, - ;; the regexp matches function heads. With a prefix, it - ;; matches any arrow. - (re (if current-prefix-arg - "^.*\\(\\)->" - (eval-when-compile - (concat "^" erlang-atom-regexp ".*\\(\\)->")))) - ;; part of regexp matching directly before the arrow - (arrow-match-pos (if current-prefix-arg - 1 - (1+ erlang-atom-regexp-matches))) - ;; accumulator for positions where arrows are found, ordered - ;; by buffer position (from greatest to smallest) - (arrow-positions '()) - ;; accumulator for longest distance from start of line to arrow - (most-indent 0) - ;; marker to track the end of the region we're aligning - (end-marker (progn (goto-char end) - (point-marker)))) - ;; Pass 1: Find the arrow positions, adjust the whitespace - ;; before each arrow to one space, and find the greatest - ;; indentation level. - (goto-char start) - (while (re-search-forward re end-marker t) - (goto-char (match-beginning arrow-match-pos)) - (just-one-space) ; adjust whitespace - (setq arrow-positions (cons (point) arrow-positions)) - (setq most-indent (max most-indent (erlang-column-number)))) - (set-marker end-marker nil) ; free the marker - ;; Pass 2: Insert extra padding so that all arrow indentation is - ;; equal. This is done last-to-first by buffer position, so that - ;; inserting spaces before one arrow doesn't change the - ;; positions of the next ones. - (mapc (lambda (arrow-pos) - (goto-char arrow-pos) - (let* ((pad (- most-indent (erlang-column-number)))) - (when (> pad 0) - (insert-char ?\ pad)))) - arrow-positions)))) - -(defun erlang-column-number () - "Return the column number of the current position in the buffer. -Tab characters are counted by their visual width." - (string-width (buffer-substring (line-beginning-position) (point)))) - -(defun erlang-current-defun () - "`add-log-current-defun-function' for Erlang." - (save-excursion - (erlang-beginning-of-function) - (if (looking-at "[a-z0-9_]+") - (match-string 0)))) - -;; Aliases for backward compatibility with older versions of Erlang Mode. -;; -;; Unfortuantely, older versions of Emacs doesn't have `defalias' and -;; `make-obsolete' so we have to define our own `obsolete' function. - -(defun erlang-obsolete (sym newdef) - "Make the obsolete function SYM refer to the defined function NEWDEF. - -Simplified version of a combination `defalias' and `make-obsolete', -it assumes that NEWDEF is loaded." - (defalias sym (symbol-function newdef)) - (if (fboundp 'make-obsolete) - (make-obsolete sym newdef "long ago"))) - - -(erlang-obsolete 'calculate-erlang-indent 'erlang-calculate-indent) -(erlang-obsolete 'calculate-erlang-stack-indent - 'erlang-calculate-stack-indent) -(erlang-obsolete 'at-erlang-keyword 'erlang-at-keyword) -(erlang-obsolete 'at-erlang-operator 'erlang-at-operator) -(erlang-obsolete 'beginning-of-erlang-clause 'erlang-beginning-of-clause) -(erlang-obsolete 'end-of-erlang-clause 'erlang-end-of-clause) -(erlang-obsolete 'mark-erlang-clause 'erlang-mark-clause) -(erlang-obsolete 'beginning-of-erlang-function 'erlang-beginning-of-function) -(erlang-obsolete 'end-of-erlang-function 'erlang-end-of-function) -(erlang-obsolete 'mark-erlang-function 'erlang-mark-function) -(erlang-obsolete 'pass-over-erlang-clause 'erlang-pass-over-function) -(erlang-obsolete 'name-of-erlang-function 'erlang-name-of-function) - - -(defconst erlang-unload-hook - (list (lambda () - (when (featurep 'advice) - (ad-unadvise 'Man-notify-when-ready) - (ad-unadvise 'set-visited-file-name))))) - - -(defun erlang-string-to-int (string) - (if (fboundp 'string-to-number) - (string-to-number string) - (funcall (symbol-function 'string-to-int) string))) - -;; The end... - -(provide 'erlang) - -(run-hooks 'erlang-load-hook) - -;; Local variables: -;; coding: iso-8859-1 -;; End: - -;;; erlang.el ends here diff --git a/elpa/erlang-20161007.57/erlang_appwiz.el b/elpa/erlang-20161007.57/erlang_appwiz.el deleted file mode 100644 index ecbce66..0000000 --- a/elpa/erlang-20161007.57/erlang_appwiz.el +++ /dev/null @@ -1,1345 +0,0 @@ -;;; -*- Emacs-Lisp -*- -;;; File: erlang_appwiz.el -;;; Author: Johan Bevermyr -;;; Created: Tue Dec 9 13:14:24 1997 -;;; Purpose: Adds a simple application wizard to erlang.el. - -;; OBS! Must be loaded before the erlang.el file is loaded. -;; Add the following to your .emacs file before erlang.el is loaded. -;; -;; (load "erlang_appwiz" t nil) -;; -;; Customisation of makefile generation: -;; -;; The templates for generating makefiles are stored in the -;; variables erlang-skel-makefile-src and erlang-skel-makefile-middle. -;; -;; These can be modified by setting the variables before or after this -;; file is loaded. -;; -;; For example, to generate OTP-style make files: -;; -;; -;;(defvar erlang-skel-makefile-src -;; '((erlang-skel-include erlang-skel-nomodule-header) -;; "CC_ROOT := $(shell pwd | sed 's/erts.*$$//')" n -;; "AUTOCONF := $(CC_ROOT)/erts/autoconf" n -;; "TARGET := $(shell $(AUTOCONF)/config.guess)" -;; "include $(CC_ROOT)/internal_tools/make/$(TARGET)/otp.mk" n -;; n -;; "# ----------------------------------------------------" n -;; "# Application version " n -;; "# ----------------------------------------------------" n -;; "include ../vsn.mk" n -;; "VSN=$(KERNEL_VSN)" n -;; n -;; "# ----------------------------------------------------" n -;; "# Release directory specification" n -;; "# ----------------------------------------------------" n -;; "RELEASE_PATH= ../../../release/$(TARGET)" n -;; "RELSYSDIR = $(RELEASE_PATH)/lib/kernel-$(VSN)" n -;; n -;; "# ----------------------------------------------------" n -;; "# Target Specs" n -;; "# ----------------------------------------------------" n -;; n -;; "MODULES= " appwiz-erlang-modulename n -;; n -;; "HRL_FILES=" -;; n -;; INTERNAL_HRL_FILES= appwiz-erlang-modulename "_sup.hrl" n -;; n -;; "ERL_FILES= $(MODULES:%=%.erl)" n -;; n -;; "TARGET_FILES= $(MODULES:%=$(EBIN)/%.$(EMULATOR)) $(APP_TARGET)" n -;; n -;; "APP_FILE= " appwiz-erlang-modulename ".app" n -;; n -;; "APP_SRC= $(APP_FILE).src" n -;; "APP_TARGET= ../ebin/$(APP_FILE)" n -;; n -;; "# ----------------------------------------------------" n -;; "# FLAGS " n -;; "# ----------------------------------------------------" n -;; "ERL_FLAGS += " n -;; "ERL_COMPILE_FLAGS += -I../include" n -;; n -;; "# ----------------------------------------------------" n -;; "# Targets" n -;; "# ----------------------------------------------------" n -;; n -;; "debug opt: $(TARGET_FILES)" n -;; n -;; "clean:" n -;; " rm -f $(TARGET_FILES) $(GEN_FILES)" n -;; " rm -f core" n -;; n -;; "docs:" n -;; n -;; "# ----------------------------------------------------" n -;; "# Special Build Targets " n -;; "# ----------------------------------------------------" n -;; " " n -;; "$(APP_TARGET): $(APP_SRC) " n -;; " sed -e 's;%VSN%;$(VSN);' $(APP_SRC) > $(APP_TARGET)" n -;; " " n -;; "# ----------------------------------------------------" n -;; "# Release Target " n -;; "# ----------------------------------------------------" n -;; "include $(CC_ROOT)/internal_tools/make/otp_release_targets.mk" n -;; n -;; "release_spec: opt" n -;; " $(INSTALL_DIR) $(RELSYSDIR)/src " n -;; " $(INSTALL_DATA) $(ERL_FILES) $(RELSYSDIR)/src " n -;; " $(INSTALL_DATA) $(INTERNAL_HRL_FILES) $(RELSYSDIR)/src " n -;; " $(INSTALL_DIR) $(RELSYSDIR)/include " n -;; " $(INSTALL_DATA) $(HRL_FILES) $(RELSYSDIR)/include " n -;; " $(INSTALL_DIR) $(RELSYSDIR)/ebin " n -;; " $(INSTALL_DATA) $(TARGET_FILES) $(RELSYSDIR)/ebin " n -;; n -;; "release_docs_spec:" n -;; )) -;; -;; -;; - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Erlang application wizard -;; - -(defun erlang-application-wizard (directory name) - "Creates all files and directories needed for an application. -The top-level directory is placed in DIRECTORY. NAME is used when -creating the root directory and for naming application files." - - (interactive "DApplication root directory: \nsName of application: ") - (let ((dir nil) - (lastchar (substring directory (- (length directory) 1))) - (apptype (completing-read "Type of application: " - '(("gen_server" 1) - ("gen_event" 2) - ("gen_fsm" 3) - ("other" 4)) - nil t "gen_server")) - (appname nil) - (apptemplate nil) - (apitemplate nil) - (extension nil)) - - (if (string= lastchar "/") - (setq dir directory) - (setq dir (concat directory "/"))) - - ;; determine type of application - (cond ((string= apptype "gen_server") - (setq extension "_server") - (setq appname (concat name extension)) - (setq apptemplate 'tempo-template-erlang-generic-server) - (setq apitemplate 'tempo-template-erlang-large-header)) - ((string= apptype "gen_event") - (setq extension "_event") - (setq appname (concat name extension)) - (setq apptemplate 'tempo-template-erlang-gen-event) - (setq apitemplate 'tempo-template-erlang-large-header)) - ((string= apptype "gen_fsm") - (setq extension "_fsm") - (setq appname (concat name extension)) - (setq apptemplate 'tempo-template-erlang-gen-fsm) - (setq apitemplate 'tempo-template-large-header)) - (t - ;; use defaults _work - (setq extension "_work") - (setq appname (concat name extension)) - (setq apptemplate 'tempo-template-erlang-large-header) - (setq apitemplate 'tempo-template-erlang-large-header))) - - (setq appwiz-erlang-modulename appname) - (setq appwiz-erlang-ext extension) - - ;; create directories - (make-directory (concat dir name "/" "src") t) - (make-directory (concat dir name "/" "ebin") t) - (make-directory (concat dir name "/" "include") t) - - ;; create directory content - ;;;;;;;;; .erl - (find-file (concat dir name "/" "src/" name ".erl")) - (funcall apitemplate) - (insert "API module for the application " name ".") - (save-buffer) - - ;;;;;;;;; _app.erl - (find-file (concat dir name "/" "src/" name "_app.erl")) - (tempo-template-erlang-application) - (insert "Application callback module for the application " name ".") - - (let ((quotedname (erlang-add-quotes-if-needed - (concat name "_sup"))) - (start (point))) - (while (search-forward "'TopSupervisor':start_link" nil t) - (replace-match (concat quotedname ":start_link") nil t)) - (goto-char start)) - - (save-buffer) - - ;;;;;;;;; _sup.erl - (find-file (concat dir name "/" "src/" name "_sup.erl")) - (tempo-template-erlang-supervisor) - (insert "Top level supervisor for the application " name ".") - - - (let ((quotedname (erlang-add-quotes-if-needed appname)) - (start (point))) - (while (search-forward "'AName'" nil t) - (replace-match quotedname nil t)) - (goto-char start)) - - (let ((quotedname (erlang-add-quotes-if-needed appname)) - (start (point))) - (goto-char 0) - (while (search-forward "'AMODULE'" nil t) - (replace-match quotedname nil t)) - (goto-char start)) - - (save-buffer) - - ;;;;;;;;; _sup.hrl - (find-file (concat dir name "/" "src/" name "_sup.hrl")) - (tempo-template-erlang-nomodule-header) - (save-buffer) - - ;;;;;;;;; _(application).erl - (find-file (concat dir name "/" "src/" appname ".erl")) - (funcall apptemplate) - (save-buffer) - - ;;;;;;;;; makefile (src) - (find-file (concat dir name "/" "src/makefile")) - (setq appwiz-erlang-modulename name) - (setq appwiz-erlang-ext extension) - (tempo-template-erlang-makefile-src) - (insert "Makefile for application " name ".") - (let ((start (point))) - (goto-char 0) - (while (search-forward "%" nil t) - (replace-match "#" nil t)) - (goto-char start)) - (save-buffer) - - ;;;;;;;;; makefile (middle) - (find-file (concat dir name "/" "makefile")) - (tempo-template-erlang-makefile-middle) - (insert "Makefile for application " name ".") - (let ((start (point))) - (goto-char 0) - (while (search-forward "%" nil t) - (replace-match "#" nil t)) - (goto-char start)) - (save-buffer) - - ;;;;;;;;; .app - (find-file (concat dir name "/" "ebin/" name ".app")) - (erlang-mode) - (tempo-template-erlang-app) - (insert "Application specification file for " name ".") - (save-buffer))) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; These are setq:ed -;; - -(defvar appwiz-erlang-modulename "foo") -(defvar appwiz-erlang-ext "_work") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Skeletons. -;; Skeletons for nomodule header and .app file added by JB. -;; - -(defvar erlang-skel - '(("If" "if" erlang-skel-if) - ("Case" "case" erlang-skel-case) - ("Receive" "receive" erlang-skel-receive) - ("Receive After" "after" erlang-skel-receive-after) - ("Receive Loop" "loop" erlang-skel-receive-loop) - ("Module" "module" erlang-skel-module) - ("Author" "author" erlang-skel-author) - ("Query" "query" erlang-skel-query) - () - ("Small Header" "small-header" - erlang-skel-small-header erlang-skel-header) - ("Normal Header" "normal-header" - erlang-skel-normal-header erlang-skel-header) - ("Large Header" "large-header" - erlang-skel-large-header erlang-skel-header) - ("No Moudle Header" "nomodule-header" - erlang-skel-nomodule-header erlang-skel-header) - () - ("Small Server" "small-server" - erlang-skel-small-server erlang-skel-header) - () - ("application" "application" - erlang-skel-application erlang-skel-header) - ("app" "app" - erlang-skel-app erlang-skel-header) - ("supervisor" "supervisor" - erlang-skel-supervisor erlang-skel-header) - ("supervisor_bridge" "supervisor-bridge" - erlang-skel-supervisor-bridge erlang-skel-header) - ("gen_server" "generic-server" - erlang-skel-generic-server erlang-skel-header) - ("gen_event" "gen-event" - erlang-skel-gen-event erlang-skel-header) - ("gen_fsm" "gen-fsm" - erlang-skel-gen-fsm erlang-skel-header)) - "*Description of all skeletons templates. -Both functions and menu entries will be created. - -Each entry in `erlang-skel' should be a list with three or four -elements, or the empty list. - -The first element is the name which shows up in the menu. The second -is the `tempo' identfier (The string \"erlang-\" will be added in -front of it). The third is the skeleton descriptor, a variable -containing `tempo' attributes as described in the function -`tempo-define-template'. The optinal fourth elements denotes a -function which should be called when the menu is selected. - -Functions corresponding to every template will be created. The name -of the function will be `tempo-template-erlang-X' where `X' is the -tempo identifier as specified in the second argument of the elements -in this list. - -A list with zero elemets means that the a horisontal line should -be placed in the menu.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Template for .app file skeleton -;; - -(defvar erlang-skel-app - '((erlang-skel-include erlang-skel-nomodule-header) - "{application, " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "," n> - "[{description, \"" (erlang-get-module-from-file-name) "\"}," n> - "{vsn, \"0.1\"}," n> - "{modules, [" - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "," n> - (erlang-add-quotes-if-needed - (concat (erlang-get-module-from-file-name) "_app")) "," n> - (erlang-add-quotes-if-needed - (concat (erlang-get-module-from-file-name) "_sup")) "," n> - (erlang-add-quotes-if-needed - (concat (erlang-get-module-from-file-name) appwiz-erlang-ext)) "]}," n> - "{registered, [" - (erlang-add-quotes-if-needed - (concat (erlang-get-module-from-file-name) appwiz-erlang-ext)) "," - (erlang-add-quotes-if-needed - (concat (erlang-get-module-from-file-name) "_sup")) "]}," n> - "{applications, [kernel," n> - "stdlib," n> - "sasl," n> - "mnesia]}," n> - "{env, []}," n> - "{mod, {" - (erlang-add-quotes-if-needed - (concat (erlang-get-module-from-file-name) "_app")) - ", []}}]}." n - ) - "*The template of an application file -Please see the function `tempo-define-template'.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Template for no-module header skeleton. -;; - -(defvar erlang-skel-nomodule-header - '(o (erlang-skel-separator) - (erlang-skel-include erlang-skel-copyright-comment - erlang-skel-file-comment - erlang-skel-author-comment) - "%%% Purpose : " p n - (erlang-skel-include erlang-skel-created-comment) - (erlang-skel-separator) n) - "*The template of a normal header. -Please see the function `tempo-define-template'.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; .app extension added. -;; - -(defvar erlang-file-name-extension-regexp "\\.\\(erl\\|hrl\\|app\\)$" - "*Regexp which should match an erlang file name. - -This regexp is used when an Erlang module name is extracted from the -name of an Erlang source file. - -The regexp should only match the section of the file name which should -be excluded from the module name. - -To match all files set this variable to \"\\\\(\\\\..*\\\\|\\\\)$\". -The matches all except the extension. This is useful if the Erlang -tags system should interpretate tags on the form `module:tag' for -files written in other languages than Erlang.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Wizard menu added. -;; - -(defvar erlang-menu-items - '(("Indent" - (("Indent Line" erlang-indent-command) - ("Indent Region " erlang-indent-region - (if erlang-xemacs-p (mark) mark-active)) - ("Indent Clause" erlang-indent-caluse) - ("Indent Function" erlang-indent-function) - ("Indent Buffer" erlang-indent-current-buffer))) - ("Edit" - (("Fill Comment" erlang-fill-paragraph) - ("Comment Region" comment-region - (if erlang-xemacs-p (mark) mark-active)) - ("Uncomment Region" erlang-uncomment-region - (if erlang-xemacs-p (mark) mark-active)) - nil - ("beginning of Function" erlang-beginning-of-function) - ("End of Function" erlang-end-of-function) - ("Mark Function" erlang-mark-function) - nil - ("beginning of Clause" erlang-beginning-of-clause) - ("End of Clause" erlang-end-of-clause) - ("Mark Clause" erlang-mark-clause) - nil - ("New Clause" erlang-generate-new-clause) - ("Clone Arguments" erlang-clone-arguments))) - ("Font Lock Mode" - (("Level 3" erlang-font-lock-level-3) - ("Level 2" erlang-font-lock-level-2) - ("Level 1" erlang-font-lock-level-1) - ("Off" erlang-font-lock-level-0))) - ("TAGS" - (("Find Tag" find-tag) - ("Find Next Tag" erlang-find-next-tag) - ;("Find Regexp" find-tag-regexp) - ("Complete Word" erlang-complete-tag) - ("Tags Apropos" tags-apropos) - ("Search Files" tags-search))) - nil - ("Erlang Shell" inferior-erlang-run-or-select) - ("Compile" erlang-compile) - ("Next Error" inferior-erlang-next-error) - nil - ("Version" erlang-version) - nil - ("Wizards" - (("Application Wizard" erlang-application-wizard)))) - "*Description of menu used in Erlang mode. - -This variable must be a list. The elements are either nil representing -a horisontal line or a list with two or three elements. The first is -the name of the menu item, the second is the function to call, or a -submenu, on the same same form as ITEMS. The third optional argument -is an expression which is evaluated every time the menu is displayed. -Should the expression evaluate to nil the menu item is ghosted. - -Example: - '((\"Func1\" function-one) - (\"SubItem\" - ((\"Yellow\" function-yellow) - (\"Blue\" function-blue))) - nil - (\"Region Funtion\" spook-function midnight-variable)) - -Call the function `erlang-menu-init' after modifying this variable.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Prefixing space removed from date string -;; - -(defun erlang-skel-d-mmm-yyyy () - "Return the current date as a string in \"DD Mon YYYY\" form. -The first character of DD is *not* space if the value is less than 10." - (let ((date (current-time-string))) - (format "%d %s %s" - (string-to-int (substring date 8 10)) - (substring date 4 7) - (substring date -4)))) - -(defvar erlang-skel-date-function 'erlang-skel-d-mmm-yyyy - "*Function which returns date string. -Look in the module `time-stamp' for a battery of functions.") - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Fixed skeletons. erlang-add-quotes-if-needed introduced where needed. -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Server templates. - -(defvar erlang-skel-small-server - '((erlang-skel-include erlang-skel-large-header) - "-export([start/0,init/1])." n n n - "start() ->" n> "spawn(" - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) - ", init, [self()])." n n - "init(From) ->" n> - "loop(From)." n n - "loop(From) ->" n> - "receive" n> - p "_ ->" n> - "loop(From)" n> - "end." - ) - "*Template of a small server. -Please see the function `tempo-define-template'.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; Behaviour templates. - -(defvar erlang-skel-application - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(application)." n - n - "%% application callbacks" n - "-export([start/2, stop/1])." n n - (erlang-skel-separator) - "%%% Callback functions from application" n - (erlang-skel-separator) - n - (erlang-skel-separator 2) - "%% Func: start/2" n - "%% Returns: {ok, Pid} |" n - "%% {ok, Pid, State} |" n - "%% {error, Reason} " n - (erlang-skel-separator 2) - "start(Type, StartArgs) ->" n> - "case 'TopSupervisor':start_link(StartArgs) of" n> - "{ok, Pid} -> " n> - "{ok, Pid};" n> - "Error ->" n> - "Error" n> - "end." n - n - (erlang-skel-separator 2) - "%% Func: stop/1" n - "%% Returns: any "n - (erlang-skel-separator 2) - "stop(State) ->" n> - "ok." n - n - (erlang-skel-separator) - "%%% Internal functions" n - (erlang-skel-separator) - ) - "*The template of an application behaviour. -Please see the function `tempo-define-template'.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar erlang-skel-supervisor - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(supervisor)." n - n - "%% External exports" n - "-export([start_link/1])." n - n - "%% supervisor callbacks" n - "-export([init/1])." n n - (erlang-skel-separator) - "%%% API" n - (erlang-skel-separator) - "start_link(StartArgs) ->" n> - "supervisor:start_link({local, " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "}, " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) - ", StartArgs)." n - n - (erlang-skel-separator) - "%%% Callback functions from supervisor" n - (erlang-skel-separator) - n - (erlang-skel-separator 2) - "%% Func: init/1" n - "%% Returns: {ok, {SupFlags, [ChildSpec]}} |" n - "%% ignore |" n - "%% {error, Reason} " n - (erlang-skel-separator 2) - "init(StartArgs) ->" n> - "AChild = {'AName',{'AModule',start_link,[]}," n> - "permanent,2000,worker,['AModule']}," n> - "{ok,{{one_for_all,4,3600}, [AChild]}}." n - n - (erlang-skel-separator) - "%%% Internal functions" n - (erlang-skel-separator) - ) - "*The template of an supervisor behaviour. -Please see the function `tempo-define-template'.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar erlang-skel-supervisor-bridge - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(supervisor_bridge)." n - n - "%% External exports" n - "-export([start_link/0])." n - n - "%% supervisor callbacks" n - "-export([init/1, terminate/2])." n n - "-record(state, {})." n - n - (erlang-skel-separator) - "%%% API" n - (erlang-skel-separator) - "start_link() -> " n> - "supervisor_bridge:start_link({local, " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "}, " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) - ", [])." n - n - (erlang-skel-separator) - "%%% Callback functions from supervisor_bridge" n - (erlang-skel-separator) - n - (erlang-skel-separator 2) - "%% Func: init/1" n - "%% Returns: {ok, Pid, State} |" n - "%% ignore |" n - "%% {error, Reason} " n - (erlang-skel-separator 2) - "init([]) ->" n> - "case 'AModule':start_link() of" n> - "{ok, Pid} ->" n> - "{ok, Pid, #state{}};" n> - "Error ->" n> - "Error" n> - "end." n - n - (erlang-skel-separator 2) - "%% Func: terminate/2" n - "%% Purpose: Synchronized shutdown of the underlying sub system." n - "%% Returns: any" n - (erlang-skel-separator 2) - "terminate(Reason, State) ->" n> - "'AModule':stop()," n> - "ok." n - n - (erlang-skel-separator) - "%%% Internal functions" n - (erlang-skel-separator) - ) - "*The template of an supervisor_bridge behaviour. -Please see the function `tempo-define-template'.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar erlang-skel-generic-server - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_server)." n - n - "%% External exports" n - "-export([start_link/0])." n - n - "%% gen_server callbacks" n - "-export([init/1, handle_call/3, handle_cast/2, " - "handle_info/2, terminate/2])." n n - "-record(state, {})." n - n - (erlang-skel-separator) - "%%% API" n - (erlang-skel-separator) - "start_link() -> " n> - "gen_server:start_link({local, " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "}, " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) - ", [], [])." n - n - (erlang-skel-separator) - "%%% Callback functions from gen_server" n - (erlang-skel-separator) - n - (erlang-skel-separator 2) - "%% Func: init/1" n - "%% Returns: {ok, State} |" n - "%% {ok, State, Timeout} |" n - "%% ignore |" n - "%% {stop, Reason}" n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Func: handle_call/3" n - "%% Returns: {reply, Reply, State} |" n - "%% {reply, Reply, State, Timeout} |" n - "%% {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, Reply, State} | (terminate/2 is called)" n - "%% {stop, Reason, State} (terminate/2 is called)" n - (erlang-skel-separator 2) - "handle_call(Request, From, State) ->" n> - "Reply = ok," n> - "{reply, Reply, State}." n - n - (erlang-skel-separator 2) - "%% Func: handle_cast/2" n - "%% Returns: {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State} (terminate/2 is called)" n - (erlang-skel-separator 2) - "handle_cast(Msg, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator 2) - "%% Func: handle_info/2" n - "%% Returns: {noreply, State} |" n - "%% {noreply, State, Timeout} |" n - "%% {stop, Reason, State} (terminate/2 is called)" n - (erlang-skel-separator 2) - "handle_info(Info, State) ->" n> - "{noreply, State}." n - n - (erlang-skel-separator 2) - "%% Func: terminate/2" n - "%% Purpose: Shutdown the server" n - "%% Returns: any (ignored by gen_server)" n - (erlang-skel-separator 2) - "terminate(Reason, State) ->" n> - "ok." n - n - (erlang-skel-separator) - "%%% Internal functions" n - (erlang-skel-separator) - ) - "*The template of a generic server. -Please see the function `tempo-define-template'.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar erlang-skel-gen-event - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_event)." n - n - "%% External exports" n - "-export([start_link/0, add_handler/0])." n - n - "%% gen_event callbacks" n - "-export([init/1, handle_event/2, handle_call/2, " - "handle_info/2, terminate/2])." n n - "-record(state, {})." n - n - (erlang-skel-separator) - "%%% API" n - (erlang-skel-separator) - "start_link() ->" n> - "gen_event:start_link({local, " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "}). " n - n - "add_handler() ->" n> - "gen_event:add_handler(" - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) ", " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) - ", [])." n - n - (erlang-skel-separator) - "%%% Callback functions from gen_event" n - (erlang-skel-separator) - n - (erlang-skel-separator 2) - "%% Func: init/1" n - "%% Returns: {ok, State} |" n - "%% Other" n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, #state{}}." n - n - (erlang-skel-separator 2) - "%% Func: handle_event/2" n - "%% Returns: {ok, State} |" n - "%% {swap_handler, Args1, State1, Mod2, Args2} |" n - "%% remove_handler " n - (erlang-skel-separator 2) - "handle_event(Event, State) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%% Func: handle_call/2" n - "%% Returns: {ok, Reply, State} |" n - "%% {swap_handler, Reply, Args1, State1, Mod2, Args2} |" n - "%% {remove_handler, Reply} " n - (erlang-skel-separator 2) - "handle_call(Request, State) ->" n> - "Reply = ok," n> - "{ok, Reply, State}." n - n - (erlang-skel-separator 2) - "%% Func: handle_info/2" n - "%% Returns: {ok, State} |" n - "%% {swap_handler, Args1, State1, Mod2, Args2} |" n - "%% remove_handler " n - (erlang-skel-separator 2) - "handle_info(Info, State) ->" n> - "{ok, State}." n - n - (erlang-skel-separator 2) - "%% Func: terminate/2" n - "%% Purpose: Shutdown the server" n - "%% Returns: any" n - (erlang-skel-separator 2) - "terminate(Reason, State) ->" n> - "ok." n - n - (erlang-skel-separator) - "%%% Internal functions" n - (erlang-skel-separator) - ) - "*The template of a gen_event. -Please see the function `tempo-define-template'.") - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defvar erlang-skel-gen-fsm - '((erlang-skel-include erlang-skel-large-header) - "-behaviour(gen_fsm)." n - n - "%% External exports" n - "-export([start_link/0])." n - n - "%% gen_fsm callbacks" n - "-export([init/1, state_name/2, state_name/3, handle_event/3," n> - "handle_sync_event/4, handle_info/3, terminate/3])." n n - "-record(state, {})." n - n - (erlang-skel-separator) - "%%% API" n - (erlang-skel-separator) - "start_link() ->" n> - "gen_fsm:start_link({local, " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) "}, " - (erlang-add-quotes-if-needed (erlang-get-module-from-file-name)) - ", [], [])." n - n - (erlang-skel-separator) - "%%% Callback functions from gen_fsm" n - (erlang-skel-separator) - n - (erlang-skel-separator 2) - "%% Func: init/1" n - "%% Returns: {ok, StateName, StateData} |" n - "%% {ok, StateName, StateData, Timeout} |" n - "%% ignore |" n - "%% {stop, StopReason} " n - (erlang-skel-separator 2) - "init([]) ->" n> - "{ok, state_name, #state{}}." n - n - (erlang-skel-separator 2) - "%% Func: StateName/2" n - "%% Returns: {next_state, NextStateName, NextStateData} |" n - "%% {next_state, NextStateName, NextStateData, Timeout} |" n - "%% {stop, Reason, NewStateData} " n - (erlang-skel-separator 2) - "state_name(Event, StateData) ->" n> - "{nextstate, state_name, StateData}." n - n - (erlang-skel-separator 2) - "%% Func: StateName/3" n - "%% Returns: {next_state, NextStateName, NextStateData} |" n - "%% {next_state, NextStateName, NextStateData, Timeout} |" n - "%% {reply, Reply, NextStateName, NextStateData} |" n - "%% {reply, Reply, NextStateName, NextStateData, Timeout} |" n - "%% {stop, Reason, NewStateData} |" n - "%% {stop, Reason, Reply, NewStateData} " n - (erlang-skel-separator 2) - "state_name(Event, From, StateData) ->" n> - "Reply = ok," n> - "{reply, Reply, state_name, StateData}." n - n - (erlang-skel-separator 2) - "%% Func: handle_event/3" n - "%% Returns: {next_state, NextStateName, NextStateData} |" n - "%% {next_state, NextStateName, NextStateData, Timeout} |" n - "%% {stop, Reason, NewStateData} " n - (erlang-skel-separator 2) - "handle_event(Event, StateName, StateData) ->" n> - "{nextstate, StateName, StateData}." n - n - (erlang-skel-separator 2) - "%% Func: handle_sync_event/4" n - "%% Returns: {next_state, NextStateName, NextStateData} |" n - "%% {next_state, NextStateName, NextStateData, Timeout} |" n - "%% {reply, Reply, NextStateName, NextStateData} |" n - "%% {reply, Reply, NextStateName, NextStateData, Timeout} |" n - "%% {stop, Reason, NewStateData} |" n - "%% {stop, Reason, Reply, NewStateData} " n - (erlang-skel-separator 2) - "handle_sync_event(Event, From, StateName, StateData) ->" n> - "Reply = ok," n> - "{reply, Reply, StateName, StateData}." n - n - (erlang-skel-separator 2) - "%% Func: handle_info/3" n - "%% Returns: {next_state, NextStateName, NextStateData} |" n - "%% {next_state, NextStateName, NextStateData, Timeout} |" n - "%% {stop, Reason, NewStateData} " n - (erlang-skel-separator 2) - "handle_info(Info, StateName, StateData) ->" n> - "{nextstate, StateName, StateData}." n - n - (erlang-skel-separator 2) - "%% Func: terminate/3" n - "%% Purpose: Shutdown the fsm" n - "%% Returns: any" n - (erlang-skel-separator 2) - "terminate(Reason, StateName, StatData) ->" n> - "ok." n - n - (erlang-skel-separator) - "%%% Internal functions" n - (erlang-skel-separator) - ) - "*The template of a gen_fsm. -Please see the function `tempo-define-template'.") - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Original erlang-add-quotes-if-needed is broken, we install a -;; new version. -;; - -(add-hook 'erlang-load-hook 'my-erlang-load-mods) - -(defun fixed-erlang-add-quotes-if-needed (str) - "Return STR, possibly with quotes." - (let ((saved-case-fold-search case-fold-search) - (result nil)) - (setq case-fold-search nil) - (setq result (if (string-match (concat "\\`" erlang-atom-regexp "\\'") str) - str - (concat "'" str "'"))) - (setq case-fold-search saved-case-fold-search) - result)) - -(defun my-erlang-load-mods () - (fset 'erlang-add-quotes-if-needed - (symbol-function 'fixed-erlang-add-quotes-if-needed)) - (appwiz-skel-init)) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Additional skeletons which are not shown in the Erlang menu. -;; - -(defvar appwiz-skel - '( -; ("generic-server-no-api" erlang-skel-generic-server-no-api) -; ("generic-server-api" erlang-skel-generic-server-api) -; ("gen-event-no-api" erlang-skel-gen-event-no-api) -; ("gen-event-api" erlang-skel-gen-event-api) -; ("gen-fsm-no-api" erlang-skel-gen-fsm-no-api) -; ("gen-fsm-api" erlang-skel-gen-fsm-api) - ("makefile-middle" erlang-skel-makefile-middle) - ("makefile-src" erlang-skel-makefile-src))) - -(defun appwiz-skel-init () - "Generate the skeleton functions." - (interactive) - (condition-case nil - (require 'tempo) - (error t)) - (if (featurep 'tempo) - (let ((skel appwiz-skel)) - (while skel - (funcall (symbol-function 'tempo-define-template) - (concat "erlang-" (nth 0 (car skel))) - ;; The tempo template used contains an `include' - ;; function call only, hence changes to the - ;; variables describing the templates take effect - ;; immdiately. - (list (list 'erlang-skel-include (nth 1 (car skel)))) - (nth 0 (car skel))) - (setq skel (cdr skel)))))) - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; -;;;; -;; -;;(defvar erlang-skel-generic-server-no-api -;; '((erlang-skel-include erlang-skel-large-header) -;; "-behaviour(gen_server)." n -;; n -;; "%% gen_server callbacks" n -;; "-export([init/1, handle_call/3, handle_cast/2, " -;; "handle_info/2, terminate/2])." n n -;; "-record(state, {})." n -;; n -;; (erlang-skel-separator) -;; "%%% Callback functions from gen_server" n -;; (erlang-skel-separator) -;; n -;; (erlang-skel-separator 2) -;; "%% Func: init/1" n -;; "%% Returns: {ok, State} |" n -;; "%% {ok, State, Timeout} |" n -;; "%% ignore |" n -;; "%% {stop, Reason}" n -;; (erlang-skel-separator 2) -;; "init([]) ->" n> -;; "{ok, #state{}}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: handle_call/3" n -;; "%% Returns: {reply, Reply, State} |" n -;; "%% {reply, Reply, State, Timeout} |" n -;; "%% {noreply, State} |" n -;; "%% {noreply, State, Timeout} |" n -;; "%% {stop, Reason, Reply, State} | (terminate/2 is called)" n -;; "%% {stop, Reason, State} (terminate/2 is called)" n -;; (erlang-skel-separator 2) -;; "handle_call(Request, From, State) ->" n> -;; "Reply = ok," n> -;; "{reply, Reply, State}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: handle_cast/2" n -;; "%% Returns: {noreply, State} |" n -;; "%% {noreply, State, Timeout} |" n -;; "%% {stop, Reason, State} (terminate/2 is called)" n -;; (erlang-skel-separator 2) -;; "handle_cast(Msg, State) ->" n> -;; "{noreply, State}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: handle_info/2" n -;; "%% Returns: {noreply, State} |" n -;; "%% {noreply, State, Timeout} |" n -;; "%% {stop, Reason, State} (terminate/2 is called)" n -;; (erlang-skel-separator 2) -;; "handle_info(Info, State) ->" n> -;; "{noreply, State}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: terminate/2" n -;; "%% Purpose: Shutdown the server" n -;; "%% Returns: any (ignored by gen_server)" n -;; (erlang-skel-separator 2) -;; "terminate(Reason, State) ->" n> -;; "ok." n -;; n -;; (erlang-skel-separator) -;; "%%% Internal functions" n -;; (erlang-skel-separator) -;; ) -;; "*The template of a generic server. -;;Please see the function `tempo-define-template'.") -;; -;;(defvar erlang-skel-generic-server-api -;; '((erlang-skel-include erlang-skel-large-header) -;; "%% External exports" n -;; "-export([start_link/0])." n -;; n -;; (erlang-skel-separator) -;; "%%% API" n -;; (erlang-skel-separator) -;; "start_link() ->" n> -;; "gen_server:start_link({local, " -;; (erlang-add-quotes-if-needed -;; (concat (erlang-get-module-from-file-name) "_server")) "}, " -;; (erlang-add-quotes-if-needed -;; (concat (erlang-get-module-from-file-name) "_server")) ", [], [])." n -;; n -;; )) -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; -;;;; -;; -;;(defvar erlang-skel-gen-event-no-api -;; '((erlang-skel-include erlang-skel-large-header) -;; "-behaviour(gen_event)." n -;; n -;; "%% gen_event callbacks" n -;; "-export([init/1, handle_event/2, handle_call/2, " -;; "handle_info/2, terminate/2])." n n -;; "-record(state, {})." n -;; n -;; (erlang-skel-separator) -;; "%%% Callback functions from gen_event" n -;; (erlang-skel-separator) -;; n -;; (erlang-skel-separator 2) -;; "%% Func: init/1" n -;; "%% Returns: {ok, State} |" n -;; "%% Other" n -;; (erlang-skel-separator 2) -;; "init([]) ->" n> -;; "{ok, #state{}}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: handle_event/2" n -;; "%% Returns: {ok, State} |" n -;; "%% {swap_handler, Args1, State1, Mod2, Args2} |" n -;; "%% remove_handler " n -;; (erlang-skel-separator 2) -;; "handle_event(Event, State) ->" n> -;; "{ok, State}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: handle_call/2" n -;; "%% Returns: {ok, Reply, State} |" n -;; "%% {swap_handler, Reply, Args1, State1, Mod2, Args2} |" n -;; "%% {remove_handler, Reply} " n -;; (erlang-skel-separator 2) -;; "handle_call(Request, State) ->" n> -;; "Reply = ok," n> -;; "{ok, Reply, State}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: handle_info/2" n -;; "%% Returns: {ok, State} |" n -;; "%% {swap_handler, Args1, State1, Mod2, Args2} |" n -;; "%% remove_handler " n -;; (erlang-skel-separator 2) -;; "handle_info(Info, State) ->" n> -;; "{ok, State}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: terminate/2" n -;; "%% Purpose: Shutdown the server" n -;; "%% Returns: any" n -;; (erlang-skel-separator 2) -;; "terminate(Reason, State) ->" n> -;; "ok." n -;; n -;; (erlang-skel-separator) -;; "%%% Internal functions" n -;; (erlang-skel-separator) -;; ) -;; "*The template of a gen_event. -;;Please see the function `tempo-define-template'.") -;; -;;(defvar erlang-skel-gen-event-api -;; '((erlang-skel-include erlang-skel-large-header) -;; "%% External exports" n -;; "-export([start_link/0, add_handler/0])." n -;; n -;; (erlang-skel-separator) -;; "%%% API" n -;; (erlang-skel-separator) -;; "start_link() ->" n> -;; "gen_event:start_link({local, " -;; (erlang-add-quotes-if-needed -;; (concat (erlang-get-module-from-file-name) "_event")) "}). " n -;; n -;; "add_handler() ->" n> -;; "gen_event:add_handler(" -;; (erlang-add-quotes-if-needed -;; (concat (erlang-get-module-from-file-name) "_event")) ", " -;; (erlang-add-quotes-if-needed -;; (concat (erlang-get-module-from-file-name) "_event")) ", [])." n -;; n)) -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; -;;;; -;; -;;(defvar erlang-skel-gen-fsm -;; '((erlang-skel-include erlang-skel-large-header) -;; "-behaviour(gen_fsm)." n -;; n -;; "%% gen_fsm callbacks" n -;; "-export([init/1, state_name/2, state_name/3, handle_event/3," n> -;; "handle_sync_event/4, handle_info/3, terminate/3])." n n -;; "-record(state, {})." n -;; n -;; (erlang-skel-separator) -;; "%%% Callback functions from gen_fsm" n -;; (erlang-skel-separator) -;; n -;; (erlang-skel-separator 2) -;; "%% Func: init/1" n -;; "%% Returns: {ok, StateName, StateData} |" n -;; "%% {ok, StateName, StateData, Timeout} |" n -;; "%% ignore |" n -;; "%% {stop, StopReason} " n -;; (erlang-skel-separator 2) -;; "init([]) ->" n> -;; "{ok, state_name, #state{}}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: StateName/2" n -;; "%% Returns: {next_state, NextStateName, NextStateData} |" n -;; "%% {next_state, NextStateName, NextStateData, Timeout} |" n -;; "%% {stop, Reason, NewStateData} " n -;; (erlang-skel-separator 2) -;; "state_name(Event, StateData) ->" n> -;; "{nextstate, state_name, StateData}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: StateName/3" n -;; "%% Returns: {next_state, NextStateName, NextStateData} |" n -;; "%% {next_state, NextStateName, NextStateData, Timeout} |" n -;; "%% {reply, Reply, NextStateName, NextStateData} |" n -;; "%% {reply, Reply, NextStateName, NextStateData, Timeout} |" n -;; "%% {stop, Reason, NewStateData} |" n -;; "%% {stop, Reason, Reply, NewStateData} " n -;; (erlang-skel-separator 2) -;; "state_name(Event, From, StateData) ->" n> -;; "Reply = ok," n> -;; "{reply, Reply, state_name, StateData}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: handle_event/3" n -;; "%% Returns: {next_state, NextStateName, NextStateData} |" n -;; "%% {next_state, NextStateName, NextStateData, Timeout} |" n -;; "%% {stop, Reason, NewStateData} " n -;; (erlang-skel-separator 2) -;; "handle_event(Event, StateName, StateData) ->" n> -;; "{nextstate, StateName, StateData}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: handle_sync_event/4" n -;; "%% Returns: {next_state, NextStateName, NextStateData} |" n -;; "%% {next_state, NextStateName, NextStateData, Timeout} |" n -;; "%% {reply, Reply, NextStateName, NextStateData} |" n -;; "%% {reply, Reply, NextStateName, NextStateData, Timeout} |" n -;; "%% {stop, Reason, NewStateData} |" n -;; "%% {stop, Reason, Reply, NewStateData} " n -;; (erlang-skel-separator 2) -;; "handle_sync_event(Event, From, StateName, StateData) ->" n> -;; "Reply = ok," n> -;; "{reply, Reply, StateName, StateData}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: handle_info/3" n -;; "%% Returns: {next_state, NextStateName, NextStateData} |" n -;; "%% {next_state, NextStateName, NextStateData, Timeout} |" n -;; "%% {stop, Reason, NewStateData} " n -;; (erlang-skel-separator 2) -;; "handle_info(Info, StateName, StateData) ->" n> -;; "{nextstate, StateName, StateData}." n -;; n -;; (erlang-skel-separator 2) -;; "%% Func: terminate/3" n -;; "%% Purpose: Shutdown the fsm" n -;; "%% Returns: any" n -;; (erlang-skel-separator 2) -;; "terminate(Reason, StateName, StatData) ->" n> -;; "ok." n -;; n -;; (erlang-skel-separator) -;; "%%% Internal functions" n -;; (erlang-skel-separator) -;; ) -;; "*The template of a gen_fsm. -;;Please see the function `tempo-define-template'.") -;; -;;(defvar erlang-skel-gen-fsm-no-api -;; '((erlang-skel-include erlang-skel-large-header) -;; "%% External exports" n -;; "-export([start_link/0])." n -;; n -;; (erlang-skel-separator) -;; "%%% API" n -;; (erlang-skel-separator) -;; "start_link() ->" n> -;; "gen_fsm:start_link({local, " -;; (erlang-add-quotes-if-needed -;; (concat (erlang-get-module-from-file-name) "_fsm")) "}, " -;; (erlang-add-quotes-if-needed -;; (concat (erlang-get-module-from-file-name) "_fsm")) ", [], [])." n -;; n -;; )) -;; - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; requires that the variables appwiz-erlang-modulename and -;; appwiz-erlang-ext are defined. -;; - -(defvar erlang-skel-makefile-src - '((erlang-skel-include erlang-skel-nomodule-header) - "MAKE = make" n - n - "ERL = erlc" n - n - "EBIN = ../ebin" n - n - (erlang-skel-makefile-separator) - n - (upcase appwiz-erlang-modulename) "_HEADER_FILES = " - appwiz-erlang-modulename "_sup.hrl" n - n - (upcase appwiz-erlang-modulename) "_SOURCE_FILES = \\" n - " " appwiz-erlang-modulename ".erl" " " - appwiz-erlang-modulename "_sup.erl \\" n - " " appwiz-erlang-modulename "_app.erl" " " - appwiz-erlang-modulename appwiz-erlang-ext ".erl" n - n - (upcase appwiz-erlang-modulename) "_OBJECT_FILES = $(" - (upcase appwiz-erlang-modulename) "_SOURCE_FILES:.erl=.jam)" n - n - n - (erlang-skel-makefile-separator) - "#" n - "# Transformations " n - "#" n - n - ".erl.jam:" n - " $(ERL) $<" n - n - (erlang-skel-makefile-separator) n - n - n - "def : " - appwiz-erlang-modulename n - n - appwiz-erlang-modulename ": $(" - (upcase appwiz-erlang-modulename) "_OBJECT_FILES)" n - " cp $(" (upcase appwiz-erlang-modulename) "_OBJECT_FILES) " - "$(EBIN)" n - n - "clean :" n - " /bin/rm -f $(" (upcase appwiz-erlang-modulename) - "_OBJECT_FILES)" n - n - "$(" (upcase appwiz-erlang-modulename) "_OBJECT_FILES): $(" - (upcase appwiz-erlang-modulename) "_HEADER_FILES)" n - n - ".SUFFIXES : .erl .jam" n - n - )) - -(defvar erlang-skel-makefile-middle - '((erlang-skel-include erlang-skel-nomodule-header) - "MAKE = make" n - n - (erlang-skel-makefile-separator) - n - "def:" n - " (cd src ; $(MAKE))" n - n - "clean:" n - " (cd src ; $(MAKE) clean)" n - n - )) - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defun erlang-skel-makefile-separator () - "Return a comment separator." - (concat (make-string 70 ?\#) "\n")) diff --git a/elpa/fiplr-20140723.2345/fiplr-autoloads.el b/elpa/fiplr-20140723.2345/fiplr-autoloads.el deleted file mode 100644 index e3d7430..0000000 --- a/elpa/fiplr-20140723.2345/fiplr-autoloads.el +++ /dev/null @@ -1,65 +0,0 @@ -;;; fiplr-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "fiplr" "fiplr.el" (22297 19831 573825 595000)) -;;; Generated autoloads from fiplr.el - -(autoload 'fiplr-find-file "fiplr" "\ -Runs a completing prompt to find a file from the project. -The root of the project is the return value of `fiplr-root'. - -\(fn)" t nil) - -(autoload 'fiplr-find-file-other-window "fiplr" "\ -Runs a completing prompt to find a file from the project. -The root of the project is the return value of `fiplr-root'. The -file is opened using `find-file-other-window'. - -\(fn)" t nil) - -(autoload 'fiplr-find-file-other-frame "fiplr" "\ -Runs a completing prompt to find a file from the project. -The root of the project is the return value of `fiplr-root'. The -file is opened using `find-file-other-frame'. - -\(fn)" t nil) - -(autoload 'fiplr-find-directory "fiplr" "\ -Runs a completing prompt to find a directory from the project. -The root of the project is the return value of `fiplr-root'. - -\(fn)" t nil) - -(autoload 'fiplr-find-directory-other-window "fiplr" "\ -Runs a completing prompt to find a directory from the project. -The root of the project is the return value of `fiplr-root'. The -directory is opened using `dired-other-window'. - -\(fn)" t nil) - -(autoload 'fiplr-find-directory-other-frame "fiplr" "\ -Runs a completing prompt to find a directory from the project. -The root of the project is the return value of `fiplr-root'. The -directory is opened using `dired-other-frame'. - -\(fn)" t nil) - -(autoload 'fiplr-clear-cache "fiplr" "\ -Clears the internal caches used by fiplr so the project is searched again. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("fiplr-pkg.el") (22297 19831 829667 665000)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; fiplr-autoloads.el ends here diff --git a/elpa/fiplr-20140723.2345/fiplr-pkg.el b/elpa/fiplr-20140723.2345/fiplr-pkg.el deleted file mode 100644 index 818b9f8..0000000 --- a/elpa/fiplr-20140723.2345/fiplr-pkg.el +++ /dev/null @@ -1,6 +0,0 @@ -(define-package "fiplr" "20140723.2345" "Fuzzy Search for Files in Projects" - '((grizzl "0.1.0") - (cl-lib "0.1"))) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/fiplr-20140723.2345/fiplr.el b/elpa/fiplr-20140723.2345/fiplr.el deleted file mode 100644 index 4a6394f..0000000 --- a/elpa/fiplr-20140723.2345/fiplr.el +++ /dev/null @@ -1,346 +0,0 @@ -;;; fiplr.el --- Fuzzy finder for files in a project. - -;; Copyright © 2013 Chris Corbyn -;; -;; Author: Chris Corbyn -;; URL: https://github.com/d11wtq/fiplr -;; Version: 0.2.8 -;; Keywords: convenience, usability, project - -;; This file is NOT part of GNU Emacs. - -;;; --- License - -;; Licensed under the same terms as Emacs. - -;;; --- Commentary - -;; Overview: -;; -;; Fiplr makes it really easy to find files anywhere within your entire -;; project by using a cached directory tree and delegating to grizzl.el -;; while you search the tree. -;; -;; M-x fiplr-find-file -;; -;; By default it looks through all the parent directories of the file you're -;; editing until it finds a .git, .hg, .bzr or .svn directory. You can -;; customize this list of root markers by setting `fiplr-root-markers'. -;; -;; (setq fiplr-root-markers '(".git" ".svn")) -;; -;; Some files are ignored from the directory tree because they are not text -;; files, or simply to speed up the search. The default list can be -;; customized by setting `fiplr-ignored-globs'. -;; -;; (setq fiplr-ignored-globs '((directories (".git" ".svn")) -;; (files ("*.jpg" "*.png" "*.zip" "*~")))) -;; -;; These globs are used by the UNIX `find' command's -name flag. -;; -;; Usage: -;; -;; Find files: M-x fiplr-find-file -;; Find directories: M-x fiplr-find-directory -;; Clear caches: M-x fiplr-clear-cache -;; -;; For convenience, bind "C-x f" to `fiplr-find-file': -;; -;; (global-set-key (kbd "C-x f") 'fiplr-find-file) -;; -;; Because fiplr caches the project tree, you may sometimes wish to clear the -;; cache while searching. Use "C-c r" to do this. - -(eval-when-compile - (require 'cl-lib) - (require 'grizzl)) - -;;; --- Package Configuration - -(defvar *fiplr-caches* '((files) (directories)) - "Internal caches used by fiplr.") - -(defvar *fiplr-default-root-markers* '(".git" ".svn" ".hg" ".bzr") - "A list of files/directories to look for that mark a project root.") - -(defvar *fiplr-default-ignored-globs* - '((directories (".git" ".svn" ".hg" ".bzr")) - (files (".#*" "*~" "*.so" "*.jpg" "*.png" "*.gif" "*.pdf" "*.gz" "*.zip"))) - "An alist of files and directories to exclude from searches.") - -(defgroup fiplr nil - "Configuration options for fiplr - find in project." - :group 'convenience) - -(defcustom fiplr-root-markers *fiplr-default-root-markers* - "A list of files or directories that are found at the root of a project." - :type '(repeat string) - :group 'fiplr) - -(defcustom fiplr-ignored-globs *fiplr-default-ignored-globs* - "An alist of glob patterns to exclude from search results." - :type '(alist :key-type symbol :value-type (repeat string)) - :group 'fiplr) - -(defcustom fiplr-list-files-function 'fiplr-list-files - "A function receiving DIR, TYPE and IGNORED, returning a list of files. - -DIR is the directory under which to locate files (recursively). -TYPE is one of the symboles 'FILES or 'DIRECTORIES. -IGNORED is an alist of glob patterns to exclude. Its keys are 'DIRECTORIES -and 'FILES, so that entire directories can be excluded. - -This setting allows for cross-platform compatibility by abstracting away the -details of locating files in a directory tree. The default uses a GNU/BSD -compatible `find' command. - -This function is only invoked once, when building the search index." - :type 'function - :group 'fiplr) - -;;; --- Public Functions - -;;;###autoload -(defun fiplr-find-file () - "Runs a completing prompt to find a file from the project. -The root of the project is the return value of `fiplr-root'." - (interactive) - (fiplr-find-file-in-directory (fiplr-root) fiplr-ignored-globs)) - -;;;###autoload -(defun fiplr-find-file-other-window () - "Runs a completing prompt to find a file from the project. -The root of the project is the return value of `fiplr-root'. The -file is opened using `find-file-other-window'." - (interactive) - (fiplr-find-file-in-directory (fiplr-root) fiplr-ignored-globs - #'find-file-other-window)) - -;;;###autoload -(defun fiplr-find-file-other-frame () - "Runs a completing prompt to find a file from the project. -The root of the project is the return value of `fiplr-root'. The -file is opened using `find-file-other-frame'." - (interactive) - (fiplr-find-file-in-directory (fiplr-root) fiplr-ignored-globs - #'find-file-other-frame)) - -;;;###autoload -(defun fiplr-find-directory () - "Runs a completing prompt to find a directory from the project. -The root of the project is the return value of `fiplr-root'." - (interactive) - (fiplr-find-directory-in-directory (fiplr-root) fiplr-ignored-globs)) - -;;;###autoload -(defun fiplr-find-directory-other-window () - "Runs a completing prompt to find a directory from the project. -The root of the project is the return value of `fiplr-root'. The -directory is opened using `dired-other-window'." - (interactive) - (fiplr-find-directory-in-directory (fiplr-root) fiplr-ignored-globs - #'dired-other-window)) - -;;;###autoload -(defun fiplr-find-directory-other-frame () - "Runs a completing prompt to find a directory from the project. -The root of the project is the return value of `fiplr-root'. The -directory is opened using `dired-other-frame'." - (interactive) - (fiplr-find-directory-in-directory (fiplr-root) fiplr-ignored-globs - #'dired-other-frame)) - -;;;###autoload -(defun fiplr-clear-cache () - "Clears the internal caches used by fiplr so the project is searched again." - (interactive) - (setq *fiplr-caches* - (list (list 'files) - (list 'directories)))) - -;;; --- Minor Mode Definition - -(defvar *fiplr-keymap* (make-sparse-keymap) - "Internal keymap used by the minor-mode in fiplr.") - -(define-key *fiplr-keymap* (kbd "C-c r") 'fiplr-reload-list) - -(define-minor-mode fiplr-mode - "Toggle the internal mode used by fiplr." - nil - " fiplr" - *fiplr-keymap*) - -;;; --- Private Macros - -(defmacro fiplr-cache (type) - "Get the internal cache used by fiplr for files of TYPE." - `(cdr (assoc ,type *fiplr-caches*))) - -;;; --- Private Functions - -(defun fiplr-root () - "Locate the root of the project by walking up the directory tree. -The first directory containing one of fiplr-root-markers is the root. -If no root marker is found, the current working directory is used." - (let ((cwd (if (buffer-file-name) - (directory-file-name - (file-name-directory (buffer-file-name))) - (file-truename ".")))) - (or (fiplr-find-root cwd fiplr-root-markers) - cwd))) - -(defun fiplr-find-root (path root-markers) - "Tail-recursive part of project-root." - (let* ((this-dir (file-name-as-directory (file-truename path))) - (parent-dir (expand-file-name (concat this-dir ".."))) - (system-root-dir (expand-file-name "/"))) - (cond - ((fiplr-root-p path root-markers) this-dir) - ((equal system-root-dir this-dir) nil) - (t (fiplr-find-root parent-dir root-markers))))) - -(defun fiplr-anyp (pred seq) - "True if any value in SEQ matches PRED." - (catch 'found - (cl-map nil (lambda (v) - (when (funcall pred v) - (throw 'found v))) - seq))) - -(defun fiplr-root-p (path root-markers) - "Predicate to check if the given directory is a project root." - (let ((dir (file-name-as-directory path))) - (fiplr-anyp (lambda (marker) - (file-exists-p (concat dir marker))) - root-markers))) - -(defun fiplr-list-files-shell-command (type path ignored-globs) - "Builds the `find' command to locate all project files & directories. - -PATH is the base directory to recurse from. -IGNORED-GLOBS is an alist with keys 'DIRECTORIES and 'FILES." - (let* ((type-abbrev - (lambda (assoc-type) - (cl-case assoc-type - ('directories "d") - ('files "f")))) - (name-matcher - (lambda (glob) - (mapconcat 'identity - `("-name" ,(shell-quote-argument glob)) - " "))) - (grouped-name-matchers - (lambda (type) - (mapconcat 'identity - `(,(shell-quote-argument "(") - ,(mapconcat (lambda (v) (funcall name-matcher v)) - (cadr (assoc type ignored-globs)) - " -o ") - ,(shell-quote-argument ")")) - " "))) - (matcher - (lambda (assoc-type) - (mapconcat 'identity - `(,(shell-quote-argument "(") - "-type" - ,(funcall type-abbrev assoc-type) - ,(funcall grouped-name-matchers assoc-type) - ,(shell-quote-argument ")")) - " ")))) - (mapconcat 'identity - `("find" - "-L" - ,(shell-quote-argument (directory-file-name path)) - ,(funcall matcher 'directories) - "-prune" - "-o" - "-not" - ,(funcall matcher 'files) - "-type" - ,(funcall type-abbrev type) - "-print") - " "))) - -(defun fiplr-list-files (type path ignored-globs) - "Expands to a flat list of files/directories found under PATH. -The first parameter TYPE is the symbol 'DIRECTORIES or 'FILES." - (let* ((prefix (file-name-as-directory (file-truename path))) - (prefix-length (length prefix)) - (list-string - (shell-command-to-string (fiplr-list-files-shell-command - type - prefix - ignored-globs)))) - (reverse (cl-reduce (lambda (acc file) - (if (> (length file) prefix-length) - (cons (substring file prefix-length) acc) - acc)) - (split-string list-string "[\r\n]+" t) - :initial-value '())))) - -(defun fiplr-reload-list () - "Clear caches and reload the file listing." - (interactive) - (when (minibufferp) - (exit-minibuffer)) - (fiplr-clear-cache) - (funcall last-command)) - -(defun fiplr-report-progress (n total) - "Show the number of files processed in the message area." - (when (= 0 (mod n 1000)) - (message (format "Indexing (%d/%d)" n total)))) - -(defun fiplr-find-file-in-directory - (path ignored-globs &optional find-file-function) - "Locate a file under the specified PATH. -If the directory has been searched previously, the cache is used. -Use FIND-FILE-FUNCTION to open the selected file, or `find-file' -if FIND-FILE-FUNCTION is `nil'." - (let* ((root-dir (file-name-as-directory path)) - (index (fiplr-get-index 'files root-dir ignored-globs)) - (file (minibuffer-with-setup-hook - (lambda () - (fiplr-mode 1)) - (grizzl-completing-read (format "Find in project (%s)" root-dir) - index)))) - (if (eq this-command 'fiplr-reload-list) ; exited for reload - (fiplr-reload-list) - (funcall (or find-file-function #'find-file) - (concat root-dir file))))) - -(defun fiplr-find-directory-in-directory - (path ignored-globs &optional dired-function) - "Locate a directory and run dired under the specified PATH. -If the directory has been searched previously, the cache is used. -Use DIRED-FUNCTION to open the selected file, or `dired' if -DIRED-FUNCTION is `nil'." - (let* ((root-dir (file-name-as-directory path)) - (index (fiplr-get-index 'directories root-dir ignored-globs)) - (dir (minibuffer-with-setup-hook - (lambda () - (fiplr-mode 1)) - (grizzl-completing-read (format "Dired in project (%s)" root-dir) - index)))) - (if (eq this-command 'fiplr-reload-list) ; exited for reload - (fiplr-reload-list) - (funcall (or dired-function #'dired) (concat root-dir dir))))) - -(defun fiplr-get-index (type path ignored-globs) - "Internal function to lazily get a fiplr fuzzy search index." - (let ((fiplr-cache-key (cons path ignored-globs))) - (unless (assoc fiplr-cache-key (fiplr-cache type)) - (message (format "Scanning... (%s)" path)) - (push (cons fiplr-cache-key - (grizzl-make-index (funcall fiplr-list-files-function - type - path - ignored-globs) - :progress-fn #'fiplr-report-progress)) - (fiplr-cache type))) - (cdr (assoc fiplr-cache-key (fiplr-cache type))))) - -(provide 'fiplr) - -;;; fiplr.el ends here diff --git a/elpa/gh-20160728.1525/gh-api.el b/elpa/gh-20160728.1525/gh-api.el deleted file mode 100644 index b99fd43..0000000 --- a/elpa/gh-20160728.1525/gh-api.el +++ /dev/null @@ -1,269 +0,0 @@ -;;; gh-api.el --- api definition for gh.el - -;; Copyright (C) 2011 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'json) - -(require 'gh-profile) -(require 'gh-url) -(require 'gh-auth) -(require 'gh-cache) - -(require 'logito) - -(defgroup gh-api nil - "Github API." - :group 'gh) - -(defcustom gh-api-username-filter 'gh-api-enterprise-username-filter - "Filter to apply to usernames to build URL components" - :type 'function - :group 'gh-api) - -;;;###autoload -(defclass gh-api () - ((sync :initarg :sync :initform t) - (cache :initarg :cache :initform nil) - (base :initarg :base :type string) - (profile :initarg :profile :type string) - (auth :initarg :auth :initform nil) - (data-format :initarg :data-format) - (num-retries :initarg :num-retries :initform 0) - (log :initarg :log :initform nil) - (cache-cls :initform gh-cache :allocation :class)) - "Github API") - -(defmethod logito-log ((api gh-api) level tag string &rest objects) - (apply 'logito-log (oref api :log) level tag string objects)) - -(defmethod initialize-instance ((api gh-api) &rest args) - (call-next-method)) - -(defmethod gh-api-set-default-auth ((api gh-api) auth) - (let ((auth (or (oref api :auth) auth)) - (cache (oref api :cache)) - (classname (symbol-name (funcall (if (fboundp 'eieio-object-class) - 'eieio-object-class - 'object-class) - api)))) - (oset api :auth auth) - (unless (or (null cache) - (and (eieio-object-p cache) - (object-of-class-p cache 'gh-cache))) - (oset api :cache (make-instance - (oref api cache-cls) - :object-name - (format "gh/%s/%s" - classname - (gh-api-get-username api))))))) - -(defmethod gh-api-expand-resource ((api gh-api) - resource) - resource) - -(defun gh-api-enterprise-username-filter (username) - (replace-regexp-in-string (regexp-quote ".") "-" username)) - -(defmethod gh-api-get-username ((api gh-api)) - (let ((username (oref (oref api :auth) :username))) - (funcall gh-api-username-filter username))) - -;;;###autoload -(defclass gh-api-v3 (gh-api) - ((data-format :initarg :data-format :initform :json)) - "Github API v3") - -(defcustom gh-api-v3-authenticator 'gh-oauth-authenticator - "Authenticator for Github API v3" - :type '(choice (const :tag "Password" gh-password-authenticator) - (const :tag "OAuth" gh-oauth-authenticator)) - :group 'gh-api) - -(defmethod initialize-instance ((api gh-api-v3) &rest args) - (call-next-method) - (let ((gh-profile-current-profile (gh-profile-current-profile))) - (oset api :profile (gh-profile-current-profile)) - (oset api :base (gh-profile-url)) - (gh-api-set-default-auth api - (or (oref api :auth) - (funcall gh-api-v3-authenticator "auth"))))) - -;;;###autoload -(defclass gh-api-request (gh-url-request) - ((default-response-cls :allocation :class :initform gh-api-response))) - -;;;###autoload -(defclass gh-api-response (gh-url-response) - ()) - -(defun gh-api-json-decode (repr) - (if (or (null repr) (string= repr "")) - 'empty - (let ((json-array-type 'list)) - (json-read-from-string repr)))) - -(defun gh-api-json-encode (json) - (json-encode-list json)) - -(defmethod gh-url-response-set-data ((resp gh-api-response) data) - (call-next-method resp (gh-api-json-decode data))) - -;;;###autoload -(defclass gh-api-paged-request (gh-api-request) - ((default-response-cls :allocation :class :initform gh-api-paged-response) - (page-limit :initarg :page-limit :initform -1))) - -;;;###autoload -(defclass gh-api-paged-response (gh-api-response) - ()) - -(defmethod gh-api-paging-links ((resp gh-api-paged-response)) - (let ((links-header (cdr (assoc "Link" (oref resp :headers))))) - (when links-header - (loop for item in (split-string links-header ", ") - when (string-match "^<\\(.*\\)>; rel=\"\\(.*\\)\"" item) - collect (cons (match-string 2 item) - (match-string 1 item)))))) - -(defmethod gh-url-response-set-data ((resp gh-api-paged-response) data) - (let ((previous-data (oref resp :data)) - (next (cdr (assoc "next" (gh-api-paging-links resp))))) - (call-next-method) - (oset resp :data (append previous-data (oref resp :data))) - (when (and next (not (equal 304 (oref resp :http-status)))) - (let* ((req (oref resp :-req)) - (last-page-limit (oref req :page-limit)) - (this-page-limit (if (numberp last-page-limit) (- last-page-limit 1) -1))) - (oset req :page-limit this-page-limit) - (unless (eq (oref req :page-limit) 0) - ;; We use an explicit check for 0 since -1 indicates that - ;; paging should continue forever. - (oset resp :data-received nil) - (oset req :url next) - ;; Params need to be set to nil because the next uri will - ;; already have query params. If params are non-nil this will - ;; cause another set of params to be added to the end of the - ;; string which will override the params that are set in the - ;; next link. - (oset req :query nil) - (gh-url-run-request req resp)))))) - -(defmethod gh-api-authenticated-request - ((api gh-api) transformer method resource &optional data params page-limit) - (let* ((fmt (oref api :data-format)) - (headers (cond ((eq fmt :form) - '(("Content-Type" . - "application/x-www-form-urlencoded"))) - ((eq fmt :json) - '(("Content-Type" . - "application/json"))))) - (cache (oref api :cache)) - (key (list resource - method - (sha1 (format "%s" transformer)))) - (cache-key (and cache - (member method (oref cache safe-methods)) - key)) - (has-value (and cache-key (pcache-has cache cache-key))) - (value (and has-value (pcache-get cache cache-key))) - (is-outdated (and has-value (gh-cache-outdated-p cache cache-key))) - (etag (and is-outdated (gh-cache-etag cache cache-key))) - (req - (and (or (not has-value) - is-outdated) - (gh-auth-modify-request - (oref api :auth) - ;; TODO: use gh-api-paged-request only when needed - (make-instance 'gh-api-paged-request - :method method - :url (concat (oref api :base) - (gh-api-expand-resource - api resource)) - :query params - :headers (if etag - (cons (cons "If-None-Match" etag) - headers) - headers) - :data (or (and (eq fmt :json) - (gh-api-json-encode data)) - (and (eq fmt :form) - (gh-url-form-encode data)) - "") - :page-limit page-limit))))) - (cond ((and has-value ;; got value from cache - (not is-outdated)) - (make-instance 'gh-api-response :data-received t :data value)) - (cache-key ;; no value, but cache exists and method is safe - (let ((resp (make-instance (oref req default-response-cls) - :transform transformer))) - (gh-url-run-request req resp) - (gh-url-add-response-callback - resp (make-instance 'gh-api-callback :cache cache :key cache-key - :revive etag)) - resp)) - (cache ;; unsafe method, cache exists - (pcache-invalidate cache key) - (gh-url-run-request req (make-instance - (oref req default-response-cls) - :transform transformer))) - (t ;; no cache involved - (gh-url-run-request req (make-instance - (oref req default-response-cls) - :transform transformer)))))) - -;;;###autoload -(defclass gh-api-callback (gh-url-callback) - ((cache :initarg :cache) - (key :initarg :key) - (revive :initarg :revive))) - -(defmethod gh-url-callback-run ((cb gh-api-callback) resp) - (let ((cache (oref cb :cache)) - (key (oref cb :key))) - (if (and (oref cb :revive) (equal (oref resp :http-status) 304)) - (progn - (gh-cache-revive cache key) - (oset resp :data (pcache-get cache key))) - (pcache-put cache key (oref resp :data)) - (gh-cache-set-etag cache key - (cdr (assoc "ETag" (oref resp :headers))))))) - -(define-obsolete-function-alias 'gh-api-add-response-callback - 'gh-url-add-response-callback "0.6.0") - -(provide 'gh-api) -;;; gh-api.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-auth.el b/elpa/gh-20160728.1525/gh-auth.el deleted file mode 100644 index 7a9486a..0000000 --- a/elpa/gh-20160728.1525/gh-auth.el +++ /dev/null @@ -1,174 +0,0 @@ -;;; gh-auth.el --- authentication for gh.el - -;; Copyright (C) 2011 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-profile) -(require 'gh-common) -(require 'gh-url) - -(defgroup gh-auth nil - "Github authentication." - :group 'gh) - -(defvar gh-auth-alist nil) - -(defun gh-auth-remember (profile key value) - (let ((cell (assoc profile gh-auth-alist))) - (when (not cell) - (setq cell (cons profile nil)) - (setq gh-auth-alist (append gh-auth-alist (list cell)))) - (setcdr cell (plist-put (cdr cell) key value)))) - -(defun gh-auth-get-username () - (let* ((profile (gh-profile-current-profile)) - (user (or (plist-get (cdr (assoc profile gh-auth-alist)) :username) - (plist-get (cdr (assoc profile gh-profile-alist)) :username) - (gh-config "user")))) - (when (not user) - (setq user (read-string "GitHub username: ")) - (gh-set-config "user" user)) - (gh-auth-remember profile :username user) - user)) - -(defun gh-auth-get-password (&optional remember) - (let* ((profile (gh-profile-current-profile)) - (pass (or (plist-get (cdr (assoc profile gh-auth-alist)) :password) - (plist-get (cdr (assoc profile gh-profile-alist)) :password) - (gh-config "password")))) - (when (not pass) - (setq pass (read-passwd "GitHub password: ")) - (gh-set-config "password" pass)) - (when remember - (gh-auth-remember profile :password pass)) - pass)) - -(declare-function 'gh-oauth-auth-new "gh-oauth") - -(defun gh-auth-get-oauth-token () - (let* ((profile (gh-profile-current-profile)) - (token (or (plist-get (cdr (assoc profile gh-auth-alist)) :token) - (plist-get (cdr (assoc profile gh-profile-alist)) :token) - (gh-config "oauth-token")))) - (when (not token) - (let* ((api (make-instance 'gh-oauth-api)) - (tok (and (fboundp 'gh-oauth-auth-new) - (oref (oref (funcall 'gh-oauth-auth-new api - '(user repo gist)) :data) - :token)))) - (setq token (or tok (read-string "GitHub OAuth token: "))) - (gh-set-config "oauth-token" token))) - (gh-auth-remember profile :token token) - token)) - -;;;###autoload -(defclass gh-authenticator () - ((username :initarg :username :initform nil)) - "Abstract authenticator") - -(defmethod initialize-instance ((auth gh-authenticator) &rest args) - (call-next-method) - (or (oref auth :username) - (oset auth :username (gh-auth-get-username)))) - -(defmethod gh-auth-modify-request ((auth gh-authenticator) req) - req) - -;;;###autoload -(defclass gh-auth-2fa-callback (gh-url-callback) - ((req :initarg :req :initform nil)) - "2-factor callback") - -(defmethod gh-url-callback-run ((cb gh-auth-2fa-callback) resp) - (when (equal (oref resp :http-status) 401) - (let* ((otp-header "X-GitHub-OTP") - (h (assoc otp-header (oref resp :headers)))) - (when (and h (string-prefix-p "required;" (cdr h))) - (let ((otp (read-from-minibuffer "Enter dual-factor auth code: ")) - (req (oref cb :req))) - ;; reset resp - (oset resp :data nil) - (oset resp :data-received nil) - - (object-add-to-list req :headers - (cons otp-header otp)) - (gh-url-run-request req resp)))))) - -;;;###autoload -(defclass gh-password-authenticator (gh-authenticator) - ((password :initarg :password :protection :private :initform nil) - (remember :allocation :class :initform t) - - (2fa-cls :initform gh-auth-2fa-callback :allocation :class)) - "Password-based authenticator") - -(defmethod initialize-instance ((auth gh-password-authenticator) &rest args) - (call-next-method) - (or (oref auth :password) - (oset auth :password (gh-auth-get-password (oref auth remember))))) - -(defmethod gh-auth-modify-request ((auth gh-password-authenticator) req) - (object-add-to-list req :headers - (cons "Authorization" - (concat "Basic " - (base64-encode-string - (format "%s:%s" (oref auth :username) - (encode-coding-string - (oref auth :password) 'utf-8)))))) - (object-add-to-list req :install-callbacks - (make-instance (oref auth 2fa-cls) :req req)) - req) - -;;;###autoload -(defclass gh-oauth-authenticator (gh-authenticator) - ((token :initarg :token :protection :private :initform nil)) - "Oauth-based authenticator") - -(defmethod initialize-instance ((auth gh-oauth-authenticator) &rest args) - (call-next-method) - (or (oref auth :token) - (oset auth :token (gh-auth-get-oauth-token)))) - -(defmethod gh-auth-modify-request ((auth gh-oauth-authenticator) req) - (object-add-to-list req :headers - (cons "Authorization" - (format "token %s" (oref auth :token)))) - req) - -(provide 'gh-auth) -;; to avoid circular dependencies... -(require 'gh-oauth) -;;; gh-auth.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-autoloads.el b/elpa/gh-20160728.1525/gh-autoloads.el deleted file mode 100644 index 11b7b5a..0000000 --- a/elpa/gh-20160728.1525/gh-autoloads.el +++ /dev/null @@ -1,255 +0,0 @@ -;;; gh-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) - -;;;### (autoloads nil "gh-api" "gh-api.el" (22454 5329 956436 690000)) -;;; Generated autoloads from gh-api.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-api 'nil "gh-api" "Github API") - -(eieio-defclass-autoload 'gh-api-v3 '(gh-api) "gh-api" "Github API v3") - -(eieio-defclass-autoload 'gh-api-request '(gh-url-request) "gh-api" nil) - -(eieio-defclass-autoload 'gh-api-response '(gh-url-response) "gh-api" nil) - -(eieio-defclass-autoload 'gh-api-paged-request '(gh-api-request) "gh-api" nil) - -(eieio-defclass-autoload 'gh-api-paged-response '(gh-api-response) "gh-api" nil) - -(eieio-defclass-autoload 'gh-api-callback '(gh-url-callback) "gh-api" nil) - -;;;*** - -;;;### (autoloads nil "gh-auth" "gh-auth.el" (22454 5330 384446 754000)) -;;; Generated autoloads from gh-auth.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-authenticator 'nil "gh-auth" "Abstract authenticator") - -(eieio-defclass-autoload 'gh-auth-2fa-callback '(gh-url-callback) "gh-auth" "2-factor callback") - -(eieio-defclass-autoload 'gh-password-authenticator '(gh-authenticator) "gh-auth" "Password-based authenticator") - -(eieio-defclass-autoload 'gh-oauth-authenticator '(gh-authenticator) "gh-auth" "Oauth-based authenticator") - -;;;*** - -;;;### (autoloads nil "gh-cache" "gh-cache.el" (22454 5330 226443 -;;;;;; 38000)) -;;; Generated autoloads from gh-cache.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-cache '(pcache-repository) "gh-cache" nil) - -(eieio-defclass-autoload 'gh-cache-entry '(pcache-entry) "gh-cache" nil) - -;;;*** - -;;;### (autoloads nil "gh-comments" "gh-comments.el" (22454 5329 -;;;;;; 753431 916000)) -;;; Generated autoloads from gh-comments.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-comments-api-mixin 'nil "gh-comments" :abstract) - -;;;*** - -;;;### (autoloads nil "gh-common" "gh-common.el" (22454 5330 91439 -;;;;;; 864000)) -;;; Generated autoloads from gh-common.el - -(require 'eieio) - -(autoload 'gh-marshal-default-spec "gh-common" "\ - - -\(fn SLOT)" nil nil) - -(autoload 'gh-defclass "gh-common" "\ - - -\(fn NAME SUPERCLASS SLOTS &rest OPTIONS-AND-DOC)" nil t) - -(gh-defclass gh-object nil nil) - -(gh-defclass gh-ref-object (gh-object) ((id :initarg :id) (url :initarg :url) (html-url :initarg :html-url))) - -(gh-defclass gh-user (gh-ref-object) ((login :initarg :login) (gravatar-url :initarg :gravatar-url)) "Github user object") - -(gh-defclass gh-comment (gh-ref-object) ((body :initarg :body) (user :initarg :user :initform nil :marshal-type gh-user) (created-at :initarg :created_at) (updated-at :initarg :updated_at)) "Github comment object") - -;;;*** - -;;;### (autoloads nil "gh-gist" "gh-gist.el" (22454 5329 821433 515000)) -;;; Generated autoloads from gh-gist.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-gist-api '(gh-api-v3) "gh-gist" "Gist API") - -(gh-defclass gh-gist-gist-stub (gh-object) ((files :initarg :files :type list :initform nil :marshal-type (list gh-gist-gist-file)) (public :initarg :public :marshal-type bool) (description :initarg :description)) "Class for user-created gist objects") - -(gh-defclass gh-gist-history-change (gh-object) ((total :initarg :total) (additions :initarg :additions) (deletions :initarg :deletions))) - -(gh-defclass gh-gist-history-entry (gh-object) ((user :initarg :user :initform nil :marshal-type gh-user) (version :initarg :version) (committed :initarg :committed :marshal ((alist . committed_at))) (change :initarg :change :marshal ((alist . change_status)) :marshal-type gh-gist-history-change) (url :initarg :url))) - -(gh-defclass gh-gist-fork-entry (gh-ref-object) ((user :initarg :user :initform nil :marshal-type gh-user) (created :initarg :created :marshal ((alist . created_at))) (updated :initarg :updated :marshal ((alist . updated_at))))) - -(gh-defclass gh-gist-gist (gh-ref-object gh-gist-gist-stub) ((date :initarg :date :marshal ((alist . created_at))) (update :initarg :update :marshal ((alist . updated_at))) (push-url :initarg :push-url :marshal ((alist . git_push_url))) (pull-url :initarg :pull-url :marshal ((alist . git_pull_url))) (comments :initarg :comments) (user :initarg :user :initform nil :marshal-type gh-user :marshal ((alist . owner))) (history :initarg :history :initform nil :type list :marshal-type (list gh-gist-history-entry)) (forks :initarg :forks :initform nil :type list :marshal-type (list gh-gist-fork-entry))) "Gist object") - -(gh-defclass gh-gist-gist-file (gh-object) ((filename :initarg :filename) (size :initarg :size) (url :initarg :url :marshal ((alist . raw_url))) (content :initarg :content))) - -;;;*** - -;;;### (autoloads nil "gh-issue-comments" "gh-issue-comments.el" -;;;;;; (22454 5330 158441 440000)) -;;; Generated autoloads from gh-issue-comments.el - -(require 'eieio) - -;;;*** - -;;;### (autoloads nil "gh-issues" "gh-issues.el" (22454 5330 260443 -;;;;;; 838000)) -;;; Generated autoloads from gh-issues.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-issues-api '(gh-api-v3 gh-comments-api-mixin) "gh-issues" "Github Issues api") - -(gh-defclass gh-issues-issue (gh-ref-object) ((number :initarg :number) (state :initarg :state) (title :initarg :title) (body :initarg :body) (user :initarg :user :initform nil :marshal-type gh-user) (labels :initarg :labels :initform nil :marshal-type (list gh-issues-label)) (assignee :initarg :assignee :initform nil :marshal-type gh-user) (milestone :initarg :milestone :initform nil :marshal-type gh-issues-milestone) (comments :initarg :comments :initform 0) (pull-request :initarg :pull-request :marshal-type gh-issues-pull-request) (closed-at :initarg :created-at) (created-at :initarg :created-at) (updated-at :initarg :updated-at)) "issues request") - -(gh-defclass gh-issues-pull-request (gh-object) ((html-url :initarg :html-url) (diff-url :initarg :diff-url) (patch-url :initarg :patch-url))) - -(gh-defclass gh-issues-label (gh-ref-object) ((name :initarg :name) (color :initarg :color))) - -(gh-defclass gh-issues-milestone (gh-ref-object) ((number :initarg :number) (state :initarg :state) (title :initarg :title) (description :initarg :description) (creator :initarg :creator :initform nil :marshal-type gh-user) (open-issues :initarg :open-issues) (closed-issues :initarg :closed-issues) (created-at :initarg :created-at) (due-on :initarg :due-on)) "github milestone") - -(gh-defclass gh-issues-comment (gh-comment) nil) - -;;;*** - -;;;### (autoloads nil "gh-oauth" "gh-oauth.el" (22454 5329 791432 -;;;;;; 810000)) -;;; Generated autoloads from gh-oauth.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-oauth-api '(gh-api-v3) "gh-oauth" "OAuth API") - -(eieio-defclass-autoload 'gh-oauth-password-authenticator '(gh-password-authenticator) "gh-oauth" nil) - -(gh-defclass gh-oauth-authorization (gh-ref-object) ((scopes :initarg :scopes) (token :initarg :token) (app :initarg :app :initform nil :marshal-type gh-oauth-app) (updated-at :initarg :updated-at) (created-at :initarg :created-at))) - -(gh-defclass gh-oauth-app (gh-object) ((url :initarg :url) (name :initarg :name))) - -;;;*** - -;;;### (autoloads nil "gh-orgs" "gh-orgs.el" (22454 5330 124440 640000)) -;;; Generated autoloads from gh-orgs.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-orgs-api '(gh-api-v3) "gh-orgs" "Orgs API") - -(gh-defclass gh-orgs-org-stub (gh-ref-object) ((login :initarg :login) (avatar-url :initarg :avatar-url) (description :initarg :description))) - -(gh-defclass gh-orgs-plan (gh-object) ((name :initarg :name) (space :initarg :space) (private-repos :initarg :private-repos))) - -(gh-defclass gh-orgs-org (gh-orgs-org-stub) ((name :initarg :name) (company :initarg :company) (blog :initarg :blog) (location :initarg :location) (email :initarg :email) (public-repos :initarg :public-repos) (public-gists :initarg :public-gists) (followers :initarg :followers) (following :initarg :following) (created-at :initarg :created-at) (type :initarg :type) (total-private-repos :initarg :total-private-repos) (owned-private-repos :initarg :owned-private-repos) (private-gists :initarg :private-gists) (disk-usage :initarg :disk-usage) (collaborators :initarg :collaborators) (billing-email :initarg :billing-email) (plan :initarg :plan :initform nil :marshal-type gh-orgs-plan)) "Class for GitHub organizations") - -;;;*** - -;;;### (autoloads nil "gh-pull-comments" "gh-pull-comments.el" (22454 -;;;;;; 5330 339445 696000)) -;;; Generated autoloads from gh-pull-comments.el - -(require 'eieio) - -;;;*** - -;;;### (autoloads nil "gh-pulls" "gh-pulls.el" (22454 5330 294444 -;;;;;; 637000)) -;;; Generated autoloads from gh-pulls.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-pulls-cache '(gh-cache) "gh-pulls" nil) - -(eieio-defclass-autoload 'gh-pulls-api '(gh-api-v3 gh-comments-api-mixin) "gh-pulls" "Git pull requests API") - -(gh-defclass gh-pulls-comment (gh-comment) ((path :initarg :path) (diff-hunk :initarg :diff-hunk) (position :initarg :position) (original-position :initarg :original-position) (commit-id :initarg :commit-id) (original-commit-id :initarg :original-commit-id) (in-reply-to :initarg :in-reply-to :initform nil))) - -(gh-defclass gh-pulls-request-stub (gh-ref-object) ((diff-url :initarg :diff-url) (patch-url :initarg :patch-url) (issue-url :initarg :issue-url) (number :initarg :number) (state :initarg :state) (title :initarg :title) (body :initarg :body) (created-at :initarg :created-at) (updated-at :initarg :updated-at) (closed-at :initarg :closed-at) (merged-at :initarg :merged-at) (head :initarg :head :initform nil :marshal-type gh-repos-ref) (base :initarg :base :initform nil :marshal-type gh-repos-ref))) - -(gh-defclass gh-pulls-request (gh-pulls-request-stub) ((merged :initarg :merged) (mergeable :initarg :mergeable) (merged-by :initarg :merged-by) (comments :initarg :comments) (user :initarg :user :initform nil :marshal-type gh-user) (commits :initarg :commits) (additions :initarg :additions) (deletions :initarg :deletions) (changed-files :initarg :changed-files)) "Git pull requests API") - -;;;*** - -;;;### (autoloads nil "gh-repos" "gh-repos.el" (22454 5330 192442 -;;;;;; 239000)) -;;; Generated autoloads from gh-repos.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-repos-api '(gh-api-v3) "gh-repos" "Repos API") - -(gh-defclass gh-repos-repo-stub (gh-object) ((name :initarg :name) (description :initarg :description) (homepage :initarg :homepage) (private :initarg :private)) "Class for user-created repository objects") - -(gh-defclass gh-repos-repo (gh-ref-object gh-repos-repo-stub) ((clone-url :initarg :clone-url) (git-url :initarg :git-url) (ssh-url :initarg :ssh-url) (svn-url :initarg :svn-url) (mirror-url :initarg :mirror-url) (owner :initarg :owner :initform nil :marshal-type gh-user) (full-name :initarg :full-name) (language :initarg :language) (fork :initarg :fork) (forks :initarg :forks) (forks-count :initarg :forks-count) (watchers :initarg :watchers) (watchers-count :initarg :watchers-count) (stargazers-count :initarg :stargazers-count) (size :initarg :size) (master-branch :initarg :master-branch) (open-issues :initarg :open-issues) (pushed-at :initarg :pushed-at) (created-at :initarg :created-at) (updated-at :initarg :updated-at) (organisation :initarg :organisation :initform nil :marshal-type gh-user) (parent :initarg :parent :marshal-type gh-repos-repo) (source :initarg :source :marshal-type gh-repos-repo) (has-issues :initarg :has-issues) (has-wiki :initarg :has-wiki) (has-downloads :initarg :has-downloads)) "Class for GitHub repositories") - -(gh-defclass gh-repos-ref (gh-object) ((label :initarg :label) (ref :initarg :ref :initform nil) (sha :initarg :sha :initform nil) (user :initarg :user :initform nil :marshal-type gh-user) (repo :initarg :repo :initform nil :marshal-type gh-repos-repo))) - -;;;*** - -;;;### (autoloads nil "gh-search" "gh-search.el" (22454 5329 866434 -;;;;;; 573000)) -;;; Generated autoloads from gh-search.el - -(eieio-defclass-autoload 'gh-search-api '(gh-api-v3) "gh-search" nil) - -;;;*** - -;;;### (autoloads nil "gh-url" "gh-url.el" (22454 5329 685430 317000)) -;;; Generated autoloads from gh-url.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-url-request 'nil "gh-url" nil) - -(eieio-defclass-autoload 'gh-url-response 'nil "gh-url" nil) - -(eieio-defclass-autoload 'gh-url-callback 'nil "gh-url" nil) - -;;;*** - -;;;### (autoloads nil "gh-users" "gh-users.el" (22454 5330 46438 -;;;;;; 806000)) -;;; Generated autoloads from gh-users.el - -(require 'eieio) - -(eieio-defclass-autoload 'gh-users-api '(gh-api-v3) "gh-users" "Users API") - -(gh-defclass gh-users-user (gh-user) ((gravatar-id :initarg :gravatar-id) (html-url :initarg :html-url) (followers-url :initarg :followers-url) (following-url :initarg :following-url) (gists-url :initarg :gists-url) (starred-url :initarg :starred-url) (subscriptions-url :initarg :subscriptions-url) (organizations-url :initarg :organizations-url) (repos-url :initarg :repos-url) (events-url :initarg :events-url) (received-events-url :initarg :received-events-url) (type :initarg :type) (site-admin :initarg :site-admin) (name :initarg :name) (company :initarg :company) (blog :initarg :blog) (location :initarg :location) (email :initarg :email) (hireable :initarg :hireable) (bio :initarg :bio) (public-repos :initarg :public-repos) (public-gists :initarg :public-gists) (followers :initarg :followers) (following :initarg :following) (created-at :initarg :created-at) (update-at :initarg :update-at))) - -;;;*** - -;;;### (autoloads nil nil ("gh-pkg.el" "gh-profile.el" "gh.el") (22454 -;;;;;; 5330 1437 747000)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; gh-autoloads.el ends here diff --git a/elpa/gh-20160728.1525/gh-cache.el b/elpa/gh-20160728.1525/gh-cache.el deleted file mode 100644 index a3050ee..0000000 --- a/elpa/gh-20160728.1525/gh-cache.el +++ /dev/null @@ -1,138 +0,0 @@ -;;; gh-cache.el --- caching for gh.el - -;; Copyright (C) 2011 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'pcache) - -(defconst gh-cache-outdated-expiration-delay (* 60 60 24)) - -(defconst gh-cache-internal-version-constant 4) - -(defconst gh-cache-version-constant - (format "%s/gh-%s" pcache-version-constant gh-cache-internal-version-constant)) - -;;;###autoload -(defclass gh-cache (pcache-repository) - ((version-constant :allocation :class) - (entries :initarg :entries :initform (make-hash-table :test 'equal)) - (safe-methods :allocation :class :initform ("HEAD" "GET" "OPTIONS" "TRACE")) - (invalidation-chain :allocation :class :initform nil) - - (entry-cls :initarg :entry-cls :initform gh-cache-entry))) - -(oset-default 'gh-cache version-constant gh-cache-version-constant) - -;;;###autoload -(defclass gh-cache-entry (pcache-entry) - ((etag :initarg :etag :initform nil) - (outdated :initarg :outdated :initform nil) - ;; (ttl :initarg :ttl :initform 0) - )) - -(defmethod pcache-invalidate :after ((cache gh-cache) key) - (let ((resource (car key))) - (pcache-map cache #'(lambda (k v) - (when (equal (car k) resource) - (pcache-invalidate cache k)))) - (dolist (next (oref cache invalidation-chain)) - (let ((nextresource - (replace-regexp-in-string (car next) (cdr next) resource))) - (when (not (equal nextresource resource)) - (pcache-map cache #'(lambda (k v) - (when (equal (car k) nextresource) - (pcache-invalidate cache k))))))))) - -(defmethod pcache-get ((cache gh-cache) key &optional default) - (let* ((table (oref cache :entries)) - (entry (gethash key table))) - (if (not entry) - default - (unless (pcache-entry-valid-p entry) - (oset entry :outdated t)) - (oref entry :value)))) - -(defmethod pcache-has ((cache pcache-repository) key) - (let* ((default (make-symbol ":nil")) - (table (oref cache :entries)) - (entry (gethash key table default))) - (not (eq entry default)))) - -(defmethod pcache-purge-invalid ((cache gh-cache)) - (let ((table (oref cache :entries))) - (maphash #'(lambda (k e) - (unless (gh-cache-expired-p e) - (remhash k table))) - table) - (pcache-save cache))) - -(defmethod gh-cache-outdated-p ((cache gh-cache) key) - (let* ((table (oref cache :entries)) - (entry (gethash key table))) - (and entry - (oref entry :outdated)))) - -(defmethod gh-cache-expired-p ((cache gh-cache) key) - (let* ((table (oref cache :entries)) - (entry (gethash key table))) - (and (gh-cache-outdated-p cache key) - (not - (let ((time (float-time (current-time)))) - (< time (+ gh-cache-outdated-expiration-delay - (oref entry :timestamp)))))))) - -(defmethod gh-cache-revive ((cache gh-cache) key) - (let* ((table (oref cache :entries)) - (entry (gethash key table))) - (and entry - (oset entry :outdated nil) - (oset entry :timestamp (float-time (current-time))) - t))) - -(defmethod gh-cache-etag ((cache gh-cache) key) - (let* ((table (oref cache :entries)) - (entry (gethash key table))) - (and entry - (oref entry :etag)))) - -(defmethod gh-cache-set-etag ((cache gh-cache) key etag) - (let* ((table (oref cache :entries)) - (entry (gethash key table))) - (and entry - (oset entry :etag etag)))) - -(provide 'gh-cache) -;;; gh-cache.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-comments.el b/elpa/gh-20160728.1525/gh-comments.el deleted file mode 100644 index 99631d2..0000000 --- a/elpa/gh-20160728.1525/gh-comments.el +++ /dev/null @@ -1,71 +0,0 @@ -;;; gh-comments.el --- support for comment-enabled APIs - -;; Copyright (C) 2014-2015 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-common) -(require 'gh-api) - -;;;###autoload -(defclass gh-comments-api-mixin () - ((comment-cls :allocation :class :initform gh-comment)) - :abstract t) - -(defmethod gh-comments-list ((api gh-comments-api-mixin) base) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api comment-cls)) "GET" - (format "%s/comments" (gh-ref-object-base base)))) - -(defmethod gh-comments-get ((api gh-comments-api-mixin) base comment-id) - (gh-api-authenticated-request - api (gh-object-reader (oref api comment-cls)) "GET" - (format "%s/comments/%s" (gh-ref-object-base base) comment-id))) - -(defmethod gh-comments-update ((api gh-comments-api-mixin) base comment-id comment) - (gh-api-authenticated-request - api (gh-object-reader (oref api comment-cls)) "PATCH" - (format "%s/comments/%s" (gh-ref-object-base base) comment-id) - (gh-comment-req-to-update comment))) - -(defmethod gh-comments-new ((api gh-comments-api-mixin) base comment) - (gh-api-authenticated-request - api (gh-object-reader (oref api comment-cls)) "POST" - (format "%s/comments" (gh-ref-object-base base)) - (gh-comment-req-to-update comment))) - -(defmethod gh-comments-delete ((api gh-comments-api-mixin) base comment-id) - (gh-api-authenticated-request - api nil "DELETE" - (format "%s/comments/%s" (gh-ref-object-base base) comment-id))) - -(provide 'gh-comments) -;;; gh-comments.el ends here diff --git a/elpa/gh-20160728.1525/gh-common.el b/elpa/gh-20160728.1525/gh-common.el deleted file mode 100644 index 4a9a8c7..0000000 --- a/elpa/gh-20160728.1525/gh-common.el +++ /dev/null @@ -1,152 +0,0 @@ -;;; gh-common.el --- common objects for gh.el - -;; Copyright (C) 2011 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'dash) -(require 'marshal) -(require 's) -(require 'gh-profile) - -(defgroup gh nil - "Github API client libraries." - :group 'applications) - -;;; Helper functions - -(defun gh-read (obj field) - (cdr (assoc field obj))) - -(defun gh-namespaced-key (key) - (let ((profile (gh-profile-current-profile))) - (concat "github." - (if (string= profile gh-profile-default-profile) - "" - (concat profile ".")) - key))) - -(defun gh-config (key) - "Returns a GitHub specific value from the global Git config." - (let ((strip (lambda (string) - (if (> (length string) 0) - (substring string 0 (- (length string) 1)))))) - (funcall strip (gh-command-to-string "config" (gh-namespaced-key key))))) - -(defun gh-set-config (key value) - "Sets a GitHub specific value to the global Git config." - (gh-command-to-string "config" "--global" (gh-namespaced-key key) value)) - -(defun gh-command-to-string (&rest args) - (let ((git (executable-find "git"))) - (with-output-to-string - (apply 'process-file git nil standard-output nil args)))) - -;;; Base classes for common objects - -;;;###autoload -(defun gh-marshal-default-spec (slot) - (let ((slot-name (symbol-name slot))) - (list (cons 'alist - (intern (s-replace "-" "_" slot-name)))))) - -;;;###autoload -(defmacro gh-defclass (name superclass slots &rest options-and-doc) - `(marshal-defclass ,name ,superclass ,slots ,@options-and-doc - :marshal-default-spec gh-marshal-default-spec)) - -;;;###autoload -(gh-defclass gh-object () - ()) - -(defmethod gh-object-read :static ((obj gh-object) data) - (let ((target (if (object-p obj) obj - (make-instance obj)))) - (when data - (gh-object-read-into target data)) - target)) - -(defmethod gh-object-reader :static ((obj gh-object)) - (apply-partially 'gh-object-read obj)) - -(defmethod gh-object-list-read :static ((obj gh-object) data) - (mapcar (gh-object-reader obj) data)) - -(defmethod gh-object-list-reader :static ((obj gh-object)) - (apply-partially 'gh-object-list-read obj)) - -(defmethod gh-object-read-into ((obj gh-object) data) - (unmarshal obj data 'alist)) - -(defmethod slot-unbound ((obj gh-object) cls slot-name fn) - (if (eq fn 'oref) nil - (call-next-method))) - -;;;###autoload -(gh-defclass gh-ref-object (gh-object) - ((id :initarg :id) - (url :initarg :url) - (html-url :initarg :html-url))) - -(defmethod gh-ref-object-base ((obj gh-ref-object)) - (let ((url (oref obj :url))) - (--> (s-split "/" url t) - (-slice it 2) - (s-join "/" it) - (concat "/" it)))) - -(defmethod gh-ref-object-base (obj) - (if (stringp obj) obj - (error "illegal input for `gh-ref-object-base'"))) - -;;;###autoload -(gh-defclass gh-user (gh-ref-object) - ((login :initarg :login) - (gravatar-url :initarg :gravatar-url)) - "Github user object") - -;;;###autoload -(gh-defclass gh-comment (gh-ref-object) - ((body :initarg :body) - (user :initarg :user :initform nil :marshal-type gh-user) - (created-at :initarg :created_at) - (updated-at :initarg :updated_at)) - "Github comment object") - -(defmethod gh-comment-req-to-update ((req gh-comment)) - `(("body" . ,(oref req :body)))) - -(provide 'gh-common) -;;; gh-common.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-gist.el b/elpa/gh-20160728.1525/gh-gist.el deleted file mode 100644 index bb7479d..0000000 --- a/elpa/gh-20160728.1525/gh-gist.el +++ /dev/null @@ -1,176 +0,0 @@ -;;; gh-gist.el --- gist module for gh.el - -;; Copyright (C) 2011 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-api) -(require 'gh-auth) -(require 'gh-common) - -;;;###autoload -(defclass gh-gist-api (gh-api-v3) - ((gist-cls :allocation :class :initform gh-gist-gist)) - "Gist API") - -;;;###autoload -(gh-defclass gh-gist-gist-stub (gh-object) - ((files :initarg :files :type list :initform nil :marshal-type (list gh-gist-gist-file)) - (public :initarg :public :marshal-type bool) - (description :initarg :description)) - "Class for user-created gist objects") - -;;;###autoload -(gh-defclass gh-gist-history-change (gh-object) - ((total :initarg :total) - (additions :initarg :additions) - (deletions :initarg :deletions))) - -;;;###autoload -(gh-defclass gh-gist-history-entry (gh-object) - ((user :initarg :user :initform nil :marshal-type gh-user) - (version :initarg :version) - (committed :initarg :committed :marshal ((alist . committed_at))) - (change :initarg :change :marshal ((alist . change_status)) - :marshal-type gh-gist-history-change) - (url :initarg :url))) - -;;;###autoload -(gh-defclass gh-gist-fork-entry (gh-ref-object) - ((user :initarg :user :initform nil :marshal-type gh-user) - (created :initarg :created :marshal ((alist . created_at))) - (updated :initarg :updated :marshal ((alist . updated_at))))) - -;;;###autoload -(gh-defclass gh-gist-gist (gh-ref-object gh-gist-gist-stub) - ((date :initarg :date :marshal ((alist . created_at))) - (update :initarg :update :marshal ((alist . updated_at))) - (push-url :initarg :push-url :marshal ((alist . git_push_url))) - (pull-url :initarg :pull-url :marshal ((alist . git_pull_url))) - (comments :initarg :comments) - (user :initarg :user :initform nil :marshal-type gh-user :marshal ((alist . owner))) - (history :initarg :history :initform nil :type list :marshal-type (list gh-gist-history-entry)) - (forks :initarg :forks :initform nil :type list :marshal-type (list gh-gist-fork-entry))) - "Gist object") - -;;;###autoload -(gh-defclass gh-gist-gist-file (gh-object) - ((filename :initarg :filename) - (size :initarg :size) - (url :initarg :url :marshal ((alist . raw_url))) - (content :initarg :content))) - -(defmethod gh-gist-gist-to-obj ((gist gh-gist-gist-stub)) - (let ((files (mapcar #'gh-gist-gist-file-to-obj (oref gist :files)))) - `(("description" . ,(oref gist :description)) - ("public" . ,(oref gist :public)) - ,@(and files (list (cons "files" files)))))) - -(defmethod gh-gist-gist-has-files ((gist gh-gist-gist-stub)) - (not (memq nil (mapcar (lambda (f) - (oref f :content)) (oref gist :files))))) - -(defmethod gh-gist-gist-file-to-obj ((file gh-gist-gist-file)) - (let* ((filename (oref file :filename)) - (content (oref file :content)) - (file (if content - `(("filename" . ,filename) - ("content" . ,content)) - nil))) - (cons filename file))) - -(defmethod gh-gist-list ((api gh-gist-api) &optional username) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api gist-cls)) "GET" - (format "/users/%s/gists" (or username (gh-api-get-username api))))) - -(defmethod gh-gist-list-public ((api gh-gist-api)) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api gist-cls)) "GET" "/gists/public")) - -(defmethod gh-gist-list-starred ((api gh-gist-api)) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api gist-cls)) "GET" "/gists/starred")) - -(defmethod gh-gist-get ((api gh-gist-api) gist-or-id) - (let (id transformer) - (if (stringp gist-or-id) - (setq id gist-or-id - transformer (gh-object-reader (oref api gist-cls))) - (setq id (oref gist-or-id :id) - transformer (gh-object-reader gist-or-id))) - (gh-api-authenticated-request - api transformer "GET" (format "/gists/%s" id)))) - -(defmethod gh-gist-new ((api gh-gist-api) gist-stub) - (gh-api-authenticated-request - api (gh-object-reader (oref api gist-cls)) "POST" "/gists" - (gh-gist-gist-to-obj gist-stub))) - -(defmethod gh-gist-edit ((api gh-gist-api) gist) - (gh-api-authenticated-request - api (gh-object-reader (oref api gist-cls)) "PATCH" - (format "/gists/%s" - (oref gist :id)) - (gh-gist-gist-to-obj gist))) - -(defmethod gh-gist-set-star ((api gh-gist-api) gist-or-id star) - (let ((id (if (stringp gist-or-id) gist-or-id - (oref gist-or-id :id)))) - (gh-api-authenticated-request - api 'ignore (if star "PUT" "DELETE") - (format "/gists/%s/star" id)))) - -(defmethod gh-gist-get-star ((api gh-gist-api) gist-or-id) - (let ((id (if (stringp gist-or-id) gist-or-id - (oref gist-or-id :id)))) - (gh-api-authenticated-request - api 'ignore "GET" (format "/gists/%s/star" id)))) - -(defmethod gh-gist-fork ((api gh-gist-api) gist-or-id) - (let ((id (if (stringp gist-or-id) gist-or-id - (oref gist-or-id :id)))) - (gh-api-authenticated-request - api (gh-object-reader (oref api gist-cls)) "POST" - (format "/gists/%s/forks" id)))) - -(defmethod gh-gist-delete ((api gh-gist-api) gist-or-id) - (let ((id (if (stringp gist-or-id) gist-or-id - (oref gist-or-id :id)))) - (gh-api-authenticated-request - api 'ignore "DELETE" (format "/gists/%s" id)))) - -(provide 'gh-gist) -;;; gh-gist.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-issue-comments.el b/elpa/gh-20160728.1525/gh-issue-comments.el deleted file mode 100644 index 8887e9a..0000000 --- a/elpa/gh-20160728.1525/gh-issue-comments.el +++ /dev/null @@ -1,72 +0,0 @@ -;;; gh-issue-comments.el --- issue comments api for github - -;; Copyright (C) 2014 Travis Thieman - -;; Author: Travis Thieman -;; Keywords: - -;; 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: - -;; TODOS: -;; * Support listing all comments in a repository - -;; Basic usage: - -;; (setf api (gh-issue-comments-api "api" :sync nil :cache nil :num-retries 1)) -;; (setf comments (gh-issue-comments-list api "user" "repo" "issue id")) -;; (setq my-comment (make-instance 'gh-issue-comments-comment :body "This is great!")) -;; (gh-issue-comments-new api "user" "repo" "issue id" my-comment) - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-api) -(require 'gh-auth) -(require 'gh-common) - -(require 'gh-issues) - -(let ((ver "1.0.0")) - (define-obsolete-function-alias - 'gh-issue-comments-api 'gh-issues-api ver) - (define-obsolete-function-alias - 'gh-issue-comments-comment 'gh-issues-comment ver) - - (define-obsolete-function-alias - 'gh-issue-comments-req-to-update 'gh-comment-req-to-update ver) - - (define-obsolete-function-alias - 'gh-issue-comments-list 'gh-issues-comments-list ver) - (define-obsolete-function-alias - 'gh-issue-comments-get 'gh-issues-comments-get ver) - (define-obsolete-function-alias - 'gh-issue-comments-update 'gh-issues-comments-update ver) - (define-obsolete-function-alias - 'gh-issue-comments-new 'gh-issues-comments-new ver) - (define-obsolete-function-alias - 'gh-issue-comments-delete 'gh-issues-comments-delete ver)) - -(provide 'gh-issue-comments) -;;; gh-issue-comments.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-issues.el b/elpa/gh-20160728.1525/gh-issues.el deleted file mode 100644 index 17f332e..0000000 --- a/elpa/gh-20160728.1525/gh-issues.el +++ /dev/null @@ -1,281 +0,0 @@ -;;; gh-issues.el --- issues api for github - -;; Copyright (C) 2014-2015 Yann Hodique -;; Copyright (C) 2014 Travis Thieman -;; Copyright (C) 2012 Raimon Grau - -;; Author: Raimon Grau -;; Keywords: - -;; 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: - -;; Basic usage: - -;; (setf api (gh-issues-api "api" :sync nil :cache nil :num-retries 1)) -;; (setf issues (gh-issues-list api "user" "repo")) -;; (last (oref issues data)) ; get one issue -;; (setq mi (make-instance 'gh-issues-issue :body "issue body" :title "issue title")) -;; (gh-issues-issue-new api "user" "repo" mi) -;; (setf comments (gh-issues-comments-list api "user" "repo" "issue id")) -;; (setq my-comment (make-instance 'gh-issues-comment :body "This is great!")) -;; (gh-issues-comments-new api "user" "repo" "issue id" my-comment) - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-api) -(require 'gh-auth) -(require 'gh-comments) -(require 'gh-common) - -(require 'gh-repos) - -;;;###autoload -(defclass gh-issues-api (gh-api-v3 gh-comments-api-mixin) - ((issue-cls :allocation :class :initform gh-issues-issue) - (milestone-cls :allocation :class :initform gh-issues-milestone) - (label-cls :allocation :class :initform gh-issues-label) - (comment-cls :allocation :class :initform gh-issues-comment)) - "Github Issues api") - -;;;###autoload -(gh-defclass gh-issues-issue (gh-ref-object) - ((number :initarg :number) - (state :initarg :state) - (title :initarg :title) - (body :initarg :body) - (user :initarg :user :initform nil :marshal-type gh-user) - (labels :initarg :labels :initform nil :marshal-type (list gh-issues-label)) - (assignee :initarg :assignee :initform nil :marshal-type gh-user) - (milestone :initarg :milestone :initform nil :marshal-type gh-issues-milestone) - (comments :initarg :comments :initform 0) - (pull-request :initarg :pull-request :marshal-type gh-issues-pull-request) - (closed-at :initarg :created-at) - (created-at :initarg :created-at) - (updated-at :initarg :updated-at)) - "issues request") - -;;;###autoload -(gh-defclass gh-issues-pull-request (gh-object) - ((html-url :initarg :html-url) - (diff-url :initarg :diff-url) - (patch-url :initarg :patch-url))) - -;;;###autoload -(gh-defclass gh-issues-label (gh-ref-object) - ((name :initarg :name) - (color :initarg :color))) - -(defmethod gh-issues-label-req-to-update ((label gh-issues-label)) - `(("name" . ,(oref label :name)) - ("color" . ,(oref label :color)))) - -;;;###autoload -(gh-defclass gh-issues-milestone (gh-ref-object) - ((number :initarg :number) - (state :initarg :state) - (title :initarg :title) - (description :initarg :description) - (creator :initarg :creator :initform nil :marshal-type gh-user) - (open-issues :initarg :open-issues ) - (closed-issues :initarg :closed-issues) - (created-at :initarg :created-at) - (due-on :initarg :due-on)) - "github milestone") - -;;;###autoload -(gh-defclass gh-issues-comment (gh-comment) - ()) - -(defmethod gh-issues-issue-list ((api gh-issues-api) user repo) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api issue-cls)) "GET" - (format "/repos/%s/%s/issues" user repo))) - -(defmethod gh-issues-milestone-list ((api gh-issues-api) user repo) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api milestone-cls)) "GET" - (format "/repos/%s/%s/milestones" user repo))) - -(defmethod gh-issues-milestone-get ((api gh-issues-api) user repo id) - (gh-api-authenticated-request - api (gh-object-reader (oref api milestone-cls)) "GET" - (format "/repos/%s/%s/milestones/%s" user repo id))) - -(defmethod gh-issues-milestone-new ((api gh-issues-api) user repo milestone) - (gh-api-authenticated-request - api (gh-object-reader (oref api milestone-cls)) "POST" - (format "/repos/%s/%s/milestones" user repo) - (gh-issues-milestone-req-to-update milestone))) - -(defmethod gh-issues-milestone-update ((api gh-issues-api) user repo - id milestone) - (gh-api-authenticated-request - api (gh-object-reader (oref api milestone-cls)) "PATCH" - (format "/repos/%s/%s/milestones/%s" user repo id) - (gh-issues-milestone-req-to-update milestone))) - -(defmethod gh-issues-milestone-req-to-update ((milestone gh-issues-milestone)) - (let ((state (oref milestone :state)) - (description (oref milestone :description)) - (due-on (oref milestone :due-on)) - (to-update `(("title" . ,(oref milestone :title))))) - (when state (nconc to-update `(("state" . ,state)))) - (when description (nconc to-update `(("description" . ,description)))) - (when due-on (nconc to-update `(("due_on" . ,due-on)))) - to-update)) - -(defmethod gh-issues-issue-get ((api gh-issues-api) user repo id) - (gh-api-authenticated-request - api (gh-object-reader (oref api issue-cls)) "GET" - (format "/repos/%s/%s/issues/%s" user repo id))) - -(defmethod gh-issues-issue-req-to-update ((req gh-issues-issue)) - (let ((assignee (oref req :assignee)) - ;; (labels (oref req labels)) - (milestone (oref req :milestone)) - (to-update `(("title" . ,(oref req :title)) - ("state" . ,(oref req :state)) - ("body" . ,(oref req :body))))) - - ;; (when labels (nconc to-update `(("labels" . ,(oref req labels) )))) - (when milestone - (nconc to-update `(("milestone" . ,(oref milestone :number))))) - (when assignee - (nconc to-update `(("assignee" . ,(oref assignee :login))))) - to-update)) - -(defmethod gh-issues-issue-update ((api gh-issues-api) user repo id req) - (gh-api-authenticated-request - api (gh-object-reader (oref api issue-cls)) "PATCH" - (format "/repos/%s/%s/issues/%s" user repo id) - (gh-issues-issue-req-to-update req))) - -(defmethod gh-issues-issue-new ((api gh-issues-api) user repo issue) - (gh-api-authenticated-request - api (gh-object-reader (oref api issue-cls)) "POST" - (format "/repos/%s/%s/issues" user repo) - (gh-issues-issue-req-to-update issue))) - -;;; Labels - -(defmethod gh-issues-label-get ((api gh-issues-api) user repo name) - (gh-api-authenticated-request - api (gh-object-reader (oref api label-cls)) "GET" - (format "/repos/%s/%s/labels/%s" user repo name))) - -(defmethod gh-issues-label-list ((api gh-issues-api) user repo) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api label-cls)) "GET" - (format "/repos/%s/%s/labels" user repo ))) - -(defmethod gh-issues-label-new ((api gh-issues-api) user repo req) - (gh-api-authenticated-request - api (gh-object-reader (oref api label-cls)) "POST" - (format "/repos/%s/%s/labels" user repo) - (gh-issues-label-req-to-update req))) - -(defmethod gh-issues-label-update ((api gh-issues-api) user repo req) - (gh-api-authenticated-request - api (gh-object-reader (oref api label-cls)) "POST" - (format "/repos/%s/%s/labels/%s" user repo (oref req :name)) - (gh-issues-label-req-to-update req))) - -(defmethod gh-issues-label-delete ((api gh-issues-api) user repo name) - (gh-api-authenticated-request - api (gh-object-reader (oref api label-cls)) "DELETE" - (format "/repos/%s/%s/labels/%s" user repo name))) - - -(defmethod gh-issues-labels-in-issue ((api gh-issues-api) user repo - issue-or-issue-id) - (let ((issue-id (gh-issues--issue-id issue-or-issue-id))) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api label-cls)) "GET" - (format "/repos/%s/%s/issues/%s/labels" user repo issue-id)))) - -(defmethod gh-issues-labels-add-to-issue ((api gh-issues-api) user repo - issue-or-issue-id labels) - (let ((issue-id (gh-issues--issue-id issue-or-issue-id))) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api label-cls)) "PUT" - (format "/repos/%s/%s/issues/%s/labels" user repo issue-id) - (mapcar #'gh-issues--label-name labels)))) - -(defmethod gh-issues-labels-remove-all-from-issue ((api gh-issues-api) user repo - issue-or-issue-id ) - (let ((issue-id (gh-issues--issue-id issue-or-issue-id))) - (gh-api-authenticated-request - api (lambda (x) x) "DELETE" - (format "/repos/%s/%s/issues/%s/labels" user repo issue-id)))) - -(defmethod gh-issues-labels-in-milestone ((api gh-issues-api) user repo - milestone-or-milestone-id) - (let ((milestone-id (gh-issues--milestone-id milestone-or-milestone-id))) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api label-cls)) "GET" - (format "/repos/%s/%s/milestones/%s/labels" user repo milestone-id)))) - -;;; Comments - -(defmethod gh-issues-comments-list ((api gh-issues-api) user repo issue-id) - (gh-comments-list api (format "/repos/%s/%s/issues/%s" user repo issue-id))) - -(defmethod gh-issues-comments-get ((api gh-issues-api) user repo comment-id) - (gh-comments-get api (format "/repos/%s/%s/issues" user repo) comment-id)) - -(defmethod gh-issues-comments-update ((api gh-issues-api) - user repo comment-id comment) - (gh-comments-update api (format "/repos/%s/%s/issues" user repo) - comment-id (gh-comment-req-to-update comment))) - -(defmethod gh-issues-comments-new ((api gh-issues-api) - user repo issue-id comment) - (gh-comments-new api (format "/repos/%s/%s/issues/%s" user repo issue-id) - (gh-comment-req-to-update comment))) - -(defmethod gh-issues-comments-delete ((api gh-issues-api) user repo comment-id) - (gh-comments-delete api (format "/repos/%s/%s/issues" user repo) comment-id)) - -;;; helpers - -(defun gh-issues--issue-id (issue-or-issue-id) - (if (eieio-object-p issue-or-issue-id) - (oref issue-or-issue-id :id) - issue-or-issue-id)) - -(defun gh-issues--milestone-id (milestone-or-milestone-id) - (if (eieio-object-p milestone-or-milestone-id) - (oref milestone-or-milestone-id :id) - milestone-or-milestone-id)) - -(defun gh-issues--label-name (label-or-label-name) - (if (eieio-object-p label-or-label-name) - (oref label-or-label-name :name) - label-or-label-name)) - - -(provide 'gh-issues) -;;; gh-issues.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-oauth.el b/elpa/gh-20160728.1525/gh-oauth.el deleted file mode 100644 index b4192fc..0000000 --- a/elpa/gh-20160728.1525/gh-oauth.el +++ /dev/null @@ -1,97 +0,0 @@ -;;; gh-oauth.el --- oauth module for gh.el - -;; Copyright (C) 2012 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-api) -(require 'gh-auth) -(require 'gh-common) - -;;;###autoload -(defclass gh-oauth-api (gh-api-v3) - ((auth-cls :allocation :class :initform gh-oauth-authorization)) - "OAuth API") - -;;;###autoload -(defclass gh-oauth-password-authenticator (gh-password-authenticator) - ((remember :allocation :class :initform nil))) - -(defmethod initialize-instance ((api gh-oauth-api) &rest args) - ;; force password authentication for this API - (let ((gh-api-v3-authenticator 'gh-oauth-password-authenticator)) - (call-next-method))) - -;;;###autoload -(gh-defclass gh-oauth-authorization (gh-ref-object) - ((scopes :initarg :scopes) - (token :initarg :token) - (app :initarg :app :initform nil :marshal-type gh-oauth-app) - (updated-at :initarg :updated-at) - (created-at :initarg :created-at))) - -;;;###autoload -(gh-defclass gh-oauth-app (gh-object) - ((url :initarg :url) - (name :initarg :name))) - -(defmethod gh-oauth-auth-list ((api gh-oauth-api)) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api auth-cls)) "GET" - (format "/authorizations"))) - -(defmethod gh-oauth-auth-get ((api gh-oauth-api) id) - (gh-api-authenticated-request - api (gh-object-reader (oref api auth-cls)) "GET" - (format "/authorizations/%s" id))) - -(defmethod gh-oauth-auth-new ((api gh-oauth-api) &optional scopes) - (gh-api-authenticated-request - api (gh-object-reader (oref api auth-cls)) "POST" - (format "/authorizations") (list (cons 'scopes scopes) - (cons 'note (format "gh.el - %s" - (system-name)))))) - -(defmethod gh-oauth-auth-update ((api gh-oauth-api) id &optional scopes) - (gh-api-authenticated-request - api (gh-object-reader (oref api auth-cls)) "PATCH" - (format "/authorizations/%s" id) (list (cons 'scopes scopes)))) - -(defmethod gh-oauth-auth-delete ((api gh-oauth-api) id) - (gh-api-authenticated-request - api nil "DELETE" (format "/authorizations/%s" id))) - -(provide 'gh-oauth) -;;; gh-oauth.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-orgs.el b/elpa/gh-20160728.1525/gh-orgs.el deleted file mode 100644 index 2f263f1..0000000 --- a/elpa/gh-20160728.1525/gh-orgs.el +++ /dev/null @@ -1,113 +0,0 @@ -;;; gh-org.el --- orgs module for gh.el - -;; Copyright (C) 2012 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-api) -(require 'gh-auth) -(require 'gh-common) - -;;;###autoload -(defclass gh-orgs-api (gh-api-v3) - ((org-cls :allocation :class :initform gh-orgs-org)) - "Orgs API") - -;;;###autoload -(gh-defclass gh-orgs-org-stub (gh-ref-object) - ((login :initarg :login) - (avatar-url :initarg :avatar-url) - (description :initarg :description))) - -;;;###autoload -(gh-defclass gh-orgs-plan (gh-object) - ((name :initarg :name) - (space :initarg :space) - (private-repos :initarg :private-repos))) - -;;;###autoload -(gh-defclass gh-orgs-org (gh-orgs-org-stub) - ((name :initarg :name) - (company :initarg :company) - (blog :initarg :blog) - (location :initarg :location) - (email :initarg :email) - (public-repos :initarg :public-repos) - (public-gists :initarg :public-gists) - (followers :initarg :followers) - (following :initarg :following) - (created-at :initarg :created-at) - (type :initarg :type) - (total-private-repos :initarg :total-private-repos) - (owned-private-repos :initarg :owned-private-repos) - (private-gists :initarg :private-gists) - (disk-usage :initarg :disk-usage) - (collaborators :initarg :collaborators) - (billing-email :initarg :billing-email) - (plan :initarg :plan :initform nil :marshal-type gh-orgs-plan)) - "Class for GitHub organizations") - -(defmethod gh-orgs-org-to-obj ((org gh-orgs-org)) - `(,@(when (slot-boundp org :billing-email) - (list (cons "billing_email" (oref org :billing-email)))) - ,@(when (slot-boundp org :blog) - (list (cons "blog" (oref org :blog)))) - ,@(when (slot-boundp org :company) - (list (cons "company" (oref org :company)))) - ,@(when (slot-boundp org :email) - (list (cons "email" (oref org :email)))) - ,@(when (slot-boundp org :location) - (list (cons "location" (oref org :location)))) - ,@(when (slot-boundp org :name) - (list (cons "name" (oref org :name)))))) - -(defmethod gh-orgs-list ((api gh-orgs-api) &optional username) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api org-cls)) "GET" - (format "/users/%s/orgs" (or username (gh-api-get-username api))))) - -(defmethod gh-orgs-get ((api gh-orgs-api) org) - (gh-api-authenticated-request - api (gh-object-reader (oref api org-cls)) "GET" - (format "/orgs/%s" org))) - -(defmethod gh-orgs-update ((api gh-orgs-api) org-obj) - (gh-api-authenticated-request - api (gh-object-reader (oref api org-cls)) "PATCH" - (format "/orgs/%s" (oref org-obj :login)) - (apply 'gh-orgs-org-to-obj org-obj nil))) - -(provide 'gh-orgs) -;;; gh-org.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-pkg.el b/elpa/gh-20160728.1525/gh-pkg.el deleted file mode 100644 index c1f1140..0000000 --- a/elpa/gh-20160728.1525/gh-pkg.el +++ /dev/null @@ -1,10 +0,0 @@ -(define-package "gh" "20160728.1525" "A GitHub library for Emacs" - '((emacs "24.3") - (s "1.9.0") - (dash "2.9.0") - (pcache "0.4.1") - (logito "0.1") - (marshal "0.6.3"))) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/gh-20160728.1525/gh-profile.el b/elpa/gh-20160728.1525/gh-profile.el deleted file mode 100644 index d2550c7..0000000 --- a/elpa/gh-20160728.1525/gh-profile.el +++ /dev/null @@ -1,103 +0,0 @@ -;;; gh-profile.el --- profile support for gh.el - -;; Copyright (C) 2013 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -(require 'rx) -(require 'url-parse) - -(defgroup gh-profile nil - "Github profile." - :group 'gh) - -(defun gh-profile-remote-regexp (domain) - (eval - `(rx bol (or ,(concat "git@" domain ":") - (and (or "git" "ssh" "http" "https") "://" - (* nonl) (? "@") ,domain "/")) - (and (group (* nonl)) "/" (group (* nonl))) (? ".git")))) - -(defcustom gh-profile-alist `(("github" - :url "https://api.github.com" - :remote-regexp - ,(gh-profile-remote-regexp "github.com"))) - "List of profiles for Github access. List every Github -Enterprise server and/or Github accounts you have access -to here." - :type '(alist :key-type string - :value-type (plist :key-type (choice (const :url) - (const :username) - (const :password) - (const :token) - (const :remote-regexp)) - :value-type string)) - :group 'gh-profile) - -(defun gh-profile-get-remote-regexp (profile) - (let* ((profile-plist (cdr (assoc profile gh-profile-alist))) - (regexp (plist-get profile-plist :remote-regexp))) - (if regexp - regexp - ;; try to guess remote format (just use the hostname) - (let* ((url (url-generic-parse-url (plist-get profile-plist :url))) - (host (url-host url))) - (gh-profile-remote-regexp host))))) - -(defcustom gh-profile-default-profile "github" - "Default profile. This needs to be a key present in - `gh-profile-alist'" - :type 'string - :group 'gh-profile) - -(defvar gh-profile-current-profile nil) -(make-variable-buffer-local 'gh-profile-current-profile) - -(defun gh-profile-current-profile () - (or gh-profile-current-profile - gh-profile-default-profile)) - -(defun gh-profile-url () - (plist-get (cdr (assoc (or gh-profile-current-profile - gh-profile-default-profile) - gh-profile-alist)) :url)) - -(defun gh-profile-completing-read () - (let ((profiles (mapcar #'car gh-profile-alist))) - (if (> (length profiles) 1) - (completing-read "Github profile: " profiles nil t nil nil (first profiles)) - (car profiles)))) - -(defun gh-profile-get-remote-profile (remote-url) - (loop for (id . props) in gh-profile-alist - if (string-match (gh-profile-get-remote-regexp id) - remote-url) - return id)) - -(provide 'gh-profile) -;;; gh-profile.el ends here diff --git a/elpa/gh-20160728.1525/gh-pull-comments.el b/elpa/gh-20160728.1525/gh-pull-comments.el deleted file mode 100644 index 5cd73c5..0000000 --- a/elpa/gh-20160728.1525/gh-pull-comments.el +++ /dev/null @@ -1,78 +0,0 @@ -;;; gh-pull-comments.el --- pull request comments api for github - -;; Copyright (C) 2014 Toni Reina - -;; Author: Toni Reina -;; Keywords: - -;; 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: - -;; TODOS: -;; * Support listing all comments in a repository - -;; Basic usage: - -;; (setf api (gh-pull-comments-api "api" :sync nil :cache nil :num-retries 1)) -;; (setf comments (gh-pull-comments-list api "user" "repo" "pull request id")) -;; (setq my-comment (make-instance 'gh-pull-comments-comment -;; :body "This is great!" -;; :path "README.md" -;; :position 2 -;; :commit-id "commit sha")) -;; (gh-pull-comments-new api "user" "repo" "pull request id" my-comment) - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-api) -(require 'gh-auth) -(require 'gh-common) - -(require 'gh-pulls) - -(let ((ver "1.0.0")) - (define-obsolete-function-alias - 'gh-pull-comments-api 'gh-pulls-api ver) - (define-obsolete-function-alias - 'gh-pull-comments-comment 'gh-pulls-comment ver) - - (define-obsolete-function-alias - 'gh-pull-comments-req-to-update 'gh-comment-req-to-update ver) - (define-obsolete-function-alias - 'gh-pull-comments-req-to-create 'gh-pulls-comment-req-to-create) - - (define-obsolete-function-alias - 'gh-pull-comments-list 'gh-pulls-comments-list ver) - (define-obsolete-function-alias - 'gh-pull-comments-get 'gh-pulls-comments-get ver) - (define-obsolete-function-alias - 'gh-pull-comments-update 'gh-pulls-comments-update ver) - (define-obsolete-function-alias - 'gh-pull-comments-new 'gh-pulls-comments-new ver) - (define-obsolete-function-alias - 'gh-pull-comments-delete 'gh-pulls-comments-delete ver)) - -(provide 'gh-pull-comments) -;;; gh-pull-comments.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-pulls.el b/elpa/gh-20160728.1525/gh-pulls.el deleted file mode 100644 index 9472943..0000000 --- a/elpa/gh-20160728.1525/gh-pulls.el +++ /dev/null @@ -1,166 +0,0 @@ -;;; gh-pulls.el --- pull requests module for gh.el - -;; Copyright (C) 2011 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-api) -(require 'gh-auth) -(require 'gh-comments) -(require 'gh-common) - -(require 'gh-repos) - -;;;###autoload -(defclass gh-pulls-cache (gh-cache) - ((invalidation-chain :allocation :class - :initform '(("^/repos/.*/.*/pulls$" . "\0") - ("^/repos/.*/.*/pulls/.*$" . "\0"))))) - -;;;###autoload -(defclass gh-pulls-api (gh-api-v3 gh-comments-api-mixin) - ((cache-cls :allocation :class :initform gh-pulls-cache) - - (req-cls :allocation :class :initform gh-pulls-request) - (comment-cls :allocation :class :initform gh-pulls-comment)) - "Git pull requests API") - -;;;###autoload -(gh-defclass gh-pulls-comment (gh-comment) - ((path :initarg :path) - (diff-hunk :initarg :diff-hunk) - (position :initarg :position) - (original-position :initarg :original-position) - (commit-id :initarg :commit-id) - (original-commit-id :initarg :original-commit-id) - (in-reply-to :initarg :in-reply-to :initform nil))) - -(defmethod gh-pulls-comment-req-to-create ((req gh-pulls-comment)) - (let ((in-reply-to (oref req in-reply-to)) - (to-update `(("body" . ,(oref req body))))) - (if in-reply-to - (nconc to-update `(("in_reply_to" . ,in-reply-to))) - (nconc to-update `(("commit_id" . ,(oref req commit-id)) - ("path" . ,(oref req path)) - ("position" . ,(oref req position))))) - to-update)) - -;;;###autoload -(gh-defclass gh-pulls-request-stub (gh-ref-object) - ((diff-url :initarg :diff-url) - (patch-url :initarg :patch-url) - (issue-url :initarg :issue-url) - (number :initarg :number) - (state :initarg :state) - (title :initarg :title) - (body :initarg :body) - (created-at :initarg :created-at) - (updated-at :initarg :updated-at) - (closed-at :initarg :closed-at) - (merged-at :initarg :merged-at) - (head :initarg :head :initform nil :marshal-type gh-repos-ref) - (base :initarg :base :initform nil :marshal-type gh-repos-ref))) - -;;;###autoload -(gh-defclass gh-pulls-request (gh-pulls-request-stub) - ((merged :initarg :merged) - (mergeable :initarg :mergeable) - (merged-by :initarg :merged-by) - (comments :initarg :comments) - (user :initarg :user :initform nil :marshal-type gh-user) - (commits :initarg :commits) - (additions :initarg :additions) - (deletions :initarg :deletions) - (changed-files :initarg :changed-files)) - "Git pull requests API") - -(defmethod gh-pulls-req-to-new ((req gh-pulls-request)) - (let ((head (oref req :head)) - (base (oref req :base))) - `(("title" . ,(oref req :title)) - ("body" . ,(oref req :body)) - ("head" . ,(or (oref head :ref) (oref head :sha))) - ("base" . ,(or (oref base :ref) (oref base :sha)))))) - -(defmethod gh-pulls-req-to-update ((req gh-pulls-request-stub)) - `(("title" . ,(oref req :title)) - ("body" . ,(oref req :body)) - ("state" . ,(oref req :state)))) - -(defmethod gh-pulls-list ((api gh-pulls-api) user repo) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api req-cls)) "GET" - (format "/repos/%s/%s/pulls" user repo))) - -(defmethod gh-pulls-get ((api gh-pulls-api) user repo id) - (gh-api-authenticated-request - api (gh-object-reader (oref api req-cls)) "GET" - (format "/repos/%s/%s/pulls/%s" user repo id))) - -(defmethod gh-pulls-new ((api gh-pulls-api) user repo req) - (gh-api-authenticated-request - api (gh-object-reader (oref api req-cls)) "POST" - (format "/repos/%s/%s/pulls" user repo) - (gh-pulls-req-to-new req))) - -(defmethod gh-pulls-update ((api gh-pulls-api) user repo id req) - (gh-api-authenticated-request - api (gh-object-reader (oref api req-cls)) "PATCH" - (format "/repos/%s/%s/pulls/%s" user repo id) - (gh-pulls-req-to-update req))) - -;;; Comments - -(defmethod gh-pulls-comments-list ((api gh-pulls-api) user repo pull-id) - (gh-comments-list api (format "/repos/%s/%s/pulls/%s" user repo pull-id))) - -(defmethod gh-pulls-comments-get ((api gh-pulls-api) user repo comment-id) - (gh-comments-get api (format "/repos/%s/%s/pulls" user repo) comment-id)) - -(defmethod gh-pulls-comments-update ((api gh-pulls-api) - user repo comment-id comment) - (gh-comments-update api (format "/repos/%s/%s/pulls" user repo) - comment-id (gh-comment-req-to-update comment))) - -(defmethod gh-pulls-comments-new ((api gh-pulls-api) - user repo pull-id comment) - (gh-comments-new api (format "/repos/%s/%s/pulls/%s" user repo pull-id) - (gh-pulls-comment-req-to-create comment))) - -(defmethod gh-pulls-comments-delete ((api gh-pulls-api) user repo comment-id) - (gh-comments-delete api (format "/repos/%s/%s/pulls" user repo) comment-id)) - -(provide 'gh-pulls) -;;; gh-pulls.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-repos.el b/elpa/gh-20160728.1525/gh-repos.el deleted file mode 100644 index ce9037c..0000000 --- a/elpa/gh-20160728.1525/gh-repos.el +++ /dev/null @@ -1,350 +0,0 @@ -;;; gh-repos.el --- repos module for gh.el - -;; Copyright (C) 2011 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-api) -(require 'gh-auth) -(require 'gh-common) - -;;;###autoload -(defclass gh-repos-api (gh-api-v3) - ((repo-cls :allocation :class :initform gh-repos-repo) - (user-cls :allocation :class :initform gh-user)) - "Repos API") - -;;;###autoload -(gh-defclass gh-repos-repo-stub (gh-object) - ((name :initarg :name) - (description :initarg :description) - (homepage :initarg :homepage) - (private :initarg :private)) - "Class for user-created repository objects") - -;;;###autoload -(gh-defclass gh-repos-repo (gh-ref-object gh-repos-repo-stub) - ((clone-url :initarg :clone-url) - (git-url :initarg :git-url) - (ssh-url :initarg :ssh-url) - (svn-url :initarg :svn-url) - (mirror-url :initarg :mirror-url) - (owner :initarg :owner :initform nil :marshal-type gh-user) - (full-name :initarg :full-name) - (language :initarg :language) - (fork :initarg :fork) - (forks :initarg :forks) - (forks-count :initarg :forks-count) - (watchers :initarg :watchers) - (watchers-count :initarg :watchers-count) - (stargazers-count :initarg :stargazers-count) - (size :initarg :size) - (master-branch :initarg :master-branch) - (open-issues :initarg :open-issues) - (pushed-at :initarg :pushed-at) - (created-at :initarg :created-at) - (updated-at :initarg :updated-at) - (organisation :initarg :organisation :initform nil :marshal-type gh-user) - (parent :initarg :parent :marshal-type gh-repos-repo) - (source :initarg :source :marshal-type gh-repos-repo) - (has-issues :initarg :has-issues) - (has-wiki :initarg :has-wiki) - (has-downloads :initarg :has-downloads)) - "Class for GitHub repositories") - -;;;###autoload -(gh-defclass gh-repos-ref (gh-object) - ((label :initarg :label) - (ref :initarg :ref :initform nil) - (sha :initarg :sha :initform nil) - (user :initarg :user :initform nil :marshal-type gh-user) - (repo :initarg :repo :initform nil :marshal-type gh-repos-repo))) - -(defmethod gh-repos-user-list ((api gh-repos-api) &optional username) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api repo-cls)) "GET" - (format "/users/%s/repos" (or username (gh-api-get-username api))))) - -(defmethod gh-repos-org-list ((api gh-repos-api) org) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api repo-cls)) "GET" - (format "/orgs/%s/repos" org))) - -(defmethod gh-repos-repo-to-obj ((repo gh-repos-repo-stub) - &rest caps) - (let ((has_issues (plist-member caps :issues)) - (has_wiki (plist-member caps :wiki)) - (has_downloads (plist-member caps :downloads))) - `(("name" . ,(oref repo :name)) - ,@(when (slot-boundp repo :homepage) - (list (cons "homepage" (oref repo :homepage)))) - ,@(when (slot-boundp repo :description) - (list (cons "description" (oref repo :description)))) - ,@(when (slot-boundp repo :private) - (list (cons "public" (not (oref repo :private))))) - ,@(when has_issues - (list (cons "has_issues" (plist-get caps :issues)))) - ,@(when has_wiki - (list (cons "has_wiki" (plist-get caps :wiki)))) - ,@(when has_downloads - (list (cons "has_downloads" (plist-get caps :downloads))))))) - -(defmethod gh-repos-repo-new ((api gh-repos-api) repo-stub - &optional org &rest caps) - (gh-api-authenticated-request - api (gh-object-reader (oref api repo-cls)) "POST" - (if org (format "/orgs/%s/repos" org) - "/user/repos") - (apply 'gh-repos-repo-to-obj repo-stub caps))) - -(defmethod gh-repos-repo-get ((api gh-repos-api) repo-id &optional user) - (gh-api-authenticated-request - api (gh-object-reader (oref api repo-cls)) "GET" - (format "/repos/%s/%s" - (or user (gh-api-get-username api)) - repo-id))) - -(defmethod gh-repos-repo-update ((api gh-repos-api) repo-stub - &optional user &rest caps) - (gh-api-authenticated-request - api (gh-object-reader (oref api repo-cls)) "PATCH" - (format "/repos/%s/%s" - (or user (gh-api-get-username api)) - (oref repo-stub :name)) - (apply 'gh-repos-repo-to-obj repo-stub caps))) - -(defmethod gh-repos-repo-rename ((api gh-repos-api) repo-stub new-name - &optional user) - (let ((new-stub (make-instance 'gh-repos-repo-stub :name new-name))) - (gh-api-authenticated-request - api (gh-object-reader (oref api repo-cls)) "PATCH" - (format "/repos/%s/%s" - (or user (gh-api-get-username api)) - (oref repo-stub :name)) - (gh-repos-repo-to-obj new-stub)))) - -(defmethod gh-repos-repo-delete ((api gh-repos-api) repo-id - &optional user) - (gh-api-authenticated-request - api (gh-object-reader (oref api repo-cls)) "DELETE" - (format "/repos/%s/%s" - (or user (gh-api-get-username api)) - repo-id))) - -;; TODO gh-repos-repo-move - -(defmethod gh-repos-repo-contributors ((api gh-repos-api) repo) - (gh-api-authenticated-request - api (gh-object-reader (oref api repo-cls)) "GET" - (format "/repos/%s/%s/contributors" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -;;; TODO: generate some useful objects with the return values - -(defmethod gh-repos-repo-languages ((api gh-repos-api) repo) - (gh-api-authenticated-request - api nil "GET" (format "/repos/%s/%s/languages" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -(defmethod gh-repos-repo-teams ((api gh-repos-api) repo) - (gh-api-authenticated-request - api nil "GET" (format "/repos/%s/%s/teams" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -(defmethod gh-repos-repo-tags ((api gh-repos-api) repo) - (gh-api-authenticated-request - api nil "GET" (format "/repos/%s/%s/tags" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -(defmethod gh-repos-repo-branches ((api gh-repos-api) repo) - (gh-api-authenticated-request - api nil "GET" (format "/repos/%s/%s/branches" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -;;; TODO gh-repos-repo-branch-commits - -;;; Collaborators sub-API - -(defmethod gh-repos-collaborators-list ((api gh-repos-api) repo) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api user-cls)) "GET" (format "/repos/%s/%s/collaborators" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -(defmethod gh-repos-collaborators-p ((api gh-repos-api) repo user) - (eq (oref (gh-api-authenticated-request - api nil "GET" - (format "/repos/%s/%s/collaborators/%s" - (oref (oref repo :owner) :login) - (oref repo :name) - user)) - :http-status) - 204)) - -(defmethod gh-repos-collaborators-add ((api gh-repos-api) repo user) - (gh-api-authenticated-request - api nil "PUT" - (format "/repos/%s/%s/collaborators/%s" - (oref (oref repo :owner) :login) - (oref repo :name) - user))) - -(defmethod gh-repos-collaborators-delete ((api gh-repos-api) repo user) - (gh-api-authenticated-request - api nil "DELETE" - (format "/repos/%s/%s/collaborators/%s" - (oref (oref repo :owner) :login) - (oref repo :name) - user))) - -;;; TODO Comments sub-API -;;; TODO Commits sub-API -;;; TODO Contents sub-API -;;; TODO Downloads sub-API - -;;; Forks sub-API - -(defmethod gh-repos-forks-list ((api gh-repos-api) repo &optional recursive) - (let ((resp (gh-api-authenticated-request - api (gh-object-list-reader (oref api repo-cls)) "GET" - (format "/repos/%s/%s/forks" - (oref (oref repo :owner) :login) - (oref repo :name))))) - (when recursive - (let ((forks (oref resp :data))) - (oset resp :data - (apply 'nconc forks - (mapcar - (lambda (f) - (oref (gh-repos-forks-list api f t) data)) - forks))))) - resp)) - -(defmethod gh-repos-fork ((api gh-repos-api) repo &optional org) - (gh-api-authenticated-request - api (gh-object-reader (oref api repo-cls)) "POST" - (format "/repos/%s/%s/forks" - (oref (oref repo :owner) :login) - (oref repo :name)) - nil (when org `(("org" . ,org))))) - -;;; TODO Keys sub-API -;;; TODO Hooks sub-API -;;; TODO Merging sub-API - -;;; Starring sub-API - -(defmethod gh-repos-stargazers ((api gh-repos-api) repo) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api user-cls)) "GET" - (format "/repos/%s/%s/stargazers" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -(defmethod gh-repos-starred-list ((api gh-repos-api) &optional username) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api repo-cls)) "GET" - (format "/users/%s/starred" (or username (gh-api-get-username api))))) - -(defmethod gh-repos-starred-p ((api gh-repos-api) repo) - (eq (oref (gh-api-authenticated-request - api nil "GET" - (format "/user/starred/%s/%s" - (oref (oref repo :owner) :login) - (oref repo :name))) - :http-status) - 204)) - -(defmethod gh-repos-star ((api gh-repos-api) repo) - (gh-api-authenticated-request - api nil "PUT" - (format "/user/starred/%s/%s" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -(defmethod gh-repos-unstar ((api gh-repos-api) repo) - (gh-api-authenticated-request - api nil "DELETE" - (format "/user/starred/%s/%s" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -;;; TODO Statuses sub-API - -;;; Watching sub-API - -(defmethod gh-repos-watchers ((api gh-repos-api) repo) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api user-cls)) "GET" - (format "/repos/%s/%s/subscribers" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -(defmethod gh-repos-watched-list ((api gh-repos-api) &optional username) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api repo-cls)) "GET" - (format "/users/%s/subscriptions" - (or username (gh-api-get-username api))))) - -(defmethod gh-repos-watched-p ((api gh-repos-api) repo) - (eq (oref (gh-api-authenticated-request - api nil "GET" - (format "/user/subscriptions/%s/%s" - (oref (oref repo :owner) :login) - (oref repo :name))) - :http-status) - 204)) - -(defmethod gh-repos-watch ((api gh-repos-api) repo) - (gh-api-authenticated-request - api nil "PUT" - (format "/user/subscriptions/%s/%s" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -(defmethod gh-repos-unwatch ((api gh-repos-api) repo) - (gh-api-authenticated-request - api nil "DELETE" - (format "/user/subscriptions/%s/%s" - (oref (oref repo :owner) :login) - (oref repo :name)))) - -(provide 'gh-repos) -;;; gh-repos.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/gh-20160728.1525/gh-search.el b/elpa/gh-20160728.1525/gh-search.el deleted file mode 100644 index 373e7cd..0000000 --- a/elpa/gh-20160728.1525/gh-search.el +++ /dev/null @@ -1,62 +0,0 @@ -;;; gh-search.el --- repository search for gh.el -;; Copyright (C) 2016 Ivan Malison - -;; Author: Ivan Malison - -;; 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: - -;; - -;;; Code: - -(require 'gh-users) -(require 'gh-repos) - -;;;###autoload -(defclass gh-search-api (gh-api-v3) - ((repo-cls :allocation :class :initform gh-repos-repo) - (user-cls :allocation :class :initform gh-users-user))) - -(defmacro gh-search-method-builder (method-name uri process-result-function) - `(defmethod ,method-name ((search-api gh-search-api) - query-string &optional page-limit - &rest additional-arguments) - (unless (and (stringp query-string) (> (length query-string) 1)) - (error "a non-empty query string must be provided to github search")) - (gh-api-authenticated-request - search-api - (apply-partially (quote ,process-result-function) search-api) - "GET" ,uri nil - `((q . ,query-string) ,@additional-arguments) page-limit))) - -(defmacro gh-search-process-method-builder (method-name class-symbol) - `(defmethod ,method-name ((search-api gh-search-api) data) - (unless (listp data) - (error "Did not recieve a list from the search query")) - (let ((items (assoc 'items data))) - (unless items - (error "Search query did not return items")) - (gh-object-list-read (oref search-api ,class-symbol) (cdr items))))) - -(gh-search-process-method-builder gh-process-repo-search-result repo-cls) -(gh-search-process-method-builder gh-process-user-search-result user-cls) -(gh-search-method-builder gh-search-repos "/search/repositories" - gh-process-repo-search-result) -(gh-search-method-builder gh-search-users "/search/users" - gh-process-user-search-result) - -(provide 'gh-search) -;;; gh-search.el ends here diff --git a/elpa/gh-20160728.1525/gh-url.el b/elpa/gh-20160728.1525/gh-url.el deleted file mode 100644 index 3c23f6c..0000000 --- a/elpa/gh-20160728.1525/gh-url.el +++ /dev/null @@ -1,193 +0,0 @@ -;;; gh-url.el --- url wrapper for gh.el - -;; Copyright (C) 2012 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'url-http) - -;;;###autoload -(defclass gh-url-request () - ((method :initarg :method :type string) - (url :initarg :url :type string) - (query :initarg :query :initform nil) - (headers :initarg :headers :initform nil) - (data :initarg :data :initform "" :type string) - (async :initarg :async :initform nil) - (num-retries :initarg :num-retries :initform 0) - (install-callbacks :initarg :install-callbacks :initform nil) - - (default-response-cls :allocation :class :initform gh-url-response))) - -;;;###autoload -(defclass gh-url-response () - ((data-received :initarg :data-received :initform nil) - (data :initarg :data :initform nil) - (headers :initarg :headers :initform nil) - (http-status :initarg :http-status :initform nil) - (callbacks :initarg :callbacks :initform nil) - (transform :initarg :transform :initform nil) - (-req :initarg :-req :initform nil))) - -(defmethod gh-url-response-set-data ((resp gh-url-response) data) - (let ((transform (oref resp :transform))) - (oset resp :data - (if transform - (funcall transform data) - data)) - (oset resp :data-received t))) - -;;;###autoload -(defclass gh-url-callback () - nil) - -(defmethod gh-url-callback-run ((cb gh-url-callback) resp) - nil) - -(defmethod gh-url-response-run-callbacks ((resp gh-url-response)) - (let ((copy-list (lambda (list) - (if (consp list) - (let ((res nil)) - (while (consp list) (push (pop list) res)) - (prog1 (nreverse res) (setcdr res list))) - (car list))))) - (let ((data (oref resp :data))) - (dolist (cb (funcall copy-list (oref resp :callbacks))) - (cond ((and (object-p cb) - (object-of-class-p cb 'gh-url-callback)) - (gh-url-callback-run cb resp)) - ((or (functionp cb) (symbolp cb)) - (funcall cb data)) - (t (apply (car cb) data (cdr cb)))) - (object-remove-from-list resp :callbacks cb)))) - resp) - -(defmethod gh-url-add-response-callback ((resp gh-url-response) callback) - (object-add-to-list resp :callbacks callback t) - (if (oref resp :data-received) - (gh-url-response-run-callbacks resp) - resp)) - -;;; code borrowed from nicferrier's web.el -(defun gh-url-parse-headers (data) - (let* ((headers nil) - (header-lines (split-string data "\n")) - (status-line (car header-lines))) - (when (string-match - "HTTP/\\([0-9.]+\\) \\([0-9]\\{3\\}\\)\\( \\(.*\\)\\)*" - status-line) - (push (cons 'status-version (match-string 1 status-line)) headers) - (push (cons 'status-code (match-string 2 status-line)) headers) - (push (cons 'status-string - (or (match-string 4 status-line) "")) - headers)) - (loop for line in (cdr header-lines) - if (string-match - "^\\([A-Za-z0-9.-]+\\):[ ]*\\(.*\\)" - line) - do - (let ((name (match-string 1 line)) - (value (match-string 2 line))) - (push (cons name value) headers))) - headers)) - -(defmethod gh-url-response-finalize ((resp gh-url-response)) - (when (oref resp :data-received) - (gh-url-response-run-callbacks resp))) - -(defmethod gh-url-response-init ((resp gh-url-response) - buffer) - (declare (special url-http-end-of-headers)) - (unwind-protect - (with-current-buffer buffer - (let ((headers (gh-url-parse-headers - (buffer-substring - (point-min) (1+ url-http-end-of-headers))))) - (oset resp :headers headers) - (oset resp :http-status (read (cdr (assoc 'status-code headers))))) - (goto-char (1+ url-http-end-of-headers)) - (let ((raw (buffer-substring (point) (point-max)))) - (gh-url-response-set-data resp raw))) - (kill-buffer buffer)) - (gh-url-response-finalize resp) - resp) - -(defun gh-url-set-response (status req-resp) - (set-buffer-multibyte t) - (destructuring-bind (req resp) req-resp - (let ((responses-req (clone req)) - (num (oref req :num-retries))) - (oset resp :-req responses-req) - (if (or (null num) (zerop num)) - (gh-url-response-init resp (current-buffer)) - (condition-case err - (gh-url-response-init resp (current-buffer)) - (error - (oset req :num-retries (1- num)) - (gh-url-run-request req resp))))))) - -(defun gh-url-form-encode (form) - (mapconcat (lambda (x) (format "%s=%s" (car x) (cdr x))) - form "&")) - -(defun gh-url-params-encode (form) - (concat "?" (gh-url-form-encode form))) - -(defmethod gh-url-run-request ((req gh-url-request) &optional resp) - (let ((url-registered-auth-schemes - '(("basic" ignore . 4))) ;; don't let default handlers kick in - (url-privacy-level 'high) - (url-request-method (oref req :method)) - (url-request-data (oref req :data)) - (url-request-extra-headers (oref req :headers)) - (url (concat (oref req :url) - (let ((params (oref req :query))) - (if params - (gh-url-params-encode params) - ""))))) - (if (oref req :async) - (let* ((resp (or resp (make-instance (oref req default-response-cls)))) - (req-resp (list req resp))) - (with-current-buffer - (url-retrieve url 'gh-url-set-response (list req-resp)) - (set (make-local-variable 'url-registered-auth-schemes) - url-registered-auth-schemes))) - (let* ((resp (or resp (make-instance (oref req default-response-cls)))) - (req-resp (list req resp))) - (with-current-buffer (url-retrieve-synchronously url) - (gh-url-set-response nil req-resp))))) - (mapc (lambda (cb) - (gh-url-add-response-callback resp cb)) - (oref req :install-callbacks)) - resp) - -(provide 'gh-url) -;;; gh-url.el ends here diff --git a/elpa/gh-20160728.1525/gh-users.el b/elpa/gh-20160728.1525/gh-users.el deleted file mode 100644 index 930b19e..0000000 --- a/elpa/gh-20160728.1525/gh-users.el +++ /dev/null @@ -1,86 +0,0 @@ -;;; gh-users.el --- users module for gh.el - -;; Copyright (C) 2013 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(eval-when-compile - (require 'cl)) - -;;;###autoload -(require 'eieio) - -(require 'gh-api) -(require 'gh-auth) -(require 'gh-common) - -;;;###autoload -(defclass gh-users-api (gh-api-v3) - ((users-cls :allocation :class :initform gh-users-user)) - "Users API") - -;;;###autoload -(gh-defclass gh-users-user (gh-user) - ((gravatar-id :initarg :gravatar-id) - (html-url :initarg :html-url) - (followers-url :initarg :followers-url) - (following-url :initarg :following-url) - (gists-url :initarg :gists-url) - (starred-url :initarg :starred-url) - (subscriptions-url :initarg :subscriptions-url) - (organizations-url :initarg :organizations-url) - (repos-url :initarg :repos-url) - (events-url :initarg :events-url) - (received-events-url :initarg :received-events-url) - (type :initarg :type) - (site-admin :initarg :site-admin) - (name :initarg :name) - (company :initarg :company) - (blog :initarg :blog) - (location :initarg :location) - (email :initarg :email) - (hireable :initarg :hireable) - (bio :initarg :bio) - (public-repos :initarg :public-repos) - (public-gists :initarg :public-gists) - (followers :initarg :followers) - (following :initarg :following) - (created-at :initarg :created-at) - (update-at :initarg :update-at))) - -(defmethod gh-users-get ((api gh-users-api) &optional username) - (gh-api-authenticated-request - api (gh-object-reader (oref api users-cls)) "GET" - (if username - (format "/users/%s" username) - "/user"))) - -(defmethod gh-users-list ((api gh-users-api)) - (gh-api-authenticated-request - api (gh-object-list-reader (oref api users-cls)) "GET" - "/users")) - -(provide 'gh-users) -;;; gh-users.el ends here diff --git a/elpa/gh-20160728.1525/gh.el b/elpa/gh-20160728.1525/gh.el deleted file mode 100644 index 3ed640e..0000000 --- a/elpa/gh-20160728.1525/gh.el +++ /dev/null @@ -1,39 +0,0 @@ -;;; gh.el --- Github API client libraries - -;; Copyright (C) 2011 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; - -;;; Code: - -(require 'gh-gist) -(require 'gh-pulls) -(require 'gh-issues) -(require 'gh-users) - -(provide 'gh) -;;; gh.el ends here - -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/github-notifier-20160702.2112/github-notifier-autoloads.el b/elpa/github-notifier-20160702.2112/github-notifier-autoloads.el deleted file mode 100644 index 0e47caf..0000000 --- a/elpa/github-notifier-20160702.2112/github-notifier-autoloads.el +++ /dev/null @@ -1,36 +0,0 @@ -;;; github-notifier-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "github-notifier" "github-notifier.el" (22500 -;;;;;; 1786 648025 550000)) -;;; Generated autoloads from github-notifier.el - -(defalias 'github-notifier 'github-notifier-mode) - -(defvar github-notifier-mode nil "\ -Non-nil if Github-Notifier mode is enabled. -See the command `github-notifier-mode' for a description of this minor mode. -Setting this variable directly does not take effect; -either customize it (see the info node `Easy Customization') -or call the function `github-notifier-mode'.") - -(custom-autoload 'github-notifier-mode "github-notifier" nil) - -(autoload 'github-notifier-mode "github-notifier" "\ -Toggle github notifications count display in mode line (Github Notifier mode). -With a prefix argument ARG, enable Github Notifier mode if ARG is -positive, and disable it otherwise. If called from Lisp, enable -the mode if ARG is omitted or nil. - -\(fn &optional ARG)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; github-notifier-autoloads.el ends here diff --git a/elpa/github-notifier-20160702.2112/github-notifier-pkg.el b/elpa/github-notifier-20160702.2112/github-notifier-pkg.el deleted file mode 100644 index 74564b5..0000000 --- a/elpa/github-notifier-20160702.2112/github-notifier-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "github-notifier" "20160702.2112" "Displays your GitHub notifications unread count in mode-line" '((emacs "24")) :url "https://github.com/xuchunyang/github-notifier.el" :keywords '("github" "mode-line")) diff --git a/elpa/github-notifier-20160702.2112/github-notifier.el b/elpa/github-notifier-20160702.2112/github-notifier.el deleted file mode 100644 index 0d7afcb..0000000 --- a/elpa/github-notifier-20160702.2112/github-notifier.el +++ /dev/null @@ -1,243 +0,0 @@ -;;; github-notifier.el --- Displays your GitHub notifications unread count in mode-line -*- lexical-binding: t; -*- - -;; Copyright (C) 2015, 2016 Chunyang Xu - -;; Author: Chunyang Xu -;; URL: https://github.com/xuchunyang/github-notifier.el -;; Package-Version: 20160702.2112 -;; Package-Requires: ((emacs "24")) -;; Keywords: github, mode-line -;; Version: 0.1 - -;; 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 is a global minor-mode. Turn it on everywhere with: -;; -;; M-x github-notifier-mode - -;;; Code: - -(require 'url) -(require 'json) - -(defgroup github-notifier nil - "Github Notifier" - :group 'emacs) - -;;; Custom -(defcustom github-notifier-token nil - "Access token to get Github Notifications. - -To generate an access token, visit -URL `https://github.com/settings/tokens/new?scopes=notifications&description=github-notifier.el' - -This is similar to how erc or jabber handle authentication in -emacs, but the following disclaimer always worth reminding. - -DISCLAIMER -When you save this variable, DON'T WRITE IT ANYWHERE PUBLIC. This -token grants (very) limited access to your account. -END DISCLAIMER - -If nil, Github-Notifier will ask you and remember your token via -`customize-save-variable'." - :type '(choice (string :tag "Token") - (const :tag "Ask me" nil)) - :group 'github-notifier) - -(defcustom github-notifier-mode-line - '(:eval - (let (unread-text help-text) - (cond ((null github-notifier-unread-count) - (setq unread-text "-?" - help-text "The Github notifications number is unknown.")) - ((zerop github-notifier-unread-count) - (setq unread-text "" - help-text "Good job, you don't have unread notification.")) - (t - (setq unread-text (format "-%d%s" github-notifier-unread-count - (if (github-notifier-notifications-checked) "*" "")) - help-text (if (= github-notifier-unread-count 1) - "You have 1 unread notification.\nmouse-1 Read it on Github." - (format "You have %d unread notifications.\nmouse-1 Read them on Github." - github-notifier-unread-count))))) - (propertize (concat " GH" unread-text) - 'help-echo help-text - 'local-map github-notifier-mode-line-map - 'mouse-face 'mode-line-highlight))) - "Mode line lighter for Github Notifier." - :type 'sexp - :risky t - :group 'github-notifier) - -(defcustom github-notifier-update-interval 60 - "Seconds after which the github notifications count will be updated." - :type 'integer - :group 'github-notifier) - -(defcustom github-notifier-only-participating nil - "If non-nil, only counts notifications in which the user is directly participating or mentioned." - :type 'boolean - :group 'github-notifier) - -(defcustom github-notifier-enterprise-domain nil - "Domain to Github installation. -Can be overriden to support Enterprise installations" - :type 'string - :group 'github-notifier) - -;;; Variables -(defvar github-notifier-unread-count nil - "Github notifications unread count. -Normally, this is a number, however, nil means unknown by Emacs.") - -(defvar github-notifier-unread-json nil - "JSON object contains latest (to github-notifier) unread notifications.") - -(defvar github-notifier-update-hook nil - "Run by `github-notifier-update-cb'. -Functions added to this hook takes one argument, the unread -notification json object BEFORE updating. Accordingly, -`github-notifier-unread-json' stores the unread notification json -AFTER updating.") - -(defvar github-notifier-mode-line-map - (let ((map (make-sparse-keymap))) - (define-key map [mode-line mouse-1] 'github-notifier-visit-github) - map)) - -(defvar github-notifier-last-notification nil) -(defvar github-notifier-last-notification-checked nil) -(defvar github-notifier-update-timer nil) - -;;; Function -(defun github-notifier-get-url (path &optional api-request) - "Get URL to Github endpoint. -Get a url to PATH on Github or Github enterprise if -`github-enterprise-domain' is set. If API-REQUEST is true it -will return an API." - (let ((url - (if github-notifier-enterprise-domain - (concat github-notifier-enterprise-domain (when api-request "/api/v3")) - (concat (when api-request "api.") "github.com")))) - (concat "https://" url path))) - -;; FIXME: Even we use `url-retrieve' to retrieve network asynchronously, Emacs -;; still gets blocked frequently (?), especially when the network situation is -;; bad, once it blocks Emacs, you have to wait to it gets finised or interrupt -;; it by hitting C-g many times. This is very annoying. -;; -;; Maybe we can try to invoke curl(1) as asynchronous process. -(defun github-notifier-update-cb (_status) - (set-buffer-multibyte t) - (goto-char (point-min)) - (if (not (string-match "200 OK" (buffer-string))) - (progn (message "[github-notifier] Problem connecting to the server") - (setq github-notifier-unread-count nil)) - (re-search-forward "^$" nil 'move) - (let (json-str - (old-count github-notifier-unread-count) - (old-json github-notifier-unread-json)) - (setq json-str (buffer-substring-no-properties (point) (point-max)) - github-notifier-unread-json (json-read-from-string json-str)) - (setq github-notifier-unread-count (length github-notifier-unread-json)) - (when (> github-notifier-unread-count 0) - (setq github-notifier-last-notification (cdr (assoc 'updated_at (elt github-notifier-unread-json 0))))) - (unless (and (equal old-count github-notifier-unread-count) - (github-notifier-notifications-checked)) - (force-mode-line-update t)) - (run-hook-with-args 'github-notifier-update-hook old-json) - ;; Debug - ;; (setq a-json-string json-str) - ;; (message "Github notification %d unread, updated at %s" - ;; github-notifier-unread-count (current-time-string)) - )) - ;; Debug - ;; (display-buffer (current-buffer)) - (kill-buffer) - (when github-notifier-mode - (setq github-notifier-update-timer - (run-at-time github-notifier-update-interval nil #'github-notifier-update)))) - -(defun github-notifier-update (&optional force) - "Update `github-notifier-unread-count'." - (when (or force github-notifier-mode) - (let ((url-request-extra-headers `(("Authorization" . - ,(format "token %s" github-notifier-token)))) - (url (github-notifier-get-url (concat "/notifications" - (when github-notifier-only-participating - "?participating=true")) t))) - (condition-case error-data - (url-retrieve url #'github-notifier-update-cb nil t t) - (error - (message "Error retrieving github notification from %s: %s" url error-data) - (when github-notifier-mode - (setq github-notifier-update-timer - (run-at-time github-notifier-update-interval nil #'github-notifier-update)))))))) - -(defun github-notifier-visit-github () - (interactive) - (browse-url (github-notifier-get-url "/notifications")) - (setq github-notifier-last-notification-checked (format-time-string "%FT%TZ" (current-time) t)) - (force-mode-line-update t)) - -(defun github-notifier-notifications-checked () - (and github-notifier-unread-count (> github-notifier-unread-count 0) - github-notifier-last-notification github-notifier-last-notification-checked - (string< github-notifier-last-notification github-notifier-last-notification-checked))) - -;;; Glboal Minor-mode - -;;;###autoload -(defalias 'github-notifier 'github-notifier-mode) - -;;;###autoload -(define-minor-mode github-notifier-mode - "Toggle github notifications count display in mode line (Github Notifier mode). -With a prefix argument ARG, enable Github Notifier mode if ARG is -positive, and disable it otherwise. If called from Lisp, enable -the mode if ARG is omitted or nil." - :global t :group 'github-notifier - (unless github-notifier-token - (setq github-notifier-token - (with-temp-buffer - (when (or - (= 0 (call-process "git" nil t nil "config" "github-notifier.oauth-token")) - (= 0 (call-process "git" nil t nil "config" "github.oauth-token"))) - (buffer-substring 1 (progn (goto-char 1) (line-end-position))))))) - (unless (stringp github-notifier-token) - (browse-url (github-notifier-get-url "/settings/tokens/new?scopes=notifications&description=github-notifier.el")) - (let (token) - (unwind-protect - (setq token (read-string "Paste Your Access Token: ")) - (if (stringp token) - (customize-save-variable 'github-notifier-token token) - (message "No Access Token") - (setq github-notifier-mode nil))))) - (unless global-mode-string - (setq global-mode-string '(""))) - (if (not github-notifier-mode) - (progn - (setq global-mode-string - (delq 'github-notifier-mode-line global-mode-string)) - (when github-notifier-update-timer - (cancel-timer github-notifier-update-timer) - (setq github-notifier-update-timer nil))) - (add-to-list 'global-mode-string 'github-notifier-mode-line t) - (github-notifier-update))) - -(provide 'github-notifier) -;;; github-notifier.el ends here diff --git a/elpa/go-mode-20161013.1055/go-guru.el b/elpa/go-mode-20161013.1055/go-guru.el deleted file mode 100644 index 92e5b2f..0000000 --- a/elpa/go-mode-20161013.1055/go-guru.el +++ /dev/null @@ -1,551 +0,0 @@ -;;; go-guru.el --- Integration of the Go 'guru' analysis tool into Emacs. - -;; Copyright 2016 The Go Authors. All rights reserved. -;; Use of this source code is governed by a BSD-style -;; license that can be found in the LICENSE file. - -;; Version: 0.1 -;; Package-Requires: ((go-mode "1.3.1") (cl-lib "0.5")) -;; Keywords: tools - -;;; Commentary: - -;; To enable the Go guru in Emacs, use this command to download, -;; build, and install the tool in $GOROOT/bin: -;; -;; $ go get golang.org/x/tools/cmd/guru -;; -;; Verify that the tool is on your $PATH: -;; -;; $ guru -help -;; Go source code guru. -;; Usage: guru [flags] -;; ... -;; -;; Then copy this file to a directory on your `load-path', -;; and add this to your ~/.emacs: -;; -;; (require 'go-guru) -;; -;; Inside a buffer of Go source code, select an expression of -;; interest, and type `C-c C-o d' (for "describe") or run one of the -;; other go-guru-xxx commands. If you use `menu-bar-mode', these -;; commands are available from the Guru menu. -;; -;; To enable identifier highlighting mode in a Go source buffer, use: -;; -;; (go-guru-hl-identifier-mode) -;; -;; To enable it automatically in all Go source buffers, -;; add this to your ~/.emacs: -;; -;; (add-hook 'go-mode-hook #'go-guru-hl-identifier-mode) -;; -;; See http://golang.org/s/using-guru for more information about guru. - -;;; Code: - -(require 'compile) -(require 'easymenu) -(require 'go-mode) -(require 'json) -(require 'simple) -(require 'cl-lib) - -(defgroup go-guru nil - "Options specific to the Go guru." - :group 'go) - -(defcustom go-guru-command "guru" - "The Go guru command." - :type 'string - :group 'go-guru) - -(defcustom go-guru-scope "" - "The scope of the analysis. See `go-guru-set-scope'." - :type 'string - :group 'go-guru) - -(defvar go-guru--scope-history - nil - "History of values supplied to `go-guru-set-scope'.") - -(defcustom go-guru-build-tags "" - "Build tags passed to guru." - :type 'string - :group 'go-guru) - -(defface go-guru-hl-identifier-face - '((t (:inherit highlight))) - "Face used for highlighting identifiers in `go-guru-hl-identifier'." - :group 'go-guru) - -(defcustom go-guru-debug nil - "Print debug messages when running guru." - :type 'boolean - :group 'go-guru) - -(defcustom go-guru-hl-identifier-idle-time 0.5 - "How long to wait after user input before highlighting the current identifier." - :type 'float - :group 'go-guru) - -(defvar go-guru--current-hl-identifier-idle-time - 0 - "The current delay for hl-identifier-mode.") - -(defvar go-guru--hl-identifier-timer - nil - "The global timer used for highlighting identifiers.") - -(defvar go-guru--last-enclosing - nil - "The remaining enclosing regions of the previous go-expand-region invocation.") - -;; Extend go-mode-map. -(let ((m (define-prefix-command 'go-guru-map))) - (define-key m "d" #'go-guru-describe) - (define-key m "f" #'go-guru-freevars) - (define-key m "i" #'go-guru-implements) - (define-key m "c" #'go-guru-peers) ; c for channel - (define-key m "r" #'go-guru-referrers) - (define-key m "j" #'go-guru-definition) ; j for jump - (define-key m "p" #'go-guru-pointsto) - (define-key m "s" #'go-guru-callstack) ; s for stack - (define-key m "e" #'go-guru-whicherrs) ; e for error - (define-key m "<" #'go-guru-callers) - (define-key m ">" #'go-guru-callees) - (define-key m "x" #'go-guru-expand-region)) ;; x for expand - -(define-key go-mode-map (kbd "C-c C-o") #'go-guru-map) - -(easy-menu-define go-guru-mode-menu go-mode-map - "Menu for Go Guru." - '("Guru" - ["Jump to Definition" go-guru-definition t] - ["Show Referrers" go-guru-referrers t] - ["Show Free Names" go-guru-freevars t] - ["Describe Expression" go-guru-describe t] - ["Show Implements" go-guru-implements t] - "---" - ["Show Callers" go-guru-callers t] - ["Show Callees" go-guru-callees t] - ["Show Callstack" go-guru-callstack t] - "---" - ["Show Points-To" go-guru-pointsto t] - ["Show Which Errors" go-guru-whicherrs t] - ["Show Channel Peers" go-guru-peers t] - "---" - ["Set pointer analysis scope..." go-guru-set-scope t])) - -;;;###autoload -(defun go-guru-set-scope () - "Set the scope for the Go guru, prompting the user to edit the previous scope. - -The scope restricts analysis to the specified packages. -Its value is a comma-separated list of patterns of these forms: - golang.org/x/tools/cmd/guru # a single package - golang.org/x/tools/... # all packages beneath dir - ... # the entire workspace. - -A pattern preceded by '-' is negative, so the scope - encoding/...,-encoding/xml -matches all encoding packages except encoding/xml." - (interactive) - (let ((scope (read-from-minibuffer "Go guru scope: " - go-guru-scope - nil - nil - 'go-guru--scope-history))) - (if (string-equal "" scope) - (error "You must specify a non-empty scope for the Go guru")) - (setq go-guru-scope scope))) - -(defun go-guru--set-scope-if-empty () - (if (string-equal "" go-guru-scope) - (go-guru-set-scope))) - -(defun go-guru--json (mode) - "Execute the Go guru in the specified MODE, passing it the -selected region of the current buffer, requesting JSON output. -Parse and return the resulting JSON object." - ;; A "what" query works even in a buffer without a file name. - (let* ((filename (file-truename (or buffer-file-name "synthetic.go"))) - (cmd (go-guru--command mode filename '("-json"))) - (buf (current-buffer)) - ;; Use temporary buffers to avoid conflict with go-guru--start. - (json-buffer (generate-new-buffer "*go-guru-json-output*")) - (input-buffer (generate-new-buffer "*go-guru-json-input*"))) - (unwind-protect - ;; Run guru, feeding it the input buffer (modified files). - (with-current-buffer input-buffer - (go-guru--insert-modified-files) - (unless (buffer-file-name buf) - (go-guru--insert-modified-file filename buf)) - (let ((exitcode (apply #'call-process-region - (append (list (point-min) - (point-max) - (car cmd) ; guru - nil ; delete - json-buffer ; output - nil) ; display - (cdr cmd))))) ; args - (with-current-buffer json-buffer - (unless (zerop exitcode) - ;; Failed: use buffer contents (sans final \n) as an error. - (error "%s" (buffer-substring (point-min) (1- (point-max))))) - ;; Success: parse JSON. - (goto-char (point-min)) - (json-read)))) - ;; Clean up temporary buffers. - (kill-buffer json-buffer) - (kill-buffer input-buffer)))) - -(define-compilation-mode go-guru-output-mode "Go guru" - "Go guru output mode is a variant of `compilation-mode' for the -output of the Go guru tool." - (set (make-local-variable 'compilation-error-screen-columns) nil) - (set (make-local-variable 'compilation-filter-hook) #'go-guru--compilation-filter-hook) - (set (make-local-variable 'compilation-start-hook) #'go-guru--compilation-start-hook)) - -(defun go-guru--compilation-filter-hook () - "Post-process a blob of input to the go-guru-output buffer." - ;; For readability, truncate each "file:line:col:" prefix to a fixed width. - ;; If the prefix is longer than 20, show "…/last/19chars.go". - ;; This usually includes the last segment of the package name. - ;; Hide the line and column numbers. - (let ((start compilation-filter-start) - (end (point))) - (goto-char start) - (unless (bolp) - ;; TODO(adonovan): not quite right: the filter may be called - ;; with chunks of output containing incomplete lines. Moving to - ;; beginning-of-line may cause duplicate post-processing. - (beginning-of-line)) - (setq start (point)) - (while (< start end) - (let ((p (search-forward ": " end t))) - (if (null p) - (setq start end) ; break out of loop - (setq p (1- p)) ; exclude final space - (let* ((posn (buffer-substring-no-properties start p)) - (flen (cl-search ":" posn)) ; length of filename - (filename (if (< flen 19) - (substring posn 0 flen) - (concat "…" (substring posn (- flen 19) flen))))) - (put-text-property start p 'display filename) - (forward-line 1) - (setq start (point)))))))) - -(defun go-guru--compilation-start-hook (proc) - "Erase default output header inserted by `compilation-mode'." - (with-current-buffer (process-buffer proc) - (let ((inhibit-read-only t)) - (beginning-of-buffer) - (delete-region (point) (point-max))))) - -(defun go-guru--start (mode) - "Start an asynchronous Go guru process for the specified query -MODE, passing it the selected region of the current buffer, and -feeding its standard input with the contents of all modified Go -buffers. Its output is handled by `go-guru-output-mode', a -variant of `compilation-mode'." - (or buffer-file-name - (error "Cannot use guru on a buffer without a file name")) - (let* ((filename (file-truename buffer-file-name)) - (cmd (mapconcat #'shell-quote-argument (go-guru--command mode filename) " ")) - (process-connection-type nil) ; use pipe (not pty) so EOF closes stdin - (procbuf (compilation-start cmd 'go-guru-output-mode))) - (with-current-buffer procbuf - (setq truncate-lines t)) ; the output is neater without line wrapping - (with-current-buffer (get-buffer-create "*go-guru-input*") - (erase-buffer) - (go-guru--insert-modified-files) - (process-send-region procbuf (point-min) (point-max)) - (process-send-eof procbuf)) - procbuf)) - -(defun go-guru--command (mode filename &optional flags) - "Return a command and argument list for a Go guru query of MODE, passing it -the selected region of the current buffer. FILENAME is the -effective name of the current buffer." - (let* ((posn (if (use-region-p) - (format "%s:#%d,#%d" - filename - (1- (go--position-bytes (region-beginning))) - (1- (go--position-bytes (region-end)))) - (format "%s:#%d" - filename - (1- (go--position-bytes (point)))))) - (cmd (append (list go-guru-command - "-modified" - "-scope" go-guru-scope - (format "-tags=%s" (mapconcat 'identity go-guru-build-tags ","))) - flags - (list mode - posn)))) - ;; Log the command to *Messages*, for debugging. - (when go-guru-debug - (message "go-guru--command: %s" cmd) - (message nil)) ; clear/shrink minibuffer - cmd)) - -(defun go-guru--insert-modified-files () - "Insert the contents of each modified Go buffer into the -current buffer in the format specified by guru's -modified flag." - (mapc #'(lambda (b) - (and (buffer-modified-p b) - (buffer-file-name b) - (string= (file-name-extension (buffer-file-name b)) "go") - (go-guru--insert-modified-file (buffer-file-name b) b))) - (buffer-list))) - -(defun go-guru--insert-modified-file (name buffer) - (insert (format "%s\n%d\n" name (go-guru--buffer-size-bytes buffer))) - (insert-buffer-substring buffer)) - -(defun go-guru--buffer-size-bytes (&optional buffer) - "Return the number of bytes in the current buffer. -If BUFFER, return the number of characters in that buffer instead." - (with-current-buffer (or buffer (current-buffer)) - (string-bytes (buffer-substring (point-min) - (point-max))))) - -(defun go-guru--goto-byte (offset) - "Go to the OFFSETth byte in the buffer." - (goto-char (byte-to-position offset))) - -(defun go-guru--goto-byte-column (offset) - "Go to the OFFSETth byte in the current line." - (goto-char (byte-to-position (+ (position-bytes (point-at-bol)) (1- offset))))) - -(defun go-guru--goto-pos (posn) - "Find the file containing the position POSN (of the form `file:line:col') -set the point to it, switching the current buffer." - (let ((file-line-pos (split-string posn ":"))) - (find-file (car file-line-pos)) - (goto-char (point-min)) - (forward-line (1- (string-to-number (cadr file-line-pos)))) - (go-guru--goto-byte-column (string-to-number (cl-caddr file-line-pos))))) - -(defun go-guru--goto-pos-no-file (posn) - "Given `file:line:col', go to the line and column. The file -component will be ignored." - (let ((file-line-pos (split-string posn ":"))) - (goto-char (point-min)) - (forward-line (1- (string-to-number (cadr file-line-pos)))) - (go-guru--goto-byte-column (string-to-number (cl-caddr file-line-pos))))) - -;;;###autoload -(defun go-guru-callees () - "Show possible callees of the function call at the current point." - (interactive) - (go-guru--set-scope-if-empty) - (go-guru--start "callees")) - -;;;###autoload -(defun go-guru-callers () - "Show the set of callers of the function containing the current point." - (interactive) - (go-guru--set-scope-if-empty) - (go-guru--start "callers")) - -;;;###autoload -(defun go-guru-callstack () - "Show an arbitrary path from a root of the call graph to the -function containing the current point." - (interactive) - (go-guru--set-scope-if-empty) - (go-guru--start "callstack")) - -;;;###autoload -(defun go-guru-definition () - "Jump to the definition of the selected identifier." - (interactive) - (or buffer-file-name - (error "Cannot use guru on a buffer without a file name")) - (let* ((res (go-guru--json "definition")) - (desc (cdr (assoc 'desc res)))) - (push-mark) - (ring-insert find-tag-marker-ring (point-marker)) - (go-guru--goto-pos (cdr (assoc 'objpos res))) - (message "%s" desc))) - -;;;###autoload -(defun go-guru-describe () - "Describe the selected syntax, its kind, type and methods." - (interactive) - (go-guru--start "describe")) - -;;;###autoload -(defun go-guru-pointsto () - "Show what the selected expression points to." - (interactive) - (go-guru--set-scope-if-empty) - (go-guru--start "pointsto")) - -;;;###autoload -(defun go-guru-implements () - "Describe the 'implements' relation for types in the package -containing the current point." - (interactive) - (go-guru--start "implements")) - -;;;###autoload -(defun go-guru-freevars () - "Enumerate the free variables of the current selection." - (interactive) - (go-guru--start "freevars")) - -;;;###autoload -(defun go-guru-peers () - "Enumerate the set of possible corresponding sends/receives for -this channel receive/send operation." - (interactive) - (go-guru--set-scope-if-empty) - (go-guru--start "peers")) - -;;;###autoload -(defun go-guru-referrers () - "Enumerate all references to the object denoted by the selected -identifier." - (interactive) - (go-guru--start "referrers")) - -;;;###autoload -(defun go-guru-whicherrs () - "Show globals, constants and types to which the selected -expression (of type 'error') may refer." - (interactive) - (go-guru--set-scope-if-empty) - (go-guru--start "whicherrs")) - -(defun go-guru-what () - "Run a 'what' query and return the parsed JSON response as an -association list." - (go-guru--json "what")) - -(defun go-guru--hl-symbols (posn face id) - "Highlight the symbols at the positions POSN by creating -overlays with face FACE. The attribute 'go-guru-overlay on the -overlays will be set to ID." - (save-excursion - (mapc (lambda (pos) - (go-guru--goto-pos-no-file pos) - (let ((x (make-overlay (point) (+ (point) (length (current-word)))))) - (overlay-put x 'go-guru-overlay id) - (overlay-put x 'face face))) - posn))) - -;;;###autoload -(defun go-guru-unhighlight-identifiers () - "Remove highlights from previously highlighted identifier." - (remove-overlays nil nil 'go-guru-overlay 'sameid)) - -;;;###autoload -(defun go-guru-hl-identifier () - "Highlight all instances of the identifier under point. Removes -highlights from previously highlighted identifier." - (interactive) - (go-guru-unhighlight-identifiers) - (go-guru--hl-identifier)) - -(defun go-guru--hl-identifier () - "Highlight all instances of the identifier under point." - (let ((posn (cdr (assoc 'sameids (go-guru-what))))) - (go-guru--hl-symbols posn 'go-guru-hl-identifier-face 'sameid))) - -(defun go-guru--hl-identifiers-function () - "Function run after an idle timeout, highlighting the -identifier at point, if necessary." - (when go-guru-hl-identifier-mode - (unless (go-guru--on-overlay-p 'sameid) - ;; Ignore guru errors. Otherwise, we might end up with an error - ;; every time the timer runs, e.g. because of a malformed - ;; buffer. - (condition-case nil - (go-guru-hl-identifier) - (error nil))) - (unless (eq go-guru--current-hl-identifier-idle-time go-guru-hl-identifier-idle-time) - (go-guru--hl-set-timer)))) - -(defun go-guru--hl-set-timer () - (if go-guru--hl-identifier-timer - (cancel-timer go-guru--hl-identifier-timer)) - (setq go-guru--current-hl-identifier-idle-time go-guru-hl-identifier-idle-time) - (setq go-guru--hl-identifier-timer (run-with-idle-timer - go-guru-hl-identifier-idle-time - t - #'go-guru--hl-identifiers-function))) - -;;;###autoload -(define-minor-mode go-guru-hl-identifier-mode - "Highlight instances of the identifier at point after a short -timeout." - :group 'go-guru - (if go-guru-hl-identifier-mode - (progn - (go-guru--hl-set-timer) - ;; Unhighlight if point moves off identifier - (add-hook 'post-command-hook #'go-guru--hl-identifiers-post-command-hook nil t) - ;; Unhighlight any time the buffer changes - (add-hook 'before-change-functions #'go-guru--hl-identifiers-before-change-function nil t)) - (remove-hook 'post-command-hook #'go-guru--hl-identifiers-post-command-hook t) - (remove-hook 'before-change-functions #'go-guru--hl-identifiers-before-change-function t) - (go-guru-unhighlight-identifiers))) - -(defun go-guru--on-overlay-p (id) - "Return whether point is on a guru overlay of type ID." - (cl-find-if (lambda (el) (eq (overlay-get el 'go-guru-overlay) id)) (overlays-at (point)))) - -(defun go-guru--hl-identifiers-post-command-hook () - (if (and go-guru-hl-identifier-mode - (not (go-guru--on-overlay-p 'sameid))) - (go-guru-unhighlight-identifiers))) - -(defun go-guru--hl-identifiers-before-change-function (_beg _end) - (go-guru-unhighlight-identifiers)) - -;; TODO(dominikh): a future feature may be to cycle through all uses -;; of an identifier. - -(defun go-guru--enclosing () - "Return a list of enclosing regions." - (cdr (assoc 'enclosing (go-guru-what)))) - -(defun go-guru--enclosing-unique () - "Return a list of enclosing regions, with duplicates removed. -Two regions are considered equal if they have the same start and -end point." - (let ((enclosing (go-guru--enclosing))) - (cl-remove-duplicates enclosing - :from-end t - :test (lambda (a b) - (and (= (cdr (assoc 'start a)) - (cdr (assoc 'start b))) - (= (cdr (assoc 'end a)) - (cdr (assoc 'end b)))))))) - -(defun go-guru-expand-region () - "Expand region to the next enclosing syntactic unit." - (interactive) - (let* ((enclosing (if (eq last-command #'go-guru-expand-region) - go-guru--last-enclosing - (go-guru--enclosing-unique))) - (block (if (> (length enclosing) 0) (elt enclosing 0)))) - (when block - (go-guru--goto-byte (1+ (cdr (assoc 'start block)))) - (set-mark (byte-to-position (1+ (cdr (assoc 'end block))))) - (setq go-guru--last-enclosing (cl-subseq enclosing 1)) - (message "Region: %s" (cdr (assoc 'desc block))) - (setq deactivate-mark nil)))) - - -(provide 'go-guru) - -;; Local variables: -;; indent-tabs-mode: t -;; tab-width: 8 -;; End - -;;; go-guru.el ends here diff --git a/elpa/go-mode-20161013.1055/go-mode-autoloads.el b/elpa/go-mode-20161013.1055/go-mode-autoloads.el deleted file mode 100644 index 44d9ca2..0000000 --- a/elpa/go-mode-20161013.1055/go-mode-autoloads.el +++ /dev/null @@ -1,209 +0,0 @@ -;;; go-mode-autoloads.el --- automatically extracted autoloads -;; -;;; Code: - - -;;;### (autoloads nil "go-guru" "go-guru.el" (22528 41395 701074 -;;;;;; 26000)) -;;; Generated autoloads from go-guru.el - -(autoload 'go-guru-set-scope "go-guru" "\ -Set the scope for the Go guru, prompting the user to edit the previous scope. - -The scope restricts analysis to the specified packages. -Its value is a comma-separated list of patterns of these forms: - golang.org/x/tools/cmd/guru # a single package - golang.org/x/tools/... # all packages beneath dir - ... # the entire workspace. - -A pattern preceded by '-' is negative, so the scope - encoding/...,-encoding/xml -matches all encoding packages except encoding/xml. - -\(fn)" t nil) - -(autoload 'go-guru-callees "go-guru" "\ -Show possible callees of the function call at the current point. - -\(fn)" t nil) - -(autoload 'go-guru-callers "go-guru" "\ -Show the set of callers of the function containing the current point. - -\(fn)" t nil) - -(autoload 'go-guru-callstack "go-guru" "\ -Show an arbitrary path from a root of the call graph to the -function containing the current point. - -\(fn)" t nil) - -(autoload 'go-guru-definition "go-guru" "\ -Jump to the definition of the selected identifier. - -\(fn)" t nil) - -(autoload 'go-guru-describe "go-guru" "\ -Describe the selected syntax, its kind, type and methods. - -\(fn)" t nil) - -(autoload 'go-guru-pointsto "go-guru" "\ -Show what the selected expression points to. - -\(fn)" t nil) - -(autoload 'go-guru-implements "go-guru" "\ -Describe the 'implements' relation for types in the package -containing the current point. - -\(fn)" t nil) - -(autoload 'go-guru-freevars "go-guru" "\ -Enumerate the free variables of the current selection. - -\(fn)" t nil) - -(autoload 'go-guru-peers "go-guru" "\ -Enumerate the set of possible corresponding sends/receives for -this channel receive/send operation. - -\(fn)" t nil) - -(autoload 'go-guru-referrers "go-guru" "\ -Enumerate all references to the object denoted by the selected -identifier. - -\(fn)" t nil) - -(autoload 'go-guru-whicherrs "go-guru" "\ -Show globals, constants and types to which the selected -expression (of type 'error') may refer. - -\(fn)" t nil) - -(autoload 'go-guru-unhighlight-identifiers "go-guru" "\ -Remove highlights from previously highlighted identifier. - -\(fn)" nil nil) - -(autoload 'go-guru-hl-identifier "go-guru" "\ -Highlight all instances of the identifier under point. Removes -highlights from previously highlighted identifier. - -\(fn)" t nil) - -(autoload 'go-guru-hl-identifier-mode "go-guru" "\ -Highlight instances of the identifier at point after a short -timeout. - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "go-mode" "go-mode.el" (22528 41395 693074 -;;;;;; 32000)) -;;; Generated autoloads from go-mode.el - -(autoload 'go-mode "go-mode" "\ -Major mode for editing Go source text. - -This mode provides (not just) basic editing capabilities for -working with Go code. It offers almost complete syntax -highlighting, indentation that is almost identical to gofmt and -proper parsing of the buffer content to allow features such as -navigation by function, manipulation of comments or detection of -strings. - -In addition to these core features, it offers various features to -help with writing Go code. You can directly run buffer content -through gofmt, read godoc documentation from within Emacs, modify -and clean up the list of package imports or interact with the -Playground (uploading and downloading pastes). - -The following extra functions are defined: - -- `gofmt' -- `godoc' and `godoc-at-point' -- `go-import-add' -- `go-remove-unused-imports' -- `go-goto-arguments' -- `go-goto-docstring' -- `go-goto-function' -- `go-goto-function-name' -- `go-goto-imports' -- `go-goto-return-values' -- `go-goto-method-receiver' -- `go-play-buffer' and `go-play-region' -- `go-download-play' -- `godef-describe' and `godef-jump' -- `go-coverage' -- `go-set-project' -- `go-reset-gopath' - -If you want to automatically run `gofmt' before saving a file, -add the following hook to your emacs configuration: - -\(add-hook 'before-save-hook #'gofmt-before-save) - -If you want to use `godef-jump' instead of etags (or similar), -consider binding godef-jump to `M-.', which is the default key -for `find-tag': - -\(add-hook 'go-mode-hook (lambda () - (local-set-key (kbd \"M-.\") #'godef-jump))) - -Please note that godef is an external dependency. You can install -it with - -go get github.com/rogpeppe/godef - - -If you're looking for even more integration with Go, namely -on-the-fly syntax checking, auto-completion and snippets, it is -recommended that you look at flycheck -\(see URL `https://github.com/flycheck/flycheck') or flymake in combination -with goflymake (see URL `https://github.com/dougm/goflymake'), gocode -\(see URL `https://github.com/nsf/gocode'), go-eldoc -\(see URL `github.com/syohex/emacs-go-eldoc') and yasnippet-go -\(see URL `https://github.com/dominikh/yasnippet-go') - -\(fn)" t nil) - -(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode)) - -(autoload 'gofmt-before-save "go-mode" "\ -Add this to .emacs to run gofmt on the current buffer when saving: - (add-hook 'before-save-hook 'gofmt-before-save). - -Note that this will cause go-mode to get loaded the first time -you save any file, kind of defeating the point of autoloading. - -\(fn)" t nil) - -(autoload 'godoc "go-mode" "\ -Show Go documentation for QUERY, much like M-x man. - -\(fn QUERY)" t nil) - -(autoload 'go-download-play "go-mode" "\ -Download a paste from the playground and insert it in a Go buffer. -Tries to look for a URL at point. - -\(fn URL)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("go-mode-pkg.el") (22528 41395 685074 -;;;;;; 38000)) - -;;;*** - -(provide 'go-mode-autoloads) -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; coding: utf-8 -;; End: -;;; go-mode-autoloads.el ends here diff --git a/elpa/go-mode-20161013.1055/go-mode-pkg.el b/elpa/go-mode-20161013.1055/go-mode-pkg.el deleted file mode 100644 index 755ebe0..0000000 --- a/elpa/go-mode-20161013.1055/go-mode-pkg.el +++ /dev/null @@ -1,5 +0,0 @@ -(define-package "go-mode" "20161013.1055" "Major mode for the Go programming language" 'nil :url "https://github.com/dominikh/go-mode.el" :keywords - '("languages" "go")) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/go-mode-20161013.1055/go-mode.el b/elpa/go-mode-20161013.1055/go-mode.el deleted file mode 100644 index cc6422b..0000000 --- a/elpa/go-mode-20161013.1055/go-mode.el +++ /dev/null @@ -1,2069 +0,0 @@ -;;; go-mode.el --- Major mode for the Go programming language - -;; Copyright 2013 The go-mode Authors. All rights reserved. -;; Use of this source code is governed by a BSD-style -;; license that can be found in the LICENSE file. - -;; Author: The go-mode Authors -;; Version: 1.4.0 -;; Keywords: languages go -;; URL: https://github.com/dominikh/go-mode.el -;; -;; This file is not part of GNU Emacs. - -;;; Code: - -(require 'cl-lib) -(require 'compile) -(require 'etags) -(require 'ffap) -(require 'find-file) -(require 'ring) -(require 'url) - -;; XEmacs compatibility guidelines -;; - Minimum required version of XEmacs: 21.5.32 -;; - Feature that cannot be backported: POSIX character classes in -;; regular expressions -;; - Functions that could be backported but won't because 21.5.32 -;; covers them: plenty. -;; - Features that are still partly broken: -;; - godef will not work correctly if multibyte characters are -;; being used -;; - Fontification will not handle unicode correctly -;; -;; - Do not use \_< and \_> regexp delimiters directly; use -;; go--regexp-enclose-in-symbol -;; -;; - The character `_` must not be a symbol constituent but a -;; character constituent -;; -;; - Do not use process-lines -;; -;; - Use go--old-completion-list-style when using a plain list as the -;; collection for completing-read -;; -;; - Use go--position-bytes instead of position-bytes -(defmacro go--xemacs-p () - (featurep 'xemacs)) - -(defmacro go--has-syntax-propertize-p () - (boundp 'syntax-propertize-function)) - -(defun go--delete-whole-line (&optional arg) - "Delete the current line without putting it in the `kill-ring'. -Derived from function `kill-whole-line'. ARG is defined as for that -function." - (setq arg (or arg 1)) - (if (and (> arg 0) - (eobp) - (save-excursion (forward-visible-line 0) (eobp))) - (signal 'end-of-buffer nil)) - (if (and (< arg 0) - (bobp) - (save-excursion (end-of-visible-line) (bobp))) - (signal 'beginning-of-buffer nil)) - (cond ((zerop arg) - (delete-region (progn (forward-visible-line 0) (point)) - (progn (end-of-visible-line) (point)))) - ((< arg 0) - (delete-region (progn (end-of-visible-line) (point)) - (progn (forward-visible-line (1+ arg)) - (unless (bobp) - (backward-char)) - (point)))) - (t - (delete-region (progn (forward-visible-line 0) (point)) - (progn (forward-visible-line arg) (point)))))) - -;; declare-function is an empty macro that only byte-compile cares -;; about. Wrap in always false if to satisfy Emacsen without that -;; macro. -(if nil - (declare-function go--position-bytes "go-mode" (point))) - -;; XEmacs unfortunately does not offer position-bytes. We can fall -;; back to just using (point), but it will be incorrect as soon as -;; multibyte characters are being used. -(if (fboundp 'position-bytes) - (defalias 'go--position-bytes #'position-bytes) - (defun go--position-bytes (point) point)) - -(defun go--old-completion-list-style (list) - (mapcar (lambda (x) (cons x nil)) list)) - -;; GNU Emacs 24 has prog-mode, older GNU Emacs and XEmacs do not, so -;; copy its definition for those. -(if (not (fboundp 'prog-mode)) - (define-derived-mode prog-mode fundamental-mode "Prog" - "Major mode for editing source code." - (set (make-local-variable 'require-final-newline) mode-require-final-newline) - (set (make-local-variable 'parse-sexp-ignore-comments) t) - (setq bidi-paragraph-direction 'left-to-right))) - -(defun go--regexp-enclose-in-symbol (s) - "Enclose S as regexp symbol. -XEmacs does not support \\_<, GNU Emacs does. In GNU Emacs we -make extensive use of \\_< to support unicode in identifiers. -Until we come up with a better solution for XEmacs, this solution -will break fontification in XEmacs for identifiers such as -\"typeµ\". XEmacs will consider \"type\" a keyword, GNU Emacs -won't." - (if (go--xemacs-p) - (concat "\\<" s "\\>") - (concat "\\_<" s "\\_>"))) - -(defun go-goto-opening-parenthesis (&optional _legacy-unused) - "Move up one level of parentheses." - ;; The old implementation of go-goto-opening-parenthesis had an - ;; optional argument to speed up the function. It didn't change the - ;; function's outcome. - - ;; Silently fail if there's no matching opening parenthesis. - (condition-case nil - (backward-up-list) - (scan-error nil))) - - -(defconst go-dangling-operators-regexp "[^-]-\\|[^+]\\+\\|[/*&><.=|^]") -(defconst go-identifier-regexp "[[:word:][:multibyte:]]+") -(defconst go-type-name-no-prefix-regexp "\\(?:[[:word:][:multibyte:]]+\\.\\)?[[:word:][:multibyte:]]+") -(defconst go-qualified-identifier-regexp (concat go-identifier-regexp "\\." go-identifier-regexp)) -(defconst go-label-regexp go-identifier-regexp) -(defconst go-type-regexp "[[:word:][:multibyte:]*]+") -(defconst go-func-regexp (concat (go--regexp-enclose-in-symbol "func") "\\s *\\(" go-identifier-regexp "\\)")) -(defconst go-func-meth-regexp (concat - (go--regexp-enclose-in-symbol "func") "\\s *\\(?:(\\s *" - "\\(" go-identifier-regexp "\\s +\\)?" go-type-regexp - "\\s *)\\s *\\)?\\(" - go-identifier-regexp - "\\)(")) - -(defconst go-builtins - '("append" "cap" "close" "complex" "copy" - "delete" "imag" "len" "make" "new" - "panic" "print" "println" "real" "recover") - "All built-in functions in the Go language. Used for font locking.") - -(defconst go-mode-keywords - '("break" "default" "func" "interface" "select" - "case" "defer" "go" "map" "struct" - "chan" "else" "goto" "package" "switch" - "const" "fallthrough" "if" "range" "type" - "continue" "for" "import" "return" "var") - "All keywords in the Go language. Used for font locking.") - -(defconst go-constants '("nil" "true" "false" "iota")) -(defconst go-type-name-regexp (concat "\\(?:[*(]\\)*\\(\\(?:" go-identifier-regexp "\\.\\)?" go-identifier-regexp "\\)")) - -;; Maximum number of identifiers that can be highlighted as type names -;; in one function type/declaration. -(defconst go--font-lock-func-param-num-groups 16) - -(defvar go-dangling-cache) -(defvar go-godoc-history nil) -(defvar go--coverage-current-file-name) - -(defgroup go nil - "Major mode for editing Go code." - :link '(url-link "https://github.com/dominikh/go-mode.el") - :group 'languages) - -(defgroup go-cover nil - "Options specific to `cover`." - :group 'go) - -(defgroup godoc nil - "Options specific to `godoc'." - :group 'go) - -(defcustom go-fontify-function-calls t - "Fontify function and method calls if this is non-nil." - :type 'boolean - :group 'go) - -(defcustom go-mode-hook nil - "Hook called by `go-mode'." - :type 'hook - :group 'go) - -(defcustom go-command "go" - "The 'go' command. -Some users have multiple Go development trees and invoke the 'go' -tool via a wrapper that sets GOROOT and GOPATH based on the -current directory. Such users should customize this variable to -point to the wrapper script." - :type 'string - :group 'go) - -(defcustom gofmt-command "gofmt" - "The 'gofmt' command. -Some users may replace this with 'goimports' -from https://golang.org/x/tools/cmd/goimports." - :type 'string - :group 'go) - -(defcustom gofmt-args nil - "Additional arguments to pass to gofmt." - :type '(repeat string) - :group 'go) - -(defcustom gofmt-show-errors 'buffer - "Where to display gofmt error output. -It can either be displayed in its own buffer, in the echo area, or not at all. - -Please note that Emacs outputs to the echo area when writing -files and will overwrite gofmt's echo output if used from inside -a `before-save-hook'." - :type '(choice - (const :tag "Own buffer" buffer) - (const :tag "Echo area" echo) - (const :tag "None" nil)) - :group 'go) - -(defcustom godef-command "godef" - "The 'godef' command." - :type 'string - :group 'go) - -(defcustom go-other-file-alist - '(("_test\\.go\\'" (".go")) - ("\\.go\\'" ("_test.go"))) - "See the documentation of `ff-other-file-alist' for details." - :type '(repeat (list regexp (choice (repeat string) function))) - :group 'go) - -(defcustom go-packages-function 'go-packages-native - "Function called by `go-packages' to determine the list of -available packages. This is used in e.g. tab completion in -`go-import-add'. - -This package provides two functions: `go-packages-native' uses -elisp to find all .a files in all /pkg/ directories. -`go-packages-go-list' uses 'go list all' to determine all Go -packages. `go-packages-go-list' generally produces more accurate -results, but can be slower than `go-packages-native'." - :type 'function - :package-version '(go-mode . 1.4.0) - :group 'go) - -(defcustom go-guess-gopath-functions (list #'go-godep-gopath - #'go-wgo-gopath - #'go-gb-gopath - #'go-plain-gopath) - "Functions to call in sequence to detect a project's GOPATH. - -The functions in this list will be called one after another, -until a function returns non-nil. The order of the functions in -this list is important, as some project layouts may superficially -look like others. For example, a subset of wgo projects look like -gb projects. That's why we need to detect wgo first, to avoid -mis-identifying them as gb projects." - :type '(repeat function) - :group 'go) - -(defcustom godoc-command "go doc" - "Which executable to use for `godoc'. This can either be -'godoc' or 'go doc', both as an absolute path or an executable in -PATH." - :type 'string - :group 'go) - -(defcustom godoc-and-godef-command "godoc" - "Which executable to use for `godoc' in -`godoc-and-godef-command'. Must be 'godoc' and not 'go doc' and -can be an absolute path or an executable in PATH." - :type 'string - :group 'go) - -(defcustom godoc-use-completing-read nil - "Provide auto-completion for godoc. Only really desirable when using `godoc' instead of `go doc'." - :type 'boolean - :group 'godoc) - -(defcustom godoc-at-point-function #'godoc-and-godef - "Function to call to display the documentation for an -identifier at a given position. - -This package provides two functions: `godoc-and-godef' uses a -combination of godef and godoc to find the documentation. This -approach has several caveats. See its documentation for more -information. The second function, `godoc-gogetdoc' uses an -additional tool that correctly determines the documentation for -any identifier. It provides better results than -`godoc-and-godef'. " - :type 'function - :group 'godoc) - -(defun godoc-and-godef (point) - "Use a combination of godef and godoc to guess the documentation. - -Due to a limitation in godoc, it is not possible to differentiate -between functions and methods, which may cause `godoc-at-point' -to display more documentation than desired. Furthermore, it -doesn't work on package names or variables. - -Consider using godoc-gogetdoc instead for more accurate results." - (condition-case nil - (let* ((output (godef--call point)) - (file (car output)) - (name-parts (split-string (cadr output) " ")) - (first (car name-parts))) - (if (not (godef--successful-p file)) - (message "%s" (godef--error file)) - (go--godoc (format "%s %s" - (file-name-directory file) - (if (or (string= first "type") (string= first "const")) - (cadr name-parts) - (car name-parts))) - godoc-and-godef-command))) - (file-error (message "Could not run godef binary")))) - -(defun godoc-gogetdoc (point) - "Use the gogetdoc tool to find the documentation for an identifier. - -You can install gogetdoc with 'go get -u github.com/zmb3/gogetdoc'." - (if (not (buffer-file-name (go--coverage-origin-buffer))) - ;; TODO: gogetdoc supports unsaved files, but not introducing - ;; new artifical files, so this limitation will stay for now. - (error "Cannot use gogetdoc on a buffer without a file name")) - (let ((posn (format "%s:#%d" (shell-quote-argument (file-truename buffer-file-name)) (1- (go--position-bytes point)))) - (out (godoc--get-buffer ""))) - (with-current-buffer (get-buffer-create "*go-gogetdoc-input*") - (setq buffer-read-only nil) - (erase-buffer) - (go--insert-modified-files) - (call-process-region (point-min) (point-max) "gogetdoc" nil out nil - "-modified" - (format "-pos=%s" posn))) - (with-current-buffer out - (goto-char (point-min)) - (godoc-mode) - (display-buffer (current-buffer) t)))) - -(defun go--kill-new-message (url) - "Make URL the latest kill and print a message." - (kill-new url) - (message "%s" url)) - -(defcustom go-play-browse-function 'go--kill-new-message - "Function to call with the Playground URL. -See `go-play-region' for more details." - :type '(choice - (const :tag "Nothing" nil) - (const :tag "Kill + Message" go--kill-new-message) - (const :tag "Browse URL" browse-url) - (function :tag "Call function")) - :group 'go) - -(defcustom go-coverage-display-buffer-func 'display-buffer-reuse-window - "How `go-coverage' should display the coverage buffer. -See `display-buffer' for a list of possible functions." - :type 'function - :group 'go-cover) - -(defface go-coverage-untracked - '((t (:foreground "#505050"))) - "Coverage color of untracked code." - :group 'go-cover) - -(defface go-coverage-0 - '((t (:foreground "#c00000"))) - "Coverage color for uncovered code." - :group 'go-cover) -(defface go-coverage-1 - '((t (:foreground "#808080"))) - "Coverage color for covered code with weight 1." - :group 'go-cover) -(defface go-coverage-2 - '((t (:foreground "#748c83"))) - "Coverage color for covered code with weight 2." - :group 'go-cover) -(defface go-coverage-3 - '((t (:foreground "#689886"))) - "Coverage color for covered code with weight 3." - :group 'go-cover) -(defface go-coverage-4 - '((t (:foreground "#5ca489"))) - "Coverage color for covered code with weight 4." - :group 'go-cover) -(defface go-coverage-5 - '((t (:foreground "#50b08c"))) - "Coverage color for covered code with weight 5." - :group 'go-cover) -(defface go-coverage-6 - '((t (:foreground "#44bc8f"))) - "Coverage color for covered code with weight 6." - :group 'go-cover) -(defface go-coverage-7 - '((t (:foreground "#38c892"))) - "Coverage color for covered code with weight 7." - :group 'go-cover) -(defface go-coverage-8 - '((t (:foreground "#2cd495"))) - "Coverage color for covered code with weight 8. -For mode=set, all covered lines will have this weight." - :group 'go-cover) -(defface go-coverage-9 - '((t (:foreground "#20e098"))) - "Coverage color for covered code with weight 9." - :group 'go-cover) -(defface go-coverage-10 - '((t (:foreground "#14ec9b"))) - "Coverage color for covered code with weight 10." - :group 'go-cover) -(defface go-coverage-covered - '((t (:foreground "#2cd495"))) - "Coverage color of covered code." - :group 'go-cover) - -(defvar go-mode-syntax-table - (let ((st (make-syntax-table))) - (modify-syntax-entry ?+ "." st) - (modify-syntax-entry ?- "." st) - (modify-syntax-entry ?% "." st) - (modify-syntax-entry ?& "." st) - (modify-syntax-entry ?| "." st) - (modify-syntax-entry ?^ "." st) - (modify-syntax-entry ?! "." st) - (modify-syntax-entry ?= "." st) - (modify-syntax-entry ?< "." st) - (modify-syntax-entry ?> "." st) - (modify-syntax-entry ?/ (if (go--xemacs-p) ". 1456" ". 124b") st) - (modify-syntax-entry ?* ". 23" st) - (modify-syntax-entry ?\n "> b" st) - (modify-syntax-entry ?\" "\"" st) - (modify-syntax-entry ?\' "\"" st) - (modify-syntax-entry ?` "\"" st) - (modify-syntax-entry ?\\ "\\" st) - ;; It would be nicer to have _ as a symbol constituent, but that - ;; would trip up XEmacs, which does not support the \_< anchor - (modify-syntax-entry ?_ "w" st) - - st) - "Syntax table for Go mode.") - -(defun go--build-font-lock-keywords () - ;; we cannot use 'symbols in regexp-opt because GNU Emacs <24 - ;; doesn't understand that - (append - `((go--match-func - ,@(mapcar (lambda (x) `(,x font-lock-type-face)) - (number-sequence 1 go--font-lock-func-param-num-groups))) - (,(go--regexp-enclose-in-symbol (regexp-opt go-mode-keywords t)) . font-lock-keyword-face) - (,(concat "\\(" (go--regexp-enclose-in-symbol (regexp-opt go-builtins t)) "\\)[[:space:]]*(") 1 font-lock-builtin-face) - (,(go--regexp-enclose-in-symbol (regexp-opt go-constants t)) . font-lock-constant-face) - (,go-func-regexp 1 font-lock-function-name-face)) ;; function (not method) name - - (if go-fontify-function-calls - `((,(concat "\\(" go-identifier-regexp "\\)[[:space:]]*(") 1 font-lock-function-name-face) ;; function call/method name - (,(concat "[^[:word:][:multibyte:]](\\(" go-identifier-regexp "\\))[[:space:]]*(") 1 font-lock-function-name-face)) ;; bracketed function call - `((,go-func-meth-regexp 2 font-lock-function-name-face))) ;; method name - - `( - ("\\(`[^`]*`\\)" 1 font-lock-multiline) ;; raw string literal, needed for font-lock-syntactic-keywords - (,(concat (go--regexp-enclose-in-symbol "type") "[[:space:]]+\\([^[:space:](]+\\)") 1 font-lock-type-face) ;; types - (,(concat (go--regexp-enclose-in-symbol "type") "[[:space:]]+" go-identifier-regexp "[[:space:]]*" go-type-name-regexp) 1 font-lock-type-face) ;; types - (,(concat "[^[:word:][:multibyte:]]\\[\\([[:digit:]]+\\|\\.\\.\\.\\)?\\]" go-type-name-regexp) 2 font-lock-type-face) ;; Arrays/slices - (,(concat "\\(" go-identifier-regexp "\\)" "{") 1 font-lock-type-face) - (,(concat (go--regexp-enclose-in-symbol "map") "\\[[^]]+\\]" go-type-name-regexp) 1 font-lock-type-face) ;; map value type - (,(concat (go--regexp-enclose-in-symbol "map") "\\[" go-type-name-regexp) 1 font-lock-type-face) ;; map key type - (,(concat (go--regexp-enclose-in-symbol "chan") "[[:space:]]*\\(?:<-[[:space:]]*\\)?" go-type-name-regexp) 1 font-lock-type-face) ;; channel type - (,(concat (go--regexp-enclose-in-symbol "\\(?:new\\|make\\)") "\\(?:[[:space:]]\\|)\\)*(" go-type-name-regexp) 1 font-lock-type-face) ;; new/make type - ;; TODO do we actually need this one or isn't it just a function call? - (,(concat "\\.\\s *(" go-type-name-regexp) 1 font-lock-type-face) ;; Type conversion - ;; Like the original go-mode this also marks compound literal - ;; fields. There, it was marked as to fix, but I grew quite - ;; accustomed to it, so it'll stay for now. - (,(concat "^[[:space:]]*\\(" go-label-regexp "\\)[[:space:]]*:\\(\\S.\\|$\\)") 1 font-lock-constant-face) ;; Labels and compound literal fields - (,(concat (go--regexp-enclose-in-symbol "\\(goto\\|break\\|continue\\)") "[[:space:]]*\\(" go-label-regexp "\\)") 2 font-lock-constant-face)))) ;; labels in goto/break/continue - -(defconst go--font-lock-syntactic-keywords - ;; Override syntax property of raw string literal contents, so that - ;; backslashes have no special meaning in ``. Used in Emacs 23 or older. - '((go--match-raw-string-literal - (1 (7 . ?`)) - (2 (15 . nil)) ;; 15 = "generic string" - (3 (7 . ?`))))) - -(let ((m (define-prefix-command 'go-goto-map))) - (define-key m "a" #'go-goto-arguments) - (define-key m "d" #'go-goto-docstring) - (define-key m "f" #'go-goto-function) - (define-key m "i" #'go-goto-imports) - (define-key m "m" #'go-goto-method-receiver) - (define-key m "n" #'go-goto-function-name) - (define-key m "r" #'go-goto-return-values)) - -(defvar go-mode-map - (let ((m (make-sparse-keymap))) - (unless (boundp 'electric-indent-chars) - (define-key m "}" #'go-mode-insert-and-indent) - (define-key m ")" #'go-mode-insert-and-indent)) - (define-key m (kbd "C-c C-a") #'go-import-add) - (define-key m (kbd "C-c C-j") #'godef-jump) - (define-key m (kbd "C-x 4 C-c C-j") #'godef-jump-other-window) - (define-key m (kbd "C-c C-d") #'godef-describe) - (define-key m (kbd "C-c C-f") 'go-goto-map) - m) - "Keymap used by go-mode.") - -(easy-menu-define go-mode-menu go-mode-map - "Menu for Go mode." - '("Go" - ["Describe Expression" godef-describe t] - ["Jump to Definition" godef-jump t] - "---" - ["Add Import" go-import-add t] - ["Remove Unused Imports" go-remove-unused-imports t] - ["Go to Imports" go-goto-imports t] - "---" - ("Playground" - ["Send Buffer" go-play-buffer t] - ["Send Region" go-play-region t] - ["Download" go-download-play t]) - "---" - ["Coverage" go-coverage t] - ["Gofmt" gofmt t] - ["Godoc" godoc t] - "---" - ["Customize Mode" (customize-group 'go) t])) - -(defun go-mode-insert-and-indent (key) - "Invoke the global binding of KEY, then reindent the line." - - (interactive (list (this-command-keys))) - (call-interactively (lookup-key (current-global-map) key)) - (indent-according-to-mode)) - -(defmacro go-paren-level () - `(car (syntax-ppss))) - -(defmacro go-in-string-or-comment-p () - `(nth 8 (syntax-ppss))) - -(defmacro go-in-string-p () - `(nth 3 (syntax-ppss))) - -(defmacro go-in-comment-p () - `(nth 4 (syntax-ppss))) - -(defmacro go-goto-beginning-of-string-or-comment () - `(goto-char (nth 8 (syntax-ppss)))) - -(defun go--backward-irrelevant (&optional stop-at-string) - "Skip backwards over any characters that are irrelevant for -indentation and related tasks. - -It skips over whitespace, comments, cases and labels and, if -STOP-AT-STRING is not true, over strings." - - (let (pos (start-pos (point))) - (skip-chars-backward "\n\s\t") - (if (and (save-excursion (beginning-of-line) (go-in-string-p)) - (looking-back "`") - (not stop-at-string)) - (backward-char)) - (if (and (go-in-string-p) - (not stop-at-string)) - (go-goto-beginning-of-string-or-comment)) - (if (looking-back "\\*/") - (backward-char)) - (if (go-in-comment-p) - (go-goto-beginning-of-string-or-comment)) - (setq pos (point)) - (beginning-of-line) - (if (or (looking-at (concat "^" go-label-regexp ":")) - (looking-at "^[[:space:]]*\\(case .+\\|default\\):")) - (end-of-line 0) - (goto-char pos)) - (if (/= start-pos (point)) - (go--backward-irrelevant stop-at-string)) - (/= start-pos (point)))) - -(defun go--buffer-narrowed-p () - "Return non-nil if the current buffer is narrowed." - (/= (buffer-size) - (- (point-max) - (point-min)))) - -(defun go--match-raw-string-literal (end) - "Search for a raw string literal. -Set point to the end of the occurence found on success. Return nil on failure." - (unless (go-in-string-or-comment-p) - (when (search-forward "`" end t) - (goto-char (match-beginning 0)) - (if (go-in-string-or-comment-p) - (progn (goto-char (match-end 0)) - (go--match-raw-string-literal end)) - (when (looking-at "\\(`\\)\\([^`]*\\)\\(`\\)") - (goto-char (match-end 0)) - t))))) - -(defun go-previous-line-has-dangling-op-p () - "Return non-nil if the current line is a continuation line." - (let* ((cur-line (line-number-at-pos)) - (val (gethash cur-line go-dangling-cache 'nope))) - (if (or (go--buffer-narrowed-p) (equal val 'nope)) - (save-excursion - (beginning-of-line) - (go--backward-irrelevant t) - (setq val (looking-back go-dangling-operators-regexp)) - (if (not (go--buffer-narrowed-p)) - (puthash cur-line val go-dangling-cache)))) - val)) - -(defun go--at-function-definition () - "Return non-nil if point is on the opening curly brace of a -function definition. - -We do this by first calling (beginning-of-defun), which will take -us to the start of *some* function. We then look for the opening -curly brace of that function and compare its position against the -curly brace we are checking. If they match, we return non-nil." - (if (= (char-after) ?\{) - (save-excursion - (let ((old-point (point)) - start-nesting) - (beginning-of-defun) - (when (looking-at "func ") - (setq start-nesting (go-paren-level)) - (skip-chars-forward "^{") - (while (> (go-paren-level) start-nesting) - (forward-char) - (skip-chars-forward "^{") 0) - (if (and (= (go-paren-level) start-nesting) (= old-point (point))) - t)))))) - -(defun go--indentation-for-opening-parenthesis () - "Return the semantic indentation for the current opening parenthesis. - -If point is on an opening curly brace and said curly brace -belongs to a function declaration, the indentation of the func -keyword will be returned. Otherwise the indentation of the -current line will be returned." - (save-excursion - (if (go--at-function-definition) - (progn - (beginning-of-defun) - (current-indentation)) - (current-indentation)))) - -(defun go-indentation-at-point () - (save-excursion - (let (start-nesting) - (back-to-indentation) - (setq start-nesting (go-paren-level)) - - (cond - ((go-in-string-p) - (current-indentation)) - ((looking-at "[])}]") - (go-goto-opening-parenthesis) - (if (go-previous-line-has-dangling-op-p) - (- (current-indentation) tab-width) - (go--indentation-for-opening-parenthesis))) - ((progn (go--backward-irrelevant t) (looking-back go-dangling-operators-regexp)) - ;; only one nesting for all dangling operators in one operation - (if (go-previous-line-has-dangling-op-p) - (current-indentation) - (+ (current-indentation) tab-width))) - ((zerop (go-paren-level)) - 0) - ((progn (go-goto-opening-parenthesis) (< (go-paren-level) start-nesting)) - (if (go-previous-line-has-dangling-op-p) - (current-indentation) - (+ (go--indentation-for-opening-parenthesis) tab-width))) - (t - (current-indentation)))))) - -(defun go-mode-indent-line () - (interactive) - (let (indent - shift-amt - (pos (- (point-max) (point))) - (point (point)) - (beg (line-beginning-position))) - (back-to-indentation) - (if (go-in-string-or-comment-p) - (goto-char point) - (setq indent (go-indentation-at-point)) - (if (looking-at (concat go-label-regexp ":\\([[:space:]]*/.+\\)?$\\|case .+:\\|default:")) - (cl-decf indent tab-width)) - (setq shift-amt (- indent (current-column))) - (if (zerop shift-amt) - nil - (delete-region beg (point)) - (indent-to indent)) - ;; If initial point was within line's indentation, - ;; position after the indentation. Else stay at same point in text. - (if (> (- (point-max) pos) (point)) - (goto-char (- (point-max) pos)))))) - -(defun go-beginning-of-defun (&optional count) - (unless (bolp) - (end-of-line)) - (setq count (or count 1)) - (let (first failure) - (dotimes (i (abs count)) - (setq first t) - (while (and (not failure) - (or first (go-in-string-or-comment-p))) - (if (>= count 0) - (progn - (go--backward-irrelevant) - (if (not (re-search-backward go-func-meth-regexp nil t)) - (setq failure t))) - (if (looking-at go-func-meth-regexp) - (forward-char)) - (if (not (re-search-forward go-func-meth-regexp nil t)) - (setq failure t))) - (setq first nil))) - (if (< count 0) - (beginning-of-line)) - (not failure))) - -(defun go-end-of-defun () - (let (orig-level) - ;; It can happen that we're not placed before a function by emacs - (if (not (looking-at "func")) - (go-beginning-of-defun -1)) - ;; Find the { that starts the function, i.e., the next { that isn't - ;; preceded by struct or interface, or a comment or struct tag. BUG: - ;; breaks if there's a comment between the struct/interface keyword and - ;; bracket, like this: - ;; - ;; struct /* why? */ { - (while (progn - (skip-chars-forward "^{") - (forward-char) - (or (go-in-string-or-comment-p) - (looking-back "\\(struct\\|interface\\)\\s-*{")))) - (setq orig-level (go-paren-level)) - (while (>= (go-paren-level) orig-level) - (skip-chars-forward "^}") - (forward-char)))) - -(defun go--find-enclosing-parentheses (position) - "Return points of outermost '(' and ')' surrounding POSITION if -such parentheses exist. - -If outermost '(' exists but ')' does not, it returns the next blank -line or end-of-buffer position instead of the position of the closing -parenthesis. - -If the starting parenthesis is not found, it returns (POSITION -POSITION)." - (save-excursion - (let (beg end) - (goto-char position) - (while (> (go-paren-level) 0) - (re-search-backward "[(\\[{]" nil t) - (when (looking-at "(") - (setq beg (point)))) - (if (null beg) - (list position position) - (goto-char position) - (while (and (> (go-paren-level) 0) - (search-forward ")" nil t))) - (when (> (go-paren-level) 0) - (unless (re-search-forward "^[[:space:]]*$" nil t) - (goto-char (point-max)))) - (list beg (point)))))) - -(defun go--search-next-comma (end) - "Search forward from point for a comma whose nesting level is -the same as point. If it reaches the end of line or a closing -parenthesis before a comma, it stops at it." - (let ((orig-level (go-paren-level))) - (while (and (< (point) end) - (or (looking-at "[^,)\n]") - (> (go-paren-level) orig-level))) - (forward-char)) - (when (and (looking-at ",") - (< (point) (1- end))) - (forward-char)))) - -(defun go--looking-at-keyword () - (and (looking-at (concat "\\(" go-identifier-regexp "\\)")) - (member (match-string 1) go-mode-keywords))) - -(defun go--match-func (end) - "Search for identifiers used as type names from a function -parameter list, and set the identifier positions as the results -of last search. Return t if search succeeded." - (when (re-search-forward (go--regexp-enclose-in-symbol "func") end t) - (let ((regions (go--match-func-type-names end))) - (if (null regions) - ;; Nothing to highlight. This can happen if the current func - ;; is "func()". Try next one. - (go--match-func end) - ;; There are something to highlight. Set those positions as - ;; last search results. - (setq regions (go--filter-match-data regions end)) - (when regions - (set-match-data (go--make-match-data regions)) - t))))) - -(defun go--match-func-type-names (end) - (cond - ;; Function declaration (e.g. "func foo(") - ((looking-at (concat "[[:space:]\n]*" go-identifier-regexp "[[:space:]\n]*(")) - (goto-char (match-end 0)) - (nconc (go--match-parameter-list end) - (go--match-function-result end))) - ;; Method declaration, function literal, or function type - ((looking-at "[[:space:]]*(") - (goto-char (match-end 0)) - (let ((regions (go--match-parameter-list end))) - ;; Method declaration (e.g. "func (x y) foo(") - (when (looking-at (concat "[[:space:]]*" go-identifier-regexp "[[:space:]\n]*(")) - (goto-char (match-end 0)) - (setq regions (nconc regions (go--match-parameter-list end)))) - (nconc regions (go--match-function-result end)))))) - -(defun go--parameter-list-type (end) - "Return `present' if the parameter list has names, or `absent' if -not, assuming point is at the beginning of a parameter list, just -after '('." - (save-excursion - (skip-chars-forward "[:space:]\n" end) - (cond ((> (point) end) - nil) - ((looking-at (concat go-identifier-regexp "[[:space:]\n]*,")) - (goto-char (match-end 0)) - (go--parameter-list-type end)) - ((or (looking-at go-qualified-identifier-regexp) - (looking-at (concat go-type-name-no-prefix-regexp "[[:space:]\n]*\\(?:)\\|\\'\\)")) - (go--looking-at-keyword) - (looking-at "[*\\[]\\|\\.\\.\\.\\|\\'")) - 'absent) - (t 'present)))) - -(defconst go--opt-dotdotdot-regexp "\\(?:\\.\\.\\.\\)?") -(defconst go--parameter-type-regexp - (concat go--opt-dotdotdot-regexp "[[:space:]*\n]*\\(" go-type-name-no-prefix-regexp "\\)[[:space:]\n]*\\([,)]\\|\\'\\)")) -(defconst go--func-type-in-parameter-list-regexp - (concat go--opt-dotdotdot-regexp "[[:space:]*\n]*\\(" (go--regexp-enclose-in-symbol "func") "\\)")) - -(defun go--match-parameters-common (identifier-regexp end) - (let ((acc ()) - (start -1)) - (while (progn (skip-chars-forward "[:space:]\n" end) - (and (not (looking-at "\\(?:)\\|\\'\\)")) - (< start (point)) - (<= (point) end))) - (setq start (point)) - (cond - ((looking-at (concat identifier-regexp go--parameter-type-regexp)) - (setq acc (nconc acc (list (match-beginning 1) (match-end 1)))) - (goto-char (match-beginning 2))) - ((looking-at (concat identifier-regexp go--func-type-in-parameter-list-regexp)) - (goto-char (match-beginning 1)) - (setq acc (nconc acc (go--match-func-type-names end))) - (go--search-next-comma end)) - (t - (go--search-next-comma end)))) - (when (and (looking-at ")") - (< (point) end)) - (forward-char)) - acc)) - -(defun go--match-parameters-with-identifier-list (end) - (go--match-parameters-common - (concat go-identifier-regexp "[[:space:]\n]+") - end)) - -(defun go--match-parameters-without-identifier-list (end) - (go--match-parameters-common "" end)) - -(defun go--filter-match-data (regions end) - "Remove points from REGIONS if they are beyond END. -REGIONS are a list whose size is multiple of 2. Element 2n is beginning of a -region and 2n+1 is end of it. - -This function is used to make sure we don't override end point -that `font-lock-mode' gave to us." - (when regions - (let* ((vec (vconcat regions)) - (i 0) - (len (length vec))) - (while (and (< i len) - (<= (nth i regions) end) - (<= (nth (1+ i) regions) end)) - (setq i (+ i 2))) - (cond ((= i len) - regions) - ((zerop i) - nil) - (t - (butlast regions (- (length regions) i))))))) - -(defun go--make-match-data (regions) - (let ((deficit (- (* 2 go--font-lock-func-param-num-groups) - (length regions)))) - (when (> deficit 0) - (let ((last (car (last regions)))) - (setq regions (nconc regions (make-list deficit last)))))) - `(,(car regions) ,@(last regions) ,@regions)) - -(defun go--match-parameter-list (end) - "Return a list of identifier positions that are used as type -names in a function parameter list, assuming point is at the -beginning of a parameter list. Return nil if the text after -point does not look like a parameter list. - -Set point to end of closing parenthesis on success. - -In Go, the names must either all be present or all be absent -within a list of parameters. - -Parsing a parameter list is a little bit complicated because we -have to scan through the parameter list to determine whether or -not the list has names. Until a type name is found or reaching -end of a parameter list, we are not sure which form the parameter -list is. - -For example, X and Y are type names in a parameter list \"(X, -Y)\" but are parameter names in \"(X, Y int)\". We cannot say if -X is a type name until we see int after Y. - -Note that even \"(int, float T)\" is a valid parameter -list. Builtin type names are not reserved words. In this example, -int and float are parameter names and only T is a type name. - -In this function, we first scan the parameter list to see if the -list has names, and then handle it accordingly." - (let ((name (go--parameter-list-type end))) - (cond ((eq name 'present) - (go--match-parameters-with-identifier-list end)) - ((eq name 'absent) - (go--match-parameters-without-identifier-list end)) - (t nil)))) - -(defun go--match-function-result (end) - "Return a list of identifier positions that are used as type -names in a function result, assuming point is at the beginning of -a result. - -Function result is a unparenthesized type or a parameter list." - (cond ((and (looking-at (concat "[[:space:]*]*\\(" go-type-name-no-prefix-regexp "\\)")) - (not (member (match-string 1) go-mode-keywords))) - (list (match-beginning 1) (match-end 1))) - ((looking-at "[[:space:]]*(") - (goto-char (match-end 0)) - (go--match-parameter-list end)) - (t nil))) - -;;;###autoload -(define-derived-mode go-mode prog-mode "Go" - "Major mode for editing Go source text. - -This mode provides (not just) basic editing capabilities for -working with Go code. It offers almost complete syntax -highlighting, indentation that is almost identical to gofmt and -proper parsing of the buffer content to allow features such as -navigation by function, manipulation of comments or detection of -strings. - -In addition to these core features, it offers various features to -help with writing Go code. You can directly run buffer content -through gofmt, read godoc documentation from within Emacs, modify -and clean up the list of package imports or interact with the -Playground (uploading and downloading pastes). - -The following extra functions are defined: - -- `gofmt' -- `godoc' and `godoc-at-point' -- `go-import-add' -- `go-remove-unused-imports' -- `go-goto-arguments' -- `go-goto-docstring' -- `go-goto-function' -- `go-goto-function-name' -- `go-goto-imports' -- `go-goto-return-values' -- `go-goto-method-receiver' -- `go-play-buffer' and `go-play-region' -- `go-download-play' -- `godef-describe' and `godef-jump' -- `go-coverage' -- `go-set-project' -- `go-reset-gopath' - -If you want to automatically run `gofmt' before saving a file, -add the following hook to your emacs configuration: - -\(add-hook 'before-save-hook #'gofmt-before-save) - -If you want to use `godef-jump' instead of etags (or similar), -consider binding godef-jump to `M-.', which is the default key -for `find-tag': - -\(add-hook 'go-mode-hook (lambda () - (local-set-key (kbd \"M-.\") #'godef-jump))) - -Please note that godef is an external dependency. You can install -it with - -go get github.com/rogpeppe/godef - - -If you're looking for even more integration with Go, namely -on-the-fly syntax checking, auto-completion and snippets, it is -recommended that you look at flycheck -\(see URL `https://github.com/flycheck/flycheck') or flymake in combination -with goflymake \(see URL `https://github.com/dougm/goflymake'), gocode -\(see URL `https://github.com/nsf/gocode'), go-eldoc -\(see URL `github.com/syohex/emacs-go-eldoc') and yasnippet-go -\(see URL `https://github.com/dominikh/yasnippet-go')" - - ;; Font lock - (set (make-local-variable 'font-lock-defaults) - '(go--build-font-lock-keywords)) - - ;; Indentation - (set (make-local-variable 'indent-line-function) #'go-mode-indent-line) - - ;; Comments - (set (make-local-variable 'comment-start) "// ") - (set (make-local-variable 'comment-end) "") - (set (make-local-variable 'comment-use-syntax) t) - (set (make-local-variable 'comment-start-skip) "\\(//+\\|/\\*+\\)\\s *") - - (set (make-local-variable 'beginning-of-defun-function) #'go-beginning-of-defun) - (set (make-local-variable 'end-of-defun-function) #'go-end-of-defun) - - (set (make-local-variable 'parse-sexp-lookup-properties) t) - (if (go--has-syntax-propertize-p) - (set (make-local-variable 'syntax-propertize-function) #'go-propertize-syntax) - (set (make-local-variable 'font-lock-syntactic-keywords) - go--font-lock-syntactic-keywords) - (set (make-local-variable 'font-lock-multiline) t)) - - (if (boundp 'electric-indent-chars) - (set (make-local-variable 'electric-indent-chars) '(?\n ?} ?\)))) - - (set (make-local-variable 'compilation-error-screen-columns) nil) - - (set (make-local-variable 'go-dangling-cache) (make-hash-table :test 'eql)) - (add-hook 'before-change-functions (lambda (x y) (setq go-dangling-cache (make-hash-table :test 'eql))) t t) - - ;; ff-find-other-file - (setq ff-other-file-alist 'go-other-file-alist) - - (setq imenu-generic-expression - '(("type" "^type *\\([^ \t\n\r\f]*\\)" 1) - ("func" "^func *\\(.*\\) {" 1))) - (imenu-add-to-menubar "Index") - - ;; Go style - (setq indent-tabs-mode t) - - ;; Handle unit test failure output in compilation-mode - ;; - ;; Note that we add our entry to the beginning of - ;; compilation-error-regexp-alist. In older versions of Emacs, the - ;; list was processed from the end, and we would've wanted to add - ;; ours last. But at some point this changed, and now the list is - ;; processed from the beginning. It's important that our entry comes - ;; before gnu, because gnu matches go test output, but includes the - ;; leading whitespace in the file name. - ;; - ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2001-12/msg00674.html - ;; documents the old, reverseed order. - (when (and (boundp 'compilation-error-regexp-alist) - (boundp 'compilation-error-regexp-alist-alist)) - (add-to-list 'compilation-error-regexp-alist 'go-test) - (add-to-list 'compilation-error-regexp-alist-alist - '(go-test . ("^\t+\\([^()\t\n]+\\):\\([0-9]+\\):? .*$" 1 2)) t))) - -;;;###autoload -(add-to-list 'auto-mode-alist (cons "\\.go\\'" 'go-mode)) - -(defun go--apply-rcs-patch (patch-buffer) - "Apply an RCS-formatted diff from PATCH-BUFFER to the current buffer." - (let ((target-buffer (current-buffer)) - ;; Relative offset between buffer line numbers and line numbers - ;; in patch. - ;; - ;; Line numbers in the patch are based on the source file, so - ;; we have to keep an offset when making changes to the - ;; buffer. - ;; - ;; Appending lines decrements the offset (possibly making it - ;; negative), deleting lines increments it. This order - ;; simplifies the forward-line invocations. - (line-offset 0)) - (save-excursion - (with-current-buffer patch-buffer - (goto-char (point-min)) - (while (not (eobp)) - (unless (looking-at "^\\([ad]\\)\\([0-9]+\\) \\([0-9]+\\)") - (error "invalid rcs patch or internal error in go--apply-rcs-patch")) - (forward-line) - (let ((action (match-string 1)) - (from (string-to-number (match-string 2))) - (len (string-to-number (match-string 3)))) - (cond - ((equal action "a") - (let ((start (point))) - (forward-line len) - (let ((text (buffer-substring start (point)))) - (with-current-buffer target-buffer - (cl-decf line-offset len) - (goto-char (point-min)) - (forward-line (- from len line-offset)) - (insert text))))) - ((equal action "d") - (with-current-buffer target-buffer - (go--goto-line (- from line-offset)) - (cl-incf line-offset len) - (go--delete-whole-line len))) - (t - (error "invalid rcs patch or internal error in go--apply-rcs-patch"))))))))) - -(defun gofmt--is-goimports-p () - (string-equal (file-name-base gofmt-command) "goimports")) - -(defun gofmt () - "Format the current buffer according to the gofmt tool." - (interactive) - (let ((tmpfile (make-temp-file "gofmt" nil ".go")) - (patchbuf (get-buffer-create "*Gofmt patch*")) - (errbuf (if gofmt-show-errors (get-buffer-create "*Gofmt Errors*"))) - (coding-system-for-read 'utf-8) - (coding-system-for-write 'utf-8) - our-gofmt-args) - - (unwind-protect - (save-restriction - (widen) - (if errbuf - (with-current-buffer errbuf - (setq buffer-read-only nil) - (erase-buffer))) - (with-current-buffer patchbuf - (erase-buffer)) - - (write-region nil nil tmpfile) - - (when (and (gofmt--is-goimports-p) buffer-file-name) - (setq our-gofmt-args - (append our-gofmt-args - (list "-srcdir" (file-name-directory (file-truename buffer-file-name)))))) - (setq our-gofmt-args (append our-gofmt-args - gofmt-args - (list "-w" tmpfile))) - (message "Calling gofmt: %s %s" gofmt-command our-gofmt-args) - ;; We're using errbuf for the mixed stdout and stderr output. This - ;; is not an issue because gofmt -w does not produce any stdout - ;; output in case of success. - (if (zerop (apply #'call-process gofmt-command nil errbuf nil our-gofmt-args)) - (progn - (if (zerop (call-process-region (point-min) (point-max) "diff" nil patchbuf nil "-n" "-" tmpfile)) - (message "Buffer is already gofmted") - (go--apply-rcs-patch patchbuf) - (message "Applied gofmt")) - (if errbuf (gofmt--kill-error-buffer errbuf))) - (message "Could not apply gofmt") - (if errbuf (gofmt--process-errors (buffer-file-name) tmpfile errbuf)))) - - (kill-buffer patchbuf) - (delete-file tmpfile)))) - - -(defun gofmt--process-errors (filename tmpfile errbuf) - (with-current-buffer errbuf - (if (eq gofmt-show-errors 'echo) - (progn - (message "%s" (buffer-string)) - (gofmt--kill-error-buffer errbuf)) - ;; Convert the gofmt stderr to something understood by the compilation mode. - (goto-char (point-min)) - (if (save-excursion - (save-match-data - (search-forward "flag provided but not defined: -srcdir" nil t))) - (insert "Your version of goimports is too old and doesn't support vendoring. Please update goimports!\n\n")) - (insert "gofmt errors:\n") - (let ((truefile - (if (gofmt--is-goimports-p) - (concat (file-name-directory filename) (file-name-nondirectory tmpfile)) - tmpfile))) - (while (search-forward-regexp (concat "^\\(" (regexp-quote truefile) "\\):") nil t) - (replace-match (file-name-nondirectory filename) t t nil 1))) - (compilation-mode) - (display-buffer errbuf)))) - -(defun gofmt--kill-error-buffer (errbuf) - (let ((win (get-buffer-window errbuf))) - (if win - (quit-window t win) - (kill-buffer errbuf)))) - -;;;###autoload -(defun gofmt-before-save () - "Add this to .emacs to run gofmt on the current buffer when saving: - (add-hook 'before-save-hook 'gofmt-before-save). - -Note that this will cause go-mode to get loaded the first time -you save any file, kind of defeating the point of autoloading." - - (interactive) - (when (eq major-mode 'go-mode) (gofmt))) - -(defun godoc--read-query () - "Read a godoc query from the minibuffer." - (if godoc-use-completing-read - (completing-read "godoc; " - (go--old-completion-list-style (go-packages)) nil nil nil 'go-godoc-history) - (read-from-minibuffer "godoc: " nil nil nil 'go-godoc-history))) - -(defun godoc--get-buffer (query) - "Get an empty buffer for a godoc query." - (let* ((buffer-name (concat "*godoc " query "*")) - (buffer (get-buffer buffer-name))) - ;; Kill the existing buffer if it already exists. - (when buffer (kill-buffer buffer)) - (get-buffer-create buffer-name))) - -(defun godoc--buffer-sentinel (proc event) - "Sentinel function run when godoc command completes." - (with-current-buffer (process-buffer proc) - (cond ((string= event "finished\n") ;; Successful exit. - (goto-char (point-min)) - (godoc-mode) - (display-buffer (current-buffer) t)) - ((/= (process-exit-status proc) 0) ;; Error exit. - (let ((output (buffer-string))) - (kill-buffer (current-buffer)) - (message (concat "godoc: " output))))))) - -(define-derived-mode godoc-mode special-mode "Godoc" - "Major mode for showing Go documentation." - (view-mode-enter)) - -;;;###autoload -(defun godoc (query) - "Show Go documentation for QUERY, much like M-x man." - (interactive (list (godoc--read-query))) - (go--godoc query godoc-command)) - -(defun go--godoc (query command) - (unless (string= query "") - (set-process-sentinel - (start-process-shell-command "godoc" (godoc--get-buffer query) - (concat command " " query)) - 'godoc--buffer-sentinel) - nil)) - -(defun godoc-at-point (point) - "Show Go documentation for the identifier at POINT. - -It uses `godoc-at-point-function' to look up the documentation." - (interactive "d") - (funcall godoc-at-point-function point)) - -(defun go-goto-imports () - "Move point to the block of imports. - -If using - - import ( - \"foo\" - \"bar\" - ) - -it will move point directly behind the last import. - -If using - - import \"foo\" - import \"bar\" - -it will move point to the next line after the last import. - -If no imports can be found, point will be moved after the package -declaration." - (interactive) - ;; FIXME if there's a block-commented import before the real - ;; imports, we'll jump to that one. - - ;; Generally, this function isn't very forgiving. it'll bark on - ;; extra whitespace. It works well for clean code. - (let ((old-point (point))) - (goto-char (point-min)) - (cond - ((re-search-forward "^import ()" nil t) - (backward-char 1) - 'block-empty) - ((re-search-forward "^import ([^)]+)" nil t) - (backward-char 2) - 'block) - ((re-search-forward "\\(^import \\([^\"]+ \\)?\"[^\"]+\"\n?\\)+" nil t) - 'single) - ((re-search-forward "^[[:space:]\n]*package .+?\n" nil t) - (message "No imports found, moving point after package declaration") - 'none) - (t - (goto-char old-point) - (message "No imports or package declaration found. Is this really a Go file?") - 'fail)))) - -(defun go-play-buffer () - "Like `go-play-region', but acts on the entire buffer." - (interactive) - (go-play-region (point-min) (point-max))) - -(defun go-play-region (start end) - "Send the region to the Playground. -If non-nil `go-play-browse-function' is called with the -Playground URL." - (interactive "r") - (let* ((url-request-method "POST") - (url-request-extra-headers - '(("Content-Type" . "application/x-www-form-urlencoded"))) - (url-request-data - (encode-coding-string - (buffer-substring-no-properties start end) - 'utf-8)) - (content-buf (url-retrieve - "https://play.golang.org/share" - (lambda (arg) - (cond - ((equal :error (car arg)) - (signal 'go-play-error (cdr arg))) - (t - (re-search-forward "\n\n") - (let ((url (format "https://play.golang.org/p/%s" - (buffer-substring (point) (point-max))))) - (when go-play-browse-function - (funcall go-play-browse-function url))))))))))) - -;;;###autoload -(defun go-download-play (url) - "Download a paste from the playground and insert it in a Go buffer. -Tries to look for a URL at point." - (interactive (list (read-from-minibuffer "Playground URL: " (ffap-url-p (ffap-string-at-point 'url))))) - (with-current-buffer - (let ((url-request-method "GET") url-request-data url-request-extra-headers) - (url-retrieve-synchronously (concat url ".go"))) - (let ((buffer (generate-new-buffer (concat (car (last (split-string url "/"))) ".go")))) - (goto-char (point-min)) - (re-search-forward "\n\n") - (copy-to-buffer buffer (point) (point-max)) - (kill-buffer) - (with-current-buffer buffer - (go-mode) - (switch-to-buffer buffer))))) - -(defun go-propertize-syntax (start end) - (save-excursion - (goto-char start) - (while (search-forward "\\" end t) - (put-text-property (1- (point)) (point) 'syntax-table (if (= (char-after) ?`) '(1) '(9)))))) - -(defun go-import-add (arg import) - "Add a new IMPORT to the list of imports. - -When called with a prefix ARG asks for an alternative name to -import the package as. - -If no list exists yet, one will be created if possible. - -If an identical import has been commented, it will be -uncommented, otherwise a new import will be added." - - ;; - If there's a matching `// import "foo"`, uncomment it - ;; - If we're in an import() block and there's a matching `"foo"`, uncomment it - ;; - Otherwise add a new import, with the appropriate syntax - (interactive - (list - current-prefix-arg - (replace-regexp-in-string "^[\"']\\|[\"']$" "" (completing-read "Package: " (go--old-completion-list-style (go-packages)))))) - (save-excursion - (let (as line import-start) - (if arg - (setq as (read-from-minibuffer "Import as: "))) - (if as - (setq line (format "%s \"%s\"" as import)) - (setq line (format "\"%s\"" import))) - - (goto-char (point-min)) - (if (re-search-forward (concat "^[[:space:]]*//[[:space:]]*import " line "$") nil t) - (uncomment-region (line-beginning-position) (line-end-position)) - (cl-case (go-goto-imports) - ('fail (message "Could not find a place to add import.")) - ('block-empty - (insert "\n\t" line "\n")) - ('block - (save-excursion - (re-search-backward "^import (") - (setq import-start (point))) - (if (re-search-backward (concat "^[[:space:]]*//[[:space:]]*" line "$") import-start t) - (uncomment-region (line-beginning-position) (line-end-position)) - (insert "\n\t" line))) - ('single (insert "import " line "\n")) - ('none (insert "\nimport (\n\t" line "\n)\n"))))))) - -(defun go-root-and-paths () - (let* ((output (process-lines go-command "env" "GOROOT" "GOPATH")) - (root (car output)) - (paths (split-string (cadr output) path-separator))) - (cons root paths))) - -(defun go--string-prefix-p (s1 s2 &optional ignore-case) - "Return non-nil if S1 is a prefix of S2. -If IGNORE-CASE is non-nil, the comparison is case-insensitive." - (eq t (compare-strings s1 nil nil - s2 0 (length s1) ignore-case))) - -(defun go--directory-dirs (dir) - "Recursively return all subdirectories in DIR." - (if (file-directory-p dir) - (let ((dir (directory-file-name dir)) - (dirs '()) - (files (directory-files dir nil nil t))) - (dolist (file files) - (unless (member file '("." "..")) - (let ((file (concat dir "/" file))) - (if (file-directory-p file) - (setq dirs (append (cons file - (go--directory-dirs file)) - dirs)))))) - dirs) - '())) - - -(defun go-packages () - (funcall go-packages-function)) - -(defun go-packages-native () - "Return a list of all installed Go packages. It looks for -archive files in /pkg/" - (sort - (delete-dups - (cl-mapcan - (lambda (topdir) - (let ((pkgdir (concat topdir "/pkg/"))) - (cl-mapcan (lambda (dir) - (mapcar (lambda (file) - (let ((sub (substring file (length pkgdir) -2))) - (unless (or (go--string-prefix-p "obj/" sub) (go--string-prefix-p "tool/" sub)) - (mapconcat #'identity (cdr (split-string sub "/")) "/")))) - (if (file-directory-p dir) - (directory-files dir t "\\.a$")))) - (if (file-directory-p pkgdir) - (go--directory-dirs pkgdir))))) - (go-root-and-paths))) - #'string<)) - -(defun go-packages-go-list () - "Return a list of all Go packages, using `go list'" - (process-lines go-command "list" "-e" "all")) - -(defun go-unused-imports-lines () - (reverse (remove nil - (mapcar - (lambda (line) - (when (string-match "^\\(.+\\):\\([[:digit:]]+\\): imported and not used: \".+\".*$" line) - (let ((error-file-name (match-string 1 line)) - (error-line-num (match-string 2 line))) - (if (string= (file-truename error-file-name) (file-truename buffer-file-name)) - (string-to-number error-line-num))))) - (split-string (shell-command-to-string - (concat go-command - (if (string-match "_test\\.go$" buffer-file-truename) - " test -c" - (concat " build -o " null-device)) - " -gcflags=-e" - " " - (shell-quote-argument (file-truename buffer-file-name)))) "\n"))))) - -(defun go-remove-unused-imports (arg) - "Remove all unused imports. -If ARG is non-nil, unused imports will be commented, otherwise -they will be removed completely." - (interactive "P") - (save-excursion - (let ((cur-buffer (current-buffer)) flymake-state lines) - (when (boundp 'flymake-mode) - (setq flymake-state flymake-mode) - (flymake-mode-off)) - (save-some-buffers nil (lambda () (equal cur-buffer (current-buffer)))) - (if (buffer-modified-p) - (message "Cannot operate on unsaved buffer") - (setq lines (go-unused-imports-lines)) - (dolist (import lines) - (go--goto-line import) - (beginning-of-line) - (if arg - (comment-region (line-beginning-position) (line-end-position)) - (go--delete-whole-line))) - (message "Removed %d imports" (length lines))) - (if flymake-state (flymake-mode-on))))) - -(defun godef--find-file-line-column (specifier other-window) - "Given a file name in the format of `filename:line:column', -visit FILENAME and go to line LINE and column COLUMN." - (if (not (string-match "\\(.+\\):\\([0-9]+\\):\\([0-9]+\\)" specifier)) - ;; We've only been given a directory name - (funcall (if other-window #'find-file-other-window #'find-file) specifier) - (let ((filename (match-string 1 specifier)) - (line (string-to-number (match-string 2 specifier))) - (column (string-to-number (match-string 3 specifier)))) - (funcall (if other-window #'find-file-other-window #'find-file) filename) - (go--goto-line line) - (beginning-of-line) - (forward-char (1- column)) - (if (buffer-modified-p) - (message "Buffer is modified, file position might not have been correct"))))) - -(defun godef--call (point) - "Call godef, acquiring definition position and expression -description at POINT." - (if (go--xemacs-p) - (error "godef does not reliably work in XEmacs, expect bad results")) - (if (not (buffer-file-name (go--coverage-origin-buffer))) - (error "Cannot use godef on a buffer without a file name") - (let ((outbuf (generate-new-buffer "*godef*")) - (coding-system-for-read 'utf-8) - (coding-system-for-write 'utf-8)) - (prog2 - (call-process-region (point-min) - (point-max) - godef-command - nil - outbuf - nil - "-i" - "-t" - "-f" - (file-truename (buffer-file-name (go--coverage-origin-buffer))) - "-o" - (number-to-string (go--position-bytes point))) - (with-current-buffer outbuf - (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n")) - (kill-buffer outbuf))))) - -(defun godef--successful-p (output) - (not (or (string= "-" output) - (string= "godef: no identifier found" output) - (go--string-prefix-p "godef: no declaration found for " output) - (go--string-prefix-p "error finding import path for " output)))) - -(defun godef--error (output) - (cond - ((godef--successful-p output) - nil) - ((string= "-" output) - "godef: expression is not defined anywhere") - (t - output))) - -(defun godef-describe (point) - "Describe the expression at POINT." - (interactive "d") - (condition-case nil - (let ((description (cdr (butlast (godef--call point) 1)))) - (if (not description) - (message "No description found for expression at point") - (message "%s" (mapconcat #'identity description "\n")))) - (file-error (message "Could not run godef binary")))) - -(defun godef-jump (point &optional other-window) - "Jump to the definition of the expression at POINT." - (interactive "d") - (condition-case nil - (let ((file (car (godef--call point)))) - (if (not (godef--successful-p file)) - (message "%s" (godef--error file)) - (push-mark) - (ring-insert find-tag-marker-ring (point-marker)) - (godef--find-file-line-column file other-window))) - (file-error (message "Could not run godef binary")))) - -(defun godef-jump-other-window (point) - (interactive "d") - (godef-jump point t)) - -(defun go--goto-line (line) - (goto-char (point-min)) - (forward-line (1- line))) - -(defun go--line-column-to-point (line column) - (save-excursion - (go--goto-line line) - (forward-char (1- column)) - (point))) - -(cl-defstruct go--covered - start-line start-column end-line end-column covered count) - -(defun go--coverage-file () - "Return the coverage file to use, either by reading it from the -current coverage buffer or by prompting for it." - (if (boundp 'go--coverage-current-file-name) - go--coverage-current-file-name - (read-file-name "Coverage file: " nil nil t))) - -(defun go--coverage-origin-buffer () - "Return the buffer to base the coverage on." - (or (buffer-base-buffer) (current-buffer))) - -(defun go--coverage-face (count divisor) - "Return the intensity face for COUNT when using DIVISOR -to scale it to a range [0,10]. - -DIVISOR scales the absolute cover count to values from 0 to 10. -For DIVISOR = 0 the count will always translate to 8." - (let* ((norm (cond - ((= count 0) - -0.1) ;; Uncovered code, set to -0.1 so n becomes 0. - ((= divisor 0) - 0.8) ;; covermode=set, set to 0.8 so n becomes 8. - (t - (/ (log count) divisor)))) - (n (1+ (floor (* norm 9))))) ;; Convert normalized count [0,1] to intensity [0,10] - (concat "go-coverage-" (number-to-string n)))) - -(defun go--coverage-make-overlay (range divisor) - "Create a coverage overlay for a RANGE of covered/uncovered code. -Use DIVISOR to scale absolute counts to a [0,10] scale." - (let* ((count (go--covered-count range)) - (face (go--coverage-face count divisor)) - (ov (make-overlay (go--line-column-to-point (go--covered-start-line range) - (go--covered-start-column range)) - (go--line-column-to-point (go--covered-end-line range) - (go--covered-end-column range))))) - - (overlay-put ov 'face face) - (overlay-put ov 'help-echo (format "Count: %d" count)))) - -(defun go--coverage-clear-overlays () - "Remove existing overlays and put a single untracked overlay -over the entire buffer." - (remove-overlays) - (overlay-put (make-overlay (point-min) (point-max)) - 'face - 'go-coverage-untracked)) - -(defun go--coverage-parse-file (coverage-file file-name) - "Parse COVERAGE-FILE and extract coverage information and -divisor for FILE-NAME." - (let (ranges - (max-count 0)) - (with-temp-buffer - (insert-file-contents coverage-file) - (go--goto-line 2) ;; Skip over mode - (while (not (eobp)) - (let* ((parts (split-string (buffer-substring (point-at-bol) (point-at-eol)) ":")) - (file (car parts)) - (rest (split-string (nth 1 parts) "[., ]"))) - - (cl-destructuring-bind - (start-line start-column end-line end-column num count) - (mapcar #'string-to-number rest) - - (when (string= (file-name-nondirectory file) file-name) - (if (> count max-count) - (setq max-count count)) - (push (make-go--covered :start-line start-line - :start-column start-column - :end-line end-line - :end-column end-column - :covered (/= count 0) - :count count) - ranges))) - - (forward-line))) - - (list ranges (if (> max-count 0) (log max-count) 0))))) - -(defun go-coverage (&optional coverage-file) - "Open a clone of the current buffer and overlay it with -coverage information gathered via go test -coverprofile=COVERAGE-FILE. - -If COVERAGE-FILE is nil, it will either be inferred from the -current buffer if it's already a coverage buffer, or be prompted -for." - (interactive) - (let* ((cur-buffer (current-buffer)) - (origin-buffer (go--coverage-origin-buffer)) - (gocov-buffer-name (concat (buffer-name origin-buffer) "")) - (coverage-file (or coverage-file (go--coverage-file))) - (ranges-and-divisor (go--coverage-parse-file - coverage-file - (file-name-nondirectory (buffer-file-name origin-buffer)))) - (cov-mtime (nth 5 (file-attributes coverage-file))) - (cur-mtime (nth 5 (file-attributes (buffer-file-name origin-buffer))))) - - (if (< (float-time cov-mtime) (float-time cur-mtime)) - (message "Coverage file is older than the source file.")) - - (with-current-buffer (or (get-buffer gocov-buffer-name) - (make-indirect-buffer origin-buffer gocov-buffer-name t)) - (set (make-local-variable 'go--coverage-current-file-name) coverage-file) - - (save-excursion - (go--coverage-clear-overlays) - (dolist (range (car ranges-and-divisor)) - (go--coverage-make-overlay range (cadr ranges-and-divisor)))) - - (if (not (eq cur-buffer (current-buffer))) - (display-buffer (current-buffer) `(,go-coverage-display-buffer-func)))))) - -(defun go-goto-function (&optional arg) - "Go to the function defintion (named or anonymous) surrounding point. - -If we are on a docstring, follow the docstring down. -If no function is found, assume that we are at the top of a file -and search forward instead. - -If point is looking at the func keyword of an anonymous function, -go to the surrounding function. - -If ARG is non-nil, anonymous functions are ignored." - (interactive "P") - (let ((p (point))) - (cond - ((save-excursion - (beginning-of-line) - (looking-at "^//")) - ;; In case we are looking at the docstring, move on forward until we are - ;; not anymore - (beginning-of-line) - (while (looking-at "^//") - (forward-line 1)) - ;; If we are still not looking at a function, retry by calling self again. - (when (not (looking-at "\\")) - (go-goto-function arg))) - - ;; If we're already looking at an anonymous func, look for the - ;; surrounding function. - ((and (looking-at "\\") - (not (looking-at "^func\\>"))) - (re-search-backward "\\" nil t)) - - ((not (looking-at "\\")) - ;; If point is on the "func" keyword, step back a word and retry - (if (string= (symbol-name (symbol-at-point)) "func") - (backward-word) - ;; If we are not looking at the beginning of a function line, do a regexp - ;; search backwards - (re-search-backward "\\" nil t)) - - ;; If nothing is found, assume that we are at the top of the file and - ;; should search forward instead. - (when (not (looking-at "\\")) - (re-search-forward "\\" nil t) - (forward-word -1)) - - ;; If we have landed at an anonymous function, it is possible that we - ;; were not inside it but below it. If we were not inside it, we should - ;; go to the containing function. - (while (and (not (go--in-function-p p)) - (not (looking-at "^func\\>"))) - (go-goto-function arg))))) - - (cond - ((go-in-comment-p) - ;; If we are still in a comment, redo the call so that we get out of it. - (go-goto-function arg)) - - ((and (looking-at "\\")) - (go-goto-function)) - (let ((start (point))) - (go--goto-opening-curly-brace) - - (unless (looking-at "{") - (error "expected to be looking at opening curly brace")) - (forward-list 1) - (and (>= compare-point start) - (<= compare-point (point)))))) - -(defun go-goto-function-name (&optional arg) - "Go to the name of the current function. - -If the function is a test, place point after 'Test'. -If the function is anonymous, place point on the 'func' keyword. - -If ARG is non-nil, anonymous functions are skipped." - (interactive "P") - (when (not (looking-at "\\")) - (go-goto-function arg)) - ;; If we are looking at func( we are on an anonymous function and - ;; nothing else should be done. - (when (not (looking-at "\\ -;; Maintainer: Bozhidar Batsov -;; URL: https://github.com/grizzl/grizzl -;; Package-Version: 20160818.37 -;; Version: 0.1.2 -;; Keywords: convenience, usability -;; Package-Requires: ((cl-lib "0.5") (emacs "24.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 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 . - -;; This file is not part of GNU Emacs. - -;;; Commentary: - -;; Grizzl provides a fuzzy completion framework for general purpose -;; use in Emacs Lisp projects. -;; -;; grizzl provides the underlying data structures and sesrch -;; algorithm without any UI attachment. At the core, a fuzzy search -;; index is created from a list of strings, using `grizzl-make-index'. -;; A fuzzy search term is then used to get a result from this index -;; with `grizzl-search'. Because grizzl considers the usage of a -;; fuzzy search index to operate in real-time as a user enters a -;; search term in the minibuffer, the framework optimizes for this use -;; case. Any result can be passed back into `grizzl-search' as a hint -;; to continue searching. The search algorithm is able to understand -;; insertions and deletions and therefore minimizes the work it needs -;; to do in this case. The intended use here is to collect a result -;; on each key press and feed that result into the search for the next -;; key press. Once a search is complete, the matched strings are then -;; read, using `grizzl-result-strings'. The results are ordered on the -;; a combination of the Levenshtein Distance and a character-proximity -;; scoring calculation. This means shorter strings are favoured, but -;; adjacent letters are more heavily favoured. -;; -;; It is assumed that the index will be re-used across multiple -;; searches on larger sets of data. -;; -;; Call `grizzl-completing-read' with an index returned by -;; `grizzl-make-index': -;; -;; (defvar *index* (grizzl-make-index '("one" "two" "three"))) -;; (grizzl-completing-read "Number: " *index*) -;; -;; When the user hits ENTER, either one of the strings is returned on -;; success, or nil of nothing matched. -;; -;; The arrow keys can be used to navigate within the results. - - -;;; Code: - -(eval-when-compile - (require 'cl-lib)) - -;;; --- Public Functions - -;;;###autoload -(defun grizzl-make-index (strings &rest options) - "Makes an index from the list STRINGS for use with `grizzl-search'. - -If :PROGRESS-FN is given as a keyword argument, it is called repeatedly -with integers N and TOTAL. - -If :CASE-SENSITIVE is specified as a non-nil keyword argument, the index -will be created case-sensitive, otherwise it will be case-insensitive." - (let ((lookup-table (make-hash-table)) - (total-strs (length strings)) - (case-sensitive (plist-get options :case-sensitive)) - (progress-fn (plist-get options :progress-fn)) - (string-data (vconcat (mapcar (lambda (s) - (cons s (length s))) - strings)))) - (cl-reduce (lambda (list-offset str) - (grizzl-index-insert str list-offset lookup-table - :case-sensitive case-sensitive) - (when progress-fn - (funcall progress-fn (1+ list-offset) total-strs)) - (1+ list-offset)) - strings - :initial-value 0) - (maphash (lambda (_char str-map) - (maphash (lambda (list-offset locations) - (puthash list-offset (reverse locations) str-map)) - str-map)) lookup-table) - `((case-sensitive . ,case-sensitive) - (lookup-table . ,lookup-table) - (string-data . ,string-data)))) - -;;;###autoload -(defun grizzl-search (term index &optional old-result) - "Fuzzy searches for TERM in INDEX prepared with `grizzl-make-index'. - -OLD-RESULT may be specified as an existing search result to increment from. -The result can be read with `grizzl-result-strings'." - (let* ((cased-term (if (grizzl-index-case-sensitive-p index) - term - (downcase term))) - (result (grizzl-rewind-result cased-term index old-result)) - (matches (copy-hash-table (grizzl-result-matches result))) - (from-pos (length (grizzl-result-term result))) - (remainder (substring cased-term from-pos)) - (lookup-table (grizzl-lookup-table index))) - (cl-reduce (lambda (acc-res ch) - (let ((sub-table (gethash ch lookup-table))) - (if (not sub-table) - (clrhash matches) - (grizzl-search-increment sub-table matches)) - (grizzl-cons-result cased-term matches acc-res))) - remainder - :initial-value result))) - -;;;###autoload -(defun grizzl-result-count (result) - "Returns the number of matches present in RESULT." - (hash-table-count (grizzl-result-matches result))) - -;;;###autoload -(defun grizzl-result-strings (result index &rest options) - "Returns the ordered list of matched strings in RESULT, using INDEX. - -If the :START option is specified, results are read from the given offset. -If the :END option is specified, up to :END results are returned." - (let* ((matches (grizzl-result-matches result)) - (strings (grizzl-index-strings index)) - (loaded '())) - (maphash (lambda (string-offset _char-offset) - (push string-offset loaded)) - matches) - (let* ((ordered (sort loaded - (lambda (a b) - (< (cadr (gethash a matches)) - (cadr (gethash b matches)))))) - (start (or (plist-get options :start) 0)) - (end (min (plist-get options :end) (length ordered))) - (best (if (or start end) - (cl-delete-if-not 'identity - (cl-subseq ordered start end)) - ordered))) - (mapcar (lambda (n) - (car (elt strings n))) - best)))) - -;;; --- Private Functions - -(defun grizzl-cons-result (term matches results) - "Build a new result for TERM and hash-table MATCHES consed with RESULTS." - (cons (cons term matches) results)) - -(defun grizzl-rewind-result (term index result) - "Adjusts RESULT according to TERM, ready for a new search." - (if result - (let* ((old-term (grizzl-result-term result)) - (new-len (length term)) - (old-len (length old-term))) - (if (and (>= new-len old-len) - (string-equal old-term (substring term 0 old-len))) - result - (grizzl-rewind-result term index (cdr result)))) - (grizzl-cons-result "" (grizzl-base-matches index) nil))) - -(defun grizzl-base-matches (index) - "Returns the full set of matches in INDEX, with an out-of-bound offset." - (let ((matches (make-hash-table))) - (cl-reduce (lambda (n s-len) - (puthash n (list -1 0 (cdr s-len)) matches) - (1+ n)) - (grizzl-index-strings index) - :initial-value 0) - matches)) - -(defun grizzl-result-term (result) - "Returns the search term used to find the matches in RESULT." - (car (car result))) - -(defun grizzl-result-matches (result) - "Returns the internal hash used to track the matches in RESULT." - (cdar result)) - -(defun grizzl-index-insert (string list-offset index &rest options) - "Inserts STRING at LIST-OFFSET into INDEX." - (let ((case-sensitive (plist-get options :case-sensitive))) - (cl-reduce (lambda (char-offset cs-char) - (let* ((char (if case-sensitive - cs-char - (downcase cs-char))) - (str-map (or (gethash char index) - (puthash char (make-hash-table) index))) - (offsets (gethash list-offset str-map))) - (puthash list-offset - (cons char-offset offsets) - str-map) - (1+ char-offset))) - string - :initial-value 0))) - -(defun grizzl-lookup-table (index) - "Returns the lookup table portion of INDEX." - (cdr (assoc 'lookup-table index))) - -(defun grizzl-index-strings (index) - "Returns the vector of strings stored in INDEX." - (cdr (assoc 'string-data index))) - -(defun grizzl-index-case-sensitive-p (index) - "Predicate to test of INDEX is case-sensitive." - (cdr (assoc 'case-sensitive index))) - -(defun grizzl-search-increment (sub-table result) - "Use the search lookup table to filter already-accumulated results." - (cl-flet ((next-offset (key current sub-table) - (cl-find-if (lambda (v) - (> v current)) - (gethash key sub-table)))) - (maphash (lambda (k v) - (let* ((oldpos (car v)) - (oldrank (cadr v)) - (len (cl-caddr v)) - (newpos (next-offset k oldpos sub-table))) - (if newpos - (puthash k (list newpos - (grizzl-inc-rank oldrank oldpos newpos len) - len) - result) - (remhash k result)))) - result))) - -(defun grizzl-inc-rank (oldrank oldpos newpos len) - "Increment the current match distance as a new char is matched." - (let ((distance (if (< oldpos 0) 1 (- newpos oldpos)))) - (+ oldrank (* len (* distance distance))))) - -;;; --- Configuration Variables - -(defvar *grizzl-read-max-results* 10 - "The maximum number of results to show in `grizzl-completing-read'.") - -;;; --- Runtime Processing Variables - -(defvar *grizzl-current-result* nil - "The search result in `grizzl-completing-read'.") - -(defvar *grizzl-current-selection* 0 - "The selected offset in `grizzl-completing-read'.") - -(defface grizzl-selection-face - `((((class color) (background light)) - (:foreground "red")) - (((class color) (background dark)) - (:foreground "red")) - (t (:foreground "red"))) - "Face for selected result." - :group 'grizzl-mode) - -(defface grizzl-prompt-face - `((t :inherit 'mode-line-inactive)) - "Face used for grizzl prompt." - :group 'grizzl-mode) - -;;; --- Minor Mode Definition - -(defvar *grizzl-keymap* (make-sparse-keymap) - "Internal keymap used by the minor-mode in `grizzl-completing-read'.") - -(define-key *grizzl-keymap* (kbd "") 'grizzl-set-selection+1) -(define-key *grizzl-keymap* (kbd "C-p") 'grizzl-set-selection+1) -(define-key *grizzl-keymap* (kbd "") 'grizzl-set-selection-1) -(define-key *grizzl-keymap* (kbd "C-n") 'grizzl-set-selection-1) - -(define-minor-mode grizzl-mode - "Toggle the internal mode used by `grizzl-completing-read'." - nil - " Grizzl" - *grizzl-keymap*) - -;;; --- Public Functions - -;;;###autoload -(defun grizzl-completing-read (prompt index) - "Performs a completing-read in the minibuffer using INDEX to fuzzy search. -Each key pressed in the minibuffer filters down the list of matches." - (minibuffer-with-setup-hook - (lambda () - (setq *grizzl-current-result* nil) - (setq *grizzl-current-selection* 0) - (grizzl-mode 1) - (let* ((hookfun (lambda () - (setq *grizzl-current-result* - (grizzl-search (minibuffer-contents) - index - *grizzl-current-result*)) - (grizzl-display-result index prompt))) - (exitfun (lambda () - (grizzl-mode -1) - (remove-hook 'post-command-hook hookfun t)))) - (add-hook 'minibuffer-exit-hook exitfun nil t) - (add-hook 'post-command-hook hookfun nil t))) - (let ((read-value (read-from-minibuffer ">>> "))) - (or (grizzl-selected-result index) read-value)))) - -;;;###autoload -(defun grizzl-selected-result (index) - "Get the selected string from INDEX in a `grizzl-completing-read'." - (elt (grizzl-result-strings *grizzl-current-result* index - :start 0 - :end *grizzl-read-max-results*) - (grizzl-current-selection))) - -;;;###autoload -(defun grizzl-set-selection+1 () - "Move the selection up one row in `grizzl-completing-read'." - (interactive) - (grizzl-move-selection 1)) - -;;;###autoload -(defun grizzl-set-selection-1 () - "Move the selection down one row in `grizzl-completing-read'." - (interactive) - (grizzl-move-selection -1)) - -;;; --- Private Functions - -(defun grizzl-move-selection (delta) - "Move the selection by DELTA rows in `grizzl-completing-read'." - (setq *grizzl-current-selection* (+ (grizzl-current-selection) delta)) - (when (not (= (grizzl-current-selection) *grizzl-current-selection*)) - (beep))) - -(defun grizzl-display-result (index prompt) - "Renders a series of overlays to list the matches in the result." - (let* ((matches (grizzl-result-strings *grizzl-current-result* index - :start 0 - :end *grizzl-read-max-results*))) - (delete-all-overlays) - (overlay-put (make-overlay (point-min) (point-min)) - 'before-string - (format "%s\n%s\n" - (mapconcat 'identity - (grizzl-map-format-matches matches) - "\n") - (grizzl-format-prompt-line prompt))) - (set-window-text-height nil (max 3 (+ 2 (length matches)))))) - -(defun grizzl-map-format-matches (matches) - "Convert the set of string MATCHES into propertized text objects." - (if (= 0 (length matches)) - (list (propertize "-- NO MATCH --" 'face 'outline-3)) - (cdr (cl-reduce (lambda (acc str) - (let* ((idx (car acc)) - (lst (cdr acc)) - (sel (= idx (grizzl-current-selection)))) - (cons (1+ idx) - (cons (grizzl-format-match str sel) lst)))) - matches - :initial-value '(0))))) - -(defun grizzl-format-match (match-str selected) - "Default match string formatter in `grizzl-completing-read'. - -MATCH-STR is the string in the selection list and SELECTED is non-nil -if this is the current selection." - (let ((margin (if selected "> " " ")) - (face (if selected 'grizzl-selection-face 'default))) - (propertize (format "%s%s" margin match-str) 'face face))) - -(defun grizzl-format-prompt-line (prompt) - "Returns a string to render a full-width prompt in `grizzl-completing-read'." - (let* ((count (grizzl-result-count *grizzl-current-result*)) - (match-info (format " (%d candidate%s) ---- *-" - count (if (= count 1) "" "s")))) - (concat (propertize (format "-*%s *-" prompt) 'face 'grizzl-prompt-face) - - (propertize " " - 'face 'grizzl-prompt-face - 'display `(space :align-to (- right - ,(1+ (length match-info))))) - (propertize match-info 'face 'grizzl-prompt-face)))) - -(defun grizzl-current-selection () - "Get the currently selected index in `grizzl-completing-read'." - (let ((max-selection - (min (1- *grizzl-read-max-results*) - (1- (grizzl-result-count *grizzl-current-result*))))) - (max 0 (min max-selection *grizzl-current-selection*)))) - -(provide 'grizzl) - -;;; grizzl.el ends here diff --git a/elpa/helm-make-20160807.1756/helm-make-autoloads.el b/elpa/helm-make-20160807.1756/helm-make-autoloads.el deleted file mode 100644 index 5cd35dd..0000000 --- a/elpa/helm-make-20160807.1756/helm-make-autoloads.el +++ /dev/null @@ -1,39 +0,0 @@ -;;; helm-make-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) - -;;;### (autoloads nil "helm-make" "helm-make.el" (22454 5313 194042 -;;;;;; 549000)) -;;; Generated autoloads from helm-make.el - -(autoload 'helm-make "helm-make" "\ -Call \"make -j ARG target\". Target is selected with completion. - -\(fn &optional ARG)" t nil) - -(autoload 'helm-make-reset-cache "helm-make" "\ -Reset cache, see `helm-make-cache-targets'. - -\(fn)" t nil) - -(autoload 'helm-make-projectile "helm-make" "\ -Call `helm-make' for `projectile-project-root'. -ARG specifies the number of cores. - -By default `helm-make-projectile' will look in `projectile-project-root' -followed by `projectile-project-root'/build, for a makefile. - -You can specify an additional directory to search for a makefile by -setting the buffer local variable `helm-make-build-dir'. - -\(fn &optional ARG)" t nil) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; helm-make-autoloads.el ends here diff --git a/elpa/helm-make-20160807.1756/helm-make-pkg.el b/elpa/helm-make-20160807.1756/helm-make-pkg.el deleted file mode 100644 index 972d2b0..0000000 --- a/elpa/helm-make-20160807.1756/helm-make-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "helm-make" "20160807.1756" "Select a Makefile target with helm" '((helm "1.5.3") (projectile "0.11.0")) :url "https://github.com/abo-abo/helm-make" :keywords '("makefile")) diff --git a/elpa/helm-make-20160807.1756/helm-make.el b/elpa/helm-make-20160807.1756/helm-make.el deleted file mode 100644 index 0cb3fc8..0000000 --- a/elpa/helm-make-20160807.1756/helm-make.el +++ /dev/null @@ -1,315 +0,0 @@ -;;; helm-make.el --- Select a Makefile target with helm - -;; Copyright (C) 2014 Oleh Krehel - -;; Author: Oleh Krehel -;; URL: https://github.com/abo-abo/helm-make -;; Package-Version: 20160807.1756 -;; Version: 0.2.0 -;; Package-Requires: ((helm "1.5.3") (projectile "0.11.0")) -;; Keywords: makefile - -;; This file is not part of GNU Emacs - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. - -;; This 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. - -;; For a full copy of the GNU General Public License -;; see . - -;;; Commentary: -;; -;; A call to `helm-make' will give you a `helm' selection of this directory -;; Makefile's targets. Selecting a target will call `compile' on it. - -;;; Code: - -(require 'helm) -(require 'helm-multi-match) - -(declare-function ivy-read "ext:ivy") - -(defgroup helm-make nil - "Select a Makefile target with helm." - :group 'convenience) - -(defcustom helm-make-do-save nil - "If t, save all open buffers visiting files from Makefile's directory." - :type 'boolean - :group 'helm-make) - -(defcustom helm-make-build-dir "" - "Specify a build directory for an out of source build. -The path should be relative to the project root. - -When non-nil `helm-make-projectile' will first look in that directory for a -makefile." - :type '(string) - :group 'helm-make) -(make-variable-buffer-local 'helm-make-build-dir) - -(defcustom helm-make-sort-targets nil - "Whether targets shall be sorted. -If t, targets will be sorted as a final step before calling the -completion method. - -HINT: If you are facing performance problems set this to nil. -This might be the case, if there are thousand of targets." - :type 'boolean - :group 'helm-make) - -(defcustom helm-make-cache-targets nil - "Whether to cache the targets or not. - -If t, cache targets of Makefile. If `helm-make' or `helm-make-projectile' -gets called for the same Makefile again, and the Makefile hasn't changed -meanwhile, i.e. the modification time is `equal' to the cached one, reuse -the cached targets, instead of recomputing them. If nil do nothing. - -You can reset the cache by calling `helm-make-reset-db'." - :type 'boolean - :group 'helm-make) - -(defcustom helm-make-executable "make" - "Store the name of make executable." - :type 'string - :group 'helm-make) - -(defcustom helm-make-require-match t - "When non-nil, don't allow selecting a target that's not on the list." - :type 'boolean) - -(defcustom helm-make-named-buffer nil - "When non-nil, name compilation buffer based on make target." - :type 'boolean) - -(defcustom helm-make-comint nil - "When non-nil, run helm-make in Comint mode instead of Compilation mode." - :type 'boolean) - -(defvar helm-make-command nil - "Store the make command.") - -(defvar helm-make-target-history nil - "Holds the recently used targets.") - -(defvar helm-make-makefile-names '("Makefile" "makefile" "GNUmakefile") - "List of Makefile names which make recognizes. -An exception is \"GNUmakefile\", only GNU make unterstand it.") - -(defun helm--make-action (target) - "Make TARGET." - (let* ((make-command (format helm-make-command target)) - (compile-buffer (compile make-command helm-make-comint))) - (when helm-make-named-buffer - (helm--make-rename-buffer compile-buffer target)))) - -(defun helm--make-rename-buffer (buffer target) - "Rename the compilation BUFFER based on the make TARGET." - (let ((buffer-name (format "*compilation (%s)*" target))) - (when (get-buffer-window buffer-name) - (delete-window (get-buffer-window buffer-name))) - (when (get-buffer buffer-name) - (kill-buffer buffer-name)) - (with-current-buffer buffer - (rename-buffer buffer-name)))) - -(defcustom helm-make-completion-method 'helm - "Method to select a candidate from a list of strings." - :type '(choice - (const :tag "Helm" helm) - (const :tag "Ido" ido) - (const :tag "Ivy" ivy))) - -;;;###autoload -(defun helm-make (&optional arg) - "Call \"make -j ARG target\". Target is selected with completion." - (interactive "p") - (setq helm-make-command (format "%s -j%d %%s" helm-make-executable arg)) - (let ((makefile (helm--make-makefile-exists default-directory))) - (if makefile - (helm--make makefile) - (error "No Makefile in %s" default-directory)))) - -(defun helm--make-target-list-qp (makefile) - "Return the target list for MAKEFILE by parsing the output of \"make -nqp\"." - (let ((default-directory (file-name-directory - (expand-file-name makefile))) - targets target) - (with-temp-buffer - (insert - (shell-command-to-string - "make -nqp __BASH_MAKE_COMPLETION__=1 .DEFAULT 2>/dev/null")) - (goto-char (point-min)) - (unless (re-search-forward "^# Files" nil t) - (error "Unexpected \"make -nqp\" output")) - (while (re-search-forward "^\\([^%$:#\n\t ]+\\):\\([^=]\\|$\\)" nil t) - (setq target (match-string 1)) - (unless (or (save-excursion - (goto-char (match-beginning 0)) - (forward-line -1) - (looking-at "^# Not a target:")) - (string-match "^\\([/a-zA-Z0-9_. -]+/\\)?\\." target)) - (push target targets)))) - targets)) - -(defun helm--make-target-list-default (makefile) - "Return the target list for MAKEFILE by parsing it." - (let (targets) - (with-temp-buffer - (insert-file-contents makefile) - (goto-char (point-min)) - (while (re-search-forward "^\\([^: \n]+\\):" nil t) - (let ((str (match-string 1))) - (unless (string-match "^\\." str) - (push str targets))))) - targets)) - -(defcustom helm-make-list-target-method 'default - "Method of obtaining the list of Makefile targets." - :type '(choice - (const :tag "Default" default) - (const :tag "make -qp" qp))) - -(defun helm--make-makefile-exists (base-dir &optional dir-list) - "Check if one of `helm-make-makefile-names' exist in BASE-DIR. - -Returns the absolute filename to the Makefile, if one exists, -otherwise nil. - -If DIR-LIST is non-nil, also search for `helm-make-makefile-names'." - (let* ((default-directory (file-truename base-dir)) - (makefiles - (progn - (unless (and dir-list (listp dir-list)) - (setq dir-list (list ""))) - (let (result) - (dolist (dir dir-list) - (dolist (makefile helm-make-makefile-names) - (push (expand-file-name makefile dir) result))) - (reverse result))))) - (cl-find-if 'file-exists-p makefiles))) - -(defvar helm-make-db (make-hash-table :test 'equal) - "An alist of Makefile and corresponding targets.") - -(cl-defstruct helm-make-dbfile - targets - modtime - sorted) - -(defun helm--make-cached-targets (makefile) - "Return cached targets of MAKEFILE. - -If there are no cached targets for MAKEFILE, the MAKEFILE modification -time has changed, or `helm-make-cache-targets' is nil, parse the MAKEFILE, -and cache targets of MAKEFILE, if `helm-make-cache-targets' is t." - (let* ((att (file-attributes makefile 'integer)) - (modtime (if att (nth 5 att) nil)) - (entry (gethash makefile helm-make-db nil)) - (new-entry (make-helm-make-dbfile)) - (targets (cond - ((and helm-make-cache-targets - entry - (equal modtime (helm-make-dbfile-modtime entry)) - (helm-make-dbfile-targets entry)) - (helm-make-dbfile-targets entry)) - (t - (delete-dups (if (eq helm-make-list-target-method 'default) - (helm--make-target-list-default makefile) - (helm--make-target-list-qp makefile))))))) - (when helm-make-sort-targets - (unless (and helm-make-cache-targets - entry - (helm-make-dbfile-sorted entry)) - (setq targets (sort targets 'string<))) - (setf (helm-make-dbfile-sorted new-entry) t)) - - (when helm-make-cache-targets - (setf (helm-make-dbfile-targets new-entry) targets - (helm-make-dbfile-modtime new-entry) modtime) - (puthash makefile new-entry helm-make-db)) - targets)) - -;;;###autoload -(defun helm-make-reset-cache () - "Reset cache, see `helm-make-cache-targets'." - (interactive) - (clrhash helm-make-db)) - -(defun helm--make (makefile) - "Call make for MAKEFILE." - (when helm-make-do-save - (let* ((regex (format "^%s" default-directory)) - (buffers - (cl-remove-if-not - (lambda (b) - (let ((name (buffer-file-name b))) - (and name - (string-match regex (expand-file-name name))))) - (buffer-list)))) - (mapc - (lambda (b) - (with-current-buffer b - (save-buffer))) - buffers))) - (let ((targets (helm--make-cached-targets makefile)) - (default-directory (file-name-directory makefile))) - (delete-dups helm-make-target-history) - (cl-case helm-make-completion-method - (helm - (helm :sources - `((name . "Targets") - (candidates . ,targets) - (action . helm--make-action)) - :history 'helm-make-target-history - :preselect (when helm-make-target-history - (format "^%s$" (car helm-make-target-history))))) - (ivy - (ivy-read "Target: " - targets - :history 'helm-make-target-history - :preselect (car helm-make-target-history) - :action 'helm--make-action - :require-match helm-make-require-match)) - (ido - (let ((target (ido-completing-read - "Target: " targets - nil nil nil - 'helm-make-target-history))) - (when target - (helm--make-action target))))))) - -;;;###autoload -(defun helm-make-projectile (&optional arg) - "Call `helm-make' for `projectile-project-root'. -ARG specifies the number of cores. - -By default `helm-make-projectile' will look in `projectile-project-root' -followed by `projectile-project-root'/build, for a makefile. - -You can specify an additional directory to search for a makefile by -setting the buffer local variable `helm-make-build-dir'." - (interactive "p") - (require 'projectile) - (setq helm-make-command (format "%s -j%d %%s" helm-make-executable arg)) - (let ((makefile (helm--make-makefile-exists - (projectile-project-root) - (if (and (stringp helm-make-build-dir) - (not (string-match-p "\\`[ \t\n\r]*\\'" helm-make-build-dir))) - `(,helm-make-build-dir "" "build") - `(,@helm-make-build-dir "" "build"))))) - (if makefile - (helm--make makefile) - (error "No Makefile found for project %s" (projectile-project-root))))) - -(provide 'helm-make) - -;;; helm-make.el ends here diff --git a/elpa/ht-20160911.1900/ht-autoloads.el b/elpa/ht-20160911.1900/ht-autoloads.el deleted file mode 100644 index 76d569b..0000000 --- a/elpa/ht-20160911.1900/ht-autoloads.el +++ /dev/null @@ -1,15 +0,0 @@ -;;; ht-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil nil ("ht.el") (22490 24933 409230 911000)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; ht-autoloads.el ends here diff --git a/elpa/ht-20160911.1900/ht-pkg.el b/elpa/ht-20160911.1900/ht-pkg.el deleted file mode 100644 index 8ed00f8..0000000 --- a/elpa/ht-20160911.1900/ht-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "ht" "20160911.1900" "The missing hash table library for Emacs" '((dash "2.12.0")) :keywords '("hash table" "hash map" "hash")) diff --git a/elpa/ht-20160911.1900/ht.el b/elpa/ht-20160911.1900/ht.el deleted file mode 100644 index 060a48f..0000000 --- a/elpa/ht-20160911.1900/ht.el +++ /dev/null @@ -1,280 +0,0 @@ -;;; ht.el --- The missing hash table library for Emacs - -;; Copyright (C) 2013 Wilfred Hughes - -;; Author: Wilfred Hughes -;; Version: 2.2 -;; Package-Version: 20160911.1900 -;; Keywords: hash table, hash map, hash -;; Package-Requires: ((dash "2.12.0")) - -;; 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: - -;; The missing hash table library for Emacs. -;; -;; See documentation at https://github.com/Wilfred/ht.el - -;;; Code: - -(require 'dash) - -(defmacro ht (&rest pairs) - "Create a hash table with the key-value pairs given. -Keys are compared with `equal'. - -\(fn (KEY-1 VALUE-1) (KEY-2 VALUE-2) ...)" - (let* ((table-symbol (make-symbol "ht-temp")) - (assignments - (mapcar - (lambda (pair) `(ht-set! ,table-symbol ,@pair)) - pairs))) - `(let ((,table-symbol (ht-create))) - ,@assignments - ,table-symbol))) - -(defun ht-create (&optional test) - "Create an empty hash table. - -TEST indicates the function used to compare the hash -keys. Default is `equal'. It can be `eq', `eql', `equal' or a -user-supplied test created via `define-hash-table-test'." - (make-hash-table :test (or test 'equal))) - -(defun ht<-alist (alist &optional test) - "Create a hash table with initial values according to ALIST. - -TEST indicates the function used to compare the hash -keys. Default is `equal'. It can be `eq', `eql', `equal' or a -user-supplied test created via `define-hash-table-test'." - (let ((h (ht-create test))) - ;; the first key-value pair in an alist gets precedence, so we - ;; start from the end of the list: - (dolist (pair (reverse alist) h) - (let ((key (car pair)) - (value (cdr pair))) - (ht-set! h key value))))) - -(defalias 'ht-from-alist 'ht<-alist) - -(defun ht<-plist (plist &optional test) - "Create a hash table with initial values according to PLIST. - -TEST indicates the function used to compare the hash -keys. Default is `equal'. It can be `eq', `eql', `equal' or a -user-supplied test created via `define-hash-table-test'." - (let ((h (ht-create test))) - (dolist (pair (-partition 2 plist) h) - (let ((key (car pair)) - (value (cadr pair))) - (ht-set! h key value))))) - -(defalias 'ht-from-plist 'ht<-plist) - -(defun ht-get (table key &optional default) - "Look up KEY in TABLE, and return the matching value. -If KEY isn't present, return DEFAULT (nil if not specified)." - (gethash key table default)) - -(defun ht-set! (table key value) - "Associate KEY in TABLE with VALUE." - (puthash key value table) - nil) - -(defalias 'ht-set 'ht-set!) - -(defun ht-update! (table from-table) - "Update TABLE according to every key-value pair in FROM-TABLE." - (maphash - (lambda (key value) (puthash key value table)) - from-table) - nil) - -(defalias 'ht-update 'ht-update!) - -(defun ht-merge (&rest tables) - "Crete a new tables that includes all the key-value pairs from TABLES. -If multiple have tables have the same key, the value in the last -table is used." - (let ((merged (ht-create))) - (mapc (lambda (table) (ht-update! merged table)) tables) - merged)) - -(defun ht-remove! (table key) - "Remove KEY from TABLE." - (remhash key table)) - -(defalias 'ht-remove 'ht-remove!) - -(defun ht-clear! (table) - "Remove all keys from TABLE." - (clrhash table) - nil) - -(defalias 'ht-clear 'ht-clear!) - -(defun ht-map (function table) - "Apply FUNCTION to each key-value pair of TABLE, and make a list of the results. -FUNCTION is called with two arguments, KEY and VALUE." - (let (results) - (maphash - (lambda (key value) - (push (funcall function key value) results)) - table) - results)) - -(defmacro ht-amap (form table) - "Anaphoric version of `ht-map'. -For every key-value pair in TABLE, evaluate FORM with the -variables KEY and VALUE bound." - `(ht-map (lambda (key value) ,form) ,table)) - -(defun ht-keys (table) - "Return a list of all the keys in TABLE." - (ht-amap key table)) - -(defun ht-values (table) - "Return a list of all the values in TABLE." - (ht-amap value table)) - -(defun ht-items (table) - "Return a list of two-element lists '(key value) from TABLE." - (ht-amap (list key value) table)) - -(defalias 'ht-each 'maphash - "Apply FUNCTION to each key-value pair of TABLE. -Returns nil, used for side-effects only.") - -(defmacro ht-aeach (form table) - "Anaphoric version of `ht-each'. -For every key-value pair in TABLE, evaluate FORM with the -variables key and value bound." - `(ht-each (lambda (key value) ,form) ,table)) - -(defun ht->plist (table) - "Return a flat list '(key1 value1 key2 value2...) from TABLE. - -Note that hash tables are unordered, so this cannot be an exact -inverse of `ht<-plist'. The following is not guaranteed: - -\(let ((data '(a b c d))) - (equalp data - (ht->plist (ht<-plist data))))" - (apply 'append (ht-items table))) - -(defalias 'ht-to-plist 'ht->plist) - -(defun ht-copy (table) - "Return a shallow copy of TABLE (keys and values are shared)." - (copy-hash-table table)) - -(defun ht->alist (table) - "Return a list of two-element lists '(key . value) from TABLE. - -Note that hash tables are unordered, so this cannot be an exact -inverse of `ht<-alist'. The following is not guaranteed: - -\(let ((data '((a . b) (c . d)))) - (equalp data - (ht->alist (ht<-alist data))))" - (ht-amap (cons key value) table)) - -(defalias 'ht-to-alist 'ht->alist) - -(defalias 'ht? 'hash-table-p) - -(defalias 'ht-p 'hash-table-p) - -(defun ht-contains? (table key) - "Return 't if TABLE contains KEY." - (not (eq (ht-get table key 'ht--not-found) 'ht--not-found))) - -(defalias 'ht-contains-p 'ht-contains?) - -(defun ht-size (table) - "Return the actual number of entries in TABLE." - (hash-table-count table)) - -(defun ht-empty? (table) - "Return true if the actual number of entries in TABLE is zero." - (zerop (ht-size table))) - -(defun ht-select (function table) - "Return a hash table containing all entries in TABLE for which -FUNCTION returns a truthy value. - -FUNCTION is called with two arguments, KEY and VALUE." - (let ((results (ht-create))) - (ht-each - (lambda (key value) - (when (funcall function key value) - (ht-set! results key value))) - table) - results)) - -(defun ht-reject (function table) - "Return a hash table containing all entries in TABLE for which -FUNCTION returns a falsy value. - -FUNCTION is called with two arguments, KEY and VALUE." - (let ((results (ht-create))) - (ht-each - (lambda (key value) - (unless (funcall function key value) - (ht-set! results key value))) - table) - results)) - -(defun ht-reject! (function table) - "Delete entries from TABLE for which FUNCTION returns a falsy value. - -FUNCTION is called with two arguments, KEY and VALUE." - (ht-each - (lambda (key value) - (when (funcall function key value) - (remhash key table))) - table) - nil) - -(defalias 'ht-delete-if 'ht-reject!) - -(defun ht-find (function table) - "Return (key, value) from TABLE for which FUNCTION returns a truthy value. -Return nil otherwise. - -FUNCTION is called with two arguments, KEY and VALUE." - (catch 'break - (ht-each - (lambda (key value) - (when (funcall function key value) - (throw 'break (list key value)))) - table))) - -(defun ht-equal? (table1 table2) - "Return t if TABLE1 and TABLE2 have the same keys and values. -Does not compare equality predicates." - (let ((keys1 (ht-keys table1)) - (keys2 (ht-keys table2)) - (sentinel (make-symbol "ht-sentinel"))) - (and (equal (length keys1) (length keys2)) - (--all? - (equal (ht-get table1 it) - (ht-get table2 it sentinel)) - keys1)))) - -(defalias 'ht-equal-p 'ht-equal?) - -(provide 'ht) -;;; ht.el ends here diff --git a/elpa/hydra-20160913.216/hydra-autoloads.el b/elpa/hydra-20160913.216/hydra-autoloads.el deleted file mode 100644 index 66e958e..0000000 --- a/elpa/hydra-20160913.216/hydra-autoloads.el +++ /dev/null @@ -1,75 +0,0 @@ -;;; hydra-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "hydra" "hydra.el" (22501 5659 447421 78000)) -;;; Generated autoloads from hydra.el - -(autoload 'defhydra "hydra" "\ -Create a Hydra - a family of functions with prefix NAME. - -NAME should be a symbol, it will be the prefix of all functions -defined here. - -BODY has the format: - - (BODY-MAP BODY-KEY &rest BODY-PLIST) - -DOCSTRING will be displayed in the echo area to identify the -Hydra. When DOCSTRING starts with a newline, special Ruby-style -substitution will be performed by `hydra--format'. - -Functions are created on basis of HEADS, each of which has the -format: - - (KEY CMD &optional HINT &rest PLIST) - -BODY-MAP is a keymap; `global-map' is used quite often. Each -function generated from HEADS will be bound in BODY-MAP to -BODY-KEY + KEY (both are strings passed to `kbd'), and will set -the transient map so that all following heads can be called -though KEY only. BODY-KEY can be an empty string. - -CMD is a callable expression: either an interactive function -name, or an interactive lambda, or a single sexp (it will be -wrapped in an interactive lambda). - -HINT is a short string that identifies its head. It will be -printed beside KEY in the echo erea if `hydra-is-helpful' is not -nil. If you don't even want the KEY to be printed, set HINT -explicitly to nil. - -The heads inherit their PLIST from BODY-PLIST and are allowed to -override some keys. The keys recognized are :exit and :bind. -:exit can be: - -- nil (default): this head will continue the Hydra state. -- t: this head will stop the Hydra state. - -:bind can be: -- nil: this head will not be bound in BODY-MAP. -- a lambda taking KEY and CMD used to bind a head. - -It is possible to omit both BODY-MAP and BODY-KEY if you don't -want to bind anything. In that case, typically you will bind the -generated NAME/body command. This command is also the return -result of `defhydra'. - -\(fn NAME BODY &optional DOCSTRING &rest HEADS)" nil t) - -(put 'defhydra 'lisp-indent-function 'defun) - -;;;*** - -;;;### (autoloads nil nil ("hydra-examples.el" "hydra-ox.el" "hydra-pkg.el" -;;;;;; "lv.el") (22501 5659 473131 612000)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; hydra-autoloads.el ends here diff --git a/elpa/hydra-20160913.216/hydra-examples.el b/elpa/hydra-20160913.216/hydra-examples.el deleted file mode 100644 index 70f75b0..0000000 --- a/elpa/hydra-20160913.216/hydra-examples.el +++ /dev/null @@ -1,386 +0,0 @@ -;;; hydra-examples.el --- Some applications for Hydra - -;; Copyright (C) 2015 Free Software Foundation, Inc. - -;; Author: Oleh Krehel - -;; 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 . - -;;; Commentary: -;; -;; These are the sample Hydras. -;; -;; If you want to use them plainly, set `hydra-examples-verbatim' to t -;; before requiring this file. But it's probably better to only look -;; at them and use them as templates for building your own. - -;;; Code: - -(require 'hydra) - -;;* Examples -;;** Example 1: text scale -(when (bound-and-true-p hydra-examples-verbatim) - (defhydra hydra-zoom (global-map "") - "zoom" - ("g" text-scale-increase "in") - ("l" text-scale-decrease "out"))) - -;; This example generates three commands: -;; -;; `hydra-zoom/text-scale-increase' -;; `hydra-zoom/text-scale-decrease' -;; `hydra-zoom/body' -;; -;; In addition, two of them are bound like this: -;; -;; (global-set-key (kbd " g") 'hydra-zoom/text-scale-increase) -;; (global-set-key (kbd " l") 'hydra-zoom/text-scale-decrease) -;; -;; Note that you can substitute `global-map' with e.g. `emacs-lisp-mode-map' if you need. -;; The functions generated will be the same, except the binding code will change to: -;; -;; (define-key emacs-lisp-mode-map [f2 103] -;; (function hydra-zoom/text-scale-increase)) -;; (define-key emacs-lisp-mode-map [f2 108] -;; (function hydra-zoom/text-scale-decrease)) - -;;** Example 2: move window splitter -(when (bound-and-true-p hydra-examples-verbatim) - (defhydra hydra-splitter (global-map "C-M-s") - "splitter" - ("h" hydra-move-splitter-left) - ("j" hydra-move-splitter-down) - ("k" hydra-move-splitter-up) - ("l" hydra-move-splitter-right))) - -;;** Example 3: jump to error -(when (bound-and-true-p hydra-examples-verbatim) - (defhydra hydra-error (global-map "M-g") - "goto-error" - ("h" first-error "first") - ("j" next-error "next") - ("k" previous-error "prev") - ("v" recenter-top-bottom "recenter") - ("q" nil "quit"))) - -;; This example introduces only one new thing: since the command -;; passed to the "q" head is nil, it will quit the Hydra without doing -;; anything. Heads that quit the Hydra instead of continuing are -;; referred to as having blue :color. All the other heads have red -;; :color, unless other is specified. - -;;** Example 4: toggle rarely used modes -(when (bound-and-true-p hydra-examples-verbatim) - (defvar whitespace-mode nil) - (global-set-key - (kbd "C-c C-v") - (defhydra hydra-toggle-simple (:color blue) - "toggle" - ("a" abbrev-mode "abbrev") - ("d" toggle-debug-on-error "debug") - ("f" auto-fill-mode "fill") - ("t" toggle-truncate-lines "truncate") - ("w" whitespace-mode "whitespace") - ("q" nil "cancel")))) - -;; Note that in this case, `defhydra' returns the `hydra-toggle-simple/body' -;; symbol, which is then passed to `global-set-key'. -;; -;; Another new thing is that both the keymap and the body prefix are -;; skipped. This means that `defhydra' will bind nothing - that's why -;; `global-set-key' is necessary. -;; -;; One more new thing is that you can assign a :color to the body. All -;; heads will inherit this color. The code above is very much equivalent to: -;; -;; (global-set-key (kbd "C-c C-v a") 'abbrev-mode) -;; (global-set-key (kbd "C-c C-v d") 'toggle-debug-on-error) -;; -;; The differences are: -;; -;; * You get a hint immediately after "C-c C-v" -;; * You can cancel and call a command immediately, e.g. "C-c C-v C-n" -;; is equivalent to "C-n" with Hydra approach, while it will error -;; that "C-c C-v C-n" isn't bound with the usual approach. - -;;** Example 5: mini-vi -(defun hydra-vi/pre () - (set-cursor-color "#e52b50")) - -(defun hydra-vi/post () - (set-cursor-color "#ffffff")) - -(when (bound-and-true-p hydra-examples-verbatim) - (global-set-key - (kbd "C-z") - (defhydra hydra-vi (:pre hydra-vi/pre :post hydra-vi/post :color amaranth) - "vi" - ("l" forward-char) - ("h" backward-char) - ("j" next-line) - ("k" previous-line) - ("m" set-mark-command "mark") - ("a" move-beginning-of-line "beg") - ("e" move-end-of-line "end") - ("d" delete-region "del" :color blue) - ("y" kill-ring-save "yank" :color blue) - ("q" nil "quit"))) - (hydra-set-property 'hydra-vi :verbosity 1)) - -;; This example introduces :color amaranth. It's similar to red, -;; except while you can quit red with any binding which isn't a Hydra -;; head, you can quit amaranth only with a blue head. So you can quit -;; this mode only with "d", "y", "q" or "C-g". -;; -;; Another novelty are the :pre and :post handlers. :pre will be -;; called before each command, while :post will be called when the -;; Hydra quits. In this case, they're used to override the cursor -;; color while Hydra is active. - -;;** Example 6: selective global bind -(when (bound-and-true-p hydra-examples-verbatim) - (defhydra hydra-next-error (global-map "C-x") - "next-error" - ("`" next-error "next") - ("j" next-error "next" :bind nil) - ("k" previous-error "previous" :bind nil))) - -;; This example will bind "C-x `" in `global-map', but it will not -;; bind "C-x j" and "C-x k". -;; You can still "C-x `jjk" though. - -;;** Example 7: toggle with Ruby-style docstring -(defvar whitespace-mode nil) -(defhydra hydra-toggle (:color pink) - " -_a_ abbrev-mode: %`abbrev-mode -_d_ debug-on-error: %`debug-on-error -_f_ auto-fill-mode: %`auto-fill-function -_t_ truncate-lines: %`truncate-lines -_w_ whitespace-mode: %`whitespace-mode - -" - ("a" abbrev-mode nil) - ("d" toggle-debug-on-error nil) - ("f" auto-fill-mode nil) - ("t" toggle-truncate-lines nil) - ("w" whitespace-mode nil) - ("q" nil "quit")) -;; Recommended binding: -;; (global-set-key (kbd "C-c C-v") 'hydra-toggle/body) - -;; Here, using e.g. "_a_" translates to "a" with proper face. -;; More interestingly: -;; -;; "foobar %`abbrev-mode" means roughly (format "foobar %S" abbrev-mode) -;; -;; This means that you actually see the state of the mode that you're changing. - -;;** Example 8: the whole menu for `Buffer-menu-mode' -(defhydra hydra-buffer-menu (:color pink - :hint nil) - " -^Mark^ ^Unmark^ ^Actions^ ^Search -^^^^^^^^----------------------------------------------------------------- (__) -_m_: mark _u_: unmark _x_: execute _R_: re-isearch (oo) -_s_: save _U_: unmark up _b_: bury _I_: isearch /------\\/ -_d_: delete ^ ^ _g_: refresh _O_: multi-occur / | || -_D_: delete up ^ ^ _T_: files only: % -28`Buffer-menu-files-only^^ * /\\---/\\ -_~_: modified ^ ^ ^ ^ ^^ ~~ ~~ -" - ("m" Buffer-menu-mark) - ("u" Buffer-menu-unmark) - ("U" Buffer-menu-backup-unmark) - ("d" Buffer-menu-delete) - ("D" Buffer-menu-delete-backwards) - ("s" Buffer-menu-save) - ("~" Buffer-menu-not-modified) - ("x" Buffer-menu-execute) - ("b" Buffer-menu-bury) - ("g" revert-buffer) - ("T" Buffer-menu-toggle-files-only) - ("O" Buffer-menu-multi-occur :color blue) - ("I" Buffer-menu-isearch-buffers :color blue) - ("R" Buffer-menu-isearch-buffers-regexp :color blue) - ("c" nil "cancel") - ("v" Buffer-menu-select "select" :color blue) - ("o" Buffer-menu-other-window "other-window" :color blue) - ("q" quit-window "quit" :color blue)) -;; Recommended binding: -;; (define-key Buffer-menu-mode-map "." 'hydra-buffer-menu/body) - -;;** Example 9: s-expressions in the docstring -;; You can inline s-expresssions into the docstring like this: -(defvar dired-mode-map) -(declare-function dired-mark "dired") -(when (bound-and-true-p hydra-examples-verbatim) - (require 'dired) - (defhydra hydra-marked-items (dired-mode-map "") - " -Number of marked items: %(length (dired-get-marked-files)) -" - ("m" dired-mark "mark"))) - -;; This results in the following dynamic docstring: -;; -;; (format "Number of marked items: %S\n" -;; (length (dired-get-marked-files))) -;; -;; You can use `format'-style width specs, e.g. % 10(length nil). - -;;** Example 10: apropos family -(defhydra hydra-apropos (:color blue - :hint nil) - " -_a_propos _c_ommand -_d_ocumentation _l_ibrary -_v_ariable _u_ser-option -^ ^ valu_e_" - ("a" apropos) - ("d" apropos-documentation) - ("v" apropos-variable) - ("c" apropos-command) - ("l" apropos-library) - ("u" apropos-user-option) - ("e" apropos-value)) -;; Recommended binding: -;; (global-set-key (kbd "C-c h") 'hydra-apropos/body) - -;;** Example 11: rectangle-mark-mode -(require 'rect) -(defhydra hydra-rectangle (:body-pre (rectangle-mark-mode 1) - :color pink - :post (deactivate-mark)) - " - ^_k_^ _d_elete _s_tring -_h_ _l_ _o_k _y_ank - ^_j_^ _n_ew-copy _r_eset -^^^^ _e_xchange _u_ndo -^^^^ ^ ^ _p_aste -" - ("h" rectangle-backward-char nil) - ("l" rectangle-forward-char nil) - ("k" rectangle-previous-line nil) - ("j" rectangle-next-line nil) - ("e" hydra-ex-point-mark nil) - ("n" copy-rectangle-as-kill nil) - ("d" delete-rectangle nil) - ("r" (if (region-active-p) - (deactivate-mark) - (rectangle-mark-mode 1)) nil) - ("y" yank-rectangle nil) - ("u" undo nil) - ("s" string-rectangle nil) - ("p" kill-rectangle nil) - ("o" nil nil)) - -;; Recommended binding: -;; (global-set-key (kbd "C-x SPC") 'hydra-rectangle/body) - -;;** Example 12: org-agenda-view -(defun org-agenda-cts () - (and (eq major-mode 'org-agenda-mode) - (let ((args (get-text-property - (min (1- (point-max)) (point)) - 'org-last-args))) - (nth 2 args)))) - -(defhydra hydra-org-agenda-view (:hint none) - " -_d_: ?d? day _g_: time grid=?g? _a_: arch-trees -_w_: ?w? week _[_: inactive _A_: arch-files -_t_: ?t? fortnight _f_: follow=?f? _r_: clock report=?r? -_m_: ?m? month _e_: entry text=?e? _D_: include diary=?D? -_y_: ?y? year _q_: quit _L__l__c_: log = ?l?" - ("SPC" org-agenda-reset-view) - ("d" org-agenda-day-view (if (eq 'day (org-agenda-cts)) "[x]" "[ ]")) - ("w" org-agenda-week-view (if (eq 'week (org-agenda-cts)) "[x]" "[ ]")) - ("t" org-agenda-fortnight-view (if (eq 'fortnight (org-agenda-cts)) "[x]" "[ ]")) - ("m" org-agenda-month-view (if (eq 'month (org-agenda-cts)) "[x]" "[ ]")) - ("y" org-agenda-year-view (if (eq 'year (org-agenda-cts)) "[x]" "[ ]")) - ("l" org-agenda-log-mode (format "% -3S" org-agenda-show-log)) - ("L" (org-agenda-log-mode '(4))) - ("c" (org-agenda-log-mode 'clockcheck)) - ("f" org-agenda-follow-mode (format "% -3S" org-agenda-follow-mode)) - ("a" org-agenda-archives-mode) - ("A" (org-agenda-archives-mode 'files)) - ("r" org-agenda-clockreport-mode (format "% -3S" org-agenda-clockreport-mode)) - ("e" org-agenda-entry-text-mode (format "% -3S" org-agenda-entry-text-mode)) - ("g" org-agenda-toggle-time-grid (format "% -3S" org-agenda-use-time-grid)) - ("D" org-agenda-toggle-diary (format "% -3S" org-agenda-include-diary)) - ("!" org-agenda-toggle-deadlines) - ("[" (let ((org-agenda-include-inactive-timestamps t)) - (org-agenda-check-type t 'timeline 'agenda) - (org-agenda-redo) - (message "Display now includes inactive timestamps as well"))) - ("q" (message "Abort") :exit t) - ("v" nil)) - -;; Recommended binding: -;; (define-key org-agenda-mode-map "v" 'hydra-org-agenda-view/body) - -;;* Helpers -(require 'windmove) - -(defun hydra-move-splitter-left (arg) - "Move window splitter left." - (interactive "p") - (if (let ((windmove-wrap-around)) - (windmove-find-other-window 'right)) - (shrink-window-horizontally arg) - (enlarge-window-horizontally arg))) - -(defun hydra-move-splitter-right (arg) - "Move window splitter right." - (interactive "p") - (if (let ((windmove-wrap-around)) - (windmove-find-other-window 'right)) - (enlarge-window-horizontally arg) - (shrink-window-horizontally arg))) - -(defun hydra-move-splitter-up (arg) - "Move window splitter up." - (interactive "p") - (if (let ((windmove-wrap-around)) - (windmove-find-other-window 'up)) - (enlarge-window arg) - (shrink-window arg))) - -(defun hydra-move-splitter-down (arg) - "Move window splitter down." - (interactive "p") - (if (let ((windmove-wrap-around)) - (windmove-find-other-window 'up)) - (shrink-window arg) - (enlarge-window arg))) - -(defvar rectangle-mark-mode) -(defun hydra-ex-point-mark () - "Exchange point and mark." - (interactive) - (if rectangle-mark-mode - (rectangle-exchange-point-and-mark) - (let ((mk (mark))) - (rectangle-mark-mode 1) - (goto-char mk)))) - -(provide 'hydra-examples) - -;; Local Variables: -;; no-byte-compile: t -;; End: -;;; hydra-examples.el ends here diff --git a/elpa/hydra-20160913.216/hydra-ox.el b/elpa/hydra-20160913.216/hydra-ox.el deleted file mode 100644 index a992efc..0000000 --- a/elpa/hydra-20160913.216/hydra-ox.el +++ /dev/null @@ -1,127 +0,0 @@ -;;; hydra-ox.el --- Org mode export widget implemented in Hydra - -;; Copyright (C) 2015 Free Software Foundation, Inc. - -;; Author: Oleh Krehel - -;; 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 . - -;;; Commentary: -;; -;; This shows how a complex dispatch menu can be built with Hydra. - -;;; Code: - -(require 'hydra) -(require 'org) -(declare-function org-html-export-as-html 'ox-html) -(declare-function org-html-export-to-html 'ox-html) -(declare-function org-latex-export-as-latex 'ox-latex) -(declare-function org-latex-export-to-latex 'ox-latex) -(declare-function org-latex-export-to-pdf 'ox-latex) -(declare-function org-ascii-export-as-ascii 'ox-ascii) -(declare-function org-ascii-export-to-ascii 'ox-ascii) - -(defhydradio hydra-ox () - (body-only "Export only the body.") - (export-scope "Export scope." [buffer subtree]) - (async-export "When non-nil, export async.") - (visible-only "When non-nil, export visible only") - (force-publishing "Toggle force publishing")) - -(defhydra hydra-ox-html (:color blue) - "ox-html" - ("H" (org-html-export-as-html - hydra-ox/async-export - (eq hydra-ox/export-scope 'subtree) - hydra-ox/visible-only - hydra-ox/body-only) - "As HTML buffer") - ("h" (org-html-export-to-html - hydra-ox/async-export - (eq hydra-ox/export-scope 'subtree) - hydra-ox/visible-only - hydra-ox/body-only) "As HTML file") - ("o" (org-open-file - (org-html-export-to-html - hydra-ox/async-export - (eq hydra-ox/export-scope 'subtree) - hydra-ox/visible-only - hydra-ox/body-only)) "As HTML file and open") - ("b" hydra-ox/body "back") - ("q" nil "quit")) - -(defhydra hydra-ox-latex (:color blue) - "ox-latex" - ("L" org-latex-export-as-latex "As LaTeX buffer") - ("l" org-latex-export-to-latex "As LaTeX file") - ("p" org-latex-export-to-pdf "As PDF file") - ("o" (org-open-file (org-latex-export-to-pdf)) "As PDF file and open") - ("b" hydra-ox/body "back") - ("q" nil "quit")) - -(defhydra hydra-ox-text (:color blue) - "ox-text" - ("A" (org-ascii-export-as-ascii - nil nil nil nil - '(:ascii-charset ascii)) - "As ASCII buffer") - - ("a" (org-ascii-export-to-ascii - nil nil nil nil - '(:ascii-charset ascii)) - "As ASCII file") - ("L" (org-ascii-export-as-ascii - nil nil nil nil - '(:ascii-charset latin1)) - "As Latin1 buffer") - ("l" (org-ascii-export-to-ascii - nil nil nil nil - '(:ascii-charset latin1)) - "As Latin1 file") - ("U" (org-ascii-export-as-ascii - nil nil nil nil - '(:ascii-charset utf-8)) - "As UTF-8 buffer") - ("u" (org-ascii-export-to-ascii - nil nil nil nil - '(:ascii-charset utf-8)) - "As UTF-8 file") - ("b" hydra-ox/body "back") - ("q" nil "quit")) - -(defhydra hydra-ox () - " -_C-b_ Body only: % -15`hydra-ox/body-only^^^ _C-v_ Visible only: %`hydra-ox/visible-only -_C-s_ Export scope: % -15`hydra-ox/export-scope _C-f_ Force publishing: %`hydra-ox/force-publishing -_C-a_ Async export: %`hydra-ox/async-export - -" - ("C-b" (hydra-ox/body-only) nil) - ("C-v" (hydra-ox/visible-only) nil) - ("C-s" (hydra-ox/export-scope) nil) - ("C-f" (hydra-ox/force-publishing) nil) - ("C-a" (hydra-ox/async-export) nil) - ("h" hydra-ox-html/body "Export to HTML" :exit t) - ("l" hydra-ox-latex/body "Export to LaTeX" :exit t) - ("t" hydra-ox-text/body "Export to Plain Text" :exit t) - ("q" nil "quit")) - -(define-key org-mode-map (kbd "C-c C-,") 'hydra-ox/body) - -(provide 'hydra-ox) - -;;; hydra-ox.el ends here diff --git a/elpa/hydra-20160913.216/hydra-pkg.el b/elpa/hydra-20160913.216/hydra-pkg.el deleted file mode 100644 index 02e88ee..0000000 --- a/elpa/hydra-20160913.216/hydra-pkg.el +++ /dev/null @@ -1,7 +0,0 @@ -(define-package "hydra" "20160913.216" "Make bindings that stick around." - '((cl-lib "0.5")) - :url "https://github.com/abo-abo/hydra" :keywords - '("bindings")) -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/hydra-20160913.216/hydra.el b/elpa/hydra-20160913.216/hydra.el deleted file mode 100644 index 61fb01c..0000000 --- a/elpa/hydra-20160913.216/hydra.el +++ /dev/null @@ -1,1273 +0,0 @@ -;;; hydra.el --- Make bindings that stick around. -*- lexical-binding: t -*- - -;; Copyright (C) 2015 Free Software Foundation, Inc. - -;; Author: Oleh Krehel -;; Maintainer: Oleh Krehel -;; URL: https://github.com/abo-abo/hydra -;; Version: 0.13.6 -;; Keywords: bindings -;; Package-Requires: ((cl-lib "0.5")) - -;; 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 . - -;;; Commentary: -;; -;; This package can be used to tie related commands into a family of -;; short bindings with a common prefix - a Hydra. -;; -;; Once you summon the Hydra (through the prefixed binding), all the -;; heads can be called in succession with only a short extension. -;; The Hydra is vanquished once Hercules, any binding that isn't the -;; Hydra's head, arrives. Note that Hercules, besides vanquishing the -;; Hydra, will still serve his orignal purpose, calling his proper -;; command. This makes the Hydra very seamless, it's like a minor -;; mode that disables itself automagically. -;; -;; Here's an example Hydra, bound in the global map (you can use any -;; keymap in place of `global-map'): -;; -;; (defhydra hydra-zoom (global-map "") -;; "zoom" -;; ("g" text-scale-increase "in") -;; ("l" text-scale-decrease "out")) -;; -;; It allows to start a command chain either like this: -;; " gg4ll5g", or " lgllg". -;; -;; Here's another approach, when you just want a "callable keymap": -;; -;; (defhydra hydra-toggle (:color blue) -;; "toggle" -;; ("a" abbrev-mode "abbrev") -;; ("d" toggle-debug-on-error "debug") -;; ("f" auto-fill-mode "fill") -;; ("t" toggle-truncate-lines "truncate") -;; ("w" whitespace-mode "whitespace") -;; ("q" nil "cancel")) -;; -;; This binds nothing so far, but if you follow up with: -;; -;; (global-set-key (kbd "C-c C-v") 'hydra-toggle/body) -;; -;; you will have bound "C-c C-v a", "C-c C-v d" etc. -;; -;; Knowing that `defhydra' defines e.g. `hydra-toggle/body' command, -;; you can nest Hydras if you wish, with `hydra-toggle/body' possibly -;; becoming a blue head of another Hydra. -;; -;; If you want to learn all intricacies of using `defhydra' without -;; having to figure it all out from this source code, check out the -;; wiki: https://github.com/abo-abo/hydra/wiki. There's a wealth of -;; information there. Everyone is welcome to bring the existing pages -;; up to date and add new ones. -;; -;; Additionally, the file hydra-examples.el serves to demo most of the -;; functionality. - -;;; Code: -;;* Requires -(require 'cl-lib) -(require 'lv) -(require 'ring) - -(defvar hydra-curr-map nil - "The keymap of the current Hydra called.") - -(defvar hydra-curr-on-exit nil - "The on-exit predicate for the current Hydra.") - -(defvar hydra-curr-foreign-keys nil - "The current :foreign-keys behavior.") - -(defvar hydra-curr-body-fn nil - "The current hydra-.../body function.") - -(defvar hydra-deactivate nil - "If a Hydra head sets this to t, exit the Hydra. -This will be done even if the head wasn't designated for exiting.") - -(defvar hydra-amaranth-warn-message "An amaranth Hydra can only exit through a blue head" - "Amaranth Warning message. Shown when the user tries to press an unbound/non-exit key while in an amaranth head.") - -(defun hydra-set-transient-map (keymap on-exit &optional foreign-keys) - "Set KEYMAP to the highest priority. - -Call ON-EXIT when the KEYMAP is deactivated. - -FOREIGN-KEYS determines the deactivation behavior, when a command -that isn't in KEYMAP is called: - -nil: deactivate KEYMAP and run the command. -run: keep KEYMAP and run the command. -warn: keep KEYMAP and issue a warning instead of running the command." - (if hydra-deactivate - (hydra-keyboard-quit) - (setq hydra-curr-map keymap) - (setq hydra-curr-on-exit on-exit) - (setq hydra-curr-foreign-keys foreign-keys) - (add-hook 'pre-command-hook 'hydra--clearfun) - (internal-push-keymap keymap 'overriding-terminal-local-map))) - -(defun hydra--clearfun () - "Disable the current Hydra unless `this-command' is a head." - (unless (eq this-command 'hydra-pause-resume) - (when (or - (memq this-command '(handle-switch-frame - keyboard-quit)) - (null overriding-terminal-local-map) - (not (or (eq this-command - (lookup-key hydra-curr-map (this-single-command-keys))) - (cl-case hydra-curr-foreign-keys - (warn - (setq this-command 'hydra-amaranth-warn)) - (run - t) - (t nil))))) - (hydra-disable)))) - -(defvar hydra--ignore nil - "When non-nil, don't call `hydra-curr-on-exit'.") - -(defvar hydra--input-method-function nil - "Store overridden `input-method-function' here.") - -(defun hydra-disable () - "Disable the current Hydra." - (setq hydra-deactivate nil) - (remove-hook 'pre-command-hook 'hydra--clearfun) - (unless hydra--ignore - (if (fboundp 'remove-function) - (remove-function input-method-function #'hydra--imf) - (when hydra--input-method-function - (setq input-method-function hydra--input-method-function) - (setq hydra--input-method-function nil)))) - (dolist (frame (frame-list)) - (with-selected-frame frame - (when overriding-terminal-local-map - (internal-pop-keymap hydra-curr-map 'overriding-terminal-local-map)))) - (unless hydra--ignore - (when hydra-curr-on-exit - (let ((on-exit hydra-curr-on-exit)) - (setq hydra-curr-on-exit nil) - (funcall on-exit))))) - -(unless (fboundp 'internal-push-keymap) - (defun internal-push-keymap (keymap symbol) - (let ((map (symbol-value symbol))) - (unless (memq keymap map) - (unless (memq 'add-keymap-witness (symbol-value symbol)) - (setq map (make-composed-keymap nil (symbol-value symbol))) - (push 'add-keymap-witness (cdr map)) - (set symbol map)) - (push keymap (cdr map)))))) - -(unless (fboundp 'internal-pop-keymap) - (defun internal-pop-keymap (keymap symbol) - (let ((map (symbol-value symbol))) - (when (memq keymap map) - (setf (cdr map) (delq keymap (cdr map)))) - (let ((tail (cddr map))) - (and (or (null tail) (keymapp tail)) - (eq 'add-keymap-witness (nth 1 map)) - (set symbol tail)))))) - -(defun hydra-amaranth-warn () - "Issue a warning that the current input was ignored." - (interactive) - (message hydra-amaranth-warn-message)) - -;;* Customize -(defgroup hydra nil - "Make bindings that stick around." - :group 'bindings - :prefix "hydra-") - -(defcustom hydra-is-helpful t - "When t, display a hint with possible bindings in the echo area." - :type 'boolean - :group 'hydra) - -(defcustom hydra-default-hint "" - "Default :hint property to use for heads when not specified in -the body or the head." - :type 'sexp - :group 'hydra) - -(defcustom hydra-lv t - "When non-nil, `lv-message' (not `message') will be used to display hints." - :type 'boolean) - -(defcustom hydra-verbose nil - "When non-nil, hydra will issue some non essential style warnings." - :type 'boolean) - -(defcustom hydra-key-format-spec "%s" - "Default `format'-style specifier for _a_ syntax in docstrings. -When nil, you can specify your own at each location like this: _ 5a_." - :type 'string) - -(defcustom hydra-doc-format-spec "%s" - "Default `format'-style specifier for ?a? syntax in docstrings." - :type 'string) - -(make-obsolete-variable - 'hydra-key-format-spec - "Since the docstrings are aligned by hand anyway, this isn't very useful." - "0.13.1") - -(defface hydra-face-red - '((t (:foreground "#FF0000" :bold t))) - "Red Hydra heads don't exit the Hydra. -Every other command exits the Hydra." - :group 'hydra) - -(defface hydra-face-blue - '((((class color) (background light)) - :foreground "#0000FF" :bold t) - (((class color) (background dark)) - :foreground "#8ac6f2" :bold t)) - "Blue Hydra heads exit the Hydra. -Every other command exits as well.") - -(defface hydra-face-amaranth - '((t (:foreground "#E52B50" :bold t))) - "Amaranth body has red heads and warns on intercepting non-heads. -Exitable only through a blue head.") - -(defface hydra-face-pink - '((t (:foreground "#FF6EB4" :bold t))) - "Pink body has red heads and runs intercepted non-heads. -Exitable only through a blue head.") - -(defface hydra-face-teal - '((t (:foreground "#367588" :bold t))) - "Teal body has blue heads and warns on intercepting non-heads. -Exitable only through a blue head.") - -;;* Fontification -(defun hydra-add-font-lock () - "Fontify `defhydra' statements." - (font-lock-add-keywords - 'emacs-lisp-mode - '(("(\\(defhydra\\)\\_> +\\(.*?\\)\\_>" - (1 font-lock-keyword-face) - (2 font-lock-type-face)) - ("(\\(defhydradio\\)\\_> +\\(.*?\\)\\_>" - (1 font-lock-keyword-face) - (2 font-lock-type-face))))) - -;;* Find Function -(eval-after-load 'find-func - '(defadvice find-function-search-for-symbol - (around hydra-around-find-function-search-for-symbol-advice - (symbol type library) activate) - "Navigate to hydras with `find-function-search-for-symbol'." - ad-do-it - ;; The orignial function returns (cons (current-buffer) (point)) - ;; if it found the point. - (unless (cdr ad-return-value) - (with-current-buffer (find-file-noselect library) - (let ((sn (symbol-name symbol))) - (when (and (null type) - (string-match "\\`\\(hydra-[a-z-A-Z0-9]+\\)/\\(.*\\)\\'" sn) - (re-search-forward (concat "(defhydra " (match-string 1 sn)) - nil t)) - (goto-char (match-beginning 0))) - (cons (current-buffer) (point))))))) - -;;* Universal Argument -(defvar hydra-base-map - (let ((map (make-sparse-keymap))) - (define-key map [?\C-u] 'hydra--universal-argument) - (define-key map [?-] 'hydra--negative-argument) - (define-key map [?0] 'hydra--digit-argument) - (define-key map [?1] 'hydra--digit-argument) - (define-key map [?2] 'hydra--digit-argument) - (define-key map [?3] 'hydra--digit-argument) - (define-key map [?4] 'hydra--digit-argument) - (define-key map [?5] 'hydra--digit-argument) - (define-key map [?6] 'hydra--digit-argument) - (define-key map [?7] 'hydra--digit-argument) - (define-key map [?8] 'hydra--digit-argument) - (define-key map [?9] 'hydra--digit-argument) - (define-key map [kp-0] 'hydra--digit-argument) - (define-key map [kp-1] 'hydra--digit-argument) - (define-key map [kp-2] 'hydra--digit-argument) - (define-key map [kp-3] 'hydra--digit-argument) - (define-key map [kp-4] 'hydra--digit-argument) - (define-key map [kp-5] 'hydra--digit-argument) - (define-key map [kp-6] 'hydra--digit-argument) - (define-key map [kp-7] 'hydra--digit-argument) - (define-key map [kp-8] 'hydra--digit-argument) - (define-key map [kp-9] 'hydra--digit-argument) - (define-key map [kp-subtract] 'hydra--negative-argument) - map) - "Keymap that all Hydras inherit. See `universal-argument-map'.") - -(defun hydra--universal-argument (arg) - "Forward to (`universal-argument' ARG)." - (interactive "P") - (setq prefix-arg (if (consp arg) - (list (* 4 (car arg))) - (if (eq arg '-) - (list -4) - '(4))))) - -(defun hydra--digit-argument (arg) - "Forward to (`digit-argument' ARG)." - (interactive "P") - (let* ((char (if (integerp last-command-event) - last-command-event - (get last-command-event 'ascii-character))) - (digit (- (logand char ?\177) ?0))) - (setq prefix-arg (cond ((integerp arg) - (+ (* arg 10) - (if (< arg 0) - (- digit) - digit))) - ((eq arg '-) - (if (zerop digit) - '- - (- digit))) - (t - digit))))) - -(defun hydra--negative-argument (arg) - "Forward to (`negative-argument' ARG)." - (interactive "P") - (setq prefix-arg (cond ((integerp arg) (- arg)) - ((eq arg '-) nil) - (t '-)))) - -;;* Repeat -(defvar hydra-repeat--prefix-arg nil - "Prefix arg to use with `hydra-repeat'.") - -(defvar hydra-repeat--command nil - "Command to use with `hydra-repeat'.") - -(defun hydra-repeat (&optional arg) - "Repeat last command with last prefix arg. -When ARG is non-nil, use that instead." - (interactive "p") - (if (eq arg 1) - (unless (string-match "hydra-repeat$" (symbol-name last-command)) - (setq hydra-repeat--command last-command) - (setq hydra-repeat--prefix-arg last-prefix-arg)) - (setq hydra-repeat--prefix-arg arg)) - (setq current-prefix-arg hydra-repeat--prefix-arg) - (funcall hydra-repeat--command)) - -;;* Misc internals -(defun hydra--callablep (x) - "Test if X is callable." - (or (functionp x) - (and (consp x) - (memq (car x) '(function quote))))) - -(defun hydra--make-callable (x) - "Generate a callable symbol from X. -If X is a function symbol or a lambda, return it. Otherwise, it -should be a single statement. Wrap it in an interactive lambda." - (cond ((or (symbolp x) (functionp x)) - x) - ((and (consp x) (eq (car x) 'function)) - (cadr x)) - (t - `(lambda () - (interactive) - ,x)))) - -(defun hydra-plist-get-default (plist prop default) - "Extract a value from a property list. -PLIST is a property list, which is a list of the form -\(PROP1 VALUE1 PROP2 VALUE2...). - -Return the value corresponding to PROP, or DEFAULT if PROP is not -one of the properties on the list." - (if (memq prop plist) - (plist-get plist prop) - default)) - -(defun hydra--head-property (h prop &optional default) - "Return for Hydra head H the value of property PROP. -Return DEFAULT if PROP is not in H." - (hydra-plist-get-default (cl-cdddr h) prop default)) - -(defun hydra--body-foreign-keys (body) - "Return what BODY does with a non-head binding." - (or - (plist-get (cddr body) :foreign-keys) - (let ((color (plist-get (cddr body) :color))) - (cl-case color - ((amaranth teal) 'warn) - (pink 'run))))) - -(defun hydra--body-exit (body) - "Return the exit behavior of BODY." - (or - (plist-get (cddr body) :exit) - (let ((color (plist-get (cddr body) :color))) - (cl-case color - ((blue teal) t) - (t nil))))) - -(defalias 'hydra--imf #'list) - -(defun hydra-default-pre () - "Default setup that happens in each head before :pre." - (when (eq input-method-function 'key-chord-input-method) - (if (fboundp 'add-function) - (add-function :override input-method-function #'hydra--imf) - (unless hydra--input-method-function - (setq hydra--input-method-function input-method-function) - (setq input-method-function nil))))) - -(defvar hydra-timeout-timer (timer-create) - "Timer for `hydra-timeout'.") - -(defvar hydra-message-timer (timer-create) - "Timer for the hint.") - -(defvar hydra--work-around-dedicated t - "When non-nil, assume there's no bug in `pop-to-buffer'. -`pop-to-buffer' should not select a dedicated window.") - -(defun hydra-keyboard-quit () - "Quitting function similar to `keyboard-quit'." - (interactive) - (hydra-disable) - (cancel-timer hydra-timeout-timer) - (cancel-timer hydra-message-timer) - (setq hydra-curr-map nil) - (unless (and hydra--ignore - (null hydra--work-around-dedicated)) - (if hydra-lv - (lv-delete-window) - (message ""))) - nil) - -(defvar hydra-head-format "[%s]: " - "The formatter for each head of a plain docstring.") - -(defvar hydra-key-doc-function 'hydra-key-doc-function-default - "The function for formatting key-doc pairs.") - -(defun hydra-key-doc-function-default (key key-width doc doc-width) - "Doc" - (format (format "%%%ds: %%%ds" key-width (- -1 doc-width)) - key doc)) - -(defun hydra--to-string (x) - (if (stringp x) - x - (eval x))) - -(defun hydra--hint (body heads) - "Generate a hint for the echo area. -BODY, and HEADS are parameters to `defhydra'." - (let (alist) - (dolist (h heads) - (let ((val (assoc (cadr h) alist)) - (pstr (hydra-fontify-head h body))) - (unless (null (cl-caddr h)) - (if val - (setf (cadr val) - (concat (cadr val) " " pstr)) - (push - (cons (cadr h) - (cons pstr (cl-caddr h))) - alist))))) - (let ((keys (nreverse (mapcar #'cdr alist))) - (n-cols (plist-get (cddr body) :columns)) - res) - (setq res - (if n-cols - (let ((n-rows (1+ (/ (length keys) n-cols))) - (max-key-len (apply #'max (mapcar (lambda (x) (length (car x))) keys))) - (max-doc-len (apply #'max (mapcar (lambda (x) - (length (hydra--to-string (cdr x)))) keys)))) - `(concat - "\n" - (mapconcat #'identity - (mapcar - (lambda (x) - (mapconcat - (lambda (y) - (and y - (funcall hydra-key-doc-function - (car y) - ,max-key-len - (hydra--to-string (cdr y)) - ,max-doc-len))) x "")) - ',(hydra--matrix keys n-cols n-rows)) - "\n"))) - - - `(concat - (mapconcat - (lambda (x) - (let ((str (hydra--to-string (cdr x)))) - (format - (if (> (length str) 0) - (concat hydra-head-format str) - "%s") - (car x)))) - ',keys - ", ") - ,(if keys "." "")))) - (if (cl-every #'stringp - (mapcar 'cddr alist)) - (eval res) - res)))) - -(defvar hydra-fontify-head-function nil - "Possible replacement for `hydra-fontify-head-default'.") - -(defun hydra-fontify-head-default (head body) - "Produce a pretty string from HEAD and BODY. -HEAD's binding is returned as a string with a colored face." - (let* ((foreign-keys (hydra--body-foreign-keys body)) - (head-exit (hydra--head-property head :exit)) - (head-color - (if head-exit - (if (eq foreign-keys 'warn) - 'teal - 'blue) - (cl-case foreign-keys - (warn 'amaranth) - (run 'pink) - (t 'red))))) - (when (and (null (cadr head)) - (not head-exit)) - (hydra--complain "nil cmd can only be blue")) - (propertize (if (string= (car head) "%") - "%%" - (car head)) - 'face - (or (hydra--head-property head :face) - (cl-case head-color - (blue 'hydra-face-blue) - (red 'hydra-face-red) - (amaranth 'hydra-face-amaranth) - (pink 'hydra-face-pink) - (teal 'hydra-face-teal) - (t (error "Unknown color for %S" head))))))) - -(defun hydra-fontify-head-greyscale (head _body) - "Produce a pretty string from HEAD and BODY. -HEAD's binding is returned as a string wrapped with [] or {}." - (format - (if (hydra--head-property head :exit) - "[%s]" - "{%s}") (car head))) - -(defun hydra-fontify-head (head body) - "Produce a pretty string from HEAD and BODY." - (funcall (or hydra-fontify-head-function 'hydra-fontify-head-default) - head body)) - -(defun hydra--strip-align-markers (str) - "Remove ^ from STR, unless they're escaped: \\^." - (let ((start 0)) - (while (setq start (string-match "\\\\?\\^" str start)) - (if (eq (- (match-end 0) (match-beginning 0)) 2) - (progn - (setq str (replace-match "^" nil nil str)) - (cl-incf start)) - (setq str (replace-match "" nil nil str)))) - str)) - -(defvar hydra-docstring-keys-translate-alist - '(("↑" . "") - ("↓" . "") - ("→" . "") - ("â†" . "") - ("⌫" . "DEL") - ("⌦" . "") - ("âŽ" . "RET"))) - -(defconst hydra-width-spec-regex " ?-?[0-9]*?" - "Regex for the width spec in keys and %` quoted sexps.") - -(defvar hydra-key-regex "\\[\\|]\\|[-[:alnum:] ~.,;:/|?<>={}*+#%@!&^↑↓â†â†’⌫⌦âŽ'`()\"$]+?" - "Regex for the key quoted in the docstring.") - -(defun hydra--format (_name body docstring heads) - "Generate a `format' statement from STR. -\"%`...\" expressions are extracted into \"%S\". -_NAME, BODY, DOCSTRING and HEADS are parameters of `defhydra'. -The expressions can be auto-expanded according to NAME." - (setq docstring (hydra--strip-align-markers docstring)) - (setq docstring (replace-regexp-in-string "___" "_β_" docstring)) - (let ((rest (if (eq (plist-get (cddr body) :hint) 'none) - "" - (hydra--hint body heads))) - (start 0) - varlist - offset) - (while (setq start - (string-match - (format - "\\(?:%%\\( ?-?[0-9]*s?\\)\\(`[a-z-A-Z/0-9]+\\|(\\)\\)\\|\\(?:[_?]\\(%s\\)\\(%s\\)[_?]\\)" - hydra-width-spec-regex - hydra-key-regex) - docstring start)) - (cond ((eq ?? (aref (match-string 0 docstring) 0)) - (let* ((key (match-string 4 docstring)) - (head (assoc key heads))) - (if head - (progn - (push (nth 2 head) varlist) - (setq docstring - (replace-match - (or - hydra-doc-format-spec - (concat "%" (match-string 3 docstring) "s")) - t nil docstring))) - (setq start (match-end 0)) - (warn "Unrecognized key: ?%s?" key)))) - ((eq ?_ (aref (match-string 0 docstring) 0)) - (let* ((key (match-string 4 docstring)) - (key (if (equal key "β") "_" key)) - normal-key - (head (or (assoc key heads) - (when (setq normal-key - (cdr (assoc - key hydra-docstring-keys-translate-alist))) - (assoc normal-key heads))))) - (if head - (progn - (push (hydra-fontify-head (if normal-key - (cons key (cdr head)) - head) - body) - varlist) - (let ((replacement - (or - hydra-key-format-spec - (concat "%" (match-string 3 docstring) "s")))) - (setq docstring - (replace-match replacement t nil docstring)) - (setq start (+ start (length replacement))))) - (setq start (match-end 0)) - (warn "Unrecognized key: _%s_" key)))) - - (t - (let* ((varp (if (eq ?` (aref (match-string 2 docstring) 0)) 1 0)) - (spec (match-string 1 docstring)) - (lspec (length spec))) - (setq offset - (with-temp-buffer - (insert (substring docstring (+ 1 start varp - (length spec)))) - (goto-char (point-min)) - (push (read (current-buffer)) varlist) - (- (point) (point-min)))) - (when (or (zerop lspec) - (/= (aref spec (1- (length spec))) ?s)) - (setq spec (concat spec "S"))) - (setq docstring - (concat - (substring docstring 0 start) - "%" spec - (substring docstring (+ start offset 1 lspec varp)))))))) - (if (eq ?\n (aref docstring 0)) - `(concat (format ,(substring docstring 1) ,@(nreverse varlist)) - ,rest) - (let ((r `(replace-regexp-in-string - " +$" "" - (concat ,docstring ": " - (replace-regexp-in-string - "\\(%\\)" "\\1\\1" ,rest))))) - (if (stringp rest) - `(format ,(eval r)) - `(format ,r)))))) - -(defun hydra--complain (format-string &rest args) - "Forward to (`message' FORMAT-STRING ARGS) unless `hydra-verbose' is nil." - (if hydra-verbose - (apply #'error format-string args) - (apply #'message format-string args))) - -(defun hydra--doc (body-key body-name heads) - "Generate a part of Hydra docstring. -BODY-KEY is the body key binding. -BODY-NAME is the symbol that identifies the Hydra. -HEADS is a list of heads." - (format - "Create a hydra with %s body and the heads:\n\n%s\n\n%s" - (if body-key - (format "a \"%s\"" body-key) - "no") - (mapconcat - (lambda (x) - (format "\"%s\": `%S'" (car x) (cadr x))) - heads ",\n") - (format "The body can be accessed via `%S'." body-name))) - -(defun hydra--call-interactively (cmd name) - "Generate a `call-interactively' statement for CMD. -Set `this-command' to NAME." - (if (and (symbolp name) - (not (memq name '(nil body)))) - `(progn - (setq this-command ',name) - (call-interactively #',cmd)) - `(call-interactively #',cmd))) - -(defun hydra--make-defun (name body doc head - keymap body-pre body-before-exit - &optional body-after-exit) - "Make a defun wrapper, using NAME, BODY, DOC, HEAD, and KEYMAP. -NAME and BODY are the arguments to `defhydra'. -DOC was generated with `hydra--doc'. -HEAD is one of the HEADS passed to `defhydra'. -BODY-PRE is added to the start of the wrapper. -BODY-BEFORE-EXIT will be called before the hydra quits. -BODY-AFTER-EXIT is added to the end of the wrapper." - (let ((cmd-name (hydra--head-name head name)) - (cmd (when (car head) - (hydra--make-callable - (cadr head)))) - (doc (if (car head) - (format "%s\n\nCall the head: `%S'." doc (cadr head)) - doc)) - (hint (intern (format "%S/hint" name))) - (body-foreign-keys (hydra--body-foreign-keys body)) - (body-timeout (plist-get body :timeout)) - (body-idle (plist-get body :idle))) - `(defun ,cmd-name () - ,doc - (interactive) - (hydra-default-pre) - ,@(when body-pre (list body-pre)) - ,@(if (hydra--head-property head :exit) - `((hydra-keyboard-quit) - (setq hydra-curr-body-fn ',(intern (format "%S/body" name))) - ,@(if body-after-exit - `((unwind-protect - ,(when cmd - (hydra--call-interactively cmd (cadr head))) - ,body-after-exit)) - (when cmd - `(,(hydra--call-interactively cmd (cadr head)))))) - (delq - nil - `((let ((hydra--ignore ,(not (eq (cadr head) 'body)))) - (hydra-keyboard-quit) - (setq hydra-curr-body-fn ',(intern (format "%S/body" name)))) - ,(when cmd - `(condition-case err - ,(hydra--call-interactively cmd (cadr head)) - ((quit error) - (message (error-message-string err)) - (unless hydra-lv - (sit-for 0.8))))) - ,(if (and body-idle (eq (cadr head) 'body)) - `(hydra-idle-message ,body-idle ,hint ',name) - `(hydra-show-hint ,hint ',name)) - (hydra-set-transient-map - ,keymap - (lambda () (hydra-keyboard-quit) ,body-before-exit) - ,(when body-foreign-keys - (list 'quote body-foreign-keys))) - ,body-after-exit - ,(when body-timeout - `(hydra-timeout ,body-timeout)))))))) - -(defvar hydra-props-alist nil) - -(defun hydra-set-property (name key val) - "Set hydra property. -NAME is the symbolic name of the hydra. -KEY and VAL are forwarded to `plist-put'." - (let ((entry (assoc name hydra-props-alist)) - plist) - (when (null entry) - (add-to-list 'hydra-props-alist (list name)) - (setq entry (assoc name hydra-props-alist))) - (setq plist (cdr entry)) - (setcdr entry (plist-put plist key val)))) - -(defun hydra-get-property (name key) - "Get hydra property. -NAME is the symbolic name of the hydra. -KEY is forwarded to `plist-get'." - (let ((entry (assoc name hydra-props-alist))) - (when entry - (plist-get (cdr entry) key)))) - -(defun hydra-show-hint (hint caller) - (let ((verbosity (plist-get (cdr (assoc caller hydra-props-alist)) - :verbosity))) - (cond ((eq verbosity 0)) - ((eq verbosity 1) - (message (eval hint))) - (t - (when hydra-is-helpful - (if hydra-lv - (lv-message (eval hint)) - (message (eval hint)))))))) - -(defmacro hydra--make-funcall (sym) - "Transform SYM into a `funcall' to call it." - `(when (and ,sym (symbolp ,sym)) - (setq ,sym `(funcall #',,sym)))) - -(defun hydra--head-name (h name) - "Return the symbol for head H of hydra with NAME." - (let ((str (format "%S/%s" name - (cond ((symbolp (cadr h)) - (cadr h)) - ((and (consp (cadr h)) - (eq (cl-caadr h) 'function)) - (cadr (cadr h))) - (t - (concat "lambda-" (car h))))))) - (when (and (hydra--head-property h :exit) - (not (memq (cadr h) '(body nil)))) - (setq str (concat str "-and-exit"))) - (intern str))) - -(defun hydra--delete-duplicates (heads) - "Return HEADS without entries that have the same CMD part. -In duplicate HEADS, :cmd-name is modified to whatever they duplicate." - (let ((ali '(((hydra-repeat . nil) . hydra-repeat))) - res entry) - (dolist (h heads) - (if (setq entry (assoc (cons (cadr h) - (hydra--head-property h :exit)) - ali)) - (setf (cl-cdddr h) (plist-put (cl-cdddr h) :cmd-name (cdr entry))) - (push (cons (cons (cadr h) - (hydra--head-property h :exit)) - (plist-get (cl-cdddr h) :cmd-name)) - ali) - (push h res))) - (nreverse res))) - -(defun hydra--pad (lst n) - "Pad LST with nil until length N." - (let ((len (length lst))) - (if (= len n) - lst - (append lst (make-list (- n len) nil))))) - -(defmacro hydra-multipop (lst n) - "Return LST's first N elements while removing them." - `(if (<= (length ,lst) ,n) - (prog1 ,lst - (setq ,lst nil)) - (prog1 ,lst - (setcdr - (nthcdr (1- ,n) (prog1 ,lst (setq ,lst (nthcdr ,n ,lst)))) - nil)))) - -(defun hydra--matrix (lst rows cols) - "Create a matrix from elements of LST. -The matrix size is ROWS times COLS." - (let ((ls (copy-sequence lst)) - res) - (dotimes (_c cols) - (push (hydra--pad (hydra-multipop ls rows) rows) res)) - (nreverse res))) - -(defun hydra--cell (fstr names) - "Format a rectangular cell based on FSTR and NAMES. -FSTR is a format-style string with two string inputs: one for the -doc and one for the symbol name. -NAMES is a list of variables." - (let ((len (cl-reduce - (lambda (acc it) (max (length (symbol-name it)) acc)) - names - :initial-value 0))) - (mapconcat - (lambda (sym) - (if sym - (format fstr - (documentation-property sym 'variable-documentation) - (let ((name (symbol-name sym))) - (concat name (make-string (- len (length name)) ?^))) - sym) - "")) - names - "\n"))) - -(defun hydra--vconcat (strs &optional joiner) - "Glue STRS vertically. They must be the same height. -JOINER is a function similar to `concat'." - (setq joiner (or joiner #'concat)) - (mapconcat - (lambda (s) - (if (string-match " +$" s) - (replace-match "" nil nil s) - s)) - (apply #'cl-mapcar joiner - (mapcar - (lambda (s) (split-string s "\n")) - strs)) - "\n")) - -(defvar hydra-cell-format "% -20s %% -8`%s" - "The default format for docstring cells.") - -(defun hydra--table (names rows cols &optional cell-formats) - "Format a `format'-style table from variables in NAMES. -The size of the table is ROWS times COLS. -CELL-FORMATS are `format' strings for each column. -If CELL-FORMATS is a string, it's used for all columns. -If CELL-FORMATS is nil, `hydra-cell-format' is used for all columns." - (setq cell-formats - (cond ((null cell-formats) - (make-list cols hydra-cell-format)) - ((stringp cell-formats) - (make-list cols cell-formats)) - (t - cell-formats))) - (hydra--vconcat - (cl-mapcar - #'hydra--cell - cell-formats - (hydra--matrix names rows cols)) - (lambda (&rest x) - (mapconcat #'identity x " ")))) - -(defun hydra-reset-radios (names) - "Set varibles NAMES to their defaults. -NAMES should be defined by `defhydradio' or similar." - (dolist (n names) - (set n (aref (get n 'range) 0)))) - -(defun hydra-idle-message (secs hint name) - "In SECS seconds display HINT." - (cancel-timer hydra-message-timer) - (setq hydra-message-timer (timer-create)) - (timer-set-time hydra-message-timer - (timer-relative-time (current-time) secs)) - (timer-set-function - hydra-message-timer - (lambda () - (hydra-show-hint hint name) - (cancel-timer hydra-message-timer))) - (timer-activate hydra-message-timer)) - -(defun hydra-timeout (secs &optional function) - "In SECS seconds call FUNCTION, then function `hydra-keyboard-quit'. -Cancel the previous `hydra-timeout'." - (cancel-timer hydra-timeout-timer) - (setq hydra-timeout-timer (timer-create)) - (timer-set-time hydra-timeout-timer - (timer-relative-time (current-time) secs)) - (timer-set-function - hydra-timeout-timer - `(lambda () - ,(when function - `(funcall ,function)) - (hydra-keyboard-quit))) - (timer-activate hydra-timeout-timer)) - -;;* Macros -;;;###autoload -(defmacro defhydra (name body &optional docstring &rest heads) - "Create a Hydra - a family of functions with prefix NAME. - -NAME should be a symbol, it will be the prefix of all functions -defined here. - -BODY has the format: - - (BODY-MAP BODY-KEY &rest BODY-PLIST) - -DOCSTRING will be displayed in the echo area to identify the -Hydra. When DOCSTRING starts with a newline, special Ruby-style -substitution will be performed by `hydra--format'. - -Functions are created on basis of HEADS, each of which has the -format: - - (KEY CMD &optional HINT &rest PLIST) - -BODY-MAP is a keymap; `global-map' is used quite often. Each -function generated from HEADS will be bound in BODY-MAP to -BODY-KEY + KEY (both are strings passed to `kbd'), and will set -the transient map so that all following heads can be called -though KEY only. BODY-KEY can be an empty string. - -CMD is a callable expression: either an interactive function -name, or an interactive lambda, or a single sexp (it will be -wrapped in an interactive lambda). - -HINT is a short string that identifies its head. It will be -printed beside KEY in the echo erea if `hydra-is-helpful' is not -nil. If you don't even want the KEY to be printed, set HINT -explicitly to nil. - -The heads inherit their PLIST from BODY-PLIST and are allowed to -override some keys. The keys recognized are :exit and :bind. -:exit can be: - -- nil (default): this head will continue the Hydra state. -- t: this head will stop the Hydra state. - -:bind can be: -- nil: this head will not be bound in BODY-MAP. -- a lambda taking KEY and CMD used to bind a head. - -It is possible to omit both BODY-MAP and BODY-KEY if you don't -want to bind anything. In that case, typically you will bind the -generated NAME/body command. This command is also the return -result of `defhydra'." - (declare (indent defun)) - (cond ((stringp docstring)) - ((and (consp docstring) - (memq (car docstring) '(hydra--table concat format))) - (setq docstring (concat "\n" (eval docstring)))) - (t - (setq heads (cons docstring heads)) - (setq docstring "hydra"))) - (when (keywordp (car body)) - (setq body (cons nil (cons nil body)))) - (condition-case-unless-debug err - (let* ((keymap (copy-keymap hydra-base-map)) - (keymap-name (intern (format "%S/keymap" name))) - (body-name (intern (format "%S/body" name))) - (body-key (cadr body)) - (body-plist (cddr body)) - (body-map (or (car body) - (plist-get body-plist :bind))) - (body-pre (plist-get body-plist :pre)) - (body-body-pre (plist-get body-plist :body-pre)) - (body-before-exit (or (plist-get body-plist :post) - (plist-get body-plist :before-exit))) - (body-after-exit (plist-get body-plist :after-exit)) - (body-inherit (plist-get body-plist :inherit)) - (body-foreign-keys (hydra--body-foreign-keys body)) - (body-exit (hydra--body-exit body))) - (dolist (base body-inherit) - (setq heads (append heads (copy-sequence (eval base))))) - (dolist (h heads) - (let ((len (length h))) - (cond ((< len 2) - (error "Each head should have at least two items: %S" h)) - ((= len 2) - (setcdr (cdr h) - (list - (hydra-plist-get-default - body-plist :hint hydra-default-hint))) - (setcdr (nthcdr 2 h) (list :exit body-exit))) - (t - (let ((hint (cl-caddr h))) - (unless (or (null hint) - (stringp hint) - (consp hint)) - (let ((inherited-hint - (hydra-plist-get-default - body-plist :hint hydra-default-hint))) - (setcdr (cdr h) (cons - (if (eq 'none inherited-hint) - nil - inherited-hint) - (cddr h)))))) - (let ((hint-and-plist (cddr h))) - (if (null (cdr hint-and-plist)) - (setcdr hint-and-plist (list :exit body-exit)) - (let* ((plist (cl-cdddr h)) - (h-color (plist-get plist :color))) - (if h-color - (progn - (plist-put plist :exit - (cl-case h-color - ((blue teal) t) - (t nil))) - (cl-remf (cl-cdddr h) :color)) - (let ((h-exit (hydra-plist-get-default plist :exit 'default))) - (plist-put plist :exit - (if (eq h-exit 'default) - body-exit - h-exit)))))))))) - (plist-put (cl-cdddr h) :cmd-name (hydra--head-name h name)) - (when (null (cadr h)) (plist-put (cl-cdddr h) :exit t))) - (let ((doc (hydra--doc body-key body-name heads)) - (heads-nodup (hydra--delete-duplicates heads))) - (mapc - (lambda (x) - (define-key keymap (kbd (car x)) - (plist-get (cl-cdddr x) :cmd-name))) - heads) - (hydra--make-funcall body-pre) - (hydra--make-funcall body-body-pre) - (hydra--make-funcall body-before-exit) - (hydra--make-funcall body-after-exit) - (when (memq body-foreign-keys '(run warn)) - (unless (cl-some - (lambda (h) - (hydra--head-property h :exit)) - heads) - (error - "An %S Hydra must have at least one blue head in order to exit" - body-foreign-keys))) - `(progn - ;; create keymap - (set (defvar ,keymap-name - nil - ,(format "Keymap for %S." name)) - ',keymap) - ;; declare heads - (set (defvar ,(intern (format "%S/heads" name)) - nil - ,(format "Heads for %S." name)) - ',(mapcar (lambda (h) - (let ((j (copy-sequence h))) - (cl-remf (cl-cdddr j) :cmd-name) - j)) - heads)) - (set - (defvar ,(intern (format "%S/hint" name)) nil - ,(format "Dynamic hint for %S." name)) - ',(hydra--format name body docstring heads)) - ;; create defuns - ,@(mapcar - (lambda (head) - (hydra--make-defun name body doc head keymap-name - body-pre - body-before-exit - body-after-exit)) - heads-nodup) - ;; free up keymap prefix - ,@(unless (or (null body-key) - (null body-map) - (hydra--callablep body-map)) - `((unless (keymapp (lookup-key ,body-map (kbd ,body-key))) - (define-key ,body-map (kbd ,body-key) nil)))) - ;; bind keys - ,@(delq nil - (mapcar - (lambda (head) - (let ((name (hydra--head-property head :cmd-name))) - (when (and (cadr head) - (or body-key body-map)) - (let ((bind (hydra--head-property head :bind body-map)) - (final-key - (if body-key - (vconcat (kbd body-key) (kbd (car head))) - (kbd (car head))))) - (cond ((null bind) nil) - ((hydra--callablep bind) - `(funcall ,bind ,final-key (function ,name))) - ((and (symbolp bind) - (if (boundp bind) - (keymapp (symbol-value bind)) - t)) - `(define-key ,bind ,final-key (quote ,name))) - (t - (error "Invalid :bind property `%S' for head %S" bind head))))))) - heads)) - ,(hydra--make-defun - name body doc '(nil body) - keymap-name - (or body-body-pre body-pre) body-before-exit - '(setq prefix-arg current-prefix-arg))))) - (error - (hydra--complain "Error in defhydra %S: %s" name (cdr err)) - nil))) - -(defmacro defhydradio (name _body &rest heads) - "Create radios with prefix NAME. -_BODY specifies the options; there are none currently. -HEADS have the format: - - (TOGGLE-NAME &optional VALUE DOC) - -TOGGLE-NAME will be used along with NAME to generate a variable -name and a function that cycles it with the same name. VALUE -should be an array. The first element of VALUE will be used to -inialize the variable. -VALUE defaults to [nil t]. -DOC defaults to TOGGLE-NAME split and capitalized." - (declare (indent defun)) - `(progn - ,@(apply #'append - (mapcar (lambda (h) - (hydra--radio name h)) - heads)) - (defvar ,(intern (format "%S/names" name)) - ',(mapcar (lambda (h) (intern (format "%S/%S" name (car h)))) - heads)))) - -(defun hydra--radio (parent head) - "Generate a hydradio with PARENT from HEAD." - (let* ((name (car head)) - (full-name (intern (format "%S/%S" parent name))) - (doc (cadr head)) - (val (or (cl-caddr head) [nil t]))) - `((defvar ,full-name ,(hydra--quote-maybe (aref val 0)) ,doc) - (put ',full-name 'range ,val) - (defun ,full-name () - (hydra--cycle-radio ',full-name))))) - -(defun hydra--quote-maybe (x) - "Quote X if it's a symbol." - (cond ((null x) - nil) - ((symbolp x) - (list 'quote x)) - (t - x))) - -(defun hydra--cycle-radio (sym) - "Set SYM to the next value in its range." - (let* ((val (symbol-value sym)) - (range (get sym 'range)) - (i 0) - (l (length range))) - (setq i (catch 'done - (while (< i l) - (if (equal (aref range i) val) - (throw 'done (1+ i)) - (cl-incf i))) - (error "Val not in range for %S" sym))) - (set sym - (aref range - (if (>= i l) - 0 - i))))) - -(defvar hydra-pause-ring (make-ring 10) - "Ring for paused hydras.") - -(defun hydra-pause-resume () - "Quit the current hydra and save it to the stack. -If there's no active hydra, pop one from the stack and call its body. -If the stack is empty, call the last hydra's body." - (interactive) - (cond (hydra-curr-map - (ring-insert hydra-pause-ring hydra-curr-body-fn) - (hydra-keyboard-quit)) - ((zerop (ring-length hydra-pause-ring)) - (funcall hydra-curr-body-fn)) - (t - (funcall (ring-remove hydra-pause-ring 0))))) - -;; Local Variables: -;; outline-regexp: ";;\\([;*]+ [^\s\t\n]\\|###autoload\\)\\|(" -;; indent-tabs-mode: nil -;; End: - -(provide 'hydra) - -;;; hydra.el ends here diff --git a/elpa/hydra-20160913.216/lv.el b/elpa/hydra-20160913.216/lv.el deleted file mode 100644 index 87f7e5e..0000000 --- a/elpa/hydra-20160913.216/lv.el +++ /dev/null @@ -1,117 +0,0 @@ -;;; lv.el --- Other echo area - -;; Copyright (C) 2015 Free Software Foundation, Inc. - -;; Author: Oleh Krehel - -;; 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 . - -;;; Commentary: -;; -;; This package provides `lv-message' intended to be used in place of -;; `message' when semi-permanent hints are needed, in order to not -;; interfere with Echo Area. -;; -;; "Я тихо-тихо пiдглÑдаю, -;; І Ñ‚iшуÑÑ Ñобi, Ñк бачу то, -;; Шо Ñтрашить i не пiдпуÑкає, -;; Ð iншi п’ють тебе, Ñк воду пiÑок." -;; -- Ðндрій Кузьменко, L.V. - -;;; Code: - -(defgroup lv nil - "The other echo area." - :group 'minibuffer - :group 'hydra) - -(defcustom lv-use-separator nil - "Whether to draw a line between the LV window and the Echo Area." - :group 'lv - :type 'boolean) - -(defface lv-separator - '((((class color) (background light)) :background "grey80") - (((class color) (background dark)) :background "grey30")) - "Face used to draw line between the lv window and the echo area. -This is only used if option `lv-use-separator' is non-nil. -Only the background color is significant." - :group 'lv) - -(defvar lv-wnd nil - "Holds the current LV window.") - -(defun lv-window () - "Ensure that LV window is live and return it." - (if (window-live-p lv-wnd) - lv-wnd - (let ((ori (selected-window)) - buf) - (prog1 (setq lv-wnd - (select-window - (let ((ignore-window-parameters t)) - (split-window - (frame-root-window) -1 'below)))) - (if (setq buf (get-buffer " *LV*")) - (switch-to-buffer buf) - (switch-to-buffer " *LV*") - (set-window-hscroll lv-wnd 0) - (setq window-size-fixed t) - (setq mode-line-format nil) - (setq cursor-type nil) - (set-window-dedicated-p lv-wnd t) - (set-window-parameter lv-wnd 'no-other-window t)) - (select-window ori))))) - -(defvar golden-ratio-mode) - -(defvar lv-force-update nil - "When non-nil, `lv-message' will refresh even for the same string.") - -(defun lv-message (format-string &rest args) - "Set LV window contents to (`format' FORMAT-STRING ARGS)." - (let* ((str (apply #'format format-string args)) - (n-lines (cl-count ?\n str)) - deactivate-mark - golden-ratio-mode) - (with-selected-window (lv-window) - (unless (and (string= (buffer-string) str) - (null lv-force-update)) - (delete-region (point-min) (point-max)) - (insert str) - (when (and (window-system) lv-use-separator) - (unless (looking-back "\n" nil) - (insert "\n")) - (insert - (propertize "__" 'face 'lv-separator 'display '(space :height (1))) - (propertize "\n" 'face 'lv-separator 'line-height t))) - (set (make-local-variable 'window-min-height) n-lines) - (setq truncate-lines (> n-lines 1)) - (let ((window-resize-pixelwise t) - (window-size-fixed nil)) - (fit-window-to-buffer nil nil 1))) - (goto-char (point-min))))) - -(defun lv-delete-window () - "Delete LV window and kill its buffer." - (when (window-live-p lv-wnd) - (let ((buf (window-buffer lv-wnd))) - (delete-window lv-wnd) - (kill-buffer buf)))) - -(provide 'lv) - -;;; lv.el ends here diff --git a/elpa/logito-20120225.1255/logito-autoloads.el b/elpa/logito-20120225.1255/logito-autoloads.el deleted file mode 100644 index 70a0911..0000000 --- a/elpa/logito-20120225.1255/logito-autoloads.el +++ /dev/null @@ -1,15 +0,0 @@ -;;; logito-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil nil ("logito.el") (22221 60700 987613 744000)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; logito-autoloads.el ends here diff --git a/elpa/logito-20120225.1255/logito-pkg.el b/elpa/logito-20120225.1255/logito-pkg.el deleted file mode 100644 index 5507668..0000000 --- a/elpa/logito-20120225.1255/logito-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "logito" "20120225.1255" "logging library for Emacs" '((eieio "1.3")) :keywords '("lisp" "tool")) diff --git a/elpa/logito-20120225.1255/logito.el b/elpa/logito-20120225.1255/logito.el deleted file mode 100644 index e7ce9e5..0000000 --- a/elpa/logito-20120225.1255/logito.el +++ /dev/null @@ -1,98 +0,0 @@ -;;; logito.el --- logging library for Emacs - -;; Copyright (C) 2012 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: lisp, tool -;; Package-Version: 20120225.1255 -;; Version: 0.1 -;; Package-Requires: ((eieio "1.3")) - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; This module provides logging facility for Emacs - -;;; Code: - -(eval-when-compile - (require 'cl)) - -(require 'eieio) - -(defclass logito-object () - ((level :initarg :level :initform nil))) - -(defmethod logito-insert-log ((log logito-object) format &rest objects) - "Base implementation, do nothing") - -(defmethod logito-should-log ((log logito-object) level) - (let ((l (oref log :level))) - (and (integerp l) - (<= level l)))) - -(defmethod logito-log ((log logito-object) level tag string &rest objects) - (when (logito-should-log log level) - (apply 'logito-insert-log log (format "[%s] %s" tag string) objects))) - -(defmethod logito-log (log level tag string &rest objects) - "Fallback implementation, do nothing. This allows in particular - to pass nil as the log object." - nil) - -(defclass logito-message-object (logito-object) - ()) - -(defmethod logito-insert-log ((log logito-message-object) format &rest objects) - (apply 'message format objects)) - -(defclass logito-buffer-object (logito-object) - ((buffer :initarg :buffer :initform nil))) - -(defmethod logito-should-log ((log logito-buffer-object) level) - (and (oref log :buffer) - (call-next-method))) - -(defmethod logito-insert-log ((log logito-buffer-object) format &rest objects) - (let ((buffer (get-buffer-create (oref log :buffer)))) - (with-current-buffer buffer - (goto-char (point-max)) - (insert (apply 'format format objects) "\n\n")))) - -(defmacro logito-def-level (sym val &optional pkg) - "Define a constant logito--level and a macro logito: -associated with this level." - (let* ((pkg (or pkg 'logito)) - (const (intern (format "%s:%s-level" - (symbol-name pkg) (symbol-name sym)))) - (mac (intern (format "%s:%s" - (symbol-name pkg) (symbol-name sym))))) - `(progn - (defconst ,const ,val) - (defmacro ,mac (log string &rest objects) - (append - (list 'logito-log log ,const '',sym string) - objects))))) - -;; built-in log levels -(logito-def-level error 0) -(logito-def-level info 5) -(logito-def-level verbose 10) -(logito-def-level debug 15) - -(provide 'logito) -;;; logito.el ends here diff --git a/elpa/marshal-20160807.1954/marshal-autoloads.el b/elpa/marshal-20160807.1954/marshal-autoloads.el deleted file mode 100644 index c3bd9ea..0000000 --- a/elpa/marshal-20160807.1954/marshal-autoloads.el +++ /dev/null @@ -1,33 +0,0 @@ -;;; marshal-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) - -;;;### (autoloads nil "marshal" "marshal.el" (22454 5328 305397 868000)) -;;; Generated autoloads from marshal.el - -(autoload 'marshal "marshal" "\ - - -\(fn OBJ TYPE)" nil nil) - -(autoload 'unmarshal "marshal" "\ - - -\(fn OBJ BLOB TYPE)" nil nil) - -(autoload 'marshal-defclass "marshal" "\ - - -\(fn NAME SUPERCLASS SLOTS &rest OPTIONS-AND-DOC)" nil t) - -(function-put 'marshal-defclass 'lisp-indent-function '2) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; marshal-autoloads.el ends here diff --git a/elpa/marshal-20160807.1954/marshal-pkg.el b/elpa/marshal-20160807.1954/marshal-pkg.el deleted file mode 100644 index bc625e7..0000000 --- a/elpa/marshal-20160807.1954/marshal-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "marshal" "20160807.1954" "eieio extension for automatic (un)marshalling" '((eieio "1.4") (json "1.3") (ht "2.1")) :url "https://github.com/sigma/marshal.el" :keywords '("eieio")) diff --git a/elpa/marshal-20160807.1954/marshal.el b/elpa/marshal-20160807.1954/marshal.el deleted file mode 100644 index 6e45fcb..0000000 --- a/elpa/marshal-20160807.1954/marshal.el +++ /dev/null @@ -1,492 +0,0 @@ -;;; marshal.el --- eieio extension for automatic (un)marshalling - -;; Copyright (C) 2015 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: eieio -;; Package-Version: 20160807.1954 -;; Version: 0.7.0 -;; URL: https://github.com/sigma/marshal.el -;; Package-Requires: ((eieio "1.4") (json "1.3") (ht "2.1")) - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; Inspired by Go tagged structs. 'alist, 'plist and 'json drivers are -;; provided, but implementing others just requires to inherit from -;; `marshal-driver'. - -;; Sometimes the types are not enough (for example with lists, whose elements -;; are not explicitly typed. In those cases, a small extension on top of types -;; can be used. Like for example :marshal-type (list string) - -;; Examples: - -;; 1. Regular use: - -;; (marshal-defclass plop () -;; ((foo :initarg :foo :type string :marshal ((alist . field_foo))) -;; (bar :initarg :bar :type integer :marshal ((alist . field_bar))) -;; (baz :initarg :baz :type integer :marshal ((alist . field_baz))))) - -;; (marshal-defclass plopi () -;; ((alpha :marshal ((alist . field_alpha))) -;; (beta :type plop :marshal ((alist . field_beta))))) - -;; (marshal (make-instance 'plop :foo "ok" :bar 42) 'alist) -;; => '((field_bar . 42) (field_foo . "ok")) - -;; (unmarshal 'plop '((field_foo . "plop") (field_bar . 0) (field_baz . 1)) 'alist) -;; => '[object plop "plop" "plop" 0 1] - -;; (marshal -;; (unmarshal 'plopi '((field_alpha . 42) -;; (field_beta . ((field_foo . "plop") -;; (field_bar . 0) -;; (field_baz . 1)))) 'alist) -;; 'alist) -;; => '((field_beta (field_baz . 1) (field_bar . 0) (field_foo . "plop")) (field_alpha . 42)) - -;; 2. Objects involving lists: - -;; (marshal-defclass foo/tree () -;; ((root :initarg :id :marshal ((plist . :root))) -;; (leaves :initarg :leaves :marshal ((plist . :leaves)) :marshal-type (list foo/tree)))) - -;; (marshal (make-instance 'foo/tree :id 0 -;; :leaves (list (make-instance 'foo/tree :id 1) -;; (make-instance 'foo/tree :id 2 -;; :leaves (list (make-instance 'foo/tree :id 3))))) -;; 'plist) -;; => (:root 0 :leaves ((:root 1) (:root 2 :leaves ((:root 3))))) - -;; (unmarshal 'foo/tree '(:root 0 :leaves ((:root 1) (:root 2 :leaves ((:root 3))))) 'plist) - -;; => [object foo/tree "foo/tree" 0 -;; ([object foo/tree "foo/tree" 1 nil] -;; [object foo/tree "foo/tree" 2 -;; ([object foo/tree "foo/tree" 3 nil])])] - -;; 3. Json - -;; (marshal (make-instance 'foo/tree :id 0 -;; :leaves (list (make-instance 'foo/tree :id 1) -;; (make-instance 'foo/tree :id 2 -;; :leaves (list (make-instance 'foo/tree :id 3))))) -;; 'json) -;; => "{\"leaves\":[{\"root\":1},{\"leaves\":[{\"root\":3}],\"root\":2}],\"root\":0}" - -;; (unmarshal 'foo/tree "{\"leaves\":[{\"root\":1},{\"leaves\":[{\"root\":3}],\"root\":2}],\"root\":0}" 'json) -;; => [object foo/tree "foo/tree" 0 -;; ([object foo/tree "foo/tree" 1 nil] -;; [object foo/tree "foo/tree" 2 -;; ([object foo/tree "foo/tree" 3 nil])])] - -;;; Code: - -(require 'json) -(require 'eieio) -(require 'ht) - -;;; eieio backward-compatibility -(dolist (sym '(object-class object-p oref oset)) - (let ((new-sym (intern (concat "eieio-" (symbol-name sym))))) - (unless (fboundp new-sym) - (fset new-sym sym)))) - -;;; json hotfix -(when (json-alist-p '(((foo)))) - (defun json-alist-p (list) - (while (consp list) - (setq list (if (and (consp (car list)) (atom (caar list))) - (cdr list) - 'not-alist))) - (null list))) - -;;; Defined drivers - -(defvar marshal-drivers nil "Alist of drivers") - -(defun marshal-register-driver (type driver) - (add-to-list 'marshal-drivers (cons type driver))) - -;;; Marshalling driver interface - -(defclass marshal-driver () - ((input :initarg :input) - (output :initarg :output))) - -(defmethod marshal-open ((obj marshal-driver) &optional input) - (if input - (oset obj :input input) - (oset obj :output nil))) - -(defmethod marshal-write ((obj marshal-driver) path value) - (unless (slot-boundp obj :output) - (error "Driver has not been opened in write mode"))) - -(defmethod marshal-read ((obj marshal-driver) path) - (unless (slot-boundp obj :input) - (error "Driver has not been opened in read mode"))) - -(defmethod marshal-close ((obj marshal-driver)) - (when (slot-boundp obj :output) - (oref obj :output))) - -(defmethod marshal-guess-type :static ((obj marshal-driver) blob) - (cond ((null blob) nil) - ((booleanp blob) 'bool) - ((stringp blob) 'string) - ((numberp blob) 'number) - ((listp blob) 'list) - ((ht? blob) 'hash))) - -(defmethod marshal-preprocess ((obj marshal-driver) blob) - blob) - -(defmethod marshal-postprocess ((obj marshal-driver) blob) - blob) - -(defmethod marshal-unmarshal-null :static ((obj marshal-driver)) - nil) - -(defmethod marshal-marshal-null :static ((obj marshal-driver)) - nil) - -(defmethod marshal-unmarshal-string :static ((obj marshal-driver) s) - (format "%s" s)) - -(defmethod marshal-marshal-string :static ((obj marshal-driver) s) - s) - -(defmethod marshal-unmarshal-number :static ((obj marshal-driver) i) - i) - -(defmethod marshal-marshal-number :static ((obj marshal-driver) i) - i) - -(defmethod marshal-unmarshal-bool :static ((obj marshal-driver) b) - (equal b t)) - -(defmethod marshal-marshal-bool :static ((obj marshal-driver) b) - (equal b t)) - -(defmethod marshal-unmarshal-list :static ((obj marshal-driver) l l-type) - (let ((type (or (and (object-p obj) (eieio-object-class obj)) - obj))) - (cons (unmarshal-internal (when (consp l-type) - (cadr l-type)) - (car l) type) - (unmarshal-internal l-type (cdr l) type)))) - -(defmethod marshal-marshal-list :static ((obj marshal-driver) l) - (unless (null l) - (let ((type (or (and (object-p obj) (eieio-object-class obj)) - obj))) - (cons (marshal-internal (car l) type) - (marshal-internal (cdr l) type))))) - -(defmethod marshal-unmarshal-hash :static ((obj marshal-driver) h h-type) - (let ((type (or (and (object-p obj) (eieio-object-class obj)) - obj)) - (k-type (when (consp h-type) (nth 1 h-type))) - (v-type (when (consp h-type) (nth 2 h-type)))) - (ht<-alist - (mapcar (lambda (item) - (cons (unmarshal-internal k-type (car item) type) - (unmarshal-internal v-type (cdr item) type))) h)))) - -(defmethod marshal-marshal-hash :static ((obj marshal-driver) h) - (unless (ht-empty? h) - (let ((type (or (and (object-p obj) (eieio-object-class obj)) - obj))) - (mapcar (lambda (item) - (cons (marshal-internal (car item) type) - (marshal-internal (cadr item) type))) - (ht-items h))))) - -;;; alist-based driver - -(defclass marshal-driver-alist (marshal-driver) - ()) - -(defmethod marshal-write ((obj marshal-driver-alist) path value) - (call-next-method) - (object-add-to-list obj :output (cons path value))) - -(defmethod marshal-read ((obj marshal-driver-alist) path) - (call-next-method) - (cdr (assoc path (oref obj :input)))) - -;;; json driver - -(defclass marshal-driver-json (marshal-driver-alist) - ()) - -(defmethod marshal-preprocess ((obj marshal-driver-json) blob) - (let ((json-array-type 'list) - (json-object-type 'alist)) - (json-read-from-string (call-next-method)))) - -(defmethod marshal-postprocess ((obj marshal-driver-json) blob) - (json-encode (call-next-method))) - -(defmethod marshal-unmarshal-bool :static ((obj marshal-driver-json) b) - (not (eq b json-false))) - -(defmethod marshal-marshal-bool :static ((obj marshal-driver-json) b) - (or b json-false)) - -;;; plist-based driver - -(defclass marshal-driver-plist (marshal-driver) - ()) - -(defmethod marshal-write ((obj marshal-driver-plist) path value) - (call-next-method) - (oset obj :output (plist-put (oref obj :output) path value))) - -(defmethod marshal-read ((obj marshal-driver-plist) path) - (call-next-method) - (plist-get (oref obj :input) path)) - -;;; helper functions - -(defun marshal--alist-add (alist key value &optional append) - (let ((existing (assoc key alist))) - (if (not existing) - (cons (cons key value) alist) - (setcdr existing (if append - (append (cdr existing) value) - value)) - alist))) - -(defun marshal--alist-merge (alist1 alist2 &optional append) - (let ((res alist1)) - (if alist2 - (let* ((pair (car alist2)) - (x (car pair)) - (y (cdr pair))) - (marshal--alist-merge - (marshal--alist-add alist1 x y append) - (cdr alist2))) - alist1))) - -(defun marshal--transpose-alist2 (l) - (let (res - (rows l)) - (while rows - (let* ((row (car rows)) - (x (car row)) - (cols (cdr row))) - (while cols - (let* ((col (car cols)) - (y (car col)) - (z (cdr col)) - (target (or (assoc y res) - (let ((p (cons y nil))) - (setq res (push p res)) - p)))) - (setcdr target (cons (cons x z) (cdr target)))) - (setq cols (cdr cols)))) - (setq rows (cdr rows))) - res)) - -;;; base-class for serializable objects - -(defclass marshal-base () - ((-marshal-info :allocation :class :initform nil :protection :protected) - (-type-info :allocation :class :initform nil :protection :protected))) - -(defmethod marshal-get-marshal-info :static ((obj marshal-base)) - nil) - -(defmethod marshal-get-type-info :static ((obj marshal-base)) - nil) - -(defun marshal-get-driver (type) - (let ((cls (or (and (class-p type) type) - (cdr (assoc type marshal-drivers)) - 'marshal-driver))) - (make-instance cls))) - -(defmethod marshal-internal ((obj marshal-base) type &optional hint) - (let* ((type (or (and (class-p type) - (car (rassoc type marshal-drivers))) - type)) - (driver (marshal-get-driver type)) - (marshal-info (cdr (assoc type (marshal-get-marshal-info obj))))) - (marshal-open driver) - (when marshal-info - (dolist (s (object-slots obj)) - (let ((path (cdr (assoc s marshal-info)))) - (when (and path - (slot-boundp obj s)) - - (marshal-write driver path - (marshal-internal - (eieio-oref obj s) - type - (cdr (assoc s (marshal-get-type-info obj))))))))) - (marshal-close driver))) - -(defmethod marshal-internal ((obj nil) type &optional hint) - (let ((driver (marshal-get-driver type))) - (cond ((and (null hint) (null obj)) - (marshal-marshal-null driver)) - ((or (eq obj t) - (and (null obj) (eq hint 'bool))) - (marshal-marshal-bool driver obj)) - ((stringp obj) - (marshal-marshal-string driver obj)) - ((numberp obj) - (marshal-marshal-number driver obj)) - ((listp obj) - (marshal-marshal-list driver obj)) - ((ht? obj) - (marshal-marshal-hash driver obj))))) - -;;;###autoload -(defun marshal (obj type) - (let ((driver (marshal-get-driver type))) - (marshal-postprocess driver - (marshal-internal obj type)))) - -(defmethod unmarshal--obj ((obj marshal-base) blob type) - (let ((driver (marshal-get-driver type)) - (marshal-info (cdr (assoc type (marshal-get-marshal-info obj))))) - (marshal-open driver blob) - (when (and marshal-info blob) - (dolist (s (object-slots obj)) - (let ((path (cdr (assoc s marshal-info)))) - (when path - (eieio-oset obj s - (unmarshal-internal - (cdr (assoc s (marshal-get-type-info obj))) - (marshal-read driver path) - type)))))) - (marshal-close driver) - obj)) - -(defun unmarshal-internal (obj blob type) - (let ((obj (if (class-p obj) - (make-instance obj) - obj))) - (unmarshal--internal obj blob type))) - -(defmethod unmarshal--internal ((obj nil) blob type) - (let* ((driver (marshal-get-driver type)) - (obj (or obj (marshal-guess-type driver blob)))) - (cond ((or (null obj) (null blob)) - (marshal-unmarshal-null driver)) - ((eq obj 'bool) - (marshal-unmarshal-bool driver blob)) - ((eq obj 'string) - (marshal-unmarshal-string driver blob)) - ((memq obj '(number integer)) - (marshal-unmarshal-number driver blob)) - ((or (eq obj 'list) - (and (consp obj) (eq (car obj) 'list))) - (marshal-unmarshal-list driver blob obj)) - ((or (eq obj 'hash) - (and (consp obj) (eq (car obj) 'hash))) - (marshal-unmarshal-hash driver blob obj))))) - -(defmethod unmarshal--internal ((obj marshal-base) blob type) - (let ((type (or (and (class-p type) - (car (rassoc type marshal-drivers))) - type))) - (unmarshal--obj obj blob type))) - -;;;###autoload -(defun unmarshal (obj blob type) - (let ((driver (marshal-get-driver type))) - (unmarshal-internal obj (marshal-preprocess driver blob) type))) - -;;;###autoload -(defmacro marshal-defclass (name superclass slots &rest options-and-doc) - (declare (debug t) (indent 2)) - (let* ((options (if (stringp (car options-and-doc)) - (cdr options-and-doc) - options-and-doc)) - (default-spec-func (or (plist-get options :marshal-default-spec) - 'ignore)) - (base-cls (or (plist-get options :marshal-base-cls) - 'marshal-base)) - (marshal-info (marshal--transpose-alist2 - (remove nil - (mapcar - (lambda (s) - (let ((name (car s))) - (let ((marshal - (or (plist-get (cdr s) :marshal) - (funcall default-spec-func name)))) - (when marshal - (cons name - (mapcar - (lambda (p) - (if (consp p) - p - (cons p name))) - marshal)))))) - slots)))) - (type-info (remove nil - (mapcar (lambda (s) - (let ((name (car s))) - (let ((type (or (plist-get (cdr s) :marshal-type) - (plist-get (cdr s) :type)))) - (when type - (cons name type))))) - slots)))) - `(progn - (defclass ,name (,@superclass ,base-cls) - (,@slots) - ,@options-and-doc) - - (defmethod marshal-get-marshal-info :static ((obj ,name)) - (let ((cls (if (eieio-object-p obj) - (eieio-object-class obj) - obj))) - (get cls :marshal-info))) - - (put ',name :marshal-info ',marshal-info) - (dolist (cls ',superclass) - (put ',name :marshal-info - (marshal--alist-merge (get ',name :marshal-info) - (marshal-get-marshal-info cls) t))) - - (defmethod marshal-get-type-info :static ((obj ,name)) - (let ((cls (if (eieio-object-p obj) - (eieio-object-class obj) - obj))) - (get cls :type-info))) - - (put ',name :type-info ',type-info) - (dolist (cls ',superclass) - (put ',name :type-info - (marshal--alist-merge (get ',name :type-info) - (marshal-get-type-info cls) t))) - - ,name))) - -;;; Default drivers -(marshal-register-driver 'alist 'marshal-driver-alist) -(marshal-register-driver 'plist 'marshal-driver-plist) -(marshal-register-driver 'json 'marshal-driver-json) - -(provide 'marshal) -;;; marshal.el ends here diff --git a/elpa/muse-3.20/ChangeLog b/elpa/muse-3.20/ChangeLog deleted file mode 100644 index d5560a7..0000000 --- a/elpa/muse-3.20/ChangeLog +++ /dev/null @@ -1,40 +0,0 @@ -2012-10-30 Stefan Monnier - - Clean up copyright notices. - -2011-07-30 Chong Yidong - - Add Texinfo files for muse package. - -2011-07-01 Chong Yidong - - Remove version numbers from filenames in packages/ dir. - -2011-06-30 Chong Yidong - - Remove version numbers in packages/ directory - -2011-01-09 Chong Yidong - - Make Muse's *-link faces inherit from the basic link face. - - * packages/muse-3.20/muse-colors.el (muse-link, muse-bad-link): - Inherit from link face. - -2010-11-20 Ted Zlatanov - - * COPYING, ChangeLog, README, admin/org-synch.el, - admin/org-synch.sh, admin/package-update.sh: Initial import. - - * packages/archive-contents, packages/auctex-11.86, - packages/auctex-readme.txt, packages/company-0.5/, - packages/company-readme.txt, packages/elpa.rss, - packages/js2-mode-20090814.el, packages/js2-mode-readme.txt, - packages/muse-3.20/, packages/muse-readme.txt, - packages/org-readme.txt, packages/rainbow-mode-0.1.el, - packages/rainbow-mode-readme.txt: Renamed from the root directory. - -2010-11-18 ELPA admin - - Initial repository contents - diff --git a/elpa/muse-3.20/README b/elpa/muse-3.20/README deleted file mode 100644 index 5f6e20e..0000000 --- a/elpa/muse-3.20/README +++ /dev/null @@ -1,7 +0,0 @@ -Muse is a tool for easily authoring and publishing documents. It -allows for rapid prototyping of hyperlinked text, which may then be -exported to multiple output formats, such as HTML, LaTeX, and Texinfo. - -The markup rules used by Muse are intended to be very friendly to -people familiar with Emacs. See the included manual for more -information. diff --git a/elpa/muse-3.20/cgi.el b/elpa/muse-3.20/cgi.el deleted file mode 100644 index 936b33f..0000000 --- a/elpa/muse-3.20/cgi.el +++ /dev/null @@ -1,217 +0,0 @@ -;;; cgi.el -- Using Emacs for CGI scripting - -;; Copyright (C) 2000, 2006, 2012 Free Software Foundation, Inc. - -;; Author: Eric Marsden -;; Michael Olson (slight modifications) -;; Keywords: CGI web scripting slow -;; Version: 0.3 -;; Time-stamp: <2001-08-24 emarsden> - -;; 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, write to the Free -;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -;; MA 02111-1307, USA. - -;;; Commentary: - -;; People who like this sort of thing will find this the sort of -;; thing they like. -- Abraham Lincoln -;; -;; -;; Overview ========================================================== -;; -;; A simple library for the Common Gateway Interface for Emacs, -;; allowing you to service requests for non static web pages in elisp. -;; Provides routines for decoding arguments to GET- and POST-type CGI -;; requests. -;; -;; Usage: place a shell script such as the following in your web -;; server's CGI directory (typically called something like -;; /var/www/cgi-bin/): -;; -;; ,------------------------------------------------------------------- -;; | #!/bin/sh -;; | -;; | emacs -batch -l cgi.el -f cgi-calendar -;; `------------------------------------------------------------------- -;; -;; (`cgi-calendar' is a sample elisp CGI script provided at the end of -;; this file). -;; -;; Alternatively, if you're running version 2.x of the linux kernel -;; you could make .elc files directly executable via the binfmt_misc -;; mechanism and run them straight from the cgi-bin directory. -;; -;; Efficiency would be improved by having Emacs bind to the http -;; service port and spawn a thread per connection. Extending Emacs to -;; support server sockets and multithreading is left as an exercise -;; for the reader. -;; -;; References: -;; * rfc1738 "Uniform Resource Locators" -;; * rfc1630 "Universal Resource Identifiers in WWW" -;; -;; Thanks to Christoph Conrad for pointing -;; out a bug in the URI-decoding. - -;;; Code: - -(eval-when-compile - (require 'cl) - (require 'calendar)) - -(defconst cgi-url-unreserved-chars '( - ?a ?b ?c ?d ?e ?f ?g ?h ?i ?j ?k ?l ?m - ?n ?o ?p ?q ?r ?s ?t ?u ?v ?w ?x ?y ?z - ?A ?B ?C ?D ?E ?F ?G ?H ?I ?J ?K ?L ?M - ?N ?O ?P ?Q ?R ?S ?T ?U ?V ?W ?X ?Y ?Z - ?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 - ?\$ ?\- ?\_ ?\. ?\! ?\~ ?\* ?\' ?\( ?\) ?\,)) - -(defun cgi-int-char (i) - (if (fboundp 'int-char) (int-char i) i)) - -(defun cgi-hex-char-p (ch) - (declare (character ch)) - (let ((hexchars '(?0 ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 - ?A ?B ?C ?D ?E ?F))) - (member (upcase ch) hexchars))) - -;; decode %xx to the corresponding character and + to ' ' -(defun cgi-decode-string (str) - (do ((i 0) - (len (length str)) - (decoded '())) - ((>= i len) (concat (nreverse decoded))) - (let ((ch (aref str i))) - (cond ((eq ?+ ch) - (push ?\ decoded) - (incf i)) - ((and (eq ?% ch) - (< (+ i 2) len) - (cgi-hex-char-p (aref str (+ i 1))) - (cgi-hex-char-p (aref str (+ i 2)))) - (let ((hex (string-to-number (substring str (+ i 1) (+ i 3)) 16))) - (push (cgi-int-char hex) decoded) - (incf i 3))) - (t (push ch decoded) - (incf i)))))) - -(defun cgi-position (item seq &optional start end) - (or start (setq start 0)) - (or end (setq end (length seq))) - (while (and (< start end) - (not (equal item (aref seq start)))) - (setq start (1+ start))) - (and (< start end) start)) - -;; Parse "foo=x&bar=y+re" into (("foo" . "x") ("bar" . "y re")) -;; Substrings are plus-decoded and then URI-decoded. -(defun cgi-decode (q) - (when q - (flet ((split-= (str) - (let ((pos (or (cgi-position ?= str) 0))) - (cons (cgi-decode-string (substring str 0 pos)) - (cgi-decode-string (substring str (+ pos 1))))))) - (mapcar #'split-= (split-string q "&"))))) - -(defun cgi-lose (fmt &rest args) - (let ((why (apply #'format fmt args))) - (message "Script error: %s" why) ; to error_log - (princ "Content-type: text/html\n\n") ; to browser - (princ "Script error\r\n") - (princ "

Script error

\r\n

\r\n") - (princ why) - (princ "\r\n\r\n") - (kill-emacs 0))) - -(defmacro cgi-evaluate (&rest forms) - `(condition-case why - (princ (with-output-to-string ,@forms)) - (error (cgi-lose "Emacs Lisp error: %s" why)))) - -(defun cgi-arguments () - (let ((method (getenv "REQUEST_METHOD")) - req buf) - (cond ((null method) - (cgi-lose "No request method specified")) - ((string= "GET" method) - (unless (getenv "QUERY_STRING") - (cgi-lose "No query string for GET request")) - (cgi-decode (getenv "QUERY_STRING"))) - ((string= "POST" method) - (setq req (getenv "CONTENT_LENGTH")) - (unless req - (cgi-lose "No content-length for POST request")) - (setq buf (get-buffer-create " *cgi*")) - (set-buffer buf) - (erase-buffer) - (loop for i from 1 to (string-to-number req) - do (insert (read-event))) - (cgi-decode (buffer-string))) - (t - (cgi-lose "Can't handle request method %s" method))))) - -;; ==================================================================== -;; a sample application: calendar via the web. If invoked without -;; arguments, presents a calendar for the three months around the -;; current date. You can request a calendar for a specific period by -;; specifying the year and the month in the query string: -;; -;; ~$ lynx -dump 'http://localhost/cgi-bin/cal?year=1975&month=6' -;; -;; When run in batch mode, text normally displayed in the echo area -;; (via `princ' for example) goes to stdout, and thus to the browser. -;; Text output using `message' goes to stderr, and thus normally to -;; your web server's error_log. -;; ==================================================================== - -(eval-and-compile - (if (fboundp 'calendar-extract-month) - (defalias 'cgi-calendar-extract-month 'calendar-extract-month) - (defalias 'cgi-calendar-extract-month 'extract-calendar-month)) - - (if (fboundp 'calendar-extract-year) - (defalias 'cgi-calendar-extract-year 'calendar-extract-year) - (defalias 'cgi-calendar-extract-year 'extract-calendar-year)) - - (if (fboundp 'calendar-generate) - (defalias 'cgi-calendar-generate 'calendar-generate) - (defalias 'cgi-calendar-generate 'generate-calendar))) - -(defun cgi-calendar-string () - (require 'calendar) - (let* ((args (cgi-arguments)) - (now (calendar-current-date)) - (mnth (cdr (assoc "month" args))) - (month (if mnth (string-to-number mnth) - (cgi-calendar-extract-month now))) - (yr (cdr (assoc "year" args))) - (year (if yr (string-to-number yr) - (cgi-calendar-extract-year now)))) - (with-temp-buffer - (cgi-calendar-generate month year) - (buffer-string)))) - -(defun cgi-calendar () - (cgi-evaluate - (princ "Content-type: text/html\n\n") - (princ "Emacs calendar\r\n") - (princ "

Emacs calendar

\r\n") - (princ "
\r\n")
-   (princ (cgi-calendar-string))
-   (princ "\r\n
\r\n"))) - -(provide 'cgi) -;;; cgi.el ends here diff --git a/elpa/muse-3.20/dir b/elpa/muse-3.20/dir deleted file mode 100644 index 22af354..0000000 --- a/elpa/muse-3.20/dir +++ /dev/null @@ -1,18 +0,0 @@ -This is the file .../info/dir, which contains the -topmost node of the Info hierarchy, called (dir)Top. -The first time you invoke Info you start off looking at this node. - -File: dir, Node: Top This is the top of the INFO tree - - This (the Directory node) gives a menu of major topics. - Typing "q" exits, "?" lists all Info commands, "d" returns here, - "h" gives a primer for first-timers, - "mEmacs" visits the Emacs manual, etc. - - In Emacs, you can click mouse button 2 on a menu item or cross reference - to select it. - -* Menu: - -Emacs -* Muse: (muse). Authoring and publishing environment for Emacs. diff --git a/elpa/muse-3.20/htmlize-hack.el b/elpa/muse-3.20/htmlize-hack.el deleted file mode 100644 index 4c9e5e8..0000000 --- a/elpa/muse-3.20/htmlize-hack.el +++ /dev/null @@ -1,19 +0,0 @@ -;; This file provides a fix for htmlize.el and Emacs 23. -;; To use it, add the path to this directory to your load path and -;; add (require 'htmlize-hack) to your Emacs init file. - -(require 'htmlize) - -(when (equal htmlize-version "1.34") - (defun htmlize-face-size (face) - ;; The size (height) of FACE, taking inheritance into account. - ;; Only works in Emacs 21 and later. - (let ((size-list - (loop - for f = face then (face-attribute f :inherit) - until (or (null f) (eq f 'unspecified)) - for h = (face-attribute f :height) - collect (if (eq h 'unspecified) nil h)))) - (reduce 'htmlize-merge-size (cons nil size-list))))) - -(provide 'htmlize-hack) diff --git a/elpa/muse-3.20/httpd.el b/elpa/muse-3.20/httpd.el deleted file mode 100644 index 1fb64a4..0000000 --- a/elpa/muse-3.20/httpd.el +++ /dev/null @@ -1,288 +0,0 @@ -;;; httpd.el -- A web server in Emacs Lisp - -;; Copyright (C) 2001, 2003, 2006, 2012 Free Software Foundation, Inc. - -;; Author: Eric Marsden -;; John Wiegley -;; Michael Olson (slight modifications) -;; Version: 1.1 -;; Keywords: games - -;; 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, write to the Free -;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -;; MA 02111-1307, USA. -;; -;; The latest version of this package should be available from -;; -;; - -;;; Commentary: - -;; httpd.el is an HTTP server embedded in the Emacs. It can handle GET -;; and HEAD requests; adding support for POST should not be too -;; difficult. By default, httpd.el will listen on server side Emacs -;; sockets for HTTP requests. -;; -;; I have only tested this code with Emacs; it may need modifications -;; to work with XEmacs. -;; -;; This version has been modified to work with GNU Emacs 21 and 22. -;; -;;; Acknowledgements: -;; -;; httpd.el was inspired by pshttpd, an HTTP server written in -;; Postscript by Anders Karlsson . -;; -;; Thanks to John Wiegley and Cyprian Adam Laskowski. - -;;; Code: - -(defvar httpd-document-root "/var/www") - -(defvar httpd-path-handlers '() - "Alist of (path-regexp . handler) forms. -If a GET request is made for an URL whose path component matches -a PATH-REGEXP, the corresponding handler is called to generate -content.") - -(defvar httpd-mime-types-alist - '(("html" . "text/html; charset=iso-8859-1") - ("txt" . "text/plain; charset=iso-8859-1") - ("jpg" . "image/jpeg") - ("jpeg" . "image/jpeg") - ("gif" . "image/gif") - ("png" . "image/png") - ("tif" . "image/tiff") - ("tiff" . "image/tiff") - ("css" . "text/css") - ("gz" . "application/octet-stream") - ("ps" . "application/postscript") - ("pdf" . "application/pdf") - ("eps" . "application/postscript") - ("tar" . "application/x-tar") - ("rpm" . "application/x-rpm") - ("zip" . "application/zip") - ("mp3" . "audio/mpeg") - ("mp2" . "audio/mpeg") - ("mid" . "audio/midi") - ("midi" . "audio/midi") - ("wav" . "audio/x-wav") - ("au" . "audio/basic") - ("ram" . "audio/pn-realaudio") - ("ra" . "audio/x-realaudio") - ("mpg" . "video/mpeg") - ("mpeg" . "video/mpeg") - ("qt" . "video/quicktime") - ("mov" . "video/quicktime") - ("avi" . "video/x-msvideo"))) - -(defun httpd-mime-type (filename) - (or (cdr (assoc (file-name-extension filename) httpd-mime-types-alist)) - "text/plain")) - -(put 'httpd-exception 'error-conditions '(httpd-exception error)) - -(defun defhttpd-exception (name code msg) - (put name 'error-conditions (list name 'httpd-exception 'error)) - (put name 'httpd-code code) - (put name 'httpd-msg msg)) - -(defhttpd-exception 'httpd-moved/perm 301 "Moved permanently") -(defhttpd-exception 'httpd-moved/temp 302 "Moved temporarily") -(defhttpd-exception 'httpd-bad-request 400 "Bad request") -(defhttpd-exception 'httpd-forbidden 403 "Forbidden") -(defhttpd-exception 'httpd-file-not-found 404 "Not found") -(defhttpd-exception 'httpd-method-forbidden 405 "Method not allowed") -(defhttpd-exception 'httpd-unimplemented 500 "Internal server error") -(defhttpd-exception 'httpd-unimplemented 501 "Not implemented") -(defhttpd-exception 'httpd-unimplemented 503 "Service unavailable") - -(defvar httpd-endl "\r\n") - -(defvar httpd-process nil) -(defvar httpd-bytes-sent nil) ; only used with `httpd-process' -(defvar httpd-log-accesses t) - -(defun httpd-add-handler (path-regexp handler) - (push (cons path-regexp handler) httpd-path-handlers)) - -(defun httpd-try-internal-handler (path &optional cont) - (catch 'result - (dolist (elem httpd-path-handlers) - (let ((regexp (car elem)) - (handler (cdr elem))) - (if (string-match regexp path) - (throw 'result (funcall handler path cont))))))) - -(defun httpd-date-stamp () - (format-time-string "[%d/%b/%Y %H:%M:%S %z]")) - -(defun httpd-log (&rest strings) - (if httpd-log-accesses - (save-excursion - (goto-char (point-max)) - (with-current-buffer (get-buffer-create "*httpd access_log*") - (mapc 'insert strings))))) - -(defun httpd-send-data (&rest strings) - (dolist (s strings) - (send-string httpd-process s) - (if httpd-bytes-sent - (setq httpd-bytes-sent (+ httpd-bytes-sent (length s)))))) - -(defun httpd-send (code msg &rest strings) - (httpd-log (number-to-string code) " ") - (apply 'httpd-send-data - "HTTP/1.0 " (number-to-string code) " " msg httpd-endl - strings)) - -(defun httpd-send-eof () - (httpd-log (number-to-string httpd-bytes-sent) "\n") - (process-send-eof httpd-process)) - -(defun httpd-send-file (filename) - (with-temp-buffer - (insert-file-contents filename) - (httpd-send-data (buffer-string)))) - -(defun httpd-lose (code msg) - (httpd-send code msg - "Content-Type: text/html" httpd-endl - "Connection: close" httpd-endl - httpd-endl - "Error" httpd-endl - "

" msg "

" httpd-endl - "

" msg httpd-endl - "" httpd-endl) - (httpd-send-eof)) - -(defun httpd-handle-redirect (req where) - "Redirect the client to new location WHERE." - (httpd-send 301 "Moved permanently" - "Location: " where httpd-endl - "URI: " where httpd-endl - "Connection: close" httpd-endl - httpd-endl) - (httpd-send-eof)) - -(defun httpd-handle-GET+HEAD (path &optional want-data req) - (if (zerop (length path)) - (setq path "index.html")) - - ;; could use `expand-file-name' here instead of `concat', but we - ;; don't want tilde expansion, etc. - (let ((filename (concat httpd-document-root "/" path)) - modified-since) - (cond ((httpd-try-internal-handler path) t) - ((file-directory-p filename) - (httpd-handle-redirect path (concat "http://" (system-name) "/" - path "/"))) - ((file-readable-p filename) - (let ((attrs (file-attributes filename))) - (if (and (string-match "^If-Modified-Since:\\s-+\\(.+\\)" req) - (setq modified-since - (apply 'encode-time - (parse-time-string (match-string 1 req)))) - (time-less-p (nth 5 attrs) modified-since)) - (httpd-send 304 "Not modified" - "Server: Emacs/httpd.el" httpd-endl - "Connection: close" httpd-endl - httpd-endl) - (httpd-send 200 "OK" - "Server: Emacs/httpd.el" httpd-endl - "Connection: close" httpd-endl - "MIME-Version: 1.0" httpd-endl - "Content-Type: " - (httpd-mime-type filename) httpd-endl - "Content-Length: " - (number-to-string (nth 7 attrs)) httpd-endl - httpd-endl) - (if want-data - (httpd-send-file filename))) - (httpd-send-eof))) - - (t (signal 'httpd-file-not-found path))))) - -(defun httpd-handle-request (req &optional cont) - (httpd-log (car (process-contact httpd-process)) " - - " - (httpd-date-stamp) " \"") - (if (not (string-match ".+" req)) - (progn - (httpd-log "\"") - (error "HTTP request was empty")) - (let ((request (match-string 0 req))) - (httpd-log request "\" ") - (cond - ((string-match "\\.\\." request) - ;; reject requests containing ".." in the path. Should really - ;; URI-decode first. - (signal 'httpd-forbidden request)) - - ((string-match "\\`\\(GET\\|HEAD\\|POST\\)\\s-/\\(\\S-*\\)" request) - (let ((kind (match-string 1 request)) - (arg (match-string 2 request))) - (if (string= kind "POST") - (unless (httpd-try-internal-handler arg cont) - (signal 'httpd-unimplemented arg)) - (httpd-handle-GET+HEAD arg (string= kind "GET") req)))) - - (t (signal 'httpd-bad-request request)))))) - -(defun httpd-serve (proc string) - (let ((httpd-process proc) - (httpd-bytes-sent 0)) - (condition-case why - (httpd-handle-request string) - (httpd-exception - (httpd-lose (get (car why) 'httpd-code) - (get (car why) 'httpd-msg))) - ;; Comment out these two lines if you want to catch errors - ;; inside Emacs itself. - (error - (httpd-lose 500 (format "Emacs Lisp error: %s" why))) - ))) - -(defun httpd-start (&optional port) - (interactive (list (read-string "Serve Web requests on port: " "8080"))) - (if (null port) - (setq port 8080) - (if (stringp port) - (setq port (string-to-number port)))) - (if httpd-process - (delete-process httpd-process)) - (setq httpd-process - (if (fboundp 'make-network-process) - (make-network-process :name "httpd" - :buffer (generate-new-buffer "httpd") - :host 'local :service port - :server t :noquery t - :filter 'httpd-serve) - (and (fboundp 'open-network-stream-server) - (open-network-stream-server "httpd" - (generate-new-buffer "httpd") - port nil 'httpd-serve)))) - (if (and (processp httpd-process) - (eq (process-status httpd-process) 'listen)) - (message "httpd.el is listening on port %d" port))) - -(defun httpd-stop () - (interactive) - (when httpd-process - (message "httpd.el server on port %d has stopped" - (cadr (process-contact httpd-process))) - (delete-process httpd-process) - (setq httpd-process nil))) - -(provide 'httpd) -;;; httpd.el ends here diff --git a/elpa/muse-3.20/muse-autoloads.el b/elpa/muse-3.20/muse-autoloads.el deleted file mode 100644 index 86f3b0a..0000000 --- a/elpa/muse-3.20/muse-autoloads.el +++ /dev/null @@ -1,277 +0,0 @@ -;;; muse-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "muse" "muse.el" (21705 22861 643843 136000)) -;;; Generated autoloads from muse.el - (add-to-list 'auto-mode-alist '("\\.muse\\'" . muse-mode-choose-mode)) - -;;;*** - -;;;### (autoloads nil "muse-blosxom" "muse-blosxom.el" (21705 22862 -;;;;;; 348828 281000)) -;;; Generated autoloads from muse-blosxom.el - -(autoload 'muse-blosxom-new-entry "muse-blosxom" "\ -Start a new blog entry with given CATEGORY. -The filename of the blog entry is derived from TITLE. -The page will be initialized with the current date and TITLE. - -\(fn CATEGORY TITLE)" t nil) - -;;;*** - -;;;### (autoloads nil "muse-colors" "muse-colors.el" (21705 22862 -;;;;;; 65834 245000)) -;;; Generated autoloads from muse-colors.el - -(autoload 'muse-colors-toggle-inline-images "muse-colors" "\ -Toggle display of inlined images on/off. - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "muse-import-docbook" "muse-import-docbook.el" -;;;;;; (21705 22862 962815 340000)) -;;; Generated autoloads from muse-import-docbook.el - -(autoload 'muse-import-docbook "muse-import-docbook" "\ -Convert the Docbook buffer SRC to Muse, writing output in the DEST buffer. - -\(fn SRC DEST)" t nil) - -(autoload 'muse-import-docbook-files "muse-import-docbook" "\ -Convert the Docbook file SRC to Muse, writing output to the DEST file. - -\(fn SRC DEST)" t nil) - -;;;*** - -;;;### (autoloads nil "muse-import-latex" "muse-import-latex.el" -;;;;;; (21705 22861 560844 887000)) -;;; Generated autoloads from muse-import-latex.el - -(autoload 'muse-import-latex "muse-import-latex" "\ - - -\(fn)" t nil) - -;;;*** - -;;;### (autoloads nil "muse-mode" "muse-mode.el" (21705 22863 3814 -;;;;;; 476000)) -;;; Generated autoloads from muse-mode.el - -(autoload 'muse-mode "muse-mode" "\ -Muse is an Emacs mode for authoring and publishing documents. -\\{muse-mode-map} - -\(fn)" t nil) - -(autoload 'muse-mode-choose-mode "muse-mode" "\ -Turn the proper Emacs Muse related mode on for this file. - -\(fn)" nil nil) - -(autoload 'muse-insert-list-item "muse-mode" "\ -Insert a list item at the current point, taking into account -your current list type and indentation level. - -\(fn)" t nil) - -(autoload 'muse-increase-list-item-indentation "muse-mode" "\ -Increase the indentation of the current list item. - -\(fn)" t nil) - -(autoload 'muse-decrease-list-item-indentation "muse-mode" "\ -Decrease the indentation of the current list item. - -\(fn)" t nil) - -(autoload 'muse-insert-relative-link-to-file "muse-mode" "\ -Insert a relative link to a file, with optional description, at point. - -\(fn)" t nil) - -(autoload 'muse-edit-link-at-point "muse-mode" "\ -Edit the current link. -Do not rename the page originally referred to. - -\(fn)" t nil) - -(autoload 'muse-browse-result "muse-mode" "\ -Visit the current page's published result. - -\(fn STYLE &optional OTHER-WINDOW)" t nil) - -(autoload 'muse-follow-name-at-point "muse-mode" "\ -Visit the link at point. - -\(fn &optional OTHER-WINDOW)" t nil) - -(autoload 'muse-follow-name-at-point-other-window "muse-mode" "\ -Visit the link at point in other window. - -\(fn)" t nil) - -(autoload 'muse-next-reference "muse-mode" "\ -Move forward to next Muse link or URL, cycling if necessary. - -\(fn)" t nil) - -(autoload 'muse-previous-reference "muse-mode" "\ -Move backward to the next Muse link or URL, cycling if necessary. -In case of Emacs x <= 21 and ignoring of intangible properties (see -`muse-mode-intangible-links'). - -This function is not entirely accurate, but it's close enough. - -\(fn)" t nil) - -(autoload 'muse-what-changed "muse-mode" "\ -Show the unsaved changes that have been made to the current file. - -\(fn)" t nil) - -(autoload 'muse-search-with-command "muse-mode" "\ -Search for the given TEXT string in the project directories -using the specified command. - -\(fn TEXT)" t nil) - -(autoload 'muse-search "muse-mode" "\ -Search for the given TEXT using the default grep command. - -\(fn)" t nil) - -(autoload 'muse-find-backlinks "muse-mode" "\ -Grep for the current pagename in all the project directories. - -\(fn)" t nil) - -(autoload 'muse-index "muse-mode" "\ -Display an index of all known Muse pages. - -\(fn)" t nil) - -(autoload 'muse-insert-tag "muse-mode" "\ -Insert a tag interactively with a blank line after it. - -\(fn TAG)" t nil) - -(autoload 'muse-list-edit-minor-mode "muse-mode" "\ -This is a global minor mode for editing files with lists. -It is meant to be used with other major modes, and not with Muse mode. - -Interactively, with no prefix argument, toggle the mode. -With universal prefix ARG turn mode on. -With zero or negative ARG turn mode off. - -This minor mode provides the Muse keybindings for editing lists, -and support for filling lists properly. - -It recognizes not only Muse-style lists, which use the \"-\" -character or numbers, but also lists that use asterisks or plus -signs. This should make the minor mode generally useful. - -Definition lists and footnotes are also recognized. - -Note that list items may omit leading spaces, for compatibility -with modes that set `left-margin', such as -`debian-changelog-mode'. - -\\{muse-list-edit-minor-mode-map} - -\(fn &optional ARG)" t nil) - -;;;*** - -;;;### (autoloads nil "muse-project" "muse-project.el" (21705 22862 -;;;;;; 680821 283000)) -;;; Generated autoloads from muse-project.el - -(autoload 'muse-project-find-file "muse-project" "\ -Open the Muse page given by NAME in PROJECT. -If COMMAND is non-nil, it is the function used to visit the file. -If DIRECTORY is non-nil, it is the directory in which the page -will be created if it does not already exist. Otherwise, the -first directory within the project's fileset is used. - -\(fn NAME PROJECT &optional COMMAND DIRECTORY)" t nil) - -(autoload 'muse-project-publish-this-file "muse-project" "\ -Publish the currently-visited file according to `muse-project-alist', -prompting if more than one style applies. - -If FORCE is given, publish the file even if it is up-to-date. - -If STYLE is given, use that publishing style rather than -prompting for one. - -\(fn &optional FORCE STYLE)" t nil) - -(autoload 'muse-project-publish "muse-project" "\ -Publish the pages of PROJECT that need publishing. - -\(fn PROJECT &optional FORCE)" t nil) - -;;;*** - -;;;### (autoloads nil "muse-protocols" "muse-protocols.el" (21705 -;;;;;; 22862 389827 417000)) -;;; Generated autoloads from muse-protocols.el - -(autoload 'muse-browse-url "muse-protocols" "\ -Handle URL with the function specified in `muse-url-protocols'. -If OTHER-WINDOW is non-nil, open in a different window. - -\(fn URL &optional OTHER-WINDOW)" t nil) - -;;;*** - -;;;### (autoloads nil "muse-publish" "muse-publish.el" (21705 22862 -;;;;;; 730820 230000)) -;;; Generated autoloads from muse-publish.el - -(autoload 'muse-publish-region "muse-publish" "\ -Apply the given STYLE's markup rules to the given region. -The result is placed in a new buffer that includes TITLE in its name. - -\(fn BEG END &optional TITLE STYLE)" t nil) - -(autoload 'muse-publish-file "muse-publish" "\ -Publish the given FILE in a particular STYLE to OUTPUT-DIR. -If the argument FORCE is nil, each file is only published if it is -newer than the published version. If the argument FORCE is non-nil, -the file is published no matter what. - -\(fn FILE STYLE &optional OUTPUT-DIR FORCE)" t nil) - -(autoload 'muse-publish-this-file "muse-publish" "\ -Publish the currently-visited file. -Prompt for both the STYLE and OUTPUT-DIR if they are not -supplied. - -\(fn STYLE OUTPUT-DIR &optional FORCE)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("cgi.el" "htmlize-hack.el" "httpd.el" -;;;;;; "muse-backlink.el" "muse-book.el" "muse-context.el" "muse-docbook.el" -;;;;;; "muse-groff.el" "muse-html.el" "muse-http.el" "muse-ikiwiki.el" -;;;;;; "muse-import-xml.el" "muse-ipc.el" "muse-journal.el" "muse-latex.el" -;;;;;; "muse-latex2png.el" "muse-pkg.el" "muse-poem.el" "muse-regexps.el" -;;;;;; "muse-texinfo.el" "muse-wiki.el" "muse-xml-common.el" "muse-xml.el") -;;;;;; (21705 22863 153833 598000)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; muse-autoloads.el ends here diff --git a/elpa/muse-3.20/muse-backlink.el b/elpa/muse-3.20/muse-backlink.el deleted file mode 100644 index bc21ddd..0000000 --- a/elpa/muse-3.20/muse-backlink.el +++ /dev/null @@ -1,327 +0,0 @@ -;;; muse-backlink.el --- backlinks for Muse - -;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; Author: Jim Ottaway -;; Keywords: - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; Hierarchical backlink insertion into new muse pages. -;; -;; To add: -;; -;; (require 'muse-backlink) -;; (muse-backlink-install) -;; -;; To control what gets backlinked, modify -;; `muse-backlink-exclude-backlink-regexp' and -;; `muse-backlink-exclude-backlink-parent-regexp'. -;; -;; To stop backlinking temporarily: -;; (setq muse-backlink-create-backlinks nil) -;; -;; To remove the backlink functionality completely: -;; -;; (muse-backlink-remove) - -;;; Contributors: - -;;; Code: - -(require 'muse) -(require 'muse-project) - -(eval-when-compile (require 'muse-mode)) - -(eval-and-compile - (if (< emacs-major-version 22) - (progn - ;; Swiped from Emacs 22.0.50.4 - (defvar muse-backlink-split-string-default-separators "[ \f\t\n\r\v]+" - "The default value of separators for `split-string'. - -A regexp matching strings of whitespace. May be locale-dependent -\(as yet unimplemented). Should not match non-breaking spaces. - -Warning: binding this to a different value and using it as default is -likely to have undesired semantics.") - - (defun muse-backlink-split-string (string &optional separators omit-nulls) - "Split STRING into substrings bounded by matches for SEPARATORS. - -The beginning and end of STRING, and each match for SEPARATORS, are -splitting points. The substrings matching SEPARATORS are removed, and -the substrings between the splitting points are collected as a list, -which is returned. - -If SEPARATORS is non-nil, it should be a regular expression matching text -which separates, but is not part of, the substrings. If nil it defaults to -`split-string-default-separators', normally \"[ \\f\\t\\n\\r\\v]+\", and -OMIT-NULLS is forced to t. - -If OMIT-NULLS is t, zero-length substrings are omitted from the list \(so -that for the default value of SEPARATORS leading and trailing whitespace -are effectively trimmed). If nil, all zero-length substrings are retained, -which correctly parses CSV format, for example. - -Note that the effect of `(split-string STRING)' is the same as -`(split-string STRING split-string-default-separators t)'). In the rare -case that you wish to retain zero-length substrings when splitting on -whitespace, use `(split-string STRING split-string-default-separators)'. - -Modifies the match data; use `save-match-data' if necessary." - (let ((keep-nulls (not (if separators omit-nulls t))) - (rexp (or separators muse-backlink-split-string-default-separators)) - (start 0) - notfirst - (list nil)) - (while (and (string-match rexp string - (if (and notfirst - (= start (match-beginning 0)) - (< start (length string))) - (1+ start) start)) - (< start (length string))) - (setq notfirst t) - (if (or keep-nulls (< start (match-beginning 0))) - (setq list - (cons (substring string start (match-beginning 0)) - list))) - (setq start (match-end 0))) - (if (or keep-nulls (< start (length string))) - (setq list - (cons (substring string start) - list))) - (nreverse list)))) - (defalias 'muse-backlink-split-string 'split-string))) - -(defgroup muse-backlink nil - "Hierarchical backlinking for Muse." - :group 'muse) - -(defcustom muse-backlink-create-backlinks t - "When non-nil, create hierarchical backlinks in new Muse pages. -For control over which pages will receive backlinks, see -`muse-backlink-exclude-backlink-parent-regexp' and -`muse-backlink-exclude-backlink-regexp'." - :type 'boolean - :group 'muse-backlink) - -(defcustom muse-backlink-avoid-bad-links t - "When non-nil, avoid bad links when backlinking." - :type 'boolean - :group 'muse-backlink) - -;; The default for exclusion stops backlinks from being added to and -;; from planner day pages. -(defcustom muse-backlink-exclude-backlink-parent-regexp - "^[0-9][0-9][0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9]$" - "Regular expression matching pages whose children should not have backlinks." - :type 'regexp - :group 'muse-backlink) - -(defcustom muse-backlink-exclude-backlink-regexp - "^[0-9][0-9][0-9][0-9]\\.[0-9][0-9]\\.[0-9][0-9]$" - "Regular expression matching pages that should not have backlinks." - :type 'regexp - :group 'muse-backlink) - -(defcustom muse-backlink-separator "/" - "String that separates backlinks. -Should be something that will not appear as a substring in an explicit -link that has no description." - :type 'string - :group 'muse-backlink) - -(defcustom muse-backlink-before-string "backlinks: " - "String to come before the backlink list." - :type 'string - :group 'muse-backlink) - -(defcustom muse-backlink-after-string "" - "String to come after the backlink list." - :type 'string - :group 'muse-backlink) - -(defcustom muse-backlink-separator "/" - "String that separates backlinks. -Should be something that will not appear as a substring in an explicit -link that has no description." - :type 'string - :group 'muse-backlink) - -(defcustom muse-backlink-regexp - (concat "^" - (regexp-quote muse-backlink-before-string) - "\\(" - (regexp-quote muse-backlink-separator) - ".+\\)" - (regexp-quote muse-backlink-after-string)) - ;; Really, I want something like this, but I can't make it work: - ;; (concat "^\\(" - ;; (regexp-quote muse-backlink-separator) - ;; "\\(?:" - ;; muse-explicit-link-regexp - ;; "\\)\\)+") - "Regular expression to match backlinks in a buffer. -Match 1 is the list of backlinks without `muse-backlink-before-string' -and `muse-backlink-after-string'." - :type 'regexp - :group 'muse-backlink) - -(defun muse-backlink-goto-insertion-point () - "Find the right place to add backlinks." - (goto-char (point-min)) - (when (looking-at "\\(?:^#.+[ \t]*\n\\)+") - (goto-char (match-end 0)))) - -(defun muse-backlink-get-current () - "Return a list of backlinks in the current buffer." - (save-excursion - (goto-char (point-min)) - (when (re-search-forward muse-backlink-regexp nil t) - (muse-backlink-split-string - (match-string 1) - (regexp-quote muse-backlink-separator) t)))) - -(defun muse-backlink-format-link-list (links) - "Format the list of LINKS as backlinks." - (concat muse-backlink-separator - (mapconcat #'identity links muse-backlink-separator))) - -(defun muse-backlink-insert-links (links) - "Insert backlinks to LINKS into the current page. -LINKS is a list of links ordered by ancestry, with the parent as the -last element." - (muse-backlink-goto-insertion-point) - (insert muse-backlink-before-string - (muse-backlink-format-link-list links) - muse-backlink-after-string - ;; Could have this in the after string, but they might get - ;; deleted. - "\n\n")) - -(defun muse-backlink-unsaved-page-p (page project) - "Return non-nil if PAGE is in PROJECT but has not been saved." - (member - page - (mapcar - #'(lambda (b) - (with-current-buffer b - (and (derived-mode-p 'muse-mode) - (equal muse-current-project project) - (not (muse-project-page-file - (muse-page-name) - muse-current-project)) - (muse-page-name)))) - (buffer-list)))) - -(defvar muse-backlink-links nil - "Internal variable. -The links to insert in the forthcomingly visited muse page.") - -(defvar muse-backlink-pending nil - "Internal variable.") - -(defvar muse-backlink-parent-buffer nil - "Internal variable. -The parent buffer of the forthcomingly visited muse page.") - - -;;; Attach hook to the derived mode hook, to avoid problems such as -;;; planner-prepare-file thinking that the buffer needs no template. -(defun muse-backlink-get-mode-hook () - (derived-mode-hook-name major-mode)) - -(defun muse-backlink-insert-hook-func () - "Insert backlinks into the current buffer and clean up." - (when (and muse-backlink-links - muse-backlink-pending - (string= (car muse-backlink-links) (muse-page-name))) - (muse-backlink-insert-links (cdr muse-backlink-links)) - (when muse-backlink-avoid-bad-links - (save-buffer) - (when muse-backlink-parent-buffer - (with-current-buffer muse-backlink-parent-buffer - (font-lock-fontify-buffer)))) - (setq muse-backlink-links nil - muse-backlink-parent-buffer nil - muse-backlink-pending nil) - (remove-hook (muse-backlink-get-mode-hook) #'muse-backlink-insert-hook-func))) - -(defun muse-backlink-handle-link (link) - "When appropriate, arrange for backlinks on visiting LINK." - (when (and muse-backlink-create-backlinks - (not muse-backlink-pending) - (memq this-command - '(muse-follow-name-at-point muse-follow-name-at-mouse)) - (not muse-publishing-p) - (not (and (boundp 'muse-colors-fontifying-p) - muse-colors-fontifying-p))) - (require 'muse-mode) - (setq - muse-backlink-links - (save-match-data - (let* ((orig-link (or link (match-string 1))) - (link (if (string-match "#" orig-link) - (substring orig-link 0 (match-beginning 0)) - orig-link))) - (unless - (or (not muse-current-project) - (string-match muse-url-regexp orig-link) - (string-match muse-image-regexp orig-link) - (and (boundp 'muse-wiki-interwiki-regexp) - (string-match muse-wiki-interwiki-regexp - orig-link)) - ;; Don't add a backlink if the page already - ;; exists, whether it has been saved or not. - (or (muse-project-page-file link muse-current-project) - (muse-backlink-unsaved-page-p link muse-current-project)) - (string-match muse-backlink-exclude-backlink-parent-regexp - (muse-page-name)) - (string-match muse-backlink-exclude-backlink-regexp link)) - ;; todo: Hmm. This will only work if the child page is the - ;; same mode as the parent page. - (add-hook (muse-backlink-get-mode-hook) #'muse-backlink-insert-hook-func) - (setq muse-backlink-pending t) - (when muse-backlink-avoid-bad-links - (setq muse-backlink-parent-buffer (current-buffer)) - (unless (muse-project-page-file - (muse-page-name) muse-current-project) - ;; It must be modified... - (save-buffer))) - (cons link - (append (muse-backlink-get-current) - (list (muse-make-link (muse-page-name)))))))))) - ;; Make sure we always return nil - nil) - -(defun muse-backlink-install () - "Add backlinking functionality to muse-mode." - (add-to-list 'muse-explicit-link-functions #'muse-backlink-handle-link)) - -(defun muse-backlink-remove () - "Remove backlinking functionality from muse-mode." - (setq muse-explicit-link-functions - (delq #'muse-backlink-handle-link muse-explicit-link-functions))) - -(provide 'muse-backlink) -;;; muse-backlink.el ends here diff --git a/elpa/muse-3.20/muse-blosxom.el b/elpa/muse-3.20/muse-blosxom.el deleted file mode 100644 index 78038d7..0000000 --- a/elpa/muse-3.20/muse-blosxom.el +++ /dev/null @@ -1,306 +0,0 @@ -;;; muse-blosxom.el --- publish a document tree for serving by (py)Blosxom - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; Author: Michael Olson -;; Date: Wed, 23 March 2005 - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; The Blosxom publishing style publishes a tree of categorised files -;; to a mirrored tree of stories to be served by blosxom.cgi or -;; pyblosxom.cgi. -;; -;; Serving entries with (py)blosxom -;; -------------------------------- -;; -;; Each Blosxom file must include `#date yyyy-mm-dd', or optionally -;; the longer `#date yyyy-mm-dd-hh-mm', a title (using the `#title' -;; directive) plus whatever normal content is desired. -;; -;; The date directive is not used directly by (py)blosxom or this -;; program. You need to find two additional items to make use of this -;; feature. -;; -;; 1. A script to gather date directives from the entire blog tree -;; into a single file. The file must associate a blog entry with -;; a date. -;; -;; 2. A plugin for (py)blosxom that reads this file. -;; -;; These 2 things are provided for pyblosxom in the contrib/pyblosxom -;; subdirectory. `getstamps.py' provides the 1st service, while -;; `hardcodedates.py' provides the second service. Eventually it is -;; hoped that a blosxom plugin and script will be found/written. -;; -;; Alternately, the pyblosxom metadate plugin may be used. On the -;; plus side, there is no need to run a script to gather the date. On -;; the downside, each entry is read twice rather than once when the -;; page is rendered. Set the value of muse-blosxom-use-metadate to -;; non-nil to enable adding a #postdate directive to all published -;; files. You can do this by: -;; -;; M-x customize-variable RET muse-blosxom-use-metadate RET -;; -;; With the metadate plugin installed in pyblosxom, the date set in -;; this directive will be used instead of the file's modification -;; time. The plugin is included with Muse at -;; contrib/pyblosxom/metadate.py. -;; -;; Generating a Muse project entry -;; ------------------------------- -;; -;; Muse-blosxom has some helper functions to make specifying -;; muse-blosxom projects a lot easier. An example follows. -;; -;; (setq muse-project-alist -;; `(("blog" -;; (,@(muse-project-alist-dirs "~/path/to/blog-entries") -;; :default "index") -;; ,@(muse-project-alist-styles "~/path/to/blog-entries" -;; "~/public_html/blog" -;; "blosxom-xhtml") -;; ))) -;; -;; Note that we need a backtick instead of a single quote on the -;; second line of this example. -;; -;; Creating new blog entries -;; ------------------------- -;; -;; There is a function called `muse-blosxom-new-entry' that will -;; automate the process of making a new blog entry. To make use of -;; it, do the following. -;; -;; - Customize `muse-blosxom-base-directory' to the location that -;; your blog entries are stored. -;; -;; - Assign the `muse-blosxom-new-entry' function to a key sequence. -;; I use the following code to assign this function to `C-c p l'. -;; -;; (global-set-key "\C-cpl" 'muse-blosxom-new-entry) -;; -;; - You should create your directory structure ahead of time under -;; your base directory. These directories, which correspond with -;; category names, may be nested. -;; -;; - When you enter this key sequence, you will be prompted for the -;; category of your entry and its title. Upon entering this -;; information, a new file will be created that corresponds with -;; the title, but in lowercase letters and having special -;; characters converted to underscores. The title and date -;; directives will be inserted automatically. -;; -;; Using tags -;; ---------- -;; -;; If you wish to keep all of your blog entries in one directory and -;; use tags to classify your entries, set `muse-blosxom-use-tags' to -;; non-nil. -;; -;; For this to work, you will need to be using the PyBlosxom plugin at -;; http://pyblosxom.sourceforge.net/blog/registry/meta/Tags. - -;;; Contributors: - -;; Gary Vaughan (gary AT gnu DOT org) is the original author of -;; `emacs-wiki-blosxom.el', which is the ancestor of this file. - -;; Brad Collins (brad AT chenla DOT org) ported this file to Muse. - -;; Björn Lindström (bkhl AT elektrubadur DOT se) made many valuable -;; suggestions. - -;; Sasha Kovar (sasha AT arcocene DOT org) fixed -;; muse-blosxom-new-entry when using tags and also implemented support -;; for the #postdate directive. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse Blosxom Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-project) -(require 'muse-publish) -(require 'muse-html) - -(defgroup muse-blosxom nil - "Options controlling the behavior of Muse Blosxom publishing. -See `muse-blosxom' for more information." - :group 'muse-publish) - -(defcustom muse-blosxom-extension ".txt" - "Default file extension for publishing Blosxom files." - :type 'string - :group 'muse-blosxom) - -(defcustom muse-blosxom-header - "(concat (muse-publishing-directive \"title\") \"\\n\" - (when muse-blosxom-use-metadate - (let ((date (muse-publishing-directive \"date\"))) - (when date (concat \"#postdate \" - (muse-blosxom-format-date date) \"\\n\")))) - (when muse-blosxom-use-tags - (let ((tags (muse-publishing-directive \"tags\"))) - (when tags (concat \"#tags \" tags \"\\n\")))))" - "Header used for publishing Blosxom files. This may be text or a filename." - :type 'string - :group 'muse-blosxom) - -(defcustom muse-blosxom-footer "" - "Footer used for publishing Blosxom files. This may be text or a filename." - :type 'string - :group 'muse-blosxom) - -(defcustom muse-blosxom-base-directory "~/Blog" - "Base directory of blog entries. -This is the top-level directory where your Muse blog entries may be found." - :type 'directory - :group 'muse-blosxom) - -(defcustom muse-blosxom-use-tags nil - "Determine whether or not to enable use of the #tags directive. - -If you wish to keep all of your blog entries in one directory and -use tags to classify your entries, set `muse-blosxom-use-tags' to -non-nil. - -For this to work, you will need to be using the PyBlosxom plugin -at http://pyblosxom.sourceforge.net/blog/registry/meta/Tags." - :type 'boolean - :group 'muse-blosxom) - -(defcustom muse-blosxom-use-metadate nil - "Determine whether or not to use the #postdate directive. - -If non-nil, published entries include the original date (as specified -in the muse #date line) which can be read by the metadate PyBlosxom -plugin. - -For this to work, you will need to be using the PyBlosxom plugin -at http://pyblosxom.sourceforge.net/blog/registry/date/metadate." - :type 'boolean - :group 'muse-blosxom) - -;; Maintain (published-file . date) alist, which will later be written -;; to a timestamps file; not implemented yet. - -(defvar muse-blosxom-page-date-alist nil) - -(defun muse-blosxom-update-page-date-alist () - "Add a date entry to `muse-blosxom-page-date-alist' for this page." - (when muse-publishing-current-file - ;; Make current file be relative to base directory - (let ((rel-file - (concat - (file-name-as-directory - (or (muse-publishing-directive "category") - (file-relative-name - (file-name-directory - (expand-file-name muse-publishing-current-file)) - (file-truename muse-blosxom-base-directory)))) - (file-name-nondirectory muse-publishing-current-file)))) - ;; Strip the file extension - (when muse-ignored-extensions-regexp - (setq rel-file (save-match-data - (and (string-match muse-ignored-extensions-regexp - rel-file) - (replace-match "" t t rel-file))))) - ;; Add to page-date alist - (add-to-list - 'muse-blosxom-page-date-alist - `(,rel-file . ,(muse-publishing-directive "date")))))) - -;; Enter a new blog entry - -(defun muse-blosxom-title-to-file (title) - "Derive a file name from the given TITLE. - -Feel free to overwrite this if you have a different concept of what -should be allowed in a filename." - (muse-replace-regexp-in-string (concat "[^-." muse-regexp-alnum "]") - "_" (downcase title))) - -(defun muse-blosxom-format-date (date) - "Convert a date string to PyBlosxom metadate plugin format." - (apply #'format "%s-%s-%s %s:%s" (split-string date "-"))) - -;;;###autoload -(defun muse-blosxom-new-entry (category title) - "Start a new blog entry with given CATEGORY. -The filename of the blog entry is derived from TITLE. -The page will be initialized with the current date and TITLE." - (interactive - (list - (if muse-blosxom-use-tags - (let ((tag "foo") - (tags nil)) - (while (progn (setq tag (read-string "Tag (RET to continue): ")) - (not (string= tag ""))) - (add-to-list 'tags tag t)) - tags) - (funcall muse-completing-read-function - "Category: " - (mapcar 'list (muse-project-recurse-directory - muse-blosxom-base-directory)))) - (read-string "Title: "))) - (let ((file (muse-blosxom-title-to-file title))) - (muse-project-find-file - file "blosxom" nil - (if muse-blosxom-use-tags - (directory-file-name muse-blosxom-base-directory) - (concat (directory-file-name muse-blosxom-base-directory) - "/" category)))) - (goto-char (point-min)) - (insert "#date " (format-time-string "%Y-%m-%d-%H-%M") - "\n#title " title) - (if muse-blosxom-use-tags - (if (> (length category) 0) - (insert (concat "\n#tags " (mapconcat #'identity category ",")))) - (unless (string= category "") - (insert (concat "\n#category " category)))) - (insert "\n\n") - (forward-line 2)) - -;;; Register the Muse Blosxom Publisher - -(muse-derive-style "blosxom-html" "html" - :suffix 'muse-blosxom-extension - :link-suffix 'muse-html-extension - :header 'muse-blosxom-header - :footer 'muse-blosxom-footer - :after 'muse-blosxom-update-page-date-alist - :browser 'find-file) - -(muse-derive-style "blosxom-xhtml" "xhtml" - :suffix 'muse-blosxom-extension - :link-suffix 'muse-xhtml-extension - :header 'muse-blosxom-header - :footer 'muse-blosxom-footer - :after 'muse-blosxom-update-page-date-alist - :browser 'find-file) - -(provide 'muse-blosxom) - -;;; muse-blosxom.el ends here diff --git a/elpa/muse-3.20/muse-book.el b/elpa/muse-3.20/muse-book.el deleted file mode 100644 index 213a64e..0000000 --- a/elpa/muse-3.20/muse-book.el +++ /dev/null @@ -1,284 +0,0 @@ -;;; muse-book.el --- publish entries into a compilation - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;;; Contributors: - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse Book Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-publish) -(require 'muse-project) -(require 'muse-latex) -(require 'muse-regexps) - -(defgroup muse-book nil - "Module for publishing a series of Muse pages as a complete book. -Each page will become a separate chapter in the book, unless the -style keyword :nochapters is used, in which case they are all run -together as if one giant chapter." - :group 'muse-publish) - -(defcustom muse-book-before-publish-hook nil - "A hook run in the book buffer before it is marked up." - :type 'hook - :group 'muse-book) - -(defcustom muse-book-after-publish-hook nil - "A hook run in the book buffer after it is marked up." - :type 'hook - :group 'muse-book) - -(defcustom muse-book-latex-header - "\\documentclass{book} - -\\usepackage[english]{babel} -\\usepackage[latin1]{inputenc} -\\usepackage[T1]{fontenc} - -\\begin{document} - -\\title{(muse-publishing-directive \"title\")} -\\author{(muse-publishing-directive \"author\")} -\\date{(muse-publishing-directive \"date\")} - -\\maketitle - -\\tableofcontents\n" - "Header used for publishing books to LaTeX. This may be text or a filename." - :type 'string - :group 'muse-book) - -(defcustom muse-book-latex-footer - "(muse-latex-bibliography) -\\end{document}" - "Footer used for publishing books to LaTeX. This may be text or a filename." - :type 'string - :group 'muse-book) - -(defun muse-book-publish-chapter (title entry style &optional nochapters) - "Publish the chapter TITLE for the file ENTRY using STYLE. -TITLE is a string, ENTRY is a cons of the form (PAGE-NAME . -FILE), and STYLE is a Muse style list. - -This routine does the same basic work as `muse-publish-markup-buffer', -but treating the page as if it were a single chapter within a book." - (let ((muse-publishing-directives (list (cons "title" title))) - (muse-publishing-current-file (cdr entry)) - (beg (point)) end) - (muse-insert-file-contents (cdr entry)) - (setq end (copy-marker (point-max) t)) - (muse-publish-markup-region beg end (car entry) style) - (goto-char beg) - (unless (or nochapters - (muse-style-element :nochapters style)) - (insert "\n") - (muse-insert-markup (muse-markup-text 'chapter)) - (insert (let ((chap (muse-publishing-directive "title"))) - (if (string= chap title) - (car entry) - chap))) - (muse-insert-markup (muse-markup-text 'chapter-end)) - (insert "\n\n")) - (save-restriction - (narrow-to-region beg end) - (muse-publish-markup (or title "") - '((100 "<\\(lisp\\)>" 0 - muse-publish-markup-tag))) - (muse-style-run-hooks :after style)) - (goto-char end))) - -(defun muse-book-publish-p (project target) - "Determine whether the book in PROJECT is out-of-date." - (let ((pats (cadr project))) - (catch 'publish - (while pats - (if (symbolp (car pats)) - (if (eq :book-end (car pats)) - (throw 'publish nil) - ;; skip past symbol-value pair - (setq pats (cddr pats))) - (dolist (entry (muse-project-file-entries (car pats))) - (when (and (not (muse-project-private-p (cdr entry))) - (file-newer-than-file-p (cdr entry) target)) - (throw 'publish t))) - (setq pats (cdr pats))))))) - -(defun muse-book-get-directives (file) - "Interpret any publishing directives contained in FILE. -This is meant to be called in a temp buffer that will later be -used for publishing." - (save-restriction - (narrow-to-region (point) (point)) - (unwind-protect - (progn - (muse-insert-file-contents file) - (muse-publish-markup - "attributes" - `(;; Remove leading and trailing whitespace from the file - (100 "\\(\\`\n+\\|\n+\\'\\)" 0 "") - ;; Remove trailing whitespace from all lines - (200 ,(concat "[" muse-regexp-blank "]+$") 0 "") - ;; Handle any leading #directives - (300 "\\`#\\([a-zA-Z-]+\\)\\s-+\\(.+\\)\n+" - 0 muse-publish-markup-directive)))) - (delete-region (point-min) (point-max))))) - -(defun muse-book-publish-project - (project book title style &optional output-dir force) - "Publish PROJECT under the name BOOK with the given TITLE and STYLE. -BOOK should be a page name, i.e., letting the style determine the -prefix and/or suffix. The book is published to OUTPUT-DIR. If FORCE -is nil, the book is only published if at least one of its component -pages has changed since it was last published." - (interactive - (let ((project (muse-read-project "Publish project as book: " nil t))) - (append (list project - (read-string "Basename of book (without extension): ") - (read-string "Title of book: ")) - (muse-publish-get-info)))) - (setq project (muse-project project)) - (let ((muse-current-project project)) - ;; See if any of the project's files need saving first - (muse-project-save-buffers project) - ;; Publish the book - (muse-book-publish book style output-dir force title))) - -(defun muse-book-publish (file style &optional output-dir force title) - "Publish FILE as a book with the given TITLE and STYLE. -The book is published to OUTPUT-DIR. If FORCE is nil, the book -is only published if at least one of its component pages has -changed since it was last published." - ;; Cleanup some of the arguments - (let ((style-name style)) - (setq style (muse-style style)) - (unless style - (error "There is no style '%s' defined" style-name))) - ;; Publish each page in the project as a chapter in one large book - (let* ((output-path (muse-publish-output-file file output-dir style)) - (output-suffix (muse-style-element :osuffix style)) - (target output-path) - (project muse-current-project) - (published nil)) - (when output-suffix - (setq target (concat (muse-path-sans-extension target) - output-suffix))) - ;; Unless force is non-nil, determine if the book needs publishing - (if (and (not force) - (not (muse-book-publish-p project target))) - (message "The book \"%s\" is up-to-date." file) - ;; Create the book from all its component parts - (muse-with-temp-buffer - (let ((style-final (muse-style-element :final style t)) - (style-header (muse-style-element :header style)) - (style-footer (muse-style-element :footer style)) - (muse-publishing-current-style style) - (muse-publishing-directives - (list (cons "title" (or title (muse-page-name file))) - (cons "date" (format-time-string "%B %e, %Y")))) - (muse-publishing-p t) - (muse-current-project project) - (pats (cadr project)) - (nochapters nil)) - (run-hooks 'muse-before-book-publish-hook) - (let ((style-final style-final) - (style-header style-header) - (style-footer style-footer)) - (unless title - (muse-book-get-directives file) - (setq title (muse-publishing-directive "title"))) - (while pats - (if (symbolp (car pats)) - (cond - ((eq :book-part (car pats)) - (insert "\n") - (muse-insert-markup (muse-markup-text 'part)) - (insert (cadr pats)) - (muse-insert-markup (muse-markup-text 'part-end)) - (insert "\n") - (setq pats (cddr pats))) - ((eq :book-chapter (car pats)) - (insert "\n") - (muse-insert-markup (muse-markup-text 'chapter)) - (insert (cadr pats)) - (muse-insert-markup (muse-markup-text 'chapter-end)) - (insert "\n") - (setq pats (cddr pats))) - ((eq :nochapters (car pats)) - (setq nochapters t - pats (cddr pats))) - ((eq :book-style (car pats)) - (setq style (muse-style (cadr pats))) - (setq style-final (muse-style-element :final style t) - style-header (muse-style-element :header style) - style-footer (muse-style-element :footer style) - muse-publishing-current-style style) - (setq pats (cddr pats))) - ((eq :book-funcall (car pats)) - (funcall (cadr pats)) - (setq pats (cddr pats))) - ((eq :book-end (car pats)) - (setq pats nil)) - (t - (setq pats (cddr pats)))) - (let ((entries (muse-project-file-entries (car pats)))) - (while (and entries (car entries) (caar entries)) - (unless (muse-project-private-p (cdar entries)) - (muse-book-publish-chapter title (car entries) - style nochapters) - (setq published t)) - (setq entries (cdr entries)))) - (setq pats (cdr pats))))) - (goto-char (point-min)) - (if style-header (muse-insert-file-or-string style-header file)) - (goto-char (point-max)) - (if style-footer (muse-insert-file-or-string style-footer file)) - (run-hooks 'muse-after-book-publish-hook) - (if (muse-write-file output-path) - (if style-final - (funcall style-final file output-path target)) - (setq published nil))))) - (if published - (message "The book \"%s\" has been published." file)) - published)) - -;;; Register the Muse BOOK Publishers - -(muse-derive-style "book-latex" "latex" - :header 'muse-book-latex-header - :footer 'muse-book-latex-footer - :publish 'muse-book-publish) - -(muse-derive-style "book-pdf" "pdf" - :header 'muse-book-latex-header - :footer 'muse-book-latex-footer - :publish 'muse-book-publish) - -(provide 'muse-book) - -;;; muse-book.el ends here diff --git a/elpa/muse-3.20/muse-colors.el b/elpa/muse-3.20/muse-colors.el deleted file mode 100644 index 132310d..0000000 --- a/elpa/muse-3.20/muse-colors.el +++ /dev/null @@ -1,1019 +0,0 @@ -;;; muse-colors.el --- coloring and highlighting used by Muse - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; Author: John Wiegley (johnw AT gnu DOT org) -;; Keywords: hypermedia -;; Date: Thu 11-Mar-2004 - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;;; Contributors: - -;; Lan Yufeng (nlany DOT web AT gmail DOT com) found an error where -;; headings were being given the wrong face, contributing a patch to -;; fix this. - -;; Sergey Vlasov (vsu AT altlinux DOT ru) fixed an issue with coloring -;; links that are in consecutive lines. - -;; Jim Ottaway ported the tag from emacs-wiki. - -;; Per B. Sederberg (per AT med DOT upenn DOT edu) contributed the -;; viewing of inline images. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Emacs Muse Highlighting -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-mode) -(require 'muse-regexps) -(require 'font-lock) - -(defgroup muse-colors nil - "Options controlling the behavior of Emacs Muse highlighting. -See `muse-colors-buffer' for more information." - :group 'muse-mode) - -(defcustom muse-colors-autogen-headings t - "Specify whether the heading faces should be auto-generated. -The default is to scale them. - -Choosing 'outline will copy the colors from the outline-mode -headings. - -If you want to customize each of the headings individually, set -this to nil." - :type '(choice (const :tag "Default (scaled) headings" t) - (const :tag "Use outline-mode headings" outline) - (const :tag "Don't touch the headings" nil)) - :group 'muse-colors) - -(defcustom muse-colors-evaluate-lisp-tags t - "Specify whether to evaluate the contents of tags at -display time. If nil, don't evaluate them. If non-nil, evaluate -them. - -The actual contents of the buffer are not changed, only the -displayed text." - :type 'boolean - :group 'muse-colors) - -(defcustom muse-colors-inline-images t - "Specify whether to inline images inside the Emacs buffer. If -nil, don't inline them. If non-nil, an image link will be -replaced by the image. - -The actual contents of the buffer are not changed, only whether -an image is displayed." - :type 'boolean - :group 'muse-colors) - -(defcustom muse-colors-inline-image-method 'default-directory - "Determine how to locate inline images. -Setting this to 'default-directory uses the current directory of -the current Muse buffer. - -Setting this to a function calls that function with the filename -of the image to be inlined. The value that is returned will be -used as the filename of the image." - :type '(choice (const :tag "Current directory" default-directory) - (const :tag "Publishing directory" - muse-colors-use-publishing-directory) - (function :tag "Custom function")) - :group 'muse-colors) - -(defvar muse-colors-region-end nil - "Indicate the end of the region that is currently being font-locked.") -(make-variable-buffer-local 'muse-colors-region-end) - -;;;###autoload -(defun muse-colors-toggle-inline-images () - "Toggle display of inlined images on/off." - (interactive) - ;; toggle the custom setting - (if (not muse-colors-inline-images) - (setq muse-colors-inline-images t) - (setq muse-colors-inline-images nil)) - ;; reprocess the buffer - (muse-colors-buffer) - ;; display informative message - (if muse-colors-inline-images - (message "Images are now displayed inline") - (message "Images are now displayed as links"))) - -(defvar muse-colors-outline-faces-list - (if (facep 'outline-1) - '(outline-1 outline-2 outline-3 outline-4 outline-5) - ;; these are equivalent in coloring to the outline faces - '(font-lock-function-name-face - font-lock-variable-name-face - font-lock-keyword-face - font-lock-builtin-face - font-lock-comment-face)) - "Outline faces to use when assigning Muse header faces.") - -(defun muse-make-faces-default (&optional later) - "Generate the default face definitions for headers." - (dolist (num '(1 2 3 4 5)) - (let ((newsym (intern (concat "muse-header-" (int-to-string num)))) - (docstring (concat - "Muse header face. See " - "`muse-colors-autogen-headings' before changing it."))) - ;; put in the proper group and give documentation - (if later - (unless (featurep 'xemacs) - (muse-copy-face 'variable-pitch newsym) - (set-face-attribute newsym nil :height (1+ (* 0.1 (- 5 num))) - :weight 'bold)) - (if (featurep 'xemacs) - (eval `(defface ,newsym - '((t (:size - ,(nth (1- num) - '("24pt" "18pt" "14pt" "12pt" "11pt")) - :bold t))) - ,docstring - :group 'muse-colors)) - (eval `(defface ,newsym - '((t (:height ,(1+ (* 0.1 (- 5 num))) - :inherit variable-pitch - :weight bold))) - ,docstring - :group 'muse-colors))))))) - -(progn (muse-make-faces-default)) - -(defun muse-make-faces (&optional frame) - "Generate face definitions for headers based the user's preferences." - (cond - ((not muse-colors-autogen-headings) - nil) - ((eq muse-colors-autogen-headings t) - (muse-make-faces-default t)) - (t - (dolist (num '(1 2 3 4 5)) - (let ((newsym (intern (concat "muse-header-" (int-to-string num))))) - ;; copy the desired face definition - (muse-copy-face (nth (1- num) muse-colors-outline-faces-list) - newsym)))))) - -;; after displaying the Emacs splash screen, the faces are wiped out, -;; so recover from that -(add-hook 'window-setup-hook #'muse-make-faces) -;; ditto for when a new frame is created -(when (boundp 'after-make-frame-functions) - (add-hook 'after-make-frame-functions #'muse-make-faces)) - -(defface muse-link - '((t :inherit link)) - "Face for Muse cross-references." - :group 'muse-colors) - -(defface muse-bad-link - '((default :inherit link) - (((class color) (background light)) - (:foreground "red" :underline "red" :bold t)) - (((class color) (background dark)) - (:foreground "coral" :underline "coral" :bold t)) - (t (:bold t))) - "Face for bad Muse cross-references." - :group 'muse-colors) - -(defface muse-verbatim - '((((class color) (background light)) - (:foreground "slate gray")) - (((class color) (background dark)) - (:foreground "gray"))) - "Face for verbatim text." - :group 'muse-colors) - -(defface muse-emphasis-1 - '((t (:italic t))) - "Face for italic emphasized text." - :group 'muse-colors) - -(defface muse-emphasis-2 - '((t (:bold t))) - "Face for bold emphasized text." - :group 'muse-colors) - -(defface muse-emphasis-3 - '((t (:bold t :italic t))) - "Face for bold italic emphasized text." - :group 'muse-colors) - -(muse-copy-face 'italic 'muse-emphasis-1) -(muse-copy-face 'bold 'muse-emphasis-2) -(muse-copy-face 'bold-italic 'muse-emphasis-3) - -(defcustom muse-colors-buffer-hook nil - "A hook run after a region is highlighted. -Each function receives three arguments: BEG END VERBOSE. -BEG and END mark the range being highlighted, and VERBOSE specifies -whether progress messages should be displayed to the user." - :type 'hook - :group 'muse-colors) - -(defvar muse-colors-highlighting-registry nil - "The rules for highlighting Muse and Muse-derived buffers. -This is automatically generated when using font-lock in Muse buffers. - -This an alist of major-mode symbols to `muse-colors-rule' objects.") - -(defun muse-colors-make-highlighting-struct () - (list nil nil nil)) -(defconst muse-colors-highlighting.regexp 0 - "Regexp matching each car of the markup of the current rule.") -(defconst muse-colors-highlighting.vector 1 - "Vector of all characters that are part of the markup of the current rule. -This is composed of the 2nd element of each markup entry.") -(defconst muse-colors-highlighting.remaining 2 - "Expressions for highlighting a buffer which have no corresponding -entry in the vector.") - -(defsubst muse-colors-highlighting-entry (mode) - "Return the highlighting rules for MODE." - (assq mode muse-colors-highlighting-registry)) - -(defun muse-colors-find-highlighting (mode) - "Return the highlighting rules to be used for MODE. -If MODE does not have highlighting rules, check its parent modes." - (let ((seen nil)) - (catch 'rules - (while (and mode (not (memq mode seen))) - (let ((entry (muse-colors-highlighting-entry mode))) - (when entry (throw 'rules (cdr entry)))) - (setq seen (cons mode seen)) - (setq mode (get mode 'derived-mode-parent))) - nil))) - -(defun muse-colors-define-highlighting (mode markup) - "Create or update the markup rules for MODE, using MARKUP. - -See `muse-colors-markup' for an explanation of the format that MARKUP -should take." - (unless (and (symbolp mode) mode (consp markup)) - (error "Invalid arguments")) - (let* ((highlighting-entry (muse-colors-highlighting-entry mode)) - (struct (cdr highlighting-entry)) - (regexp nil) - (vector nil) - (remaining nil)) - ;; Initialize struct - (if struct - (setq vector (nth muse-colors-highlighting.vector struct)) - (setq struct (muse-colors-make-highlighting-struct))) - ;; Initialize vector - (if vector - (let ((i 0)) - (while (< i 128) - (aset vector i nil) - (setq i (1+ i)))) - (setq vector (make-vector 128 nil))) - ;; Determine vector, regexp, remaining - (let ((regexps nil) - (rules nil)) - (dolist (rule markup) - (let ((value (cond ((symbolp (car rule)) - (symbol-value (car rule))) - ((stringp (car rule)) - (car rule)) - (t nil)))) - (when value - (setq rules (cons rule rules)) - (setq regexps (cons value regexps))))) - (setq regexps (nreverse regexps)) - (setq regexp (concat "\\(" (mapconcat #'identity regexps "\\|") "\\)")) - (dolist (rule rules) - (if (eq (nth 1 rule) t) - (setq remaining (cons (cons (nth 0 rule) (nth 2 rule)) - remaining)) - (aset vector (nth 1 rule) - (cons (cons (nth 0 rule) (nth 2 rule)) - (aref vector (nth 1 rule))))))) - ;; Update the struct - (setcar (nthcdr muse-colors-highlighting.regexp struct) regexp) - (setcar (nthcdr muse-colors-highlighting.vector struct) vector) - (setcar (nthcdr muse-colors-highlighting.remaining struct) remaining) - ;; Update entry for mode in muse-colors-highlighting-registry - (if highlighting-entry - (setcdr highlighting-entry struct) - (setq muse-colors-highlighting-registry - (cons (cons mode struct) - muse-colors-highlighting-registry))))) - -(defun muse-configure-highlighting (sym val) - "Extract color markup information from VAL and set to SYM. -This is usually called with `muse-colors-markup' as both arguments." - (muse-colors-define-highlighting 'muse-mode val) - (set sym val)) - -(defun muse-colors-emphasized () - "Color emphasized text and headings." - ;; Here we need to check four different points - the start and end - ;; of the leading *s, and the start and end of the trailing *s. We - ;; allow the outsides to be surrounded by whitespace or punctuation, - ;; but no word characters, and the insides must not be surrounded by - ;; whitespace or punctuation. Thus the following are valid: - ;; - ;; " *foo bar* " - ;; "**foo**," - ;; and the following is invalid: - ;; "** testing **" - (let* ((beg (match-beginning 0)) - (e1 (match-end 0)) - (leader (- e1 beg)) - b2 e2 multiline) - (unless (or (eq (get-text-property beg 'invisible) 'muse) - (get-text-property beg 'muse-comment) - (get-text-property beg 'muse-directive)) - ;; check if it's a header - (if (eq (char-after e1) ?\ ) - (when (or (= beg (point-min)) - (eq (char-before beg) ?\n)) - (add-text-properties - (muse-line-beginning-position) (muse-line-end-position) - (list 'face (intern (concat "muse-header-" - (int-to-string leader)))))) - ;; beginning of line or space or symbol - (when (or (= beg (point-min)) - (eq (char-syntax (char-before beg)) ?\ ) - (memq (char-before beg) - '(?\- ?\[ ?\< ?\( ?\' ?\` ?\" ?\n))) - (save-excursion - (skip-chars-forward "^*<>\n" muse-colors-region-end) - (when (eq (char-after) ?\n) - (setq multiline t) - (skip-chars-forward "^*<>" muse-colors-region-end)) - (setq b2 (point)) - (skip-chars-forward "*" muse-colors-region-end) - (setq e2 (point)) - ;; Abort if space exists just before end - ;; or bad leader - ;; or no '*' at end - ;; or word constituent follows - (unless (or (> leader 5) - (not (eq leader (- e2 b2))) - (eq (char-syntax (char-before b2)) ?\ ) - (not (eq (char-after b2) ?*)) - (and (not (eobp)) - (eq (char-syntax (char-after (1+ b2))) ?w))) - (add-text-properties beg e1 '(invisible muse)) - (add-text-properties - e1 b2 (list 'face (cond ((= leader 1) 'muse-emphasis-1) - ((= leader 2) 'muse-emphasis-2) - ((= leader 3) 'muse-emphasis-3)))) - (add-text-properties b2 e2 '(invisible muse)) - (when multiline - (add-text-properties - beg e2 '(font-lock-multiline t)))))))))) - -(defun muse-colors-underlined () - "Color underlined text." - (let ((start (match-beginning 0)) - multiline) - (unless (or (eq (get-text-property start 'invisible) 'muse) - (get-text-property start 'muse-comment) - (get-text-property start 'muse-directive)) - ;; beginning of line or space or symbol - (when (or (= start (point-min)) - (eq (char-syntax (char-before start)) ?\ ) - (memq (char-before start) - '(?\- ?\[ ?\< ?\( ?\' ?\` ?\" ?\n))) - (save-excursion - (skip-chars-forward "^_<>\n" muse-colors-region-end) - (when (eq (char-after) ?\n) - (setq multiline t) - (skip-chars-forward "^_<>" muse-colors-region-end)) - ;; Abort if space exists just before end - ;; or no '_' at end - ;; or word constituent follows - (unless (or (eq (char-syntax (char-before (point))) ?\ ) - (not (eq (char-after (point)) ?_)) - (and (not (eobp)) - (eq (char-syntax (char-after (1+ (point)))) ?w))) - (add-text-properties start (1+ start) '(invisible muse)) - (add-text-properties (1+ start) (point) '(face underline)) - (add-text-properties (point) - (min (1+ (point)) (point-max)) - '(invisible muse)) - (when multiline - (add-text-properties - start (min (1+ (point)) (point-max)) - '(font-lock-multiline t))))))))) - -(defun muse-colors-verbatim () - "Render in teletype and suppress further parsing." - (let ((start (match-beginning 0)) - multiline) - (unless (or (eq (get-text-property start 'invisible) 'muse) - (get-text-property start 'muse-comment) - (get-text-property start 'muse-directive)) - ;; beginning of line or space or symbol - (when (or (= start (point-min)) - (eq (char-syntax (char-before start)) ?\ ) - (memq (char-before start) - '(?\- ?\[ ?\< ?\( ?\' ?\` ?\" ?\n))) - (let ((pos (point))) - (skip-chars-forward "^=\n" muse-colors-region-end) - (when (eq (char-after) ?\n) - (setq multiline t) - (skip-chars-forward "^=" muse-colors-region-end)) - ;; Abort if space exists just before end - ;; or no '=' at end - ;; or word constituent follows - (unless (or (eq (char-syntax (char-before (point))) ?\ ) - (not (eq (char-after (point)) ?=)) - (and (not (eobp)) - (eq (char-syntax (char-after (1+ (point)))) ?w))) - (setq pos (min (1+ (point)) (point-max))) - (add-text-properties start (1+ start) '(invisible muse)) - (add-text-properties (1+ start) (point) '(face muse-verbatim)) - (add-text-properties (point) - (min (1+ (point)) (point-max)) - '(invisible muse)) - (when multiline - (add-text-properties - start (min (1+ (point)) (point-max)) - '(font-lock-multiline t)))) - (goto-char pos)))))) - -(defcustom muse-colors-markup - `(;; make emphasized text appear emphasized - ("\\*\\{1,5\\}" ?* muse-colors-emphasized) - - ;; make underlined text appear underlined - (,(concat "_[^" muse-regexp-blank "_\n]") - ?_ muse-colors-underlined) - - ("^#title " ?\# muse-colors-title) - - (muse-explicit-link-regexp ?\[ muse-colors-explicit-link) - - ;; render in teletype and suppress further parsing - (,(concat "=[^" muse-regexp-blank "=\n]") ?= muse-colors-verbatim) - - ;; highlight any markup tags encountered - (muse-tag-regexp ?\< muse-colors-custom-tags) - - ;; display comments - (,(concat "^;[" muse-regexp-blank "]") ?\; muse-colors-comment) - - ;; this has to come later since it doesn't have a special - ;; character in the second cell - (muse-url-regexp t muse-colors-implicit-link) - ) - "Expressions to highlight an Emacs Muse buffer. -These are arranged in a rather special fashion, so as to be as quick as -possible. - -Each element of the list is itself a list, of the form: - - (LOCATE-REGEXP TEST-CHAR MATCH-FUNCTION) - -LOCATE-REGEXP is a partial regexp, and should be the smallest possible -regexp to differentiate this rule from other rules. It may also be a -symbol containing such a regexp. The buffer region is scanned only -once, and LOCATE-REGEXP indicates where the scanner should stop to -look for highlighting possibilities. - -TEST-CHAR is a char or t. The character should match the beginning -text matched by LOCATE-REGEXP. These chars are used to build a vector -for fast MATCH-FUNCTION calling. - -MATCH-FUNCTION is the function called when a region has been -identified. It is responsible for adding the appropriate text -properties to change the appearance of the buffer. - -This markup is used to modify the appearance of the original text to -make it look more like the published HTML would look (like making some -markup text invisible, inlining images, etc). - -font-lock is used to apply the markup rules, so that they can happen -on a deferred basis. They are not always accurate, but you can use -\\[font-lock-fontifty-block] near the point of error to force -fontification in that area." - :type '(repeat - (list :tag "Highlight rule" - (choice (regexp :tag "Locate regexp") - (symbol :tag "Regexp symbol")) - (choice (character :tag "Confirm character") - (const :tag "Default rule" t)) - function)) - :set 'muse-configure-highlighting - :group 'muse-colors) - -;; XEmacs users don't have `font-lock-multiline'. -(unless (boundp 'font-lock-multiline) - (defvar font-lock-multiline nil)) - -(defun muse-use-font-lock () - "Set up font-locking for Muse." - (muse-add-to-invisibility-spec 'muse) - (set (make-local-variable 'font-lock-multiline) 'undecided) - (set (make-local-variable 'font-lock-defaults) - `(nil t nil nil beginning-of-line - (font-lock-fontify-region-function . muse-colors-region) - (font-lock-unfontify-region-function - . muse-unhighlight-region))) - (set (make-local-variable 'font-lock-fontify-region-function) - 'muse-colors-region) - (set (make-local-variable 'font-lock-unfontify-region-function) - 'muse-unhighlight-region) - (muse-make-faces) - (muse-colors-define-highlighting 'muse-mode muse-colors-markup) - (font-lock-mode t)) - -(defun muse-colors-buffer () - "Re-highlight the entire Muse buffer." - (interactive) - (muse-colors-region (point-min) (point-max) t)) - -(defvar muse-colors-fontifying-p nil - "Indicate whether Muse is fontifying the current buffer.") -(make-variable-buffer-local 'muse-colors-fontifying-p) - -(defvar muse-colors-delayed-commands nil - "Commands to be run immediately after highlighting a region. - -This is meant to accommodate highlighting in #title -directives after everything else. - -It may be modified by Muse functions during highlighting, but not -the user.") -(make-variable-buffer-local 'muse-colors-delayed-commands) - -(defun muse-colors-region (beg end &optional verbose) - "Apply highlighting according to `muse-colors-markup'. -Note that this function should NOT change the buffer, nor should any -of the functions listed in `muse-colors-markup'." - (let ((buffer-undo-list t) - (inhibit-read-only t) - (inhibit-point-motion-hooks t) - (inhibit-modification-hooks t) - (modified-p (buffer-modified-p)) - (muse-colors-fontifying-p t) - (muse-colors-region-end (muse-line-end-position end)) - (muse-colors-delayed-commands nil) - (highlighting (muse-colors-find-highlighting major-mode)) - regexp vector remaining - deactivate-mark) - (unless highlighting - (error "No highlighting found for this mode")) - (setq regexp (nth muse-colors-highlighting.regexp highlighting) - vector (nth muse-colors-highlighting.vector highlighting) - remaining (nth muse-colors-highlighting.remaining highlighting)) - (unwind-protect - (save-excursion - (save-restriction - (widen) - ;; check to see if we should expand the beg/end area for - ;; proper multiline matches - (when (and font-lock-multiline - (> beg (point-min)) - (get-text-property (1- beg) 'font-lock-multiline)) - ;; We are just after or in a multiline match. - (setq beg (or (previous-single-property-change - beg 'font-lock-multiline) - (point-min))) - (goto-char beg) - (setq beg (muse-line-beginning-position))) - (when font-lock-multiline - (setq end (or (text-property-any end (point-max) - 'font-lock-multiline nil) - (point-max)))) - (goto-char end) - (setq end (muse-line-beginning-position 2)) - ;; Undo any fontification in the area. - (font-lock-unfontify-region beg end) - ;; And apply fontification based on `muse-colors-markup' - (let ((len (float (- end beg))) - (case-fold-search nil) - markup-list) - (goto-char beg) - (while (and (< (point) end) - (re-search-forward regexp end t)) - (if verbose - (message "Highlighting buffer...%d%%" - (* (/ (float (- (point) beg)) len) 100))) - (let ((ch (char-after (match-beginning 0)))) - (when (< ch 128) - (setq markup-list (aref vector ch)))) - (unless markup-list - (setq markup-list remaining)) - (let ((prev (point))) - ;; backtrack and figure out which rule matched - (goto-char (match-beginning 0)) - (catch 'done - (dolist (entry markup-list) - (let ((value (cond ((symbolp (car entry)) - (symbol-value (car entry))) - ((stringp (car entry)) - (car entry)) - (t nil)))) - (when (and (stringp value) (looking-at value)) - (goto-char (match-end 0)) - (when (cdr entry) - (funcall (cdr entry))) - (throw 'done t)))) - ;; if no rule matched, which should never happen, - ;; return to previous position so that forward - ;; progress is ensured - (goto-char prev)))) - (dolist (command muse-colors-delayed-commands) - (apply (car command) (cdr command))) - (run-hook-with-args 'muse-colors-buffer-hook - beg end verbose) - (if verbose (message "Highlighting buffer...done"))))) - (set-buffer-modified-p modified-p)))) - -(defcustom muse-colors-tags - '(("example" t nil nil muse-colors-example-tag) - ("code" t nil nil muse-colors-example-tag) - ("verbatim" t nil nil muse-colors-literal-tag) - ("lisp" t t nil muse-colors-lisp-tag) - ("literal" t nil nil muse-colors-literal-tag)) - "A list of tag specifications for specially highlighting text. -XML-style tags are the best way to add custom highlighting to Muse. -This is easily accomplished by customizing this list of markup tags. - -For each entry, the name of the tag is given, whether it expects -a closing tag and/or an optional set of attributes, whether it is -nestable, and a function that performs whatever action is desired -within the delimited region. - -The function is called with three arguments, the beginning and -end of the region surrounded by the tags. If properties are -allowed, they are passed as a third argument in the form of an -alist. The `end' argument to the function is the last character -of the enclosed tag or region. - -Functions should not modify the contents of the buffer." - :type '(repeat (list (string :tag "Markup tag") - (boolean :tag "Expect closing tag" :value t) - (boolean :tag "Parse attributes" :value nil) - (boolean :tag "Nestable" :value nil) - function)) - :group 'muse-colors) - -(defvar muse-colors-inhibit-tags-in-directives t - "If non-nil, don't allow tags to be interpreted in directives. -This is used to delay highlighting of tags in #title until later.") -(make-variable-buffer-local 'muse-colors-inhibit-tags-in-directives) - -(defsubst muse-colors-tag-info (tagname &rest args) - "Get tag info associated with TAGNAME, ignoring ARGS." - (assoc tagname muse-colors-tags)) - -(defun muse-colors-custom-tags () - "Highlight `muse-colors-tags'." - (let ((tag-info (muse-colors-tag-info (match-string 1)))) - (unless (or (not tag-info) - (get-text-property (match-beginning 0) 'muse-comment) - (and muse-colors-inhibit-tags-in-directives - (get-text-property (match-beginning 0) 'muse-directive))) - (let ((closed-tag (match-string 3)) - (start (match-beginning 0)) - end attrs) - (when (nth 2 tag-info) - (let ((attrstr (match-string 2))) - (while (and attrstr - (string-match (concat "\\([^" - muse-regexp-blank - "=\n]+\\)\\(=\"" - "\\([^\"]+\\)\"\\)?") - attrstr)) - (let ((attr (cons (downcase - (muse-match-string-no-properties 1 attrstr)) - (muse-match-string-no-properties 3 attrstr)))) - (setq attrstr (replace-match "" t t attrstr)) - (if attrs - (nconc attrs (list attr)) - (setq attrs (list attr))))))) - (if (and (cadr tag-info) (not closed-tag)) - (if (muse-goto-tag-end (car tag-info) (nth 3 tag-info)) - (setq end (match-end 0)) - (setq tag-info nil))) - (when tag-info - (let ((args (list start end))) - (if (nth 2 tag-info) - (nconc args (list attrs))) - (apply (nth 4 tag-info) args))))))) - -(defun muse-unhighlight-region (begin end &optional verbose) - "Remove all visual highlights in the buffer (except font-lock)." - (let ((buffer-undo-list t) - (inhibit-read-only t) - (inhibit-point-motion-hooks t) - (inhibit-modification-hooks t) - (modified-p (buffer-modified-p)) - deactivate-mark) - (unwind-protect - (remove-text-properties - begin end '(face nil font-lock-multiline nil end-glyph nil - invisible nil intangible nil display nil - mouse-face nil keymap nil help-echo nil - muse-link nil muse-directive nil muse-comment nil - muse-no-implicit-link nil muse-no-flyspell nil)) - (set-buffer-modified-p modified-p)))) - -(defun muse-colors-example-tag (beg end) - "Strip properties and colorize with `muse-verbatim'." - (muse-unhighlight-region beg end) - (let ((multi (save-excursion - (goto-char beg) - (forward-line 1) - (> end (point))))) - (add-text-properties beg end `(face muse-verbatim - font-lock-multiline ,multi)))) - -(defun muse-colors-literal-tag (beg end) - "Strip properties and mark as literal." - (muse-unhighlight-region beg end) - (let ((multi (save-excursion - (goto-char beg) - (forward-line 1) - (> end (point))))) - (add-text-properties beg end `(font-lock-multiline ,multi)))) - -(defun muse-colors-lisp-tag (beg end attrs) - "Color the region enclosed by a tag." - (if (not muse-colors-evaluate-lisp-tags) - (muse-colors-literal-tag beg end) - (muse-unhighlight-region beg end) - (let (beg-lisp end-lisp) - (save-match-data - (goto-char beg) - (setq beg-lisp (and (looking-at "<[^>]+>") - (match-end 0))) - (goto-char end) - (setq end-lisp (and (muse-looking-back "]+>") - (match-beginning 0)))) - (add-text-properties - beg end - (list 'font-lock-multiline t - 'display (muse-eval-lisp - (concat - "(progn " - (buffer-substring-no-properties beg-lisp end-lisp) - ")")) - 'intangible t))))) - -(defvar muse-mode-local-map - (let ((map (make-sparse-keymap))) - (define-key map [return] 'muse-follow-name-at-point) - (define-key map [(control ?m)] 'muse-follow-name-at-point) - (define-key map [(shift return)] 'muse-follow-name-at-point-other-window) - (if (featurep 'xemacs) - (progn - (define-key map [(button2)] 'muse-follow-name-at-mouse) - (define-key map [(shift button2)] - 'muse-follow-name-at-mouse-other-window)) - (define-key map [(shift control ?m)] - 'muse-follow-name-at-point-other-window) - (define-key map [mouse-2] 'muse-follow-name-at-mouse) - (define-key map [(shift mouse-2)] - 'muse-follow-name-at-mouse-other-window) - (unless (eq emacs-major-version 21) - (set-keymap-parent map muse-mode-map))) - map) - "Local keymap used by Muse while on a link.") - -(defvar muse-keymap-property - (if (or (featurep 'xemacs) - (>= emacs-major-version 21)) - 'keymap - 'local-map) - "The name of the keymap or local-map property.") - -(defsubst muse-link-properties (help-str &optional face) - "Determine text properties to use for a link." - (append (if face - (list 'face face 'mouse-face 'highlight 'muse-link t) - (list 'invisible 'muse 'intangible t)) - (list 'help-echo help-str 'rear-nonsticky t - muse-keymap-property muse-mode-local-map))) - -(defun muse-link-face (link-name &optional explicit) - "Return the type of LINK-NAME as a face symbol. -For EXPLICIT links, this is either a normal link or a bad-link -face. For implicit links, it is either colored normally or -ignored." - (save-match-data - (let ((link (if explicit - (muse-handle-explicit-link link-name) - (muse-handle-implicit-link link-name)))) - (when link - (cond ((string-match muse-url-regexp link) - 'muse-link) - ((muse-file-remote-p link) - 'muse-link) - ((string-match muse-file-regexp link) - (when (string-match "/[^/]+#[^#./]+\\'" link) - ;; strip anchor from the end of a path - (setq link (substring link 0 (match-beginning 0)))) - (if (file-exists-p link) - 'muse-link - 'muse-bad-link)) - ((not (featurep 'muse-project)) - 'muse-link) - (t - (if (string-match "#" link) - (setq link (substring link 0 (match-beginning 0)))) - (if (or (and (muse-project-of-file) - (muse-project-page-file - link muse-current-project t)) - (file-exists-p link)) - 'muse-link - 'muse-bad-link))))))) - -(defun muse-colors-use-publishing-directory (link) - "Make LINK relative to the directory where we will publish the -current file." - (let ((style (car (muse-project-applicable-styles - link (cddr (muse-project))))) - path) - (when (and style - (setq path (muse-style-element :path style))) - (expand-file-name link path)))) - -(defun muse-colors-resolve-image-file (link) - "Determine if we can create images and see if the link is an image -file." - (save-match-data - (and (or (fboundp 'create-image) - (fboundp 'make-glyph)) - (not (string-match "\\`[uU][rR][lL]:" link)) - (string-match muse-image-regexp link)))) - -(defun muse-make-file-glyph (filename) - "Given a file name, return a newly-created image glyph. -This is a hack for supporting inline images in XEmacs." - (let ((case-fold-search nil)) - ;; Scan filename to determine image type - (when (fboundp 'make-glyph) - (save-match-data - (cond ((string-match "jpe?g" filename) - (make-glyph (vector 'jpeg :file filename) 'buffer)) - ((string-match "gif" filename) - (make-glyph (vector 'gif :file filename) 'buffer)) - ((string-match "png" filename) - (make-glyph (vector 'png :file filename) 'buffer))))))) - -(defun muse-colors-insert-image (link beg end invis-props) - "Create an image using create-image or make-glyph and insert it -in place of an image link defined by BEG and END." - (setq link (expand-file-name link)) - (let ((image-file (cond - ((eq muse-colors-inline-image-method 'default-directory) - link) - ((functionp muse-colors-inline-image-method) - (funcall muse-colors-inline-image-method link)))) - glyph) - (when (stringp image-file) - (if (fboundp 'create-image) - ;; use create-image and display property - (let ((display-stuff (condition-case nil - (create-image image-file) - (error nil)))) - (when display-stuff - (add-text-properties beg end (list 'display display-stuff)))) - ;; use make-glyph and invisible property - (and (setq glyph (muse-make-file-glyph image-file)) - (progn - (add-text-properties beg end invis-props) - (add-text-properties beg end (list - 'end-glyph glyph - 'help-echo link)))))))) - -(defun muse-colors-explicit-link () - "Color explicit links." - (when (and (eq ?\[ (char-after (match-beginning 0))) - (not (get-text-property (match-beginning 0) 'muse-comment)) - (not (get-text-property (match-beginning 0) 'muse-directive))) - ;; remove flyspell overlays - (when (fboundp 'flyspell-unhighlight-at) - (let ((cur (match-beginning 0))) - (while (> (match-end 0) cur) - (flyspell-unhighlight-at cur) - (setq cur (1+ cur))))) - (let* ((unesc-link (muse-get-link)) - (unesc-desc (muse-get-link-desc)) - (link (muse-link-unescape unesc-link)) - (desc (muse-link-unescape unesc-desc)) - (props (muse-link-properties desc (muse-link-face link t))) - (invis-props (append props (muse-link-properties desc)))) - ;; see if we should try and inline an image - (if (and muse-colors-inline-images - (or (muse-colors-resolve-image-file link) - (and desc - (muse-colors-resolve-image-file desc) - (setq link desc)))) - ;; we found an image, so inline it - (muse-colors-insert-image - link - (match-beginning 0) (match-end 0) invis-props) - (if desc - (progn - ;; we put the normal face properties on the invisible - ;; portion too, since emacs sometimes will position - ;; the cursor on an intangible character - (add-text-properties (match-beginning 0) - (match-beginning 2) invis-props) - (add-text-properties (match-beginning 2) (match-end 2) props) - (add-text-properties (match-end 2) (match-end 0) invis-props) - ;; in case specials were escaped, cause the unescaped - ;; text to be displayed - (unless (string= desc unesc-desc) - (add-text-properties (match-beginning 2) (match-end 2) - (list 'display desc)))) - (add-text-properties (match-beginning 0) - (match-beginning 1) invis-props) - (add-text-properties (match-beginning 1) (match-end 0) props) - (add-text-properties (match-end 1) (match-end 0) invis-props) - (unless (string= link unesc-link) - (add-text-properties (match-beginning 1) (match-end 1) - (list 'display link)))) - (goto-char (match-end 0)) - (add-text-properties - (match-beginning 0) (match-end 0) - (muse-link-properties (muse-match-string-no-properties 0) - (muse-link-face link t))))))) - -(defun muse-colors-implicit-link () - "Color implicit links." - (unless (or (eq (get-text-property (match-beginning 0) 'invisible) 'muse) - (get-text-property (match-beginning 0) 'muse-comment) - (get-text-property (match-beginning 0) 'muse-directive) - (get-text-property (match-beginning 0) 'muse-no-implicit-link) - (eq (char-before (match-beginning 0)) ?\") - (eq (char-after (match-end 0)) ?\")) - ;; remove flyspell overlays - (when (fboundp 'flyspell-unhighlight-at) - (let ((cur (match-beginning 0))) - (while (> (match-end 0) cur) - (flyspell-unhighlight-at cur) - (setq cur (1+ cur))))) - ;; colorize link - (let ((link (muse-match-string-no-properties 0)) - (face (muse-link-face (match-string 0)))) - (when face - (add-text-properties (match-beginning 0) (match-end 0) - (muse-link-properties - (muse-match-string-no-properties 0) face)))))) - -(defun muse-colors-title () - "Color #title directives." - (let ((beg (+ 7 (match-beginning 0)))) - (add-text-properties beg (muse-line-end-position) '(muse-directive t)) - ;; colorize tags in #title after other tags have had a - ;; chance to run, so that we can have behavior that is consistent - ;; with how the document is published - (setq muse-colors-delayed-commands - (cons (list 'muse-colors-title-lisp beg (muse-line-end-position)) - muse-colors-delayed-commands)))) - -(defun muse-colors-title-lisp (beg end) - "Called after other highlighting is done for a region in order to handle - tags that exist in #title directives." - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - (let ((muse-colors-inhibit-tags-in-directives nil) - (muse-colors-tags '(("lisp" t t nil muse-colors-lisp-tag)))) - (while (re-search-forward muse-tag-regexp nil t) - (muse-colors-custom-tags)))) - (add-text-properties beg end '(face muse-header-1))) - -(defun muse-colors-comment () - "Color comments." - (add-text-properties (match-beginning 0) (muse-line-end-position) - (list 'face 'font-lock-comment-face - 'muse-comment t))) - - -(provide 'muse-colors) - -;;; muse-colors.el ends here diff --git a/elpa/muse-3.20/muse-context.el b/elpa/muse-3.20/muse-context.el deleted file mode 100644 index 45968b0..0000000 --- a/elpa/muse-3.20/muse-context.el +++ /dev/null @@ -1,458 +0,0 @@ -;;; muse-context.el --- publish entries in ConTeXt or PDF format - -;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. - -;; Author: Jean Magnan de Bornier (jean@bornier.net) -;; Created: 16-Apr-2007 - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; This file when loaded allows you to publish .muse files as ConTeXt -;; files or as pdf files, using respectively the "context" and -;; "context-pdf" styles. It is far from being perfect, so any feedback -;; will be welcome and any mistake hopefully fixed. - -;;; Author: - -;; Jean Magnan de Bornier, who based this file on muse-latex.el and -;; made the context, context-pdf, context-slides, and -;; context-slides-pdf Muse publishing styles. - -;; 16 Avril 2007 - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse ConTeXt Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-publish) - -(defgroup muse-context nil - "Rules for marking up a Muse file as a ConTeXt article." - :group 'muse-publish) - -(defcustom muse-context-extension ".tex" - "Default file extension for publishing ConTeXt files." - :type 'string - :group 'muse-context) - -(defcustom muse-context-pdf-extension ".pdf" - "Default file extension for publishing ConTeXt files to PDF." - :type 'string - :group 'muse-context) - -(defcustom muse-context-pdf-program "texexec --pdf" - "The program that is called to generate PDF content from ConTeXt content." - :type 'string - :group 'muse-context) - -(defcustom muse-context-pdf-cruft '(".pgf" ".tmp" ".tui" ".tuo" ".toc" ".log") - "Extensions of files to remove after generating PDF output successfully." - :type 'string - :group 'muse-context) - -(defcustom muse-context-header - "\\setupinteraction [state=start] -\\usemodule[tikz] -\\usemodule[bib]\n -(muse-context-setup-bibliography) - \\setuppublications[]\n -\\setuppublicationlist[]\n\\setupcite[]\n -\\starttext -\\startalignment[center] - \\blank[2*big] - {\\tfd (muse-publishing-directive \"title\")} - \\blank[3*medium] - {\\tfa (muse-publishing-directive \"author\")} - \\blank[2*medium] - {\\tfa (muse-publishing-directive \"date\")} - \\blank[3*medium] -\\stopalignment - -(and muse-publish-generate-contents - (not muse-context-permit-contents-tag) - \"\\\\placecontent\n\\\\page[yes]\")\n\n" - "Header used for publishing ConTeXt files. This may be text or a filename." - :type 'string - :group 'muse-context) - -(defcustom muse-context-footer "(muse-context-bibliography) -\\stoptext\n" - "Footer used for publishing ConTeXt files. This may be text or a filename." - :type 'string - :group 'muse-context) - -(defcustom muse-context-markup-regexps - `(;; numeric ranges - (10000 "\\([0-9]+\\)-\\([0-9]+\\)" 0 "\\1--\\2") - - ;; be careful of closing quote pairs - (10100 "\"'" 0 "\"\\\\-'")) - "List of markup regexps for identifying regions in a Muse page. -For more on the structure of this list, see `muse-publish-markup-regexps'." - :type '(repeat (choice - (list :tag "Markup rule" - integer - (choice regexp symbol) - integer - (choice string function symbol)) - function)) - :group 'muse-context) - -(defcustom muse-context-markup-functions - '((table . muse-context-markup-table)) - "An alist of style types to custom functions for that kind of text. -For more on the structure of this list, see -`muse-publish-markup-functions'." - :type '(alist :key-type symbol :value-type function) - :group 'muse-context) - -(defcustom muse-context-markup-strings - '((image-with-desc . "\\placefigure[][]{%3%}{\\externalfigure[%1%.%2%]}") - (image . "\\placefigure[][]{}{\\externalfigure[%s.%s]}") - (image-link . "\\useURL[aa][%s][][%1%] \\from[aa]") - (anchor-ref . "\\goto{%2%}{}[%1%]") - (url . "\\useURL[aa][%s][][%s] \\from[aa]") - (url-and-desc . "\\useURL[bb][%s][][%s]\\from[bb]\\footnote{%1%}") - (link . "\\goto{%2%}[program(%1%)]\\footnote{%1%}") - (link-and-anchor . "\\useexternaldocument[%4%][%4%][] \\at{%3%, page}{}[%4%::%2%]\\footnote{%1%}") - (email-addr . "\\useURL[mail][mailto:%s][][%s]\\from[mail]") - (anchor . "\\reference[%s] ") - (emdash . "---") - (comment-begin . "\\doifmode{comment}{") - (comment-end . "}") - (rule . "\\blank[medium]\\hrule\\blank[medium]") - (no-break-space . "~") - (enddots . "\\ldots ") - (dots . "\\dots ") - (part . "\\part{") - (part-end . "}") - (chapter . "\\chapter{") - (chapter-end . "}") - (section . "\\section{") - (section-end . "}") - (subsection . "\\subsection{") - (subsection-end . "}") - (subsubsection . "\\subsubsection{") - (subsubsection-end . "}") - (section-other . "\\subsubsubject{") - (section-other-end . "}") - (footnote . "\\footnote{") - (footnote-end . "}") - (footnotetext . "\\footnotetext[%d]{") - (begin-underline . "\\underbar{") - (end-underline . "}") - (begin-literal . "\\type{") - (end-literal . "}") - (begin-emph . "{\\em ") - (end-emph . "}") - (begin-more-emph . "{\\bf ") - (end-more-emph . "}") - (begin-most-emph . "{\\bf {\\em ") - (end-most-emph . "}}") - (begin-example . "\\starttyping") - (end-example . "\\stoptyping") - (begin-center . "\\startalignment[center]\n") - (end-center . "\n\\stopalignment") - (begin-quote . "\\startquotation\n") - (end-quote . "\n\\stopquotation") - (begin-cite . "\\cite[authoryear][") - (begin-cite-author . "\\cite[author][") - (begin-cite-year . "\\cite[year][") - (end-cite . "]") - (begin-uli . "\\startitemize\n") - (end-uli . "\n\\stopitemize") - (begin-uli-item . "\\item ") - (begin-oli . "\\startitemize[n]\n") - (end-oli . "\n\\stopitemize") - (begin-oli-item . "\\item ") - (begin-dl . "\\startitemize\n") - (end-dl . "\n\\stopitemize") - (begin-ddt . "\\head ") - (end-ddt . "\n") - (begin-verse . "\\blank[big]") - (end-verse-line . "\\par") - (verse-space . "\\fixedspaces ~~") - (end-verse . "\\blank[big]")) - "Strings used for marking up text. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles." - :type '(alist :key-type symbol :value-type string) - :group 'muse-context) - -(defcustom muse-context-slides-header - "\\usemodule[(if (string-equal (muse-publishing-directive \"module\") nil) \"pre-01\" (muse-publishing-directive \"module\"))] -\\usemodule[tikz] -\\usemodule[newmat] -\\setupinteraction [state=start] -\\starttext -\\TitlePage { (muse-publishing-directive \"title\") -\\blank[3*medium] -\\tfa (muse-publishing-directive \"author\") - \\blank[2*medium] - \\tfa (muse-publishing-directive \"date\")}" - "Header for publishing a presentation (slides) using ConTeXt. -Any of the predefined modules, which are available in the -tex/context/base directory, can be used by writing a \"module\" -directive at the top of the muse file; if no such directive is -provided, module pre-01 is used. Alternatively, you can use your -own style (\"mystyle\", in this example) by replacing -\"\\usemodule[]\" with \"\\input mystyle\". - -This may be text or a filename." - :type 'string - :group 'muse-context) - -(defcustom muse-context-slides-markup-strings - '((section . "\\Topic {") - (subsection . "\\page \n{\\bf ") - (subsubsection . "{\\em ")) - "Strings used for marking up text in ConTeXt slides." - :type '(alist :key-type symbol :value-type string) - :group 'muse-context) - -(defcustom muse-context-markup-specials-document - '((?\\ . "\\textbackslash{}") - (?\_ . "\\textunderscore{}") - (?\< . "\\switchtobodyfont[small]") - (?\> . "\\switchtobodyfont[big]") - (?^ . "\\^") - (?\~ . "\\~") - (?\@ . "\\@") - (?\$ . "\\$") - (?\% . "\\%") - (?\{ . "\\{") - (?\} . "\\}") - (?\& . "\\&") - (?\# . "\\#")) - "A table of characters which must be represented specially. -These are applied to the entire document, sans already-escaped -regions." - :type '(alist :key-type character :value-type string) - :group 'muse-context) - -(defcustom muse-context-markup-specials-example - '() - "A table of characters which must be represented specially. -These are applied to regions. - -With the default interpretation of regions, no specials -need to be escaped." - :type '(alist :key-type character :value-type string) - :group 'muse-context) - -(defcustom muse-context-markup-specials-literal - '() - "A table of characters which must be represented specially. -This applies to =monospaced text= and regions." - :type '(alist :key-type character :value-type string) - :group 'muse-context) - -(defcustom muse-context-markup-specials-url - '((?\\ . "\\textbackslash") - (?\_ . "\\_") - (?\< . "\\<") - (?\> . "\\>") - (?\$ . "\\$") - (?\% . "\\%") - (?\{ . "\\{") - (?\} . "\\}") - (?\& . "\\&") - (?\# . "\\#")) - "A table of characters which must be represented specially. -These are applied to URLs." - :type '(alist :key-type character :value-type string) - :group 'muse-context) - -(defcustom muse-context-markup-specials-image - '((?\\ . "\\textbackslash") ; cannot find suitable replacement - (?\< . "\\<") - (?\> . "\\>") - (?\$ . "\\$") - (?\% . "\\%") - (?\{ . "\\{") - (?\} . "\\}") - (?\& . "\\&") - (?\# . "\\#") ; cannot find suitable replacement - ) - "A table of characters which must be represented specially. -These are applied to image filenames." - :type '(alist :key-type character :value-type string) - :group 'muse-context) - -(defun muse-context-decide-specials (context) - "Determine the specials to escape, depending on the CONTEXT argument." - (cond ((memq context '(underline emphasis document url-desc verbatim - footnote)) - muse-context-markup-specials-document) - ((eq context 'image) - muse-context-markup-specials-image) - ((memq context '(email url)) - muse-context-markup-specials-url) - ((eq context 'literal) - muse-context-markup-specials-literal) - ((eq context 'example) - muse-context-markup-specials-example) - (t (error "Invalid context argument '%s' in muse-context" context)))) - -(defun muse-context-markup-table () - (let* ((table-info (muse-publish-table-fields (match-beginning 0) - (match-end 0))) - (row-len (car table-info)) - (field-list (cdr table-info))) - (when table-info - (muse-insert-markup "\\starttable[|" - (mapconcat 'symbol-name (make-vector row-len 'l) - "|") "|]\n \\HL\n \\VL ") - (dolist (fields field-list) - (let ((type (car fields))) - (setq fields (cdr fields)) - (when (= type 3) - (muse-insert-markup "")) - (insert (car fields)) - (setq fields (cdr fields)) - (dolist (field fields) - (muse-insert-markup " \\VL ") - (insert field)) - (muse-insert-markup "\\VL\\NR\n \\HL\n \\VL ") - (when (= type 2) - (muse-insert-markup " ")))) - (muse-insert-markup "\\stoptable\n") - (while (search-backward "VL \\stoptable" nil t) - (replace-match "stoptable" nil t))))) - -(defun muse-context-fixup-dquotes () - "Fixup double quotes." - (goto-char (point-min)) - (let ((open t)) - (while (search-forward "\"" nil t) - (unless (get-text-property (match-beginning 0) 'read-only) - (when (or (bobp) - (eq (char-before) ?\n)) - (setq open t)) - (if open - (progn - (replace-match "``") - (setq open nil)) - (replace-match "''") - (setq open t)))))) - -(defcustom muse-context-permit-contents-tag nil - "If nil, ignore tags. Otherwise, insert table of contents. - -Most of the time, it is best to have a table of contents on the -first page, with a new page immediately following. To make this -work with documents published in both HTML and ConTeXt, we need to -ignore the tag. - -If you don't agree with this, then set this option to non-nil, -and it will do what you expect." - :type 'boolean - :group 'muse-context) - -(defun muse-context-fixup-citations () - "Replace semicolons in multi-head citations with colons." - (goto-char (point-min)) - (while (re-search-forward "\\\\cite.?\\[" nil t) - (let ((start (point)) - (end (re-search-forward "]"))) - (save-restriction - (narrow-to-region start end) - (goto-char (point-min)) - (while (re-search-forward ";" nil t) - (replace-match ",")))))) - -(defun muse-context-munge-buffer () - (muse-context-fixup-dquotes) - (muse-context-fixup-citations) - (when (and muse-context-permit-contents-tag - muse-publish-generate-contents) - (goto-char (car muse-publish-generate-contents)) - (muse-insert-markup "\\placecontent"))) - -(defun muse-context-bibliography () - (save-excursion - (goto-char (point-min)) - (if (re-search-forward "\\\\cite.?\\[" nil t) - "\\completepublications[criterium=all]" - ""))) - -(defun muse-context-setup-bibliography () - (save-excursion - (goto-char (point-min)) - (if (re-search-forward "\\\\cite.?\\[" nil t) - (concat - "\\usemodule[bibltx]\n\\setupbibtex [database=" - (muse-publishing-directive "bibsource") "]") - ""))) - -(defun muse-context-pdf-browse-file (file) - (shell-command (concat "open " file))) - -(defun muse-context-pdf-generate (file output-path final-target) - (apply - #'muse-publish-transform-output - file output-path final-target "PDF" - (function - (lambda (file output-path) - (let* ((fnd (file-name-directory output-path)) - (command (format "%s \"%s\"" - muse-context-pdf-program - (file-relative-name file fnd))) - (times 0) - (default-directory fnd) - result) - ;; XEmacs can sometimes return a non-number result. We'll err - ;; on the side of caution by continuing to attempt to generate - ;; the PDF if this happens and treat the final result as - ;; successful. - (while (and (< times 2) - (or (not (numberp result)) - (not (eq result 0)) - ;; table of contents takes 2 passes -;; (file-readable-p -;; (muse-replace-regexp-in-string -;; "\\.tex\\'" ".toc" file t t)) - )) - (setq result (shell-command command) - times (1+ times))) - (if (or (not (numberp result)) - (eq result 0)) - t - nil)))) - muse-context-pdf-cruft)) - -(muse-define-style "context" - :suffix 'muse-context-extension - :regexps 'muse-context-markup-regexps - :functions 'muse-context-markup-functions - :strings 'muse-context-markup-strings - :specials 'muse-context-decide-specials - :after 'muse-context-munge-buffer - :header 'muse-context-header - :footer 'muse-context-footer - :browser 'find-file) - -(muse-derive-style "context-pdf" "context" - :final 'muse-context-pdf-generate - :browser 'muse-context-pdf-browse-file - :link-suffix 'muse-context-pdf-extension - :osuffix 'muse-context-pdf-extension) - -(muse-derive-style "context-slides" "context" - :header 'muse-context-slides-header - :strings 'muse-context-slides-markup-strings) - -(muse-derive-style "context-slides-pdf" "context-pdf" - :header 'muse-context-slides-header - :strings 'muse-context-slides-markup-strings) - -(provide 'muse-context) - -;;; muse-context.el ends here diff --git a/elpa/muse-3.20/muse-docbook.el b/elpa/muse-3.20/muse-docbook.el deleted file mode 100644 index a54089f..0000000 --- a/elpa/muse-3.20/muse-docbook.el +++ /dev/null @@ -1,352 +0,0 @@ -;;; muse-docbook.el --- publish DocBook files - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;;; Contributors: - -;; Dale P. Smith (dpsm AT en DOT com) improved the markup -;; significantly and made many valuable suggestions. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse DocBook XML Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-publish) -(require 'muse-regexps) -(require 'muse-xml-common) - -(defgroup muse-docbook nil - "Options controlling the behavior of Muse DocBook XML publishing. -See `muse-docbook' for more information." - :group 'muse-publish) - -(defcustom muse-docbook-extension ".xml" - "Default file extension for publishing DocBook XML files." - :type 'string - :group 'muse-docbook) - -(defcustom muse-docbook-header - " - (muse-docbook-encoding)\"?> -(muse-docbook-entities)> -

- - <lisp>(muse-publishing-directive \"title\")</lisp> - (muse-docbook-get-author - (muse-publishing-directive \"author\")) - (muse-publishing-directive \"date\") - - \n" - "Header used for publishing DocBook XML files. -This may be text or a filename." - :type 'string - :group 'muse-docbook) - -(defcustom muse-docbook-footer " - -(muse-docbook-bibliography)
\n" - "Footer used for publishing DocBook XML files. -This may be text or a filename." - :type 'string - :group 'muse-docbook) - -(defcustom muse-docbook-markup-regexps - `(;; Beginning of doc, end of doc, or plain paragraph separator - (10000 ,(concat "\\(\\(\n\\(?:[" muse-regexp-blank "]*\n\\)*" - "\\([" muse-regexp-blank "]*\n\\)\\)" - "\\|\\`\\s-*\\|\\s-*\\'\\)") - 3 muse-docbook-markup-paragraph)) - "List of markup rules for publishing a Muse page to DocBook XML. -For more on the structure of this list, see `muse-publish-markup-regexps'." - :type '(repeat (choice - (list :tag "Markup rule" - integer - (choice regexp symbol) - integer - (choice string function symbol)) - function)) - :group 'muse-docbook) - -(defcustom muse-docbook-markup-functions - '((anchor . muse-xml-markup-anchor) - (table . muse-xml-markup-table)) - "An alist of style types to custom functions for that kind of text. -For more on the structure of this list, see -`muse-publish-markup-functions'." - :type '(alist :key-type symbol :value-type function) - :group 'muse-docbook) - -(defcustom muse-docbook-markup-strings - '((image-with-desc . " - - - -%3% -") - (image . " - -") - (image-link . " - -") - (anchor-ref . "%s") - (url . "%s") - (link . "%s") - (link-and-anchor . "%s") - (email-addr . "%s") - (anchor . "\n") - (emdash . "%s—%s") - (comment-begin . "") - (rule . "") - (no-break-space . " ") - (enddots . "....") - (dots . "...") - (section . "
") - (section-end . "") - (subsection . "
") - (subsection-end . "") - (subsubsection . "
") - (subsubsection-end . "") - (section-other . "
") - (section-other-end . "") - (section-close . "
") - (footnote . "") - (footnote-end . "") - (begin-underline . "") - (end-underline . "") - (begin-literal . "") - (end-literal . "") - (begin-emph . "") - (end-emph . "") - (begin-more-emph . "") - (end-more-emph . "") - (begin-most-emph . "") - (end-most-emph . "") - (begin-verse . "\n") - (verse-space . " ") - (end-verse . "") - (begin-example . "") - (end-example . "") - (begin-center . "\n") - (end-center . "\n") - (begin-quote . "
\n") - (end-quote . "\n
") - (begin-cite . "") - (begin-cite-author . "A:") - (begin-cite-year . "Y:") - (end-cite . "") - (begin-quote-item . "") - (end-quote-item . "") - (begin-uli . "\n") - (end-uli . "\n") - (begin-uli-item . "") - (end-uli-item . "") - (begin-oli . "\n") - (end-oli . "\n") - (begin-oli-item . "") - (end-oli-item . "") - (begin-dl . "\n") - (end-dl . "\n") - (begin-dl-item . "\n") - (end-dl-item . "\n") - (begin-ddt . "") - (end-ddt . "") - (begin-dde . "") - (end-dde . "") - (begin-table . "\n") - (end-table . "") - (begin-table-group . " \n") - (end-table-group . " \n") - (begin-table-row . " \n") - (end-table-row . " \n") - (begin-table-entry . " ") - (end-table-entry . "\n")) - "Strings used for marking up text. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles." - :type '(alist :key-type symbol :value-type string) - :group 'muse-docbook) - -(defcustom muse-docbook-encoding-default 'utf-8 - "The default Emacs buffer encoding to use in published files. -This will be used if no special characters are found." - :type 'symbol - :group 'muse-docbook) - -(defcustom muse-docbook-charset-default "utf-8" - "The default DocBook XML charset to use if no translation is -found in `muse-docbook-encoding-map'." - :type 'string - :group 'muse-docbook) - -(defun muse-docbook-encoding () - (muse-xml-transform-content-type - (or (and (boundp 'buffer-file-coding-system) - buffer-file-coding-system) - muse-docbook-encoding-default) - muse-docbook-charset-default)) - -(defun muse-docbook-markup-paragraph () - (catch 'bail-out - (let ((end (copy-marker (match-end 0) t))) - (goto-char (match-beginning 0)) - (when (save-excursion - (save-match-data - (and (not (get-text-property (max (point-min) (1- (point))) - 'muse-no-paragraph)) - (re-search-backward - "<\\(/?\\)\\(para\\|footnote\\|literallayout\\)[ >]" - nil t) - (cond ((string= (match-string 2) "literallayout") - (and (not (string= (match-string 1) "/")) - (throw 'bail-out t))) - ((string= (match-string 2) "para") - (and - (not (string= (match-string 1) "/")) - ;; don't mess up nested lists - (not (and (muse-looking-back "") - (throw 'bail-out t))))) - ((string= (match-string 2) "footnote") - (string= (match-string 1) "/")) - (t nil))))) - (when (get-text-property (1- (point)) 'muse-end-list) - (goto-char (previous-single-property-change (1- (point)) - 'muse-end-list))) - (muse-insert-markup "")) - (goto-char end)) - (cond - ((eobp) - (unless (bolp) - (insert "\n"))) - ((get-text-property (point) 'muse-no-paragraph) - (forward-char 1) - nil) - ((eq (char-after) ?\<) - (when (looking-at (concat "<\\(emphasis\\|systemitem\\|inlinemediaobject" - "\\|u?link\\|anchor\\|email\\)[ >]")) - (muse-insert-markup ""))) - (t - (muse-insert-markup ""))))) - -(defun muse-docbook-get-author (&optional author) - "Split the AUTHOR directive into separate fields. -AUTHOR should be of the form: \"Firstname Other Names Lastname\", -and anything after `Firstname' is optional." - (setq author (save-match-data (split-string author))) - (let ((num-el (length author))) - (cond ((eq num-el 1) - (concat "" (car author) "")) - ((eq num-el 2) - (concat "" (nth 0 author) "" - "" (nth 1 author) "")) - ((eq num-el 3) - (concat "" (nth 0 author) "" - "" (nth 1 author) "" - "" (nth 2 author) "")) - (t - (let (first last) - (setq first (car author)) - (setq author (nreverse (cdr author))) - (setq last (car author)) - (setq author (nreverse (cdr author))) - (concat "" first "" - "" - (mapconcat 'identity author " ") - "" - "" last "")))))) - -(defun muse-docbook-fixup-images () - (goto-char (point-min)) - (while (re-search-forward (concat "$") - nil t) - (replace-match (upcase (match-string 1)) t t nil 1))) - -(defun muse-docbook-fixup-citations () - ;; remove the role attribute if there is no role - (goto-char (point-min)) - (while (re-search-forward "<\\(citation role=\"nil\"\\)>" nil t) - (replace-match "citation" t t nil 1)) - ;; replace colons in multi-head citations with semicolons - (goto-char (point-min)) - (while (re-search-forward "" nil t) - (let ((start (point)) - (end (re-search-forward ""))) - (save-restriction - (narrow-to-region start end) - (goto-char (point-min)) - (while (re-search-forward "," nil t) - (replace-match ";")))))) - -(defun muse-docbook-munge-buffer () - (muse-docbook-fixup-images) - (muse-docbook-fixup-citations)) - -(defun muse-docbook-entities () - (save-excursion - (goto-char (point-min)) - (if (re-search-forward "\n]") - ""))) - -(defun muse-docbook-bibliography () - (save-excursion - (goto-char (point-min)) - (if (re-search-forward "(muse-publishing-directive \"title\")\" -.SUBTITLE \"(muse-publishing-directive \"date\")\" -.AUTHOR \"(muse-publishing-directive \"author\")\" -.PRINTSTYLE TYPESET -.de list -. LIST \\$1 -. SHIFT_LIST \\$2 -.. -.PARA_INDENT 0 -.START -(and muse-publish-generate-contents \".TOC\n\")\n" - "Header used for publishing groff -mom -mwww files." - :type '(choice string file) - :group 'muse-groff) - -(defcustom muse-groff-footer " " - "Footer used for publishing groff -mom -mwww files." - :type '(choice string file) - :group 'muse-groff) - -(defcustom muse-groff-markup-regexps - `((10400 ,(concat "\\(\n\\)?\n" - "\\([" - muse-regexp-blank - "]*\n\\)+\\(<\\(blockquote\\|center\\)>\n\\)?") - 0 muse-groff-markup-paragraph)) -"List of markup regexps for identifying regions in a Muse page. -For more on the structure of this list, see `muse-publish-markup-regexps'." - :type '(repeat (choice - (list :tag "Markup rule" - integer - (choice regexp symbol) - integer - (choice string function symbol)) - function)) - :group 'muse-groff) - -(defcustom muse-groff-markup-functions - '((table . muse-groff-markup-table)) - "An alist of style types to custom functions for that kind of text. -For more on the structure of this list, see -`muse-publish-markup-functions'." - :type '(alist :key-type symbol :value-type function) - :group 'muse-groff) - -(defcustom muse-groff-markup-tags - '() - "A list of tag specifications, for specially marking up GROFF." - :type '(repeat (list (string :tag "Markup tag") - (boolean :tag "Expect closing tag" :value t) - (boolean :tag "Parse attributes" :value nil) - (boolean :tag "Nestable" :value nil) - function)) - :group 'muse-groff) - -(defcustom muse-groff-markup-strings - `((image-with-desc . "\n.MPIMG -R %s.%s\n") - (image . "\n.MPIMG -R %s.%s\n") - (image-link . "\n.\\\" %s\n.MPIMG -R %s.%s") - (url . "\n.URL %s %s\n\\z") - (link . "\n.URL %s %s\n\\z") - (email-addr . "\f[C]%s\f[]") - (emdash . "\\(em") - (rule . "\n.RULE\n") - (no-break-space . "\\h") - (line-break . "\\p") - (enddots . "....") - (dots . "...") -;; (part . "\\part{") -;; (part-end . "}") -;; (chapter . "\\chapter{") -;; (chapter-end . "}") - (section . ".HEAD \"") - (section-end . "\"") - (subsection . ".SUBHEAD \"") - (subsection-end . "\"") - (subsubsection . ".PARAHEAD \"") - (subsubsection-end . "\"") -;; (footnote . "\\c\n.FOOTNOTE\n") -;; (footnote-end . "\n.FOOTNOTE OFF\n") -;; (footnotemark . "\\footnotemark[%d]") -;; (footnotetext . "\\footnotetext[%d]{") -;; (footnotetext-end . "}") - (begin-underline . "\n.UNDERSCORE \"") - (end-underline . "\"\n") - (begin-literal . "\\fC") - (end-literal . "\\fP") - (begin-emph . "\\fI") - (end-emph . "\\fP") - (begin-more-emph . "\\fB") - (end-more-emph . "\\fP") - (begin-most-emph . "\\f(BI") - (end-most-emph . "\\fP") - (begin-verse . ".QUOTE") - (end-verse . ".QUOTE OFF") - (begin-center . "\n.CENTER\n") - (end-center . "\n.QUAD L\n") - (begin-example . ,(concat - ".QUOTE_FONT CR\n.QUOTE_INDENT 1\n"".QUOTE_SIZE -2\n" - ".UNDERLINE_QUOTES OFF\n.QUOTE")) - (end-example . ".QUOTE OFF") - (begin-quote . ".BLOCKQUOTE") - (end-quote . ".BLOCKQUOTE OFF") - (begin-cite . "") - (begin-cite-author . "") - (begin-cite-year . "") - (end-cite . "") - (begin-uli . ".list BULLET\n.SHIFT_LIST 2m\n.ITEM\n") - (end-uli . "\n.LIST OFF") - (begin-oli . ".list DIGIT\n.SHIFT_LIST 2m\n.ITEM\n") - (end-oli . "\n.LIST OFF") - (begin-ddt . "\\fB") - (begin-dde . "\\fP\n.IR 4P\n") - (end-ddt . ".IRX CLEAR")) - "Strings used for marking up text. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles." - :type '(alist :key-type symbol :value-type string) - :group 'muse-groff) - -(defcustom muse-groff-markup-specials - '((?\\ . "\\e")) - "A table of characters which must be represented specially." - :type '(alist :key-type character :value-type string) - :group 'muse-groff) - -(defun muse-groff-markup-paragraph () - (let ((end (copy-marker (match-end 0) t))) - (goto-char (1+ (match-beginning 0))) - (delete-region (point) end) - (unless (looking-at "\.\\(\\(\\(SUB\\|PARA\\)?HEAD \\)\\|RULE$\\)") - (muse-insert-markup ".ALD .5v\n.PP\n.ne 2\n")))) - -(defun muse-groff-protect-leading-chars () - "Protect leading periods and apostrophes from being interpreted as -command characters." - (while (re-search-forward "^[.']" nil t) - (replace-match "\\\\&\\&" t))) - -(defun muse-groff-concat-lists () - "Join like lists." - (let ((type "") - arg begin) - (while (re-search-forward "^\.LIST[ \t]+\\(.*\\)\n" nil t) - (setq arg (match-string 1)) - (if (string= arg "OFF") - (setq begin (match-beginning 0)) - (if (and begin (string= type arg)) - (delete-region begin (match-end 0)) - (setq type arg - begin 0)))))) - -(defun muse-groff-fixup-dquotes () - "Fixup double quotes." - (let ((open t)) - (while (search-forward "\"" nil t) - (unless (get-text-property (match-beginning 0) 'read-only) - (if (and (bolp) (eq (char-before) ?\n)) - (setq open t)) - (if open - (progn - (replace-match "``") - (setq open nil)) - (replace-match "''") - (setq open t)))))) - -(defun muse-groff-prepare-buffer () - (goto-char (point-min)) - (muse-groff-protect-leading-chars)) - -(defun muse-groff-munge-buffer () - (goto-char (point-min)) - (muse-groff-concat-lists)) - -(defun muse-groff-pdf-browse-file (file) - (shell-command (concat "open " file))) - -(defun muse-groff-pdf-generate (file output-path final-target) - (muse-publish-transform-output - file output-path final-target "PDF" - (function - (lambda (file output-path) - (let ((command - (format - (concat "file=%s; ext=%s; cd %s && cp $file$ext $file.ref && " - "groff -mom -mwww -t $file$ext > $file.ps && " - "pstopdf $file.ps") - (file-name-sans-extension file) - muse-groff-extension - (file-name-directory output-path)))) - (shell-command command)))) - ".ps")) - -;;; Register the Muse GROFF Publisher - -(muse-define-style "groff" - :suffix 'muse-groff-extension - :regexps 'muse-groff-markup-regexps -;;; :functions 'muse-groff-markup-functions - :strings 'muse-groff-markup-strings - :tags 'muse-groff-markup-tags - :specials 'muse-groff-markup-specials - :before 'muse-groff-prepare-buffer - :before-end 'muse-groff-munge-buffer - :header 'muse-groff-header - :footer 'muse-groff-footer - :browser 'find-file) - -(muse-derive-style "groff-pdf" "groff" - :final 'muse-groff-pdf-generate - :browser 'muse-groff-pdf-browse-file - :osuffix 'muse-groff-pdf-extension) - -(provide 'muse-groff) - -;;; muse-groff.el ends here -;; -;; Local Variables: -;; indent-tabs-mode: nil -;; End: diff --git a/elpa/muse-3.20/muse-html.el b/elpa/muse-3.20/muse-html.el deleted file mode 100644 index 6a9356b..0000000 --- a/elpa/muse-3.20/muse-html.el +++ /dev/null @@ -1,754 +0,0 @@ -;;; muse-html.el --- publish to HTML and XHTML - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;;; Contributors: - -;; Zhiqiang Ye (yezq AT mail DOT cbi DOT pku DOT edu DOT cn) suggested -;; appending an 'encoding="..."' fragment to the first line of the -;; sample publishing header so that when editing the resulting XHTML -;; file, Emacs would use the proper encoding. - -;; Sun Jiyang (sunyijiang AT gmail DOT com) came up with the idea for -;; the tag and provided an implementation for emacs-wiki. - -;; Charles Wang (wcy123 AT gmail DOT com) provided an initial -;; implementation of the tag for Muse. - -;; Clinton Ebadi (clinton AT unknownlamer DOT org) provided further -;; ideas for the implementation of the tag. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse HTML Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-publish) -(require 'muse-regexps) -(require 'muse-xml-common) - -(defgroup muse-html nil - "Options controlling the behavior of Muse HTML publishing." - :group 'muse-publish) - -(defcustom muse-html-extension ".html" - "Default file extension for publishing HTML files." - :type 'string - :group 'muse-html) - -(defcustom muse-xhtml-extension ".html" - "Default file extension for publishing XHTML files." - :type 'string - :group 'muse-html) - -(defcustom muse-html-style-sheet - "" - "Store your stylesheet definitions here. -This is used in `muse-html-header'. -You can put raw CSS in here or a tag to an external stylesheet. -This text may contain markup tags. - -An example of using is as follows. - -" - :type 'string - :group 'muse-html) - -(defcustom muse-xhtml-style-sheet - "" - "Store your stylesheet definitions here. -This is used in `muse-xhtml-header'. -You can put raw CSS in here or a tag to an external stylesheet. -This text may contain markup tags. - -An example of using is as follows. - -" - :type 'string - :group 'muse-html) - -(defcustom muse-html-header - " - - - <lisp> - (concat (muse-publishing-directive \"title\") - (let ((author (muse-publishing-directive \"author\"))) - (if (not (string= author (user-full-name))) - (concat \" (by \" author \")\"))))</lisp> - - muse-html-meta-http-equiv\" - content=\"muse-html-meta-content-type\"> - - (let ((maintainer (muse-style-element :maintainer))) - (when maintainer - (concat \"\"))) - - (muse-style-element :style-sheet muse-publishing-current-style) - - - -

- (concat (muse-publishing-directive \"title\") - (let ((author (muse-publishing-directive \"author\"))) - (if (not (string= author (user-full-name))) - (concat \" (by \" author \")\"))))

- \n" - "Header used for publishing HTML files. This may be text or a filename." - :type 'string - :group 'muse-html) - -(defcustom muse-html-footer " - - -\n" - "Footer used for publishing HTML files. This may be text or a filename." - :type 'string - :group 'muse-html) - -(defcustom muse-xhtml-header - " - (muse-html-encoding)
\"?> - - - - <lisp> - (concat (muse-publishing-directive \"title\") - (let ((author (muse-publishing-directive \"author\"))) - (if (not (string= author (user-full-name))) - (concat \" (by \" author \")\"))))</lisp> - - muse-html-meta-http-equiv\" - content=\"muse-html-meta-content-type\" /> - - (let ((maintainer (muse-style-element :maintainer))) - (when maintainer - (concat \"\"))) - - (muse-style-element :style-sheet muse-publishing-current-style) - - - -

- (concat (muse-publishing-directive \"title\") - (let ((author (muse-publishing-directive \"author\"))) - (if (not (string= author (user-full-name))) - (concat \" (by \" author \")\"))))

- \n" - "Header used for publishing XHTML files. This may be text or a filename." - :type 'string - :group 'muse-html) - -(defcustom muse-xhtml-footer " - - -\n" - "Footer used for publishing XHTML files. This may be text or a filename." - :type 'string - :group 'muse-html) - -(defcustom muse-html-anchor-on-word nil - "When true, anchors surround the closest word. This allows you -to select them in a browser (i.e. for pasting), but has the -side-effect of marking up headers in multiple colors if your -header style is different from your link style." - :type 'boolean - :group 'muse-html) - -(defcustom muse-html-table-attributes - " class=\"muse-table\" border=\"2\" cellpadding=\"5\"" - "The attribute to be used with HTML tags. -Note that Muse supports insertion of raw HTML tags, as long -as you wrap the region in ." - :type 'string - :group 'muse-html) - -(defcustom muse-html-markup-regexps - `(;; Beginning of doc, end of doc, or plain paragraph separator - (10000 ,(concat "\\(\\(\n\\(?:[" muse-regexp-blank "]*\n\\)*" - "\\([" muse-regexp-blank "]*\n\\)\\)" - "\\|\\`\\s-*\\|\\s-*\\'\\)") - ;; this is somewhat repetitive because we only require the - ;; line just before the paragraph beginning to be not - ;; read-only - 3 muse-html-markup-paragraph)) - "List of markup rules for publishing a Muse page to HTML. -For more on the structure of this list, see `muse-publish-markup-regexps'." - :type '(repeat (choice - (list :tag "Markup rule" - integer - (choice regexp symbol) - integer - (choice string function symbol)) - function)) - :group 'muse-html) - -(defcustom muse-html-markup-functions - '((anchor . muse-html-markup-anchor) - (table . muse-html-markup-table) - (footnote . muse-html-markup-footnote)) - "An alist of style types to custom functions for that kind of text. -For more on the structure of this list, see -`muse-publish-markup-functions'." - :type '(alist :key-type symbol :value-type function) - :group 'muse-html) - -(defcustom muse-html-markup-strings - '((image-with-desc . "
- - -
\"%3%\"
%3%
") - (image . "\"\"") - (image-link . " -") - (anchor-ref . "%s") - (url . "%s") - (link . "%s") - (link-and-anchor . "%s") - (email-addr . "%s") - (anchor . "") - (emdash . "%s—%s") - (comment-begin . "") - (rule . "
") - (fn-sep . "
\n") - (no-break-space . " ") - (line-break . "
") - (enddots . "....") - (dots . "...") - (section . "

") - (section-end . "

") - (subsection . "

") - (subsection-end . "

") - (subsubsection . "

") - (subsubsection-end . "

") - (section-other . "
") - (section-other-end . "
") - (begin-underline . "") - (end-underline . "") - (begin-literal . "") - (end-literal . "") - (begin-cite . "") - (begin-cite-author . "") - (begin-cite-year . "") - (end-cite . "") - (begin-emph . "") - (end-emph . "") - (begin-more-emph . "") - (end-more-emph . "") - (begin-most-emph . "") - (end-most-emph . "") - (begin-verse . "

\n") - (verse-space . "  ") - (end-verse-line . "
") - (end-last-stanza-line . "
") - (empty-verse-line . "
") - (end-verse . "

") - (begin-example . "
")
-    (end-example     . "
") - (begin-center . "
\n

") - (end-center . "

\n
") - (begin-quote . "
\n") - (end-quote . "\n
") - (begin-quote-item . "

") - (end-quote-item . "

") - (begin-uli . "
    \n") - (end-uli . "\n
") - (begin-uli-item . "
  • ") - (end-uli-item . "
  • ") - (begin-oli . "
      \n") - (end-oli . "\n
    ") - (begin-oli-item . "
  • ") - (end-oli-item . "
  • ") - (begin-dl . "
    \n") - (end-dl . "\n
    ") - (begin-ddt . "
    ") - (end-ddt . "
    ") - (begin-dde . "
    ") - (end-dde . "
    ") - (begin-table . "\n") - (end-table . "") - (begin-table-row . " \n") - (end-table-row . " \n") - (begin-table-entry . " <%s>") - (end-table-entry . "\n")) - "Strings used for marking up text as HTML. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles." - :type '(alist :key-type symbol :value-type string) - :group 'muse-html) - -(defcustom muse-xhtml-markup-strings - '((image-with-desc . " - - -
    \"%3%\"
    %3%
    ") - (image . "\"\"") - (image-link . "
    -\"\"") - (rule . "
    ") - (fn-sep . "
    \n") - (line-break . "
    ") - (begin-underline . "") - (end-underline . "") - (begin-center . "

    \n") - (end-center . "\n

    ") - (end-verse-line . "
    ") - (end-last-stanza-line . "
    ") - (empty-verse-line . "
    ")) - "Strings used for marking up text as XHTML. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -If a markup rule is not found here, `muse-html-markup-strings' is -searched." - :type '(alist :key-type symbol :value-type string) - :group 'muse-html) - -(defcustom muse-xhtml1.1-markup-strings - '((anchor . "")) - "Strings used for marking up text as XHTML 1.1. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -If a markup rule is not found here, `muse-xhtml-markup-strings' -and `muse-html-markup-strings' are searched." - :type '(alist :key-type symbol :value-type string) - :group 'muse-html) - -(defcustom muse-html-markup-tags - '(("class" t t t muse-html-class-tag) - ("div" t t t muse-html-div-tag) - ("src" t t nil muse-html-src-tag)) - "A list of tag specifications, for specially marking up HTML." - :type '(repeat (list (string :tag "Markup tag") - (boolean :tag "Expect closing tag" :value t) - (boolean :tag "Parse attributes" :value nil) - (boolean :tag "Nestable" :value nil) - function)) - :group 'muse-html) - -(defcustom muse-html-meta-http-equiv "Content-Type" - "The http-equiv attribute used for the HTML tag." - :type 'string - :group 'muse-html) - -(defcustom muse-html-meta-content-type "text/html" - "The content type used for the HTML tag. -If you are striving for XHTML 1.1 compliance, you may want to -change this to \"application/xhtml+xml\"." - :type 'string - :group 'muse-html) - -(defcustom muse-html-meta-content-encoding (if (featurep 'mule) - 'detect - "iso-8859-1") - "The charset to append to the HTML tag. -If set to the symbol 'detect, use `muse-html-encoding-map' to try -and determine the HTML charset from emacs's coding. If set to a -string, this string will be used to force a particular charset" - :type '(choice string symbol) - :group 'muse-html) - -(defcustom muse-html-encoding-default 'iso-8859-1 - "The default Emacs buffer encoding to use in published files. -This will be used if no special characters are found." - :type 'symbol - :group 'muse-html) - -(defcustom muse-html-charset-default "iso-8859-1" - "The default HTML meta charset to use if no translation is found in -`muse-html-encoding-map'." - :type 'string - :group 'muse-html) - -(defcustom muse-html-src-allowed-modes t - "Modes that we allow the tag to colorize. -If t, permit the tag to colorize any mode. - -If a list of mode names, such as '(\"html\" \"latex\"), and the -lang argument to is not in the list, then use fundamental -mode instead." - :type '(choice (const :tag "Any" t) - (repeat (string :tag "Mode"))) - :group 'muse-html) - -(defun muse-html-insert-anchor (anchor) - "Insert an anchor, either around the word at point, or within a tag." - (skip-chars-forward (concat muse-regexp-blank "\n")) - (if (looking-at (concat "<\\([^" muse-regexp-blank "/>\n]+\\)>")) - (let ((tag (match-string 1))) - (goto-char (match-end 0)) - (muse-insert-markup (muse-markup-text 'anchor anchor)) - (when muse-html-anchor-on-word - (or (and (search-forward (format "" tag) - (muse-line-end-position) t) - (goto-char (match-beginning 0))) - (forward-word 1))) - (muse-insert-markup "")) - (muse-insert-markup (muse-markup-text 'anchor anchor)) - (when muse-html-anchor-on-word - (forward-word 1)) - (muse-insert-markup "\n"))) - -(defun muse-html-markup-anchor () - (unless (get-text-property (match-end 1) 'muse-link) - (save-match-data - (muse-html-insert-anchor (match-string 2))) - (match-string 1))) - -(defun muse-html-markup-paragraph () - (let ((end (copy-marker (match-end 0) t))) - (goto-char (match-beginning 0)) - (when (save-excursion - (save-match-data - (and (not (get-text-property (max (point-min) (1- (point))) - 'muse-no-paragraph)) - (re-search-backward "<\\(/?\\)p[ >]" nil t) - (not (string-equal (match-string 1) "/"))))) - (when (get-text-property (1- (point)) 'muse-end-list) - (goto-char (previous-single-property-change (1- (point)) - 'muse-end-list))) - (muse-insert-markup "

    ")) - (goto-char end)) - (cond - ((eobp) - (unless (bolp) - (insert "\n"))) - ((get-text-property (point) 'muse-no-paragraph) - (forward-char 1) - nil) - ((eq (char-after) ?\<) - (cond - ((looking-at "<\\(em\\|strong\\|code\\|span\\)[ >]") - (muse-insert-markup "

    ")) - ((looking-at "\n]+>") - (muse-insert-markup "

    "))) - ((looking-at "]") - (muse-insert-markup "

    ")) - (t - (forward-char 1) - nil))) - ((muse-looking-back "\\(\\|


    \\)\n\n") - (muse-insert-markup "

    ")) - (t - (muse-insert-markup "

    ")))) - -(defun muse-html-markup-footnote () - (cond - ((get-text-property (match-beginning 0) 'muse-link) - nil) - ((= (muse-line-beginning-position) (match-beginning 0)) - (prog1 - (let ((text (match-string 1))) - (muse-insert-markup - (concat "

    " - "" - text "."))) - (save-excursion - (save-match-data - (let* ((beg (goto-char (match-end 0))) - (end (and (search-forward "\n\n" nil t) - (prog1 - (copy-marker (match-beginning 0)) - (goto-char beg))))) - (while (re-search-forward (concat "^[" - muse-regexp-blank - "]+\\([^\n]\\)") - end t) - (replace-match "\\1" t))))) - (replace-match ""))) - (t (let ((text (match-string 1))) - (muse-insert-markup - (concat "" - text ""))) - (replace-match "")))) - -(defun muse-html-markup-table () - (muse-xml-markup-table muse-html-table-attributes)) - -;; Handling of tags for HTML - -(defun muse-html-strip-links (string) - "Remove all HTML links from STRING." - (muse-replace-regexp-in-string "\\(\\|\\)" "" string nil t)) - -(defun muse-html-insert-contents (depth) - "Scan the current document and generate a table of contents at point. -DEPTH indicates how many levels of headings to include. The default is 2." - (let ((max-depth (or depth 2)) - (index 1) - base contents l end) - (save-excursion - (goto-char (point-min)) - (search-forward "Page published by Emacs Muse begins here" nil t) - (catch 'done - (while (re-search-forward "\\(.+?\\)$" nil t) - (unless (and (get-text-property (point) 'read-only) - (not (get-text-property (match-beginning 0) - 'muse-contents))) - (remove-text-properties (match-beginning 0) (match-end 0) - '(muse-contents nil)) - (setq l (1- (string-to-number (match-string 1)))) - (if (null base) - (setq base l) - (if (< l base) - (throw 'done t))) - (when (<= l max-depth) - ;; escape specials now before copying the text, so that we - ;; can deal sanely with both emphasis in titles and - ;; special characters - (goto-char (match-end 2)) - (setq end (point-marker)) - (muse-publish-escape-specials (match-beginning 2) end - nil 'document) - (muse-publish-mark-read-only (match-beginning 2) end) - (setq contents (cons (cons l (buffer-substring-no-properties - (match-beginning 2) end)) - contents)) - (set-marker end nil) - (goto-char (match-beginning 2)) - (muse-html-insert-anchor (concat "sec" (int-to-string index))) - (setq index (1+ index))))))) - (setq index 1 contents (nreverse contents)) - (let ((depth 1) (sub-open 0) (p (point))) - (muse-insert-markup "

    \n
    \n") - (while contents - (muse-insert-markup "
    \n" - "" - (muse-html-strip-links (cdar contents)) - "\n" - "
    \n") - (setq index (1+ index) - depth (caar contents) - contents (cdr contents)) - (when contents - (cond - ((< (caar contents) depth) - (let ((idx (caar contents))) - (while (< idx depth) - (muse-insert-markup "
    \n\n") - (setq sub-open (1- sub-open) - idx (1+ idx))))) - ((> (caar contents) depth) ; can't jump more than one ahead - (muse-insert-markup "
    \n
    \n") - (setq sub-open (1+ sub-open)))))) - (while (> sub-open 0) - (muse-insert-markup "
    \n
    \n") - (setq sub-open (1- sub-open))) - (muse-insert-markup "\n
    \n") - (muse-publish-mark-read-only p (point))))) - -(defun muse-html-denote-headings () - "Place a text property on any headings in the current buffer. -This allows the headings to be picked up later on if publishing a -table of contents." - (save-excursion - (goto-char (point-min)) - (search-forward "Page published by Emacs Muse begins here" nil t) - (while (re-search-forward "\\(.+?\\)$" nil t) - (unless (get-text-property (point) 'read-only) - (add-text-properties (match-beginning 0) (match-end 0) - '(muse-contents t)))))) - -(defun muse-html-class-tag (beg end attrs) - (let ((name (cdr (assoc "name" attrs)))) - (when name - (goto-char beg) - (muse-insert-markup "") - (save-excursion - (goto-char end) - (muse-insert-markup ""))))) - -(defun muse-html-div-tag (beg end attrs) - "Publish a
    tag for HTML." - (let ((id (cdr (assoc "id" attrs))) - (style (cdr (assoc "style" attrs)))) - (when (or id style) - (goto-char beg) - (if (null id) - (muse-insert-markup "
    ") - (muse-insert-markup "
    ")) - (save-excursion - (goto-char end) - (muse-insert-markup "
    "))))) - -(defun muse-html-src-tag (beg end attrs) - "Publish the region using htmlize. -The language to use may be specified by the \"lang\" attribute. - -Muse will look for a function named LANG-mode, where LANG is the -value of the \"lang\" attribute. - -This tag requires htmlize 1.34 or later in order to work." - (if (condition-case nil - (progn - (require 'htmlize) - (if (fboundp 'htmlize-region-for-paste) - nil - (muse-display-warning - (concat "The `htmlize-region-for-paste' function was not" - " found.\nThis is available in htmlize.el 1.34" - " or later.")) - t)) - (error nil t)) - ;; if htmlize.el was not found, treat this like an example tag - (muse-publish-example-tag beg end) - (muse-publish-ensure-block beg end) - (let* ((lang (cdr (assoc "lang" attrs))) - (mode (or (and (not (eq muse-html-src-allowed-modes t)) - (not (member lang muse-html-src-allowed-modes)) - 'fundamental-mode) - (intern-soft (concat lang "-mode")))) - (text (muse-delete-and-extract-region beg end)) - (htmltext - (with-temp-buffer - (insert text) - (if (functionp mode) - (funcall mode) - (fundamental-mode)) - (font-lock-fontify-buffer) - ;; silence the byte-compiler - (when (fboundp 'htmlize-region-for-paste) - ;; transform the region to HTML - (htmlize-region-for-paste (point-min) (point-max)))))) - (save-restriction - (narrow-to-region (point) (point)) - (insert htmltext) - (goto-char (point-min)) - (re-search-forward "]*\\)>\n?" nil t) - (replace-match "
    ")
    -        (goto-char (point-max))
    -        (muse-publish-mark-read-only (point-min) (point-max))))))
    -
    -;; Register the Muse HTML Publisher
    -
    -(defun muse-html-browse-file (file)
    -  (browse-url (concat "file:" file)))
    -
    -(defun muse-html-encoding ()
    -  (if (stringp muse-html-meta-content-encoding)
    -      muse-html-meta-content-encoding
    -    (muse-xml-transform-content-type
    -     (or (and (boundp 'buffer-file-coding-system)
    -              buffer-file-coding-system)
    -         muse-html-encoding-default)
    -     muse-html-charset-default)))
    -
    -(defun muse-html-prepare-buffer ()
    -  (make-local-variable 'muse-html-meta-http-equiv)
    -  (set (make-local-variable 'muse-html-meta-content-type)
    -       (if (save-match-data
    -             (string-match "charset=" muse-html-meta-content-type))
    -           muse-html-meta-content-type
    -         (concat muse-html-meta-content-type "; charset="
    -                 (muse-html-encoding)))))
    -
    -(defun muse-html-munge-buffer ()
    -  (if muse-publish-generate-contents
    -      (progn
    -        (goto-char (car muse-publish-generate-contents))
    -        (muse-html-insert-contents (cdr muse-publish-generate-contents))
    -        (setq muse-publish-generate-contents nil))
    -    (muse-html-denote-headings)))
    -
    -(defun muse-html-finalize-buffer ()
    -  (when (and (boundp 'buffer-file-coding-system)
    -             (memq buffer-file-coding-system '(no-conversion undecided-unix)))
    -    ;; make it agree with the default charset
    -    (setq buffer-file-coding-system muse-html-encoding-default)))
    -
    -;;; Register the Muse HTML and XHTML Publishers
    -
    -(muse-define-style "html"
    -                   :suffix    'muse-html-extension
    -                   :regexps   'muse-html-markup-regexps
    -                   :functions 'muse-html-markup-functions
    -                   :strings   'muse-html-markup-strings
    -                   :tags      'muse-html-markup-tags
    -                   :specials  'muse-xml-decide-specials
    -                   :before    'muse-html-prepare-buffer
    -                   :before-end 'muse-html-munge-buffer
    -                   :after     'muse-html-finalize-buffer
    -                   :header    'muse-html-header
    -                   :footer    'muse-html-footer
    -                   :style-sheet 'muse-html-style-sheet
    -                   :browser   'muse-html-browse-file)
    -
    -(muse-derive-style "xhtml" "html"
    -                   :suffix    'muse-xhtml-extension
    -                   :strings   'muse-xhtml-markup-strings
    -                   :header    'muse-xhtml-header
    -                   :footer    'muse-xhtml-footer
    -                   :style-sheet 'muse-xhtml-style-sheet)
    -
    -;; xhtml1.0 is an alias for xhtml
    -(muse-derive-style "xhtml1.0" "xhtml")
    -
    -;; xhtml1.1 has some quirks that need attention from us
    -(muse-derive-style "xhtml1.1" "xhtml"
    -                   :strings   'muse-xhtml1.1-markup-strings)
    -
    -(provide 'muse-html)
    -
    -;;; muse-html.el ends here
    diff --git a/elpa/muse-3.20/muse-http.el b/elpa/muse-3.20/muse-http.el
    deleted file mode 100644
    index 40bd1cb..0000000
    --- a/elpa/muse-3.20/muse-http.el
    +++ /dev/null
    @@ -1,239 +0,0 @@
    -;;; muse-http.el --- publish HTML files over HTTP
    -
    -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
    -;;   Free Software Foundation, Inc.
    -
    -;; This file is part of Emacs Muse.  It is not part of GNU Emacs.
    -
    -;; Emacs Muse is free software; you can redistribute it and/or modify
    -;; it under the terms of the GNU General Public License as published
    -;; by the Free Software Foundation; either version 3, or (at your
    -;; option) any later version.
    -
    -;; Emacs Muse 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 Emacs Muse; see the file COPYING.  If not, write to the
    -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    -;; Boston, MA 02110-1301, USA.
    -
    -;;; Commentary:
    -
    -;;; Contributors:
    -
    -;;; Code:
    -
    -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    -;;
    -;; Publishing HTML over HTTP (using httpd.el)
    -;;
    -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    -
    -(require 'muse-html)
    -(require 'muse-project)
    -(require 'httpd)
    -(require 'cgi)
    -
    -(defgroup muse-http nil
    -  "Options controlling the behavior of Emacs Muse over HTTP."
    -  :group 'press)
    -
    -(defcustom muse-http-maintainer (concat "webmaster@" (system-name))
    -  "The maintainer address to use for the HTTP 'From' field."
    -  :type 'string
    -  :group 'muse-http)
    -
    -(defcustom muse-http-publishing-style "html"
    -  "The style to use when publishing projects over http."
    -  :type 'string
    -  :group 'muse-http)
    -
    -(defcustom muse-http-max-cache-size 64
    -  "The number of pages to cache when serving over HTTP.
    -This only applies if set while running the persisted invocation
    -server.  See main documentation for the `muse-http'
    -customization group."
    -  :type 'integer
    -  :group 'muse-http)
    -
    -(defvar muse-buffer-mtime nil)
    -(make-variable-buffer-local 'muse-buffer-mtime)
    -
    -(defun muse-sort-buffers (l r)
    -  (let ((l-mtime (with-current-buffer l muse-buffer-mtime))
    -        (r-mtime (with-current-buffer r muse-buffer-mtime)))
    -    (cond
    -     ((and (null l-mtime) (null r-mtime)) l)
    -     ((null l-mtime) r)
    -     ((null r-mtime) l)
    -     (t (muse-time-less-p r-mtime l-mtime)))))
    -
    -(defun muse-winnow-list (entries &optional predicate)
    -  "Return only those ENTRIES for which PREDICATE returns non-nil."
    -  (let ((flist (list t)))
    -    (let ((entry entries))
    -      (while entry
    -        (if (funcall predicate (car entry))
    -            (nconc flist (list (car entry))))
    -        (setq entry (cdr entry))))
    -    (cdr flist)))
    -
    -(defun muse-http-prune-cache ()
    -  "If the page cache has become too large, prune it."
    -  (let* ((buflist
    -          (sort (muse-winnow-list (buffer-list)
    -                                  (function
    -                                   (lambda (buf)
    -                                     (with-current-buffer buf
    -                                       muse-buffer-mtime))))
    -                'muse-sort-buffers))
    -         (len (length buflist)))
    -    (while (> len muse-http-max-cache-size)
    -      (kill-buffer (car buflist))
    -      (setq len (1- len)))))
    -
    -(defvar muse-http-serving-p nil)
    -
    -(defun muse-http-send-buffer (&optional modified code msg)
    -  "Markup and send the contents of the current buffer via HTTP."
    -  (httpd-send (or code 200) (or msg "OK")
    -              "Server: muse.el/" muse-version httpd-endl
    -              "Connection: close" httpd-endl
    -              "MIME-Version: 1.0" httpd-endl
    -              "Date: " (format-time-string "%a, %e %b %Y %T %Z")
    -              httpd-endl
    -              "From: " muse-http-maintainer httpd-endl)
    -  (when modified
    -    (httpd-send-data "Last-Modified: "
    -                     (format-time-string "%a, %e %b %Y %T %Z" modified)
    -                     httpd-endl))
    -  (httpd-send-data "Content-Type: text/html; charset=iso-8859-1" httpd-endl
    -                   "Content-Length: " (number-to-string (1- (point-max)))
    -                   httpd-endl httpd-endl
    -                   (buffer-string))
    -  (httpd-send-eof))
    -
    -(defun muse-http-reject (title msg &optional annotation)
    -  (muse-with-temp-buffer
    -    (insert msg ".\n")
    -    (if annotation
    -        (insert annotation "\n"))
    -    (muse-publish-markup-buffer title muse-http-publishing-style)
    -    (muse-http-send-buffer nil 404 msg)))
    -
    -(defun muse-http-prepare-url (target explicit)
    -  (save-match-data
    -    (unless (or (not explicit)
    -                (string-match muse-url-regexp target)
    -                (string-match muse-image-regexp target)
    -                (string-match muse-file-regexp target))
    -      (setq target (concat "page?" target
    -                           "&project=" muse-http-serving-p))))
    -  (muse-publish-read-only target))
    -
    -(defun muse-http-render-page (name)
    -  "Render the Muse page identified by NAME.
    -When serving from a dedicated Emacs process (see the httpd-serve
    -script), a maximum of `muse-http-max-cache-size' pages will be
    -cached in memory to speed up serving time."
    -  (let ((file (muse-project-page-file name muse-http-serving-p))
    -        (muse-publish-url-transforms
    -         (cons 'muse-http-prepare-url muse-publish-url-transforms))
    -        (inhibit-read-only t))
    -    (when file
    -      (with-current-buffer (get-buffer-create file)
    -        (let ((modified-time (nth 5 (file-attributes file)))
    -              (muse-publishing-current-file file)
    -              muse-publishing-current-style)
    -          (when (or (null muse-buffer-mtime)
    -                    (muse-time-less-p muse-buffer-mtime modified-time))
    -            (erase-buffer)
    -            (setq muse-buffer-mtime modified-time))
    -          (goto-char (point-max))
    -          (when (bobp)
    -            (muse-insert-file-contents file t)
    -            (let ((styles (cddr (muse-project muse-http-serving-p)))
    -                  style)
    -              (while (and styles (null style))
    -                (let ((include-regexp
    -                       (muse-style-element :include (car styles)))
    -                      (exclude-regexp
    -                       (muse-style-element :exclude (car styles))))
    -                  (when (and (or (and (null include-regexp)
    -                                      (null exclude-regexp))
    -                                 (if include-regexp
    -                                     (string-match include-regexp file)
    -                                   (not (string-match exclude-regexp file))))
    -                             (not (muse-project-private-p file)))
    -                    (setq style (car styles))
    -                    (while (muse-style-element :base style)
    -                      (setq style
    -                            (muse-style (muse-style-element :base style))))
    -                    (if (string= (car style) muse-http-publishing-style)
    -                        (setq style (car styles))
    -                      (setq style nil))))
    -                (setq styles (cdr styles)))
    -              (muse-publish-markup-buffer
    -               name (or style muse-http-publishing-style))))
    -          (set-buffer-modified-p nil)
    -          (muse-http-prune-cache)
    -          (current-buffer))))))
    -
    -(defun muse-http-transmit-page (name)
    -  "Render the Muse page identified by NAME.
    -When serving from a dedicated Emacs process (see the httpd-serve
    -script), a maximum of `muse-http-max-cache-size' pages will be
    -cached in memory to speed up serving time."
    -  (let ((inhibit-read-only t)
    -        (buffer (muse-http-render-page name)))
    -    (if buffer
    -        (with-current-buffer buffer
    -          (muse-http-send-buffer muse-buffer-mtime)))))
    -
    -(defvar httpd-vars nil)
    -
    -(defsubst httpd-var (var)
    -  "Return value of VAR as a URL variable.  If VAR doesn't exist, nil."
    -  (cdr (assoc var httpd-vars)))
    -
    -(defsubst httpd-var-p (var)
    -  "Return non-nil if VAR was passed as a URL variable."
    -  (not (null (assoc var httpd-vars))))
    -
    -(defun muse-http-serve (page &optional content)
    -  "Serve the given PAGE from this press server."
    -  ;; index.html is really a reference to the project home page
    -  (if (and muse-project-alist
    -           (string-match "\\`index.html?\\'" page))
    -      (setq page (concat "page?"
    -                         (muse-get-keyword :default
    -                                           (cadr (car muse-project-alist))))))
    -  ;; handle the actual request
    -  (let ((vc-follow-symlinks t)
    -        (muse-publish-report-threshhold nil)
    -        muse-http-serving-p
    -        httpd-vars)
    -    (save-excursion
    -      ;; process any CGI variables, if cgi.el is available
    -      (if (string-match "\\`\\([^&]+\\)&" page)
    -          (setq httpd-vars (cgi-decode (substring page (match-end 0)))
    -                page (match-string 1 page)))
    -      (unless (setq muse-http-serving-p (httpd-var "project"))
    -        (let ((project (car muse-project-alist)))
    -          (setq muse-http-serving-p (car project))
    -          (setq httpd-vars (cons (cons "project" (car project))
    -                                 httpd-vars))))
    -      (if (and muse-http-serving-p
    -               (string-match "\\`page\\?\\(.+\\)" page))
    -          (muse-http-transmit-page (match-string 1 page))))))
    -
    -(if (featurep 'httpd)
    -    (httpd-add-handler "\\`\\(index\\.html?\\|page\\(\\?\\|\\'\\)\\)"
    -                       'muse-http-serve))
    -
    -(provide 'muse-http)
    -
    -;;; muse-http.el ends here
    diff --git a/elpa/muse-3.20/muse-ikiwiki.el b/elpa/muse-3.20/muse-ikiwiki.el
    deleted file mode 100644
    index a664880..0000000
    --- a/elpa/muse-3.20/muse-ikiwiki.el
    +++ /dev/null
    @@ -1,219 +0,0 @@
    -;;; muse-ikiwiki.el --- integrate with Ikiwiki
    -
    -;; Copyright (C) 2008, 2009, 2010  Free Software Foundation, Inc.
    -
    -;; This file is part of Emacs Muse.  It is not part of GNU Emacs.
    -
    -;; Emacs Muse is free software; you can redistribute it and/or modify
    -;; it under the terms of the GNU General Public License as published
    -;; by the Free Software Foundation; either version 3, or (at your
    -;; option) any later version.
    -
    -;; Emacs Muse 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 Emacs Muse; see the file COPYING.  If not, write to the
    -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    -;; Boston, MA 02110-1301, USA.
    -
    -;;; Commentary:
    -
    -;;; Contributors:
    -
    -;;; Code:
    -
    -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    -;;
    -;; Muse Ikiwiki Integration
    -;;
    -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    -
    -(require 'muse)
    -(require 'muse-html)
    -(require 'muse-ipc)
    -(require 'muse-publish)
    -
    -(eval-when-compile
    -  (require 'muse-colors))
    -
    -(defgroup muse-ikiwiki nil
    -  "Options controlling the behavior of Muse integration with Ikiwiki."
    -  :group 'muse-publish)
    -
    -(defcustom muse-ikiwiki-header ""
    -  "Header used for publishing Ikiwiki output files.
    -This may be text or a filename."
    -  :type 'string
    -  :group 'muse-ikiwiki)
    -
    -(defcustom muse-ikiwiki-footer ""
    -  "Footer used for publishing Ikiwiki output files.
    -This may be text or a filename."
    -  :type 'string
    -  :group 'muse-ikiwiki)
    -
    -(defcustom muse-ikiwiki-markup-regexps
    -  `(;; Ikiwiki directives
    -    (1350 ,(concat "\\(\\\\?\\)\\[\\[!""\\(?:-\\|\\w\\)+"
    -                   "\\([" muse-regexp-blank "\n]+"
    -                   "\\(?:\\(?:\\(?:-\\|\\w\\)+=\\)?"
    -                   "\\(?:\"\"\".*?\"\"\"\\|\"[^\"]+\""
    -                   "\\|[^]" muse-regexp-blank "\n]+\\)"
    -                   "[" muse-regexp-blank "\n]*\\)*\\)?\\]\\]")
    -          0 muse-ikiwiki-markup-directive))
    -  "List of markup rules for publishing Ikiwiki markup on Muse pages.
    -For more on the structure of this list, see `muse-publish-markup-regexps'."
    -  :type '(repeat (choice
    -                  (list :tag "Markup rule"
    -                        integer
    -                        (choice regexp symbol)
    -                        integer
    -                        (choice string function symbol))
    -                  function))
    -  :group 'muse-ikiwiki)
    -
    -;;; Publishing
    -
    -(defun muse-ikiwiki-markup-directive ()
    -  "Handle publishing of an Ikiwiki directive."
    -  (unless (get-text-property (match-beginning 0) 'read-only)
    -    (add-text-properties (match-beginning 0) (match-end 0)
    -                         '(muse-no-paragraph t))
    -    (muse-publish-mark-read-only (match-beginning 0) (match-end 0))))
    -
    -(defun muse-ikiwiki-publish-buffer (name title &optional style)
    -  "Publish a buffer for Ikiwki.
    -The name of the corresponding file is NAME.
    -The name of the style is given by STYLE.  It defaults to \"ikiwiki\"."
    -  (unless style (setq style "ikiwiki"))
    -  (unless title (setq title (muse-page-name name)))
    -  (let ((muse-batch-publishing-p t)
    -        (muse-publishing-current-file name)
    -        (muse-publishing-current-output-path name)
    -        (muse-publishing-current-style style)
    -        (font-lock-verbose nil)
    -        (vc-handled-backends nil)) ; don't activate VC when publishing files
    -    (run-hooks 'muse-before-publish-hook)
    -    (let ((muse-inhibit-before-publish-hook t))
    -      (muse-publish-markup-buffer title style))))
    -
    -(defun muse-ikiwiki-publish-file (file name &optional style)
    -  "Publish a single file for Ikiwiki.
    -The name of the real file is NAME, and the name of the temporary
    -file containing the content is FILE.
    -The name of the style is given by STYLE.  It defaults to \"ikiwiki\"."
    -  (if (not (stringp file))
    -      (message "Error: No file given to publish")
    -    (unless style
    -      (setq style "ikiwiki"))
    -    (let ((output-path file)
    -          (target file)
    -          (vc-handled-backends nil) ; don't activate VC when publishing files
    -          auto-mode-alist
    -          muse-current-output-style)
    -      (setq auto-mode-alist
    -            (delete (cons (concat "\\." muse-file-extension "\\'")
    -                          'muse-mode-choose-mode)
    -                    auto-mode-alist))
    -      (setq muse-current-output-style (list :base style :path file))
    -      (muse-with-temp-buffer
    -        (muse-insert-file-contents file)
    -        (muse-ikiwiki-publish-buffer name nil style)
    -        (when (muse-write-file output-path t)
    -          (muse-style-run-hooks :final style file output-path target))))))
    -
    -(defun muse-ikiwiki-start-server (port)
    -  "Start Muse IPC server, initializing with the client on PORT."
    -  (muse-ipc-start "foo" #'muse-ikiwiki-publish-buffer port))
    -
    -;;; Colors
    -
    -(defface muse-ikiwiki-directive
    -  '((((class color) (background light))
    -     (:foreground "dark green"))
    -    (((class color) (background dark))
    -     (:foreground "green")))
    -  "Face for Ikiwiki directives."
    -  :group 'muse-ikiwiki)
    -
    -(defun muse-colors-ikiwiki-directive ()
    -  "Color ikiwiki directives."
    -  (let ((start (match-beginning 0)))
    -    (unless (or (eq (get-text-property start 'invisible) 'muse)
    -                (get-text-property start 'muse-comment)
    -                (get-text-property start 'muse-directive))
    -      ;; beginning of line or space or symbol
    -      (save-excursion
    -        (and
    -         (catch 'valid
    -           (while t
    -             (skip-chars-forward "^\"]" muse-colors-region-end)
    -             (cond ((eq (point) (point-max))
    -                    (throw 'valid nil))
    -                   ((> (point) muse-colors-region-end)
    -                    (throw 'valid nil))
    -                   ((eq (char-after) ?\")
    -                    (if (and (< (1+ (point)) muse-colors-region-end)
    -                             (eq (char-after (1+ (point))) ?\"))
    -                        (if (and (< (+ 2 (point)) muse-colors-region-end)
    -                                 (eq (char-after (+ 2 (point))) ?\"))
    -                            ;; triple-quote
    -                            (progn
    -                              (forward-char 3)
    -                              (or (and (looking-at "\"\"\"")
    -                                       (goto-char (match-end 0)))
    -                                  (re-search-forward
    -                                   "\"\"\"" muse-colors-region-end t)
    -                                  (throw 'valid nil)))
    -                          ;; empty quotes (""), which are invalid
    -                          (throw 'valid nil))
    -                      ;; quote with content
    -                      (forward-char 1)
    -                      (skip-chars-forward "^\"" muse-colors-region-end)
    -                      (when (eq (char-after) ?\")
    -                        (forward-char 1))))
    -                   ((eq (char-after) ?\])
    -                    (forward-char 1)
    -                    (when (and (< (point) muse-colors-region-end)
    -                               (eq (char-after (point)) ?\]))
    -                      (forward-char 1)
    -                      (throw 'valid t)))
    -                   (t (throw 'valid nil)))))
    -         ;; found a valid directive
    -         (let ((end (point)))
    -           ;; remove flyspell overlays
    -           (when (fboundp 'flyspell-unhighlight-at)
    -             (let ((cur start))
    -               (while (> end cur)
    -                 (flyspell-unhighlight-at cur)
    -                 (setq cur (1+ cur)))))
    -           (add-text-properties start end
    -                                '(face muse-ikiwiki-directive
    -                                  muse-directive t muse-no-flyspell t))
    -           (when (progn
    -                   (goto-char start)
    -                   (skip-chars-forward "^\n" end)
    -                   (and (eq (char-after) ?\n)
    -                        (not (= (point) end))))
    -             (add-text-properties start end
    -                                  '(font-lock-multiline t)))))))))
    -
    -(defun muse-ikiwiki-insinuate-colors ()
    -  (add-to-list 'muse-colors-markup
    -               '("\\[\\[!" ?\[ muse-colors-ikiwiki-directive)
    -               nil))
    -
    -(eval-after-load "muse-colors" '(muse-ikiwiki-insinuate-colors))
    -
    -;; Styles
    -(muse-derive-style "ikiwiki" "xhtml"
    -                   :header  'muse-ikiwiki-header
    -                   :footer  'muse-ikiwiki-footer
    -                   :regexps 'muse-ikiwiki-markup-regexps)
    -
    -(provide 'muse-ikiwiki)
    -
    -;;; muse-ikiwiki.el ends here
    diff --git a/elpa/muse-3.20/muse-import-docbook.el b/elpa/muse-3.20/muse-import-docbook.el
    deleted file mode 100644
    index ed1b22b..0000000
    --- a/elpa/muse-3.20/muse-import-docbook.el
    +++ /dev/null
    @@ -1,137 +0,0 @@
    -;;; muse-import-docbook.el --- convert Docbook XML into Muse format
    -
    -;; Copyright (C) 2006, 2007, 2008, 2009, 2010
    -;;   Free Software Foundation, Inc.
    -
    -;; Author: Elena Pomohaci 
    -
    -;; This file is part of Emacs Muse.  It is not part of GNU Emacs.
    -
    -;; Emacs Muse is free software; you can redistribute it and/or modify
    -;; it under the terms of the GNU General Public License as published
    -;; by the Free Software Foundation; either version 3, or (at your
    -;; option) any later version.
    -
    -;; Emacs Muse 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 Emacs Muse; see the file COPYING.  If not, write to the
    -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    -;; Boston, MA 02110-1301, USA.
    -
    -;;; Commentary:
    -
    -;; It works only for article type docbook docs and recognize
    -;; followings elements: article, sect1, sect2, sect3, title,
    -
    -;;; Contributors:
    -
    -;;; Code:
    -
    -(require 'muse-import-xml)
    -
    -(defvar muse-import-docbook-prefix "muse-import-docbook-"
    -  "The name prefix for tag functions")
    -
    -(defvar muse-import-docbook-para-indent "\n\n"
    -  "Para elements indentation (0, less than 6 spaces, more than 6 spaces)")
    -
    -(defun muse-import-docbook-reset-para-indent ()
    -  (setq muse-import-docbook-para-indent "\n\n"))
    -
    -
    -;;;###autoload
    -(defun muse-import-docbook (src dest)
    -  "Convert the Docbook buffer SRC to Muse, writing output in the DEST buffer."
    -  (interactive "bDocbook buffer:\nBMuse buffer:")
    -  (setq muse-import-xml-prefix muse-import-docbook-prefix)
    -  (setq muse-import-xml-generic-function-name "muse-import-xml-node")
    -  (muse-import-xml src dest))
    -
    -;;;###autoload
    -(defun muse-import-docbook-files (src dest)
    -  "Convert the Docbook file SRC to Muse, writing output to the DEST file."
    -  (interactive "fDocbook file:\nFMuse file:")
    -  (with-temp-file dest
    -    (muse-import-docbook (find-file-noselect src) (current-buffer))))
    -
    -
    -;;; element specific functions
    -
    -(defun muse-import-docbook-get-title (node)
    -  (let ((tit (car (xml-get-children node 'title))))
    -    (insert (car (cddr tit)) ?\n ?\n)
    -    (muse-import-xml-parse-tree (xml-node-children (remove tit node)))))
    -
    -
    -(defun muse-import-docbook-article (node)
    -  "Article conversion function"
    -  (muse-import-xml-node node))
    -
    -(defun muse-import-docbook-articleinfo (node)
    -  "Article conversion function"
    -  (insert "#title ")
    -  (muse-import-docbook-get-title node)
    -  (insert ?\n))
    -
    -
    -(defalias 'muse-import-docbook-appendix 'muse-import-docbook-article)
    -
    -(defalias 'muse-import-docbook-appendixinfo 'muse-import-docbook-articleinfo)
    -
    -
    -(defun muse-import-docbook-sect1 (node)
    -  "Section 1 conversion function"
    -  (insert ?\n "* ")
    -  (muse-import-docbook-get-title node))
    -
    -(defun muse-import-docbook-sect2 (node)
    -  "Section 2 conversion function"
    -  (insert ?\n "** ")
    -  (muse-import-docbook-get-title node))
    -
    -(defun muse-import-docbook-sect3 (node)
    -  "Section 3 conversion function"
    -  (insert ?\n "*** ")
    -  (muse-import-docbook-get-title node))
    -
    -
    -(defun muse-import-docbook-graphic (node)
    -  "Graphic conversion function. Image format is forced to PNG"
    -  (let ((name (xml-get-attribute node 'fileref)))
    -  (insert "\n[[img/" name ".png][" name "]]")))
    -
    -(defun muse-import-docbook-para (node)
    -  (insert muse-import-docbook-para-indent)
    -  (muse-import-xml-node node))
    -
    -
    -(defun muse-import-docbook-emphasis (node)
    -  (insert "*")
    -  (muse-import-xml-node node)
    -  (insert "*"))
    -
    -(defun muse-import-docbook-quote (node)
    -  (insert "\"")
    -  (muse-import-xml-node node)
    -  (insert "\""))
    -
    -(defun muse-import-docbook-blockquote (node)
    -  (setq muse-import-docbook-para-indent "\n\n  ")
    -  (muse-import-xml-node node)
    -  (muse-import-docbook-reset-para-indent))
    -
    -(defun muse-import-docbook-member (node)
    -  (insert "\n> ")
    -  (muse-import-xml-node node))
    -
    -(defun muse-import-docbook-bridgehead (node)
    -  (insert "\n* ")
    -  (muse-import-xml-node node))
    -
    -(provide 'muse-import-docbook)
    -
    -;;; muse-import-docbook.el ends here
    diff --git a/elpa/muse-3.20/muse-import-latex.el b/elpa/muse-3.20/muse-import-latex.el
    deleted file mode 100644
    index 5297131..0000000
    --- a/elpa/muse-3.20/muse-import-latex.el
    +++ /dev/null
    @@ -1,149 +0,0 @@
    -;;; muse-import-latex.el --- convert a LaTex file into a Muse file
    -
    -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
    -;;   Free Software Foundation, Inc.
    -
    -;; This file is part of Emacs Muse.  It is not part of GNU Emacs.
    -
    -;; Emacs Muse is free software; you can redistribute it and/or modify
    -;; it under the terms of the GNU General Public License as published
    -;; by the Free Software Foundation; either version 3, or (at your
    -;; option) any later version.
    -
    -;; Emacs Muse 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 Emacs Muse; see the file COPYING.  If not, write to the
    -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    -;; Boston, MA 02110-1301, USA.
    -
    -;;; Commentary:
    -
    -;; Helper commands for converting a LaTeX file into a Muse file.
    -
    -;;; Contributors:
    -
    -;;; Code:
    -
    -(require 'muse)
    -(require 'muse-regexps)
    -
    -(defun muse-i-l-write-citation (note author citation pages)
    -  (save-excursion
    -    (goto-char (point-max))
    -    (if (= note 1)
    -        (insert "\nFootnotes:\n\n"))
    -    (let ((beg (point)))
    -      (insert "\n[" (number-to-string note) "]  " author)
    -      (if (and citation pages)
    -          (insert ", " citation ", " pages))
    -      (insert "\n")
    -      (goto-char beg)
    -      (while (re-search-forward (concat "p.\\\\[" muse-regexp-blank "\n]+")
    -                                nil t)
    -        (replace-match "p."))
    -      (goto-char beg)
    -      (while (re-search-forward "--" nil t)
    -        (replace-match "-")))))
    -
    -(defun muse-i-l-write-footnote (note text)
    -  (save-excursion
    -    (goto-char (point-max))
    -    (if (= note 1)
    -        (insert "\nFootnotes:\n\n"))
    -    (insert "\n[" (number-to-string note) "]  " text ?\n)))
    -
    -;;;###autoload
    -(defun muse-import-latex ()
    -  (interactive)
    -  (goto-char (point-min))
    -  (while (not (eobp))
    -    (cond
    -     ((or (looking-at "^\\\\documentclass")
    -          (looking-at "^\\\\input")
    -          (looking-at "^\\\\begin{document}")
    -          (looking-at "^\\\\end{document}")
    -          (looking-at "^\\\\author")
    -          (looking-at "^\\\\\\(med\\|big\\|small\\)skip")
    -          (looking-at "^\\\\maketitle"))
    -      (delete-region (point) (muse-line-end-position)))
    -     ((looking-at "^\\\\title{\\(.+\\)}")
    -      (delete-region (match-end 1) (muse-line-end-position))
    -      (delete-region (point) (match-beginning 1))
    -      (insert "#title ")))
    -    (forward-line))
    -  (goto-char (point-min))
    -  (while (re-search-forward "\\\\\\(l\\)?dots{}" nil t)
    -    (replace-match (concat (and (string= (match-string 1) "l") ".")
    -                           "...")))
    -  (goto-char (point-min))
    -  (while (re-search-forward "\\(``\\|''\\)" nil t)
    -    (replace-match "\""))
    -  (goto-char (point-min))
    -  (while (re-search-forward "---" nil t)
    -    (replace-match " -- "))
    -  (goto-char (point-min))
    -  (while (re-search-forward "\\\\tableofcontents" nil t)
    -    (replace-match ""))
    -  (goto-char (point-min))
    -  (while (re-search-forward "\\\\\\\\" nil t)
    -    (replace-match ""))
    -  (goto-char (point-min))
    -  (while (re-search-forward "\\\\\\(sub\\)?section{\\([^}]+\\)}" nil t)
    -    (replace-match (concat (if (string= (match-string 1) "sub")
    -                               "**" "*")
    -                           " " (match-string 2))))
    -  (goto-char (point-min))
    -  (while (re-search-forward "\\\\\\(begin\\|end\\){verse}" nil t)
    -    (replace-match (concat "<" (if (string= (match-string 1) "end") "/")
    -                           "verse>")))
    -  (goto-char (point-min))
    -  (while (re-search-forward "\\\\\\(begin\\|end\\){quote}\n" nil t)
    -    (replace-match ""))
    -  (goto-char (point-min))
    -  (while (re-search-forward
    -          "\\\\\\(emph\\|textbf\\){\\([^}]+?\\)\\(\\\\/\\)?}" nil t)
    -    (replace-match
    -     (if (string= (match-string 1) "emph") "*\\2*" "**\\2**")))
    -  (let ((footnote-index 1))
    -    (goto-char (point-min))
    -    (while (re-search-forward
    -            (concat "\\\\\\(q\\)?\\(footnote\\|excerpt\\)\\(np\\)?"
    -                    "\\({\\([^}]+\\)}\\)?"
    -                    "\\({\\([^}]+\\)}{\\([^}]+\\)}\\)?{\\([^}]+\\)}") nil t)
    -      (let ((beg (match-beginning 0))
    -            (end (match-end 0)))
    -        (unless (string= (match-string 2) "footnote")
    -          (if (null (match-string 1))
    -              (insert "  " (match-string 9))
    -            (let ((b (point)) e)
    -              (insert "\"" (match-string 9) "\"")
    -              (setq e (point-marker))
    -              (save-match-data
    -                (save-excursion
    -                  (goto-char b)
    -                  (while (< (point) e)
    -                    (if (looking-at "\\s-+")
    -                        (delete-region (match-beginning 0)
    -                                       (match-end 0)))
    -                    (forward-line))))
    -              (set-marker e nil))))
    -        (insert "[" (number-to-string footnote-index) "]")
    -        (if (string= (match-string 2) "footnote")
    -            (muse-i-l-write-footnote footnote-index (match-string 9))
    -          (muse-i-l-write-citation footnote-index (match-string 5)
    -                                   (match-string 7) (match-string 8)))
    -        (setq footnote-index (1+ footnote-index))
    -        (delete-region beg end))))
    -  (goto-char (point-min))
    -  (while (looking-at "\n") (delete-char 1))
    -  (goto-char (point-min))
    -  (while (re-search-forward "\n\n+" nil t)
    -    (replace-match "\n\n")))
    -
    -(provide 'muse-import-latex)
    -
    -;;; muse-import-latex.el ends here
    diff --git a/elpa/muse-3.20/muse-import-xml.el b/elpa/muse-3.20/muse-import-xml.el
    deleted file mode 100644
    index 2579ce8..0000000
    --- a/elpa/muse-3.20/muse-import-xml.el
    +++ /dev/null
    @@ -1,88 +0,0 @@
    -;;; muse-import-xml.el --- common to all from-xml converters
    -
    -;; Copyright (C) 2006, 2007, 2008, 2009, 2010
    -;;   Free Software Foundation, Inc.
    -
    -;; Author: Elena Pomohaci 
    -
    -;; This file is part of Emacs Muse.  It is not part of GNU Emacs.
    -
    -;; Emacs Muse is free software; you can redistribute it and/or modify
    -;; it under the terms of the GNU General Public License as published
    -;; by the Free Software Foundation; either version 3, or (at your
    -;; option) any later version.
    -
    -;; Emacs Muse 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 Emacs Muse; see the file COPYING.  If not, write to the
    -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    -;; Boston, MA 02110-1301, USA.
    -
    -;;; Commentary:
    -
    -;;; Contributors:
    -
    -;;; Code:
    -
    -(provide 'muse-import-xml)
    -
    -(require 'xml)
    -(require 'muse)
    -
    -(defvar muse-import-xml-prefix ""
    -  "The name prefix for tag functions")
    -
    -(defvar muse-import-xml-generic-function-name "muse-import-xml-generic"
    -  "The generic function name")
    -
    -(defun muse-import-xml-convert-to-list (buf)
    -  "Convert xml BUF in a xml-list"
    -  (with-temp-buffer
    -    (insert-buffer-substring buf)
    -    (goto-char (point-min))
    -    (while (re-search-forward ">[ \n\t]*<" nil t)
    -      (replace-match "><" nil nil)) ; clean all superfluous blank characters
    -    (xml-parse-region (point-min)
    -                      (point-max)
    -                      (current-buffer))))
    -
    -
    -(defun muse-import-xml-generic (node)
    -  "The generic function called when there is no node specific function."
    -  (let ((name (xml-node-name node)))
    -    (insert "<" (symbol-name name)  ">")
    -    (muse-import-xml-node node)
    -    (insert "")))
    -
    -(defun muse-import-xml-parse-tree (lst)
    -  "Parse an xml tree list"
    -  (mapc #'muse-import-xml-parse-node lst))
    -
    -(defun muse-import-xml-parse-node (node)
    -  "Parse a xml tree node"
    -  (if (stringp node)
    -      (insert (muse-replace-regexp-in-string "^[ \t]+" "" node))
    -    (let ((fname (intern-soft (concat muse-import-xml-prefix
    -                                      (symbol-name (xml-node-name node))))))
    -      (if (functionp fname)
    -          (funcall fname node)
    -        (funcall (intern muse-import-xml-generic-function-name) node)))))
    -
    -
    -(defun muse-import-xml-node (node)
    -  "Default node function"
    -  (muse-import-xml-parse-tree (xml-node-children node)))
    -
    -
    -(defun muse-import-xml (src dest)
    -  "Convert the xml SRC buffer in a muse DEST buffer"
    -  (set-buffer (get-buffer-create dest))
    -  (when (fboundp 'muse-mode)
    -    (muse-mode))
    -  (muse-import-xml-parse-tree (muse-import-xml-convert-to-list src)))
    -
    -;;; muse-import-xml.el ends here
    diff --git a/elpa/muse-3.20/muse-ipc.el b/elpa/muse-3.20/muse-ipc.el
    deleted file mode 100644
    index 9ce8eb1..0000000
    --- a/elpa/muse-3.20/muse-ipc.el
    +++ /dev/null
    @@ -1,194 +0,0 @@
    -;;; muse-ipc.el --- publish Muse documents from other processes
    -
    -;; Copyright (C) 2009, 2010  Free Software Foundation, Inc.
    -
    -;; This file is part of Emacs Muse.  It is not part of GNU Emacs.
    -
    -;; Emacs Muse is free software; you can redistribute it and/or modify
    -;; it under the terms of the GNU General Public License as published
    -;; by the Free Software Foundation; either version 3, or (at your
    -;; option) any later version.
    -
    -;; Emacs Muse 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 Emacs Muse; see the file COPYING.  If not, write to the
    -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    -;; Boston, MA 02110-1301, USA.
    -
    -;;; Commentary:
    -
    -;; This file is still in alpha state.  Not for production use!
    -
    -;;; Contributors:
    -
    -;;; Code:
    -
    -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    -;;
    -;; Muse Inter-Process Communication
    -;;
    -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    -
    -(eval-when-compile (require 'cl))
    -
    -(require 'muse)
    -(require 'muse-publish)
    -
    -(defgroup muse-ipc nil
    -  "Options controlling the behavior of Muse's IPC module."
    -  :group 'muse-publish)
    -
    -(defcustom muse-ipc-timeout 60
    -  "Maximum time to wait for a client to respond."
    -  :group 'muse-ipc
    -  :type 'number)
    -
    -(defcustom muse-ipc-ignore-done nil
    -  "If non-nil, ignore any 'done' messages that we get from clients."
    -  :group 'muse-ipc
    -  :type 'boolean)
    -
    -(defvar muse-ipc-server-port nil
    -  "Port of the Emacs server.")
    -
    -(defvar muse-ipc-server-process nil
    -  "Process of the Emacs server.")
    -
    -(defvar muse-ipc-server-registered nil
    -  "Whether we have successfully registered our port with the client.")
    -
    -(defun muse-ipc-init-filter (proc string)
    -  "Handle data from client while initiating a connection."
    -  (unless muse-ipc-server-registered
    -    (when (string-match "\\`ok$" string)
    -      (setq muse-ipc-server-registered t))))
    -
    -(defun muse-ipc-delete-client (proc)
    -  "Delete a client."
    -  (let ((buffer (process-get proc :buffer)))
    -    (when (and buffer (buffer-live-p buffer))
    -      (with-current-buffer buffer
    -        (set-buffer-modified-p nil))
    -      (kill-buffer buffer)))
    -  (when (eq (process-status proc) 'open)
    -    (delete-process proc)))
    -
    -(defun* muse-ipc-server-filter (proc string)
    -  "Handle data from a client after it connects."
    -  ;; Authenticate
    -  (unless (process-get proc :authenticated)
    -    (if (and (string-match "\\`begin \\(.+\\)$" string)
    -             (equal (match-string 1 string)
    -                    (process-get proc :shared-secret)))
    -        (progn
    -          (setq string (substring string (match-end 0)))
    -          (process-put proc :authenticated t)
    -          (process-send-string proc "ok\n"))
    -      (process-send-string proc "nok\n")
    -      (delete-process proc))
    -    (return-from muse-ipc-server-filter))
    -
    -  ;; Handle case where the client is sending data to be published
    -  (when (process-get proc :sending-data)
    -    (with-current-buffer (process-get proc :buffer)
    -      (insert string)
    -      (let ((buf-len (1- (point)))
    -            (expected-len (process-get proc :data-bytes)))
    -        (cond ((= buf-len expected-len)
    -               (process-put proc :sending-data nil))
    -              ((> buf-len expected-len)
    -               (process-send-string proc "nok\n")
    -               (muse-ipc-delete-client proc)))))
    -    (return-from muse-ipc-server-filter))
    -
    -  ;; Dispatch commands
    -  (cond
    -   ((string-match "\\`done$" string)
    -    ;; done, close the server
    -    (unless muse-ipc-ignore-done
    -      (muse-ipc-stop-server)))
    -
    -   ((string-match "\\`name \\(.+\\)$" string)
    -    ;; set name
    -    (process-put proc :file-name (match-string 1 string))
    -    (process-send-string proc "ok\n"))
    -
    -   ((string-match "\\`title \\(.+\\)$" string)
    -    ;; set title
    -    (process-put proc :title (match-string 1 string))
    -    (process-send-string proc "ok\n"))
    -
    -   (t
    -    ;; unrecognized command
    -    (process-send-string proc "nok\n"))))
    -
    -(defun muse-ipc-stop-server ()
    -  "Stop Muse IPC server and reset connection data."
    -  (stop-process muse-ipc-server-process)
    -  (delete-process muse-ipc-server-process)
    -  (setq muse-ipc-server-port nil)
    -  (setq muse-ipc-server-process nil))
    -
    -(defun muse-ipc-start (shared-secret publish-fn client-port &optional server-port)
    -  "Start an IPC connection and send a response to CLIENT-PORT.
    -If SERVER-PORT is provided, start the IPC server on that port, otherwise
    -choose a random port.
    -
    -SHARED-SECRET is used as a very minimal security measure to
    -authenticate the Muse IPC server during initialization, and also
    -any incoming clients once the server is started.
    -
    -PUBLISH-FN is the function which should be called in buffer of
    -the received contents.  It should transform the buffer into a
    -published state.  It must take at least two arguments.  The first
    -argument is the full path of the file that the contents
    -correspond with.  The second argument is the title to use when
    -publishing the file."
    -  (when (stringp client-port)
    -    (setq client-port (string-to-number client-port)))
    -  (when (stringp server-port)
    -    (setq server-port (string-to-number server-port)))
    -  (setq muse-ipc-server-process
    -        (make-network-process
    -         :name "muse-ipc"
    -         :buffer nil
    -         :host 'local :service (or server-port t)
    -         :server t :noquery t :nowait t
    -         :plist (list :authenticated nil :shared-secret shared-secret
    -                      :publish-fn publish-fn)
    -         :filter 'muse-ipc-server-filter))
    -  (unless muse-ipc-server-process
    -    (error "Error: Could not start Muse IPC Server process"))
    -  (set-process-coding-system muse-ipc-server-process
    -                             'raw-text-unix 'raw-text-unix)
    -  (setq muse-ipc-server-port
    -        (number-to-string
    -         (cadr (process-contact muse-ipc-server-process))))
    -  (let ((client-proc
    -         (make-network-process
    -          :name "muse-ipc-client"
    -          :buffer nil
    -          :host 'local :service client-port
    -          :noquery t
    -          :filter 'muse-ipc-init-filter)))
    -    (setq muse-ipc-server-registered nil)
    -    (process-send-string client-proc
    -                         (concat "begin " shared-secret "\n"))
    -    (accept-process-output client-proc muse-ipc-timeout nil t)
    -    (unless muse-ipc-server-registered
    -      (error "Error: Did not register listener"))
    -    (process-send-string client-proc
    -                         (concat "port " muse-ipc-server-port "\n"))
    -    (stop-process client-proc)
    -    (delete-process client-proc))
    -
    -  ;; Accept process output until the server dies
    -  (while muse-ipc-server-process (accept-process-output nil 1)))
    -
    -(provide 'muse-ipc)
    -
    -;;; muse-ipc.el ends here
    diff --git a/elpa/muse-3.20/muse-journal.el b/elpa/muse-3.20/muse-journal.el
    deleted file mode 100644
    index e523b4c..0000000
    --- a/elpa/muse-3.20/muse-journal.el
    +++ /dev/null
    @@ -1,774 +0,0 @@
    -;;; muse-journal.el --- keep and publish a journal
    -
    -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
    -;;   Free Software Foundation, Inc.
    -
    -;; This file is part of Emacs Muse.  It is not part of GNU Emacs.
    -
    -;; Emacs Muse is free software; you can redistribute it and/or modify
    -;; it under the terms of the GNU General Public License as published
    -;; by the Free Software Foundation; either version 3, or (at your
    -;; option) any later version.
    -
    -;; Emacs Muse 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 Emacs Muse; see the file COPYING.  If not, write to the
    -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    -;; Boston, MA 02110-1301, USA.
    -
    -;;; Commentary:
    -
    -;; The module facilitates the keeping and publication of a journal.
    -;; When publishing to HTML, it assumes the form of a web log, or blog.
    -;;
    -;; The input format for each entry is as follows:
    -;;
    -;;   * 20040317: Title of entry
    -;;
    -;;   Text for the entry.
    -;;
    -;;   
    -;;   "You know who you are. It comes down to a simple gut check: You
    -;;   either love what you do or you don't. Period." -- P. Bronson
    -;;   
    -;;
    -;; The "qotd", or Quote of the Day, is entirely optional.  When
    -;; generated to HTML, this entry is rendered as:
    -;;
    -;;   
    -;;
    -;;

    Quote of the Day:

    -;;

    "You know who you are. It comes down to a simple gut -;; check: You either love what you do or you don't. Period." -;; -- P. Bronson

    -;;
    -;;
    -;;
    -;; -;;
    -;;

    Title of entry

    -;;
    -;;
    -;;
    -;;

    Text for the entry.

    -;;
    -;;
    -;;
    -;; -;; The plurality of "div" tags makes it possible to display the -;; entries in any form you wish, using a CSS style. -;; -;; Also, an .RDF file can be generated from your journal by publishing -;; it with the "rdf" style. It uses the first two sentences of the -;; first paragraph of each entry as its "description", and -;; autogenerates tags for linking to the various entries. - -;;; Contributors: - -;; René Stadler (mail AT renestadler DOT de) provided a patch that -;; causes dates in RSS feeds to be generated in a format that RSS -;; readers can parse. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse Journal Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-publish) -(require 'muse-html) -(require 'muse-latex) -(require 'muse-book) - -(defgroup muse-journal nil - "Rules for transforming a journal into its final form." - :group 'muse-publish) - -(defcustom muse-journal-heading-regexp - "\\(?:\\([0-9]+\\)\\(?:: \\)?\\)?\\(.+?\\)?" - "A regexp that matches a journal heading. -Paren group 1 is the ISO date, group 2 is the optional category, -and group 3 is the optional heading for the entry." - :type 'regexp - :group 'muse-journal) - -(defcustom muse-journal-date-format "%a, %e %b %Y" - "Date format to use for journal entries." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-html-heading-regexp - (concat "^\n]*>" muse-journal-heading-regexp "$") - "A regexp that matches a journal heading from an HTML document. -Paren group 1 is the ISO date, group 2 is the optional category, -and group 3 is the optional heading for the entry." - :type 'regexp - :group 'muse-journal) - -(defcustom muse-journal-rss-heading-regexp - (concat "^\\* " muse-journal-heading-regexp "$") - "A regexp that matches a journal heading from an HTML document. -Paren group 1 is the ISO date, group 2 is the optional category, -and group 3 is the optional heading for the entry." - :type 'regexp - :group 'muse-journal) - -(defcustom muse-journal-html-entry-template - "
    -   -
    -
    -
    - %date% -
    -
    -

    %title%

    -
    -
    -
    -
    -

    %qotd%

    -
    -%text% -
    -
    -
    \n\n" - "Template used to publish individual journal entries as HTML. -This may be text or a filename." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-latex-section - "\\section*{%title% \\hfill {\\normalsize %date%}} -\\addcontentsline{toc}{chapter}{%title%}" - "Template used to publish a LaTeX section." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-latex-subsection - "\\subsection*{%title%} -\\addcontentsline{toc}{section}{%title%}" - "Template used to publish a LaTeX subsection." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-markup-tags - '(("qotd" t nil nil muse-journal-qotd-tag)) - "A list of tag specifications, for specially marking up Journal entries. -See `muse-publish-markup-tags' for more info. - -This is used by journal-latex and its related styles, as well as -the journal-rss-entry style, which both journal-rdf and -journal-rss use." - :type '(repeat (list (string :tag "Markup tag") - (boolean :tag "Expect closing tag" :value t) - (boolean :tag "Parse attributes" :value nil) - (boolean :tag "Nestable" :value nil) - function)) - :group 'muse-journal) - -;; FIXME: This doesn't appear to be used. -(defun muse-journal-generate-pages () - (let ((output-dir (muse-style-element :path))) - (goto-char (point-min)) - (while (re-search-forward muse-journal-heading-regexp nil t) - (let* ((date (match-string 1)) - (category (match-string 1)) - (category-file (concat output-dir category "/index.html")) - (heading (match-string 1))) - t)))) - -(defcustom muse-journal-rdf-extension ".rdf" - "Default file extension for publishing RDF (RSS 1.0) files." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rdf-base-url "" - "The base URL of the website referenced by the RDF file." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rdf-header - " - (concat (muse-style-element :base-url) - (muse-publish-link-name))\"> - <lisp>(muse-publishing-directive \"title\")</lisp> - (concat (muse-style-element :base-url) - (concat (muse-page-name) - muse-html-extension)) - (muse-publishing-directive \"desc\") - - - - (concat (muse-style-element :base-url) - (concat (muse-page-name) - muse-html-extension))\"/> - - - \n" - "Header used for publishing RDF (RSS 1.0) files. -This may be text or a filename." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rdf-footer - "\n" - "Footer used for publishing RDF (RSS 1.0) files. -This may be text or a filename." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rdf-date-format - "%Y-%m-%dT%H:%M:%S" - "Date format to use for RDF entries." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rdf-entry-template - "\n - %title% - - %desc% - - %link%#%anchor% - %date% - %maintainer% - \n" - "Template used to publish individual journal entries as RDF. -This may be text or a filename." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rdf-summarize-entries nil - "If non-nil, include only summaries in the RDF file, not the full data. - -The default is nil, because this annoys some subscribers." - :type 'boolean - :group 'muse-journal) - -(defcustom muse-journal-rss-extension ".xml" - "Default file extension for publishing RSS 2.0 files." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rss-base-url "" - "The base URL of the website referenced by the RSS file." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rss-header - "<\?xml version=\"1.0\" encoding=\" - (muse-html-encoding)\"?> - - - <lisp>(muse-publishing-directive \"title\")</lisp> - (concat (muse-style-element :base-url) - (concat (muse-page-name) - muse-html-extension)) - (muse-publishing-directive \"desc\") - en-us - Emacs Muse\n\n" - "Header used for publishing RSS 2.0 files. This may be text or a filename." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rss-footer - "\n\n -\n" - "Footer used for publishing RSS 2.0 files. This may be text or a filename." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rss-date-format - "%a, %d %b %Y %H:%M:%S %Z" - "Date format to use for RSS 2.0 entries." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rss-entry-template - "\n - %title% - %link%#%anchor% - %desc% - (muse-publishing-directive \"author\") - %date% - %link%#%anchor% - %enclosure% - \n" - "Template used to publish individual journal entries as RSS 2.0. -This may be text or a filename." - :type 'string - :group 'muse-journal) - -(defcustom muse-journal-rss-enclosure-types-alist - '(("mp3" . "audio/mpeg")) - "File types that are accepted as RSS enclosures. -This is an alist that maps file extension to content type. -Useful for podcasting." - :type '(alist :key-type string :value-type string) - :group 'muse-journal) - -(defcustom muse-journal-rss-summarize-entries nil - "If non-nil, include only summaries in the RSS file, not the full data. - -The default is nil, because this annoys some subscribers." - :type 'boolean - :group 'muse-journal) - -(defcustom muse-journal-rss-markup-regexps - '((10000 muse-explicit-link-regexp 0 "\\2")) - "List of markup rules for publishing a Muse journal page to RSS 2.0. -For more information on the structure of this list, see -`muse-publish-markup-regexps'." - :type '(repeat (choice - (list :tag "Markup rule" - integer - (choice regexp symbol) - integer - (choice string function symbol)) - function)) - :group 'muse-journal) - -(defcustom muse-journal-rss-markup-functions - '((email . ignore) - (link . ignore) - (url . ignore)) - "An alist of style types to custom functions for that kind of text. -For more on the structure of this list, see -`muse-publish-markup-functions'." - :type '(alist :key-type symbol :value-type function) - :group 'muse-journal) - -(defun muse-journal-anchorize-title (title) - "This strips tags from TITLE, truncates TITLE at begin parenthesis, -and escapes any remaining non-alphanumeric characters." - (save-match-data - (if (string-match "(" title) - (setq title (substring title 0 (match-beginning 0)))) - (if (string-match "<[^>]+>" title) - (setq title (replace-match "" nil nil title))) - (let (pos code len ch) - (while (setq pos (string-match (concat "[^" muse-regexp-alnum "_]") - title pos)) - (setq ch (aref title pos) - code (format "%%%02X" (cond ((fboundp 'char-to-ucs) - (char-to-ucs ch)) - ((fboundp 'char-to-int) - (char-to-int ch)) - (t ch))) - len (length code) - title (concat (substring title 0 pos) - code - (when (< pos (length title)) - (substring title (1+ pos) nil))) - pos (+ len pos))) - title))) - -(defun muse-journal-sort-entries (&optional direction) - (interactive "P") - (sort-subr - direction - (function - (lambda () - (if (re-search-forward "^\\* [0-9]+" nil t) - (goto-char (match-beginning 0)) - (goto-char (point-max))))) - (function - (lambda () - (if (re-search-forward "^\\* [0-9]+" nil t) - (goto-char (1- (match-beginning 0))) - (goto-char (point-max))))) - (function - (lambda () - (forward-char 2))) - (function - (lambda () - (end-of-line))))) - -(defun muse-journal-qotd-tag (beg end) - (muse-publish-ensure-block beg end) - (muse-insert-markup (muse-markup-text 'begin-quote)) - (muse-insert-markup (muse-markup-text 'begin-quote-item)) - (goto-char end) - (muse-insert-markup (muse-markup-text 'end-quote-item)) - (muse-insert-markup (muse-markup-text 'end-quote))) - -(defun muse-journal-html-munge-buffer () - (goto-char (point-min)) - (let ((heading-regexp muse-journal-html-heading-regexp) - (inhibit-read-only t)) - (while (re-search-forward heading-regexp nil t) - (let* ((date (match-string 1)) - (orig-date date) - (title (match-string 2)) - (clean-title title) - datestamp qotd text) - (delete-region (match-beginning 0) (match-end 0)) - (if clean-title - (save-match-data - (while (string-match "\\(^<[^>]+>\\|<[^>]+>$\\)" clean-title) - (setq clean-title (replace-match "" nil nil clean-title))))) - (save-match-data - (when (and date - (string-match - (concat "\\`\\([1-9][0-9][0-9][0-9]\\)[./]?" - "\\([0-1][0-9]\\)[./]?\\([0-3][0-9]\\)") date)) - (setq datestamp - (encode-time - 0 0 0 - (string-to-number (match-string 3 date)) - (string-to-number (match-string 2 date)) - (string-to-number (match-string 1 date)) - nil) - date (concat (format-time-string - muse-journal-date-format datestamp) - (substring date (match-end 0)))))) - (save-restriction - (narrow-to-region - (point) (if (re-search-forward - (concat "\\(^
    $\\|" - heading-regexp "\\)") nil t) - (match-beginning 0) - (point-max))) - (goto-char (point-max)) - (while (and (not (bobp)) - (eq ?\ (char-syntax (char-before)))) - (delete-char -1)) - (goto-char (point-min)) - (while (and (not (eobp)) - (eq ?\ (char-syntax (char-after)))) - (delete-char 1)) - (save-excursion - (when (search-forward "" nil t) - (let ((tag-beg (match-beginning 0)) - (beg (match-end 0)) - end) - (re-search-forward "\n*") - (setq end (point-marker)) - (save-restriction - (narrow-to-region beg (match-beginning 0)) - (muse-publish-escape-specials (point-min) (point-max) - nil 'document) - (setq qotd (buffer-substring-no-properties - (point-min) (point-max)))) - (delete-region tag-beg end) - (set-marker end nil)))) - (setq text (buffer-string)) - (delete-region (point-min) (point-max)) - (let ((entry muse-journal-html-entry-template)) - (muse-insert-file-or-string entry) - (muse-publish-mark-read-only (point-min) (point-max)) - (goto-char (point-min)) - (while (search-forward "%date%" nil t) - (remove-text-properties (match-beginning 0) (match-end 0) - '(read-only nil rear-nonsticky nil)) - (replace-match (or date "") nil t)) - (goto-char (point-min)) - (while (search-forward "%title%" nil t) - (remove-text-properties (match-beginning 0) (match-end 0) - '(read-only nil rear-nonsticky nil)) - (replace-match (or title " ") nil t)) - (goto-char (point-min)) - (while (search-forward "%anchor%" nil t) - (replace-match (muse-journal-anchorize-title - (or clean-title orig-date)) - nil t)) - (goto-char (point-min)) - (while (search-forward "%qotd%" nil t) - (save-restriction - (narrow-to-region (match-beginning 0) (match-end 0)) - (delete-region (point-min) (point-max)) - (when qotd (muse-insert-markup qotd)))) - (goto-char (point-min)) - (while (search-forward "%text%" nil t) - (remove-text-properties (match-beginning 0) (match-end 0) - '(read-only nil rear-nonsticky nil)) - (replace-match text nil t)) - (when (null qotd) - (goto-char (point-min)) - (when (search-forward "
    " nil t) - (let ((beg (match-beginning 0))) - (re-search-forward "
    \n*" nil t) - (delete-region beg (point)))))))))) - ;; indicate that we are to continue the :before-end processing - nil) - -(defun muse-journal-latex-munge-buffer () - (goto-char (point-min)) - (let ((heading-regexp - (concat "^" (regexp-quote (muse-markup-text 'section)) - muse-journal-heading-regexp - (regexp-quote (muse-markup-text 'section-end)) "$")) - (inhibit-read-only t)) - (when (re-search-forward heading-regexp nil t) - (goto-char (match-beginning 0)) - (sort-subr nil - (function - (lambda () - (if (re-search-forward heading-regexp nil t) - (goto-char (match-beginning 0)) - (goto-char (point-max))))) - (function - (lambda () - (if (re-search-forward heading-regexp nil t) - (goto-char (1- (match-beginning 0))) - (goto-char (point-max))))) - (function - (lambda () - (forward-char 2))) - (function - (lambda () - (end-of-line))))) - (while (re-search-forward heading-regexp nil t) - (let ((date (match-string 1)) - (title (match-string 2)) - ;; FIXME: Nothing is done with qotd - qotd section) - (save-match-data - (when (and date - (string-match - (concat "\\([1-9][0-9][0-9][0-9]\\)[./]?" - "\\([0-1][0-9]\\)[./]?\\([0-3][0-9]\\)") date)) - (setq date (encode-time - 0 0 0 - (string-to-number (match-string 3 date)) - (string-to-number (match-string 2 date)) - (string-to-number (match-string 1 date)) - nil) - date (format-time-string - muse-journal-date-format date)))) - (save-restriction - (narrow-to-region (match-beginning 0) (match-end 0)) - (delete-region (point-min) (point-max)) - (muse-insert-markup muse-journal-latex-section) - (goto-char (point-min)) - (while (search-forward "%title%" nil t) - (replace-match (or title "Untitled") nil t)) - (goto-char (point-min)) - (while (search-forward "%date%" nil t) - (replace-match (or date "") nil t)))))) - (goto-char (point-min)) - (let ((subheading-regexp - (concat "^" (regexp-quote (muse-markup-text 'subsection)) - "\\([^\n}]+\\)" - (regexp-quote (muse-markup-text 'subsection-end)) "$")) - (inhibit-read-only t)) - (while (re-search-forward subheading-regexp nil t) - (let ((title (match-string 1))) - (save-restriction - (narrow-to-region (match-beginning 0) (match-end 0)) - (delete-region (point-min) (point-max)) - (muse-insert-markup muse-journal-latex-subsection) - (goto-char (point-min)) - (while (search-forward "%title%" nil t) - (replace-match title nil t)))))) - ;; indicate that we are to continue the :before-end processing - nil) - -(defun muse-journal-rss-munge-buffer () - (goto-char (point-min)) - (let ((heading-regexp muse-journal-rss-heading-regexp) - (inhibit-read-only t)) - (while (re-search-forward heading-regexp nil t) - (let* ((date (match-string 1)) - (orig-date date) - (title (match-string 2)) - ;; FIXME: Nothing is done with qotd - enclosure qotd desc) - (if title - (save-match-data - (if (string-match muse-explicit-link-regexp title) - (setq enclosure (muse-get-link title) - title (muse-get-link-desc title))))) - (save-match-data - (when (and date - (string-match - (concat "\\([1-9][0-9][0-9][0-9]\\)[./]?" - "\\([0-1][0-9]\\)[./]?\\([0-3][0-9]\\)") date)) - (setq date (encode-time 0 0 0 - (string-to-number (match-string 3 date)) - (string-to-number (match-string 2 date)) - (string-to-number (match-string 1 date)) - nil) - ;; make sure that date is in a format that RSS - ;; readers can handle - date (let ((system-time-locale "C")) - (format-time-string - (muse-style-element :date-format) date))))) - (save-restriction - (narrow-to-region - (match-beginning 0) - (if (re-search-forward heading-regexp nil t) - (match-beginning 0) - (if (re-search-forward "^Footnotes:" nil t) - (match-beginning 0) - (point-max)))) - (goto-char (point-min)) - (delete-region (point) (muse-line-end-position)) - (re-search-forward "\n+" nil t) - (while (and (char-after) - (eq ?\ (char-syntax (char-after)))) - (delete-char 1)) - (let ((beg (point))) - (if (muse-style-element :summarize) - (progn - (forward-sentence 2) - (setq desc (concat (buffer-substring beg (point)) "..."))) - (save-restriction - (muse-publish-markup-buffer "rss-entry" "journal-rss-entry") - (goto-char (point-min)) - (if (re-search-forward "Page published by Emacs Muse" nil t) - (goto-char (muse-line-end-position)) - (muse-display-warning - (concat - "Cannot find 'Page published by Emacs Muse begins here'.\n" - "You will probably need this text in your header.")) - (goto-char (point-min))) - (setq beg (point)) - (if (re-search-forward "Page published by Emacs Muse" nil t) - (goto-char (muse-line-beginning-position)) - (muse-display-warning - (concat - "Cannot find 'Page published by Emacs Muse ends here'.\n" - "You will probably need this text in your footer.")) - (goto-char (point-max))) - (setq desc (buffer-substring beg (point)))))) - (unless (string= desc "") - (setq desc (concat ""))) - (delete-region (point-min) (point-max)) - (let ((entry (muse-style-element :entry-template))) - (muse-insert-file-or-string entry) - (goto-char (point-min)) - (while (search-forward "%date%" nil t) - (replace-match (or date "") nil t)) - (goto-char (point-min)) - (while (search-forward "%title%" nil t) - (replace-match "") - (save-restriction - (narrow-to-region (point) (point)) - (insert (or title "Untitled")) - (remove-text-properties (match-beginning 0) (match-end 0) - '(read-only nil rear-nonsticky nil)) - (let ((muse-publishing-current-style (muse-style "html"))) - (muse-publish-escape-specials (point-min) (point-max) - nil 'document)))) - (goto-char (point-min)) - (while (search-forward "%desc%" nil t) - (replace-match desc nil t)) - (goto-char (point-min)) - (while (search-forward "%enclosure%" nil t) - (replace-match - (if (null enclosure) - "" - (save-match-data - (format - "" - (if (string-match "//" enclosure) - enclosure - (concat (muse-style-element :base-url) - enclosure)) - (let ((file - (expand-file-name enclosure - (muse-style-element :path)))) - (if (file-readable-p file) - (format "length=\"%d\" " - (nth 7 (file-attributes file))) - "")) - (if (string-match "\\.\\([^.]+\\)$" enclosure) - (let* ((ext (match-string 1 enclosure)) - (type - (assoc - ext muse-journal-rss-enclosure-types-alist))) - (if type - (cdr type) - "application/octet-stream")))))) - nil t)) - (goto-char (point-min)) - (while (search-forward "%link%" nil t) - (replace-match - (concat (muse-style-element :base-url) - (concat (muse-page-name) - muse-html-extension)) - nil t)) - (goto-char (point-min)) - (while (search-forward "%anchor%" nil t) - (replace-match - (muse-journal-anchorize-title (or title orig-date)) - nil t)) - (goto-char (point-min)) - (while (search-forward "%maintainer%" nil t) - (replace-match - (or (muse-style-element :maintainer) - (concat "webmaster@" (system-name))) - nil t))))))) - ;; indicate that we are to continue the :before-end processing - nil) - - -;;; Register the Muse Journal Publishers - -(muse-derive-style "journal-html" "html" - :before-end 'muse-journal-html-munge-buffer) - -(muse-derive-style "journal-xhtml" "xhtml" - :before-end 'muse-journal-html-munge-buffer) - -(muse-derive-style "journal-latex" "latex" - :tags 'muse-journal-markup-tags - :before-end 'muse-journal-latex-munge-buffer) - -(muse-derive-style "journal-pdf" "pdf" - :tags 'muse-journal-markup-tags - :before-end 'muse-journal-latex-munge-buffer) - -(muse-derive-style "journal-book-latex" "book-latex" - ;;:nochapters - :tags 'muse-journal-markup-tags - :before-end 'muse-journal-latex-munge-buffer) - -(muse-derive-style "journal-book-pdf" "book-pdf" - ;;:nochapters - :tags 'muse-journal-markup-tags - :before-end 'muse-journal-latex-munge-buffer) - -(muse-define-style "journal-rdf" - :suffix 'muse-journal-rdf-extension - :regexps 'muse-journal-rss-markup-regexps - :functions 'muse-journal-rss-markup-functions - :before 'muse-journal-rss-munge-buffer - :header 'muse-journal-rdf-header - :footer 'muse-journal-rdf-footer - :date-format 'muse-journal-rdf-date-format - :entry-template 'muse-journal-rdf-entry-template - :base-url 'muse-journal-rdf-base-url - :summarize 'muse-journal-rdf-summarize-entries) - -(muse-define-style "journal-rss" - :suffix 'muse-journal-rss-extension - :regexps 'muse-journal-rss-markup-regexps - :functions 'muse-journal-rss-markup-functions - :before 'muse-journal-rss-munge-buffer - :header 'muse-journal-rss-header - :footer 'muse-journal-rss-footer - :date-format 'muse-journal-rss-date-format - :entry-template 'muse-journal-rss-entry-template - :base-url 'muse-journal-rss-base-url - :summarize 'muse-journal-rss-summarize-entries) - -;; Used by `muse-journal-rss-munge-buffer' to mark up individual entries -(muse-derive-style "journal-rss-entry" "html" - :tags 'muse-journal-markup-tags) - -(provide 'muse-journal) - -;;; muse-journal.el ends here diff --git a/elpa/muse-3.20/muse-latex.el b/elpa/muse-3.20/muse-latex.el deleted file mode 100644 index e416367..0000000 --- a/elpa/muse-3.20/muse-latex.el +++ /dev/null @@ -1,669 +0,0 @@ -;;; muse-latex.el --- publish entries in LaTex or PDF format - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;;; Contributors: - -;; Li Daobing (lidaobing AT gmail DOT com) provided CJK support. - -;; Trent Buck (trentbuck AT gmail DOT com) gave valuable advice for -;; how to treat LaTeX specials and the like. - -;; Matthias Kegelmann (mathias DOT kegelmann AT sdm DOT de) provided a -;; scenario where we would need to respect the tag. - -;; Jean Magnan de Bornier (jean AT bornier DOT net) provided the -;; markup string for link-and-anchor. - -;; Jim Ottaway (j DOT ottaway AT lse DOT ac DOT uk) implemented slides -;; and lecture notes. - -;; Karl Berry (karl AT freefriends DOT org) suggested how to escape -;; additional special characters in image filenames. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse LaTeX Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-publish) - -(defgroup muse-latex nil - "Rules for marking up a Muse file as a LaTeX article." - :group 'muse-publish) - -(defcustom muse-latex-extension ".tex" - "Default file extension for publishing LaTeX files." - :type 'string - :group 'muse-latex) - -(defcustom muse-latex-pdf-extension ".pdf" - "Default file extension for publishing LaTeX files to PDF." - :type 'string - :group 'muse-latex) - -(defcustom muse-latex-pdf-browser "open %s" - "The program to use when browsing a published PDF file. -This should be a format string." - :type 'string - :group 'muse-latex) - -(defcustom muse-latex-pdf-program "pdflatex" - "The program that is called to generate PDF content from LaTeX content." - :type 'string - :group 'muse-latex) - -(defcustom muse-latex-pdf-cruft - '(".aux" ".log" ".nav" ".out" ".snm" ".toc" ".vrb") - "Extensions of files to remove after generating PDF output successfully." - :type 'string - :group 'muse-latex) - -(defcustom muse-latex-header - "\\documentclass{article} - -\\usepackage[english]{babel} -\\usepackage{ucs} -\\usepackage[utf8x]{inputenc} -\\usepackage[T1]{fontenc} -\\usepackage{hyperref} -\\usepackage[pdftex]{graphicx} - -\\def\\museincludegraphics{% - \\begingroup - \\catcode`\\|=0 - \\catcode`\\\\=12 - \\catcode`\\#=12 - \\includegraphics[width=0.75\\textwidth] -} - -\\begin{document} - -\\title{(muse-publish-escape-specials-in-string - (muse-publishing-directive \"title\") 'document)} -\\author{(muse-publishing-directive \"author\")} -\\date{(muse-publishing-directive \"date\")} - -\\maketitle - -(and muse-publish-generate-contents - (not muse-latex-permit-contents-tag) - \"\\\\tableofcontents\n\\\\newpage\")\n\n" - "Header used for publishing LaTeX files. This may be text or a filename." - :type 'string - :group 'muse-latex) - -(defcustom muse-latex-footer "(muse-latex-bibliography) -\\end{document}\n" - "Footer used for publishing LaTeX files. This may be text or a filename." - :type 'string - :group 'muse-latex) - -(defcustom muse-latexcjk-header - "\\documentclass{article} - -\\usepackage{CJK} -\\usepackage{indentfirst} -\\usepackage[CJKbookmarks=true]{hyperref} -\\usepackage[pdftex]{graphicx} - -\\begin{document} -\\begin{CJK*}(muse-latexcjk-encoding) - -\\title{(muse-publish-escape-specials-in-string - (muse-publishing-directive \"title\") 'document)} -\\author{(muse-publishing-directive \"author\")} -\\date{(muse-publishing-directive \"date\")} - -\\maketitle - -(and muse-publish-generate-contents - (not muse-latex-permit-contents-tag) - \"\\\\tableofcontents\n\\\\newpage\")\n\n" - "Header used for publishing LaTeX files (CJK). This may be text or a -filename." - :type 'string - :group 'muse-latex) - -(defcustom muse-latexcjk-footer - "\n\\end{CJK*} -\\end{document}\n" - "Footer used for publishing LaTeX files (CJK). This may be text or a -filename." - :type 'string - :group 'muse-latex) - -(defcustom muse-latex-slides-header - "\\documentclass[ignorenonframetext]{beamer} - -\\usepackage[english]{babel} -\\usepackage{ucs} -\\usepackage[utf8x]{inputenc} -\\usepackage[T1]{fontenc} -\\usepackage{hyperref} - -\\def\\museincludegraphics{% - \\begingroup - \\catcode`\\|=0 - \\catcode`\\\\=12 - \\catcode`\\#=12 - \\includegraphics[width=0.50\\textwidth] -} - -\\title{(muse-publish-escape-specials-in-string - (muse-publishing-directive \"title\") 'document)} -\\author{(muse-publishing-directive \"author\")} -\\date{(muse-publishing-directive \"date\")} - -\\begin{document} - -\\frame{\\titlepage} - -(and muse-publish-generate-contents - \"\\\\frame{\\\\tableofcontents}\")\n\n" - "Header for publishing of slides using LaTeX. -This may be text or a filename. - -You must have the Beamer extension for LaTeX installed for this to work." - :type 'string - :group 'muse-latex) - -(defcustom muse-latex-lecture-notes-header - "\\documentclass{article} -\\usepackage{beamerarticle} - -\\usepackage[english]{babel} -\\usepackage{ucs} -\\usepackage[utf8x]{inputenc} -\\usepackage[T1]{fontenc} -\\usepackage{hyperref} -\\usepackage[pdftex]{graphicx} - -\\def\\museincludegraphics{% - \\begingroup - \\catcode`\\|=0 - \\catcode`\\\\=12 - \\catcode`\\#=12 - \\includegraphics[width=0.50\\textwidth] -} - -\\title{(muse-publish-escape-specials-in-string - (muse-publishing-directive \"title\") 'document)} -\\author{(muse-publishing-directive \"author\")} -\\date{(muse-publishing-directive \"date\")} - -\\begin{document} - -\\frame{\\titlepage} - -(and muse-publish-generate-contents - \"\\\\frame{\\\\tableofcontents}\")\n\n" - "Header for publishing of lecture notes using LaTeX. -This may be text or a filename. - -You must have the Beamer extension for LaTeX installed for this to work." - :type 'string - :group 'muse-latex) - -(defcustom muse-latex-markup-regexps - `(;; numeric ranges - (10000 "\\([0-9]+\\)-\\([0-9]+\\)" 0 "\\1--\\2") - - ;; be careful of closing quote pairs - (10100 "\"'" 0 "\"\\\\-'")) - "List of markup regexps for identifying regions in a Muse page. -For more on the structure of this list, see `muse-publish-markup-regexps'." - :type '(repeat (choice - (list :tag "Markup rule" - integer - (choice regexp symbol) - integer - (choice string function symbol)) - function)) - :group 'muse-latex) - -(defcustom muse-latex-markup-functions - '((table . muse-latex-markup-table)) - "An alist of style types to custom functions for that kind of text. -For more on the structure of this list, see -`muse-publish-markup-functions'." - :type '(alist :key-type symbol :value-type function) - :group 'muse-latex) - -(defcustom muse-latex-markup-strings - '((image-with-desc . "\\begin{figure}[h] -\\centering\\museincludegraphics{%s.%s}|endgroup -\\caption{%s} -\\end{figure}") - (image . "\\begin{figure}[h] -\\centering\\museincludegraphics{%s.%s}|endgroup -\\end{figure}") - (image-link . "%% %s -\\museincludegraphics{%s.%s}|endgroup") - (anchor-ref . "\\ref{%s}") - (url . "\\url{%s}") - (url-and-desc . "\\href{%s}{%s}\\footnote{%1%}") - (link . "\\href{%s}{%s}\\footnote{%1%}") - (link-and-anchor . "\\href{%1%}{%3%}\\footnote{%1%}") - (email-addr . "\\verb|%s|") - (anchor . "\\label{%s}") - (emdash . "---") - (comment-begin . "% ") - (rule . "\\vspace{.5cm}\\hrule\\vspace{.5cm}") - (no-break-space . "~") - (line-break . "\\\\") - (enddots . "\\ldots{}") - (dots . "\\dots{}") - (part . "\\part{") - (part-end . "}") - (chapter . "\\chapter{") - (chapter-end . "}") - (section . "\\section{") - (section-end . "}") - (subsection . "\\subsection{") - (subsection-end . "}") - (subsubsection . "\\subsubsection{") - (subsubsection-end . "}") - (section-other . "\\paragraph{") - (section-other-end . "}") - (footnote . "\\footnote{") - (footnote-end . "}") - (footnotetext . "\\footnotetext[%d]{") - (begin-underline . "\\underline{") - (end-underline . "}") - (begin-literal . "\\texttt{") - (end-literal . "}") - (begin-emph . "\\emph{") - (end-emph . "}") - (begin-more-emph . "\\textbf{") - (end-more-emph . "}") - (begin-most-emph . "\\textbf{\\emph{") - (end-most-emph . "}}") - (begin-verse . "\\begin{verse}\n") - (end-verse-line . " \\\\") - (verse-space . "~~~~") - (end-verse . "\n\\end{verse}") - (begin-example . "\\begin{quote}\n\\begin{verbatim}") - (end-example . "\\end{verbatim}\n\\end{quote}") - (begin-center . "\\begin{center}\n") - (end-center . "\n\\end{center}") - (begin-quote . "\\begin{quote}\n") - (end-quote . "\n\\end{quote}") - (begin-cite . "\\cite{") - (begin-cite-author . "\\citet{") - (begin-cite-year . "\\citet{") - (end-cite . "}") - (begin-uli . "\\begin{itemize}\n") - (end-uli . "\n\\end{itemize}") - (begin-uli-item . "\\item ") - (begin-oli . "\\begin{enumerate}\n") - (end-oli . "\n\\end{enumerate}") - (begin-oli-item . "\\item ") - (begin-dl . "\\begin{description}\n") - (end-dl . "\n\\end{description}") - (begin-ddt . "\\item[") - (end-ddt . "] \\mbox{}\n")) - "Strings used for marking up text. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles." - :type '(alist :key-type symbol :value-type string) - :group 'muse-latex) - -(defcustom muse-latex-slides-markup-tags - '(("slide" t t nil muse-latex-slide-tag)) - "A list of tag specifications, for specially marking up LaTeX slides." - :type '(repeat (list (string :tag "Markup tag") - (boolean :tag "Expect closing tag" :value t) - (boolean :tag "Parse attributes" :value nil) - (boolean :tag "Nestable" :value nil) - function)) - :group 'muse-latex) - -(defcustom muse-latexcjk-encoding-map - '((utf-8 . "{UTF8}{song}") - (japanese-iso-8bit . "[dnp]{JIS}{min}") - (chinese-big5 . "{Bg5}{bsmi}") - (mule-utf-8 . "{UTF8}{song}") - (chinese-iso-8bit . "{GB}{song}") - (chinese-gbk . "{GBK}{song}")) - "An alist mapping emacs coding systems to appropriate CJK codings. -Use the base name of the coding system (ie, without the -unix)." - :type '(alist :key-type coding-system :value-type string) - :group 'muse-latex) - -(defcustom muse-latexcjk-encoding-default "{GB}{song}" - "The default Emacs buffer encoding to use in published files. -This will be used if no special characters are found." - :type 'string - :group 'muse-latex) - -(defun muse-latexcjk-encoding () - (when (boundp 'buffer-file-coding-system) - (muse-latexcjk-transform-content-type buffer-file-coding-system))) - -(defun muse-latexcjk-transform-content-type (content-type) - "Using `muse-cjklatex-encoding-map', try and resolve an emacs coding -system to an associated CJK coding system." - (let ((match (and (fboundp 'coding-system-base) - (assoc (coding-system-base content-type) - muse-latexcjk-encoding-map)))) - (if match - (cdr match) - muse-latexcjk-encoding-default))) - -(defcustom muse-latex-markup-specials-document - '((?\\ . "\\textbackslash{}") - (?\_ . "\\textunderscore{}") - (?\< . "\\textless{}") - (?\> . "\\textgreater{}") - (?^ . "\\^{}") - (?\~ . "\\~{}") - (?\@ . "\\@") - (?\$ . "\\$") - (?\% . "\\%") - (?\{ . "\\{") - (?\} . "\\}") - (?\& . "\\&") - (?\# . "\\#")) - "A table of characters which must be represented specially. -These are applied to the entire document, sans already-escaped -regions." - :type '(alist :key-type character :value-type string) - :group 'muse-latex) - -(defcustom muse-latex-markup-specials-example - '() - "A table of characters which must be represented specially. -These are applied to regions. - -With the default interpretation of regions, no specials -need to be escaped." - :type '(alist :key-type character :value-type string) - :group 'muse-latex) - -(defcustom muse-latex-markup-specials-literal - '((?\n . "\\\n") - (?\\ . "\\textbackslash{}") - (?_ . "\\textunderscore{}") - (?\< . "\\textless{}") - (?\> . "\\textgreater{}") - (?^ . "\\^{}") - (?\~ . "\\~{}") - (?\$ . "\\$") - (?\% . "\\%") - (?\{ . "\\{") - (?\} . "\\}") - (?\& . "\\&") - (?\# . "\\#")) - "A table of characters which must be represented specially. -This applies to =monospaced text= and regions." - :type '(alist :key-type character :value-type string) - :group 'muse-latex) - -(defcustom muse-latex-markup-specials-url - '((?\\ . "\\textbackslash{}") - (?\_ . "\\_") - (?\< . "\\<") - (?\> . "\\>") - (?\$ . "\\$") - (?\% . "\\%") - (?\{ . "\\{") - (?\} . "\\}") - (?\& . "\\&") - (?\# . "\\#")) - "A table of characters which must be represented specially. -These are applied to URLs." - :type '(alist :key-type character :value-type string) - :group 'muse-latex) - -(defcustom muse-latex-markup-specials-image - '((?\\ . "\\\\") - (?\< . "\\<") - (?\> . "\\>") - (?\$ . "\\$") - (?\% . "\\%") - (?\{ . "\\{") - (?\} . "\\}") - (?\& . "\\&") - (?\# . "\\#") - (?\| . "\\|")) - "A table of characters which must be represented specially. -These are applied to image filenames." - :type '(alist :key-type character :value-type string) - :group 'muse-latex) - -(defun muse-latex-decide-specials (context) - "Determine the specials to escape, depending on CONTEXT." - (cond ((memq context '(underline emphasis document url-desc verbatim - footnote)) - muse-latex-markup-specials-document) - ((eq context 'image) - muse-latex-markup-specials-image) - ((memq context '(email url)) - muse-latex-markup-specials-url) - ((eq context 'literal) - muse-latex-markup-specials-literal) - ((eq context 'example) - muse-latex-markup-specials-example) - (t (error "Invalid context '%s' in muse-latex" context)))) - -(defcustom muse-latex-permit-contents-tag nil - "If nil, ignore tags. Otherwise, insert table of contents. - -Most of the time, it is best to have a table of contents on the -first page, with a new page immediately following. To make this -work with documents published in both HTML and LaTeX, we need to -ignore the tag. - -If you don't agree with this, then set this option to non-nil, -and it will do what you expect." - :type 'boolean - :group 'muse-latex) - -(defun muse-latex-markup-table () - (let* ((table-info (muse-publish-table-fields (match-beginning 0) - (match-end 0))) - (row-len (car table-info)) - (field-list (cdr table-info))) - (when table-info - (muse-insert-markup "\\begin{tabular}{" (make-string row-len ?l) "}\n") - (dolist (fields field-list) - (let ((type (car fields))) - (setq fields (cdr fields)) - (if (eq type 'hline) - (muse-insert-markup "\\hline\n") - (when (= type 3) - (muse-insert-markup "\\hline\n")) - (insert (car fields)) - (setq fields (cdr fields)) - (dolist (field fields) - (muse-insert-markup " & ") - (insert field)) - (muse-insert-markup " \\\\\n") - (when (= type 2) - (muse-insert-markup "\\hline\n"))))) - (muse-insert-markup "\\end{tabular}")))) - -;;; Tags for LaTeX - -(defun muse-latex-slide-tag (beg end attrs) - "Publish the tag in LaTeX. -This is used by the slides and lecture-notes publishing styles." - (let ((title (cdr (assoc "title" attrs)))) - (goto-char beg) - (muse-insert-markup "\\begin{frame}[fragile]\n") - (when title - (muse-insert-markup "\\frametitle{") - (insert title) - (muse-insert-markup "}\n")) - (save-excursion - (goto-char end) - (muse-insert-markup "\n\\end{frame}")))) - -;;; Post-publishing functions - -(defun muse-latex-fixup-dquotes () - "Fixup double quotes." - (goto-char (point-min)) - (let ((open t)) - (while (search-forward "\"" nil t) - (unless (get-text-property (match-beginning 0) 'read-only) - (when (or (bobp) - (eq (char-before) ?\n)) - (setq open t)) - (if open - (progn - (replace-match "``") - (setq open nil)) - (replace-match "''") - (setq open t)))))) - -(defun muse-latex-fixup-citations () - "Replace semicolons in multi-head citations with colons." - (goto-char (point-min)) - (while (re-search-forward "\\\\cite.?{" nil t) - (let ((start (point)) - (end (re-search-forward "}"))) - (save-restriction - (narrow-to-region start end) - (goto-char (point-min)) - (while (re-search-forward ";" nil t) - (replace-match ",")))))) - -(defun muse-latex-fixup-headings () - "Remove footnotes in headings, since LaTeX does not permit them to exist. - -This can happen if there is a link in a heading, because by -default Muse will add a footnote for each link." - (goto-char (point-min)) - (while (re-search-forward "^\\\\section.?{" nil t) - (save-restriction - (narrow-to-region (match-beginning 0) (muse-line-end-position)) - (goto-char (point-min)) - (while (re-search-forward "\\\\footnote{[^}\n]+}" nil t) - (replace-match "")) - (forward-line 1)))) - -(defun muse-latex-munge-buffer () - (muse-latex-fixup-dquotes) - (muse-latex-fixup-citations) - (muse-latex-fixup-headings) - (when (and muse-latex-permit-contents-tag - muse-publish-generate-contents) - (goto-char (car muse-publish-generate-contents)) - (muse-insert-markup "\\tableofcontents"))) - -(defun muse-latex-bibliography () - (save-excursion - (goto-char (point-min)) - (if (re-search-forward "\\\\cite.?{" nil t) - (concat - "\\bibliography{" - (muse-publishing-directive "bibsource") - "}\n") - ""))) - -(defun muse-latex-pdf-browse-file (file) - (shell-command (format muse-latex-pdf-browser file))) - -(defun muse-latex-pdf-generate (file output-path final-target) - (apply - #'muse-publish-transform-output - file output-path final-target "PDF" - (function - (lambda (file output-path) - (let* ((fnd (file-name-directory output-path)) - (command (format "%s \"%s\"" - muse-latex-pdf-program - (file-relative-name file fnd))) - (times 0) - (default-directory fnd) - result) - ;; XEmacs can sometimes return a non-number result. We'll err - ;; on the side of caution by continuing to attempt to generate - ;; the PDF if this happens and treat the final result as - ;; successful. - (while (and (< times 2) - (or (not (numberp result)) - (not (eq result 0)) - ;; table of contents takes 2 passes - (file-readable-p - (muse-replace-regexp-in-string - "\\.tex\\'" ".toc" file t t)))) - (setq result (shell-command command) - times (1+ times))) - (if (or (not (numberp result)) - (eq result 0)) - t - nil)))) - muse-latex-pdf-cruft)) - -;;; Register the Muse LATEX Publishers - -(muse-define-style "latex" - :suffix 'muse-latex-extension - :regexps 'muse-latex-markup-regexps - :functions 'muse-latex-markup-functions - :strings 'muse-latex-markup-strings - :specials 'muse-latex-decide-specials - :before-end 'muse-latex-munge-buffer - :header 'muse-latex-header - :footer 'muse-latex-footer - :browser 'find-file) - -(muse-derive-style "pdf" "latex" - :final 'muse-latex-pdf-generate - :browser 'muse-latex-pdf-browse-file - :link-suffix 'muse-latex-pdf-extension - :osuffix 'muse-latex-pdf-extension) - -(muse-derive-style "latexcjk" "latex" - :header 'muse-latexcjk-header - :footer 'muse-latexcjk-footer) - -(muse-derive-style "pdfcjk" "latexcjk" - :final 'muse-latex-pdf-generate - :browser 'muse-latex-pdf-browse-file - :link-suffix 'muse-latex-pdf-extension - :osuffix 'muse-latex-pdf-extension) - -(muse-derive-style "slides" "latex" - :header 'muse-latex-slides-header - :tags 'muse-latex-slides-markup-tags) - -(muse-derive-style "slides-pdf" "pdf" - :header 'muse-latex-slides-header - :tags 'muse-latex-slides-markup-tags) - -(muse-derive-style "lecture-notes" "slides" - :header 'muse-latex-lecture-notes-header) - -(muse-derive-style "lecture-notes-pdf" "slides-pdf" - :header 'muse-latex-lecture-notes-header) - -(provide 'muse-latex) - -;;; muse-latex.el ends here diff --git a/elpa/muse-3.20/muse-latex2png.el b/elpa/muse-3.20/muse-latex2png.el deleted file mode 100644 index 2b4373d..0000000 --- a/elpa/muse-3.20/muse-latex2png.el +++ /dev/null @@ -1,277 +0,0 @@ -;; muse-latex2png.el --- generate PNG images from inline LaTeX code - -;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; Author: Michael Olson -;; Created: 12-Oct-2005 - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; This was taken from latex2png.el, by Ganesh Swami , which was made for emacs-wiki. It has since -;; been extensively rewritten for Muse. - -;;; To do - -;; Remove stale image files. This could be done by making a function -;; for `muse-before-publish-hook' that deletes according to -;; (muse-page-name). - -;;; Code - -(require 'muse-publish) - -(defgroup muse-latex2png nil - "Publishing LaTeX formulas as PNG files." - :group 'muse-publish) - -(defcustom muse-latex2png-img-dest "./latex" - "The folder where the generated images will be placed. -This is relative to the current publishing directory." - :type 'string - :group 'muse-latex2png) - -(defcustom muse-latex2png-scale-factor 2.5 - "The scale factor to be used for sizing the resulting LaTeX output." - :type 'number - :group 'muse-latex2png) - -(defcustom muse-latex2png-fg "Black" - "The foreground color." - :type 'string - :group 'muse-latex2png) - -(defcustom muse-latex2png-bg "Transparent" - "The background color." - :type 'string - :group 'muse-latex2png) - -(defcustom muse-latex2png-template - "\\documentclass{article} -\\usepackage{fullpage} -\\usepackage{amssymb} -\\usepackage[usenames]{color} -\\usepackage{amsmath} -\\usepackage{latexsym} -\\usepackage[mathscr]{eucal} -%preamble% -\\pagestyle{empty} -\\begin{document} -{%code%} -\\end{document}\n" - "The LaTeX template to use." - :type 'string - :group 'muse-latex2png) - -(defun muse-latex2png-move2pubdir (file prefix pubdir) - "Move FILE to the PUBDIR folder. - -This is done so that the resulting images do not clutter your -main publishing directory. - -Old files with PREFIX in the name are deleted." - (when file - (if (file-exists-p file) - (progn - (unless (file-directory-p pubdir) - (message "Creating latex directory %s" pubdir) - (make-directory pubdir)) - (copy-file file (expand-file-name (file-name-nondirectory file) - pubdir) - t) - (delete-file file) - (concat muse-latex2png-img-dest "/" (file-name-nondirectory file))) - (message "Cannot find %s!" file)))) - -(defun muse-latex2png (code prefix preamble) - "Convert the LaTeX CODE into a png file beginning with PREFIX. -PREAMBLE indicates extra packages and definitions to include." - (unless preamble - (setq preamble "")) - (unless prefix - (setq prefix "muse-latex2png")) - (let* ((tmpdir (cond ((boundp 'temporary-file-directory) - temporary-file-directory) - ((fboundp 'temp-directory) - (temp-directory)) - (t "/tmp"))) - (texfile (expand-file-name - (concat prefix "__" (format "%d" (abs (sxhash code)))) - tmpdir)) - (defalt-directory default-directory)) - (with-temp-file (concat texfile ".tex") - (insert muse-latex2png-template) - (goto-char (point-min)) - (while (search-forward "%preamble%" nil t) - (replace-match preamble nil t)) - (goto-char (point-min)) - (while (search-forward "%code%" nil t) - (replace-match code nil t))) - (setq default-directory tmpdir) - (call-process "latex" nil nil nil texfile) - (if (file-exists-p (concat texfile ".dvi")) - (progn - (call-process - "dvipng" nil nil nil - "-E" - "-fg" muse-latex2png-fg - "-bg" muse-latex2png-bg - "-T" "tight" - "-x" (format "%s" (* muse-latex2png-scale-factor 1000)) - "-y" (format "%s" (* muse-latex2png-scale-factor 1000)) - "-o" (concat texfile ".png") - (concat texfile ".dvi")) - (if (file-exists-p (concat texfile ".png")) - (progn - (delete-file (concat texfile ".dvi")) - (delete-file (concat texfile ".tex")) - (delete-file (concat texfile ".aux")) - (delete-file (concat texfile ".log")) - (concat texfile ".png")) - (message "Failed to create png file") - nil)) - (message (concat "Failed to create dvi file " texfile)) - nil))) - -(defun muse-latex2png-region (beg end attrs) - "Generate an image for the Latex code between BEG and END. -If a Muse page is currently being published, replace the given -region with the appropriate markup that displays the image. -Otherwise, just return the path of the generated image. - -Valid keys for the ATTRS alist are as follows. - -prefix: The prefix given to the image file. -preamble: Extra text to add to the Latex preamble. -inline: Display image as inline, instead of a block." - (let ((end-marker (set-marker (make-marker) (1+ end))) - (pubdir (expand-file-name - muse-latex2png-img-dest - (file-name-directory muse-publishing-current-output-path)))) - (save-restriction - (narrow-to-region beg end) - (let* ((text (buffer-substring-no-properties beg end)) - ;; the prefix given to the image file. - (prefix (cdr (assoc "prefix" attrs))) - ;; preamble (for extra options) - (preamble (cdr (assoc "preamble" attrs))) - ;; display inline or as a block - (display (car (assoc "inline" attrs)))) - (when muse-publishing-p - (delete-region beg end) - (goto-char (point-min))) - (unless (file-directory-p pubdir) - (make-directory pubdir)) - (let ((path (muse-latex2png-move2pubdir - (muse-latex2png text prefix preamble) - prefix pubdir))) - (when path - (when muse-publishing-p - (muse-insert-markup - (if (muse-style-derived-p "html") - (concat "\"latex2png" - ">") - (muse-insert-markup "")) - (let ((ext (or (file-name-extension path) "")) - (path (muse-path-sans-extension path))) - (muse-markup-text 'image path ext)))) - (goto-char (point-max))) - path)))))) - -(defun muse-publish-latex-tag (beg end attrs) - "If the current style is not Latex-based, generate an image for the -given Latex code. Otherwise, don't do anything to the region. -See `muse-latex2png-region' for valid keys for ATTRS." - (unless (assoc "prefix" attrs) - (setq attrs (cons (cons "prefix" - (concat "latex2png-" (muse-page-name))) - attrs))) - (if (or (muse-style-derived-p "latex") (muse-style-derived-p "context")) - (muse-publish-mark-read-only beg end) - (muse-latex2png-region beg end attrs))) - -(put 'muse-publish-latex-tag 'muse-dangerous-tag t) - -(defun muse-publish-math-tag (beg end) - "Surround the given region with \"$\" characters. Then, if the -current style is not Latex-based, generate an image for the given -Latex math code. - -If 6 or more spaces come before the tag, and the end of the tag -is at the end of a line, then surround the region with the -equivalent of \"$$\" instead. This causes the region to be -centered in the published output, among other things." - (let* ((centered (and (re-search-backward - (concat "^[" muse-regexp-blank "]\\{6,\\}\\=") - nil t) - (save-excursion - (save-match-data - (goto-char end) - (looking-at (concat "[" muse-regexp-blank "]*$")))) - (prog1 t - (replace-match "") - (when (and (or (muse-style-derived-p "latex") - (muse-style-derived-p "context")) - (not (bobp))) - (backward-char 1) - (if (bolp) - (delete-char 1) - (forward-char 1))) - (setq beg (point))))) - (tag-beg (if centered - (if (muse-style-derived-p "context") - "\\startformula " "\\[ ") - "$")) - (tag-end (if centered - (if (muse-style-derived-p "context") - " \\stopformula" " \\]") - "$")) - (attrs (nconc (list (cons "prefix" - (concat "latex2png-" (muse-page-name)))) - (if centered nil - '(("inline" . t)))))) - (goto-char beg) - (muse-insert-markup tag-beg) - (goto-char end) - (muse-insert-markup tag-end) - (if (or (muse-style-derived-p "latex") (muse-style-derived-p "context")) - (muse-publish-mark-read-only beg (point)) - (muse-latex2png-region beg (point) attrs)))) - -(put 'muse-publish-math-tag 'muse-dangerous-tag t) - -;;; Insinuate with muse-publish - -(add-to-list 'muse-publish-markup-tags - '("latex" t t nil muse-publish-latex-tag) - t) - -(add-to-list 'muse-publish-markup-tags - '("math" t nil nil muse-publish-math-tag) - t) - -(provide 'muse-latex2png) -;;; muse-latex2png.el ends here diff --git a/elpa/muse-3.20/muse-mode.el b/elpa/muse-3.20/muse-mode.el deleted file mode 100644 index 9659843..0000000 --- a/elpa/muse-3.20/muse-mode.el +++ /dev/null @@ -1,1013 +0,0 @@ -;;; muse-mode.el --- mode for editing Muse files; has font-lock support - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; The Emacs Muse major mode is basically a hyped-up text-mode which -;; knows a lot more about the apparent structure of the document. - -;;; Contributors: - -;; Andrea Riciputi (ariciputi AT pito DOT com) gave an initial -;; implementation for tag completion by means of the `muse-insert-tag' -;; function. - -;; Per B. Sederberg (per AT med DOT upenn DOT edu) contributed the -;; insertion of relative links and list items, backlink searching, and -;; other things as well. - -;; Stefan Schlee (stefan_schlee AT yahoo DOT com) fixed a bug in -;; muse-next-reference and muse-previous-reference involving links -;; that begin at point 1. - -;; Gregory Collins (greg AT gregorycollins DOT net) fixed a bug with -;; paragraph separation and headings when filling. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Emacs Muse Major Mode -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(provide 'muse-mode) - -(require 'muse) -(require 'muse-regexps) -(require 'muse-project) - -(autoload 'muse-use-font-lock "muse-colors") -(autoload 'muse-publish-this-file "muse-publish") -(autoload 'muse-publish-get-style "muse-publish") -(autoload 'muse-publish-output-file "muse-publish") - -(require 'derived) -(eval-when-compile - (condition-case nil - (require 'pcomplete) ; load if available - (error nil))) - -;;; Options: - -(defgroup muse-mode nil - "Options controlling the behavior of the Muse editing Mode." - :group 'muse) - -(defcustom muse-mode-highlight-p t - "If non-nil, highlight the content of Muse buffers." - :type 'boolean - :require 'muse-colors - :group 'muse-mode) - -(defcustom muse-mode-auto-p nil - "If non-nil, automagically determine when Muse mode should be activated." - :type 'boolean - :set (function - (lambda (sym value) - (if value - (add-hook 'find-file-hooks 'muse-mode-maybe) - (remove-hook 'find-file-hooks 'muse-mode-maybe)) - (set sym value))) - :group 'muse-mode) - -(defun muse-mode-maybe-after-init () - (when muse-mode-auto-p - (add-hook 'find-file-hooks 'muse-mode-maybe))) - -;; If the user sets this value in their init file, make sure that -;; it takes effect -(add-hook 'after-init-hook 'muse-mode-maybe-after-init) - -(defcustom muse-mode-intangible-links nil - "If non-nil, use the intangible property on links. -This can cause problems with flyspell (and potentially fill-mode), -so only enable this if you don't use either of these." - :type 'boolean - :group 'muse-mode) - -(defcustom muse-mode-hook nil - "A hook that is run when Muse mode is entered." - :type 'hook - :options '(flyspell-mode footnote-mode turn-on-auto-fill - highlight-changes-mode) - :group 'muse-mode) - -(defcustom muse-grep-command - "find %D -type f ! -name '*~' | xargs -I {} echo \\\"{}\\\" | xargs egrep -n -e \"%W\"" - "The command to use when grepping for backlinks and other -searches through the muse projects. The string %D is replaced by -the directories from muse-project-alist, space-separated. The -string %W is replaced with the name of the muse page or whatever -else you are searching for. This command has been modified to -handle spaces in filenames, which were giving egrep a problem. - -Note: We highly recommend using glimpse to search large projects. -To use glimpse, install and edit a file called .glimpse_exclude -in your home directory. Put a list of glob patterns in that file -to exclude Emacs backup files, etc. Then, run the indexer using: - - glimpseindex -o - -Once that's completed, customize this variable to have the -following value: - - glimpse -nyi \"%W\" - -Your searches will go much, much faster, especially for very -large projects. Don't forget to add a user cronjob to update the -index at intervals." - :type 'string - :group 'muse-mode) - -(defvar muse-insert-map - (let ((map (make-sparse-keymap))) - (define-key map "l" 'muse-insert-relative-link-to-file) - (define-key map "t" 'muse-insert-tag) - (define-key map "u" 'muse-insert-url) - - map)) - -;;; Muse mode - -(defvar muse-mode-map - (let ((map (make-sparse-keymap))) - (define-key map [(control ?c) (control ?a)] 'muse-index) - (define-key map [(control ?c) (control ?e)] 'muse-edit-link-at-point) - (define-key map [(control ?c) (control ?l)] 'font-lock-mode) - (define-key map [(control ?c) (control ?t)] - 'muse-project-publish-this-file) - (define-key map [(control ?c) (control ?T)] 'muse-publish-this-file) - (define-key map [(control ?c) (meta control ?t)] 'muse-publish-this-file) - (define-key map [(control ?c) (control ?v)] 'muse-browse-result) - - (define-key map [(control ?c) ?=] 'muse-what-changed) - - (define-key map [tab] 'muse-next-reference) - (define-key map [(control ?i)] 'muse-next-reference) - - (if (featurep 'xemacs) - (progn - (define-key map [(button2)] 'muse-follow-name-at-mouse) - (define-key map [(shift button2)] - 'muse-follow-name-at-mouse-other-window)) - (define-key map [(shift control ?m)] - 'muse-follow-name-at-point-other-window) - (define-key map [mouse-2] 'muse-follow-name-at-mouse) - (define-key map [(shift mouse-2)] - 'muse-follow-name-at-mouse-other-window)) - - (define-key map [(shift tab)] 'muse-previous-reference) - (unless (featurep 'xemacs) - (define-key map [(shift iso-lefttab)] 'muse-previous-reference) - (define-key map [(shift control ?i)] 'muse-previous-reference)) - - (define-key map [(control ?c) (control ?f)] 'muse-project-find-file) - (define-key map [(control ?c) (control ?p)] 'muse-project-publish) - - (define-key map [(control ?c) (control ?i)] 'muse-insert-thing) - (define-key map [(control ?c) tab] 'muse-insert-thing) - - ;; Searching functions - (define-key map [(control ?c) (control ?b)] 'muse-find-backlinks) - (define-key map [(control ?c) (control ?s)] 'muse-search) - - ;; Enhanced list functions - (define-key map [(meta return)] 'muse-insert-list-item) - (define-key map [(control ?>)] 'muse-increase-list-item-indentation) - (define-key map [(control ?<)] 'muse-decrease-list-item-indentation) - - (when (featurep 'pcomplete) - (define-key map [(meta tab)] 'pcomplete) - (define-key map [(meta control ?i)] 'pcomplete)) - - map) - "Keymap used by Emacs Muse mode.") - -;;;###autoload -(define-derived-mode muse-mode text-mode "Muse" - "Muse is an Emacs mode for authoring and publishing documents. -\\{muse-mode-map}" - ;; Since we're not inheriting from normal-mode, we need to - ;; explicitly run file variables. - (condition-case err - (hack-local-variables) - (error (message "File local-variables error: %s" - (prin1-to-string err)))) - ;; Avoid lock-up caused by use of the 'intangible' text property - ;; with flyspell. - (unless muse-mode-intangible-links - (set (make-local-variable 'inhibit-point-motion-hooks) t)) - (setq muse-current-project (muse-project-of-file)) - (muse-project-set-variables) - ;; Make fill not split up links - (when (boundp 'fill-nobreak-predicate) - (make-local-variable 'fill-nobreak-predicate) - ;; Work around annoying inconsistency in fill handling between - ;; Emacs 21 and 22. - (if (< emacs-major-version 22) - (setq fill-nobreak-predicate 'muse-mode-fill-nobreak-p) - (add-to-list 'fill-nobreak-predicate - 'muse-mode-fill-nobreak-p))) - ;; Make fill work nicely with item lists - (let ((regexp (concat "\\s-+\\(-\\|[0-9]+\\.\\)\\s-+" - "\\|\\[[0-9]+\\]\\s-*" - "\\|.*\\s-*::\\s-+" - "\\|\\*+\\s-+"))) - (set (make-local-variable 'adaptive-fill-regexp) - (concat regexp "\\|\\s-*")) - (set (make-local-variable 'paragraph-start) - (concat paragraph-start "\\|" regexp)) - (set (make-local-variable 'paragraph-separate) - (concat paragraph-separate "\\|\\*+\\s-+"))) - (set (make-local-variable 'fill-paragraph-function) - 'muse-mode-fill-paragraph) - - ;; Comment syntax is `; comment' - (set (make-local-variable 'comment-start) - "; ") - (set (make-local-variable 'comment-start-skip) - "^;\\s-+") - (set (make-local-variable 'indent-line-function) - #'ignore) - ;; If we're using Emacs21, this makes flyspell work like it should - (when (boundp 'flyspell-generic-check-word-p) - (set (make-local-variable 'flyspell-generic-check-word-p) - 'muse-mode-flyspell-p)) - ;; If pcomplete is available, set it up - (when (featurep 'pcomplete) - (set (make-local-variable 'pcomplete-default-completion-function) - 'muse-mode-completions) - (set (make-local-variable 'pcomplete-command-completion-function) - 'muse-mode-completions) - (set (make-local-variable 'pcomplete-parse-arguments-function) - 'muse-mode-current-word)) - ;; Initialize any auto-generated variables - (run-hooks 'muse-update-values-hook) - (when muse-mode-highlight-p - (muse-use-font-lock))) - -(put 'muse-mode - 'flyspell-mode-predicate - 'muse-mode-flyspell-p) - -(defun muse-mode-fill-nobreak-p () - "Return nil if we should allow a fill to occur at point. -Otherwise return non-nil. - -This is used to keep long explicit links from being mangled by -fill mode." - (save-excursion - (save-match-data - (and (re-search-backward "\\[\\[\\|\\]\\]" - (line-beginning-position) t) - (string= (or (match-string 0) "") - "[["))))) - -(defun muse-mode-fill-paragraph (arg) - "If a definition list is at point, use special filling rules for it. -Otherwise return nil to let the normal filling function take care -of things. - -ARG is passed to `fill-paragraph'." - (let ((count 2)) - (and (not (muse-mode-fill-nobreak-p)) - (save-excursion - (beginning-of-line) - (and (looking-at muse-dl-term-regexp) - (prog1 t - ;; Take initial whitespace into account - (when (looking-at (concat "[" muse-regexp-blank "]+")) - (setq count (+ count (length (match-string 0)))))))) - (let ((fill-prefix (make-string count ?\ )) - (fill-paragraph-function nil)) - (prog1 t - (fill-paragraph arg)))))) - -(defun muse-mode-flyspell-p () - "Return non-nil if we should allow spell-checking to occur at point. -Otherwise return nil. - -This is used to keep links from being improperly colorized by flyspell." - (let ((pos (if (bobp) (point) (1- (point))))) - (and (not (get-text-property pos 'muse-no-flyspell)) - (not (get-text-property pos 'muse-link)) - (save-match-data - (null (muse-link-at-point)))))) - -;;;###autoload -(defun muse-mode-choose-mode () - "Turn the proper Emacs Muse related mode on for this file." - (let ((project (muse-project-of-file))) - (funcall (or (and project (muse-get-keyword :major-mode (cadr project) t)) - 'muse-mode)))) - -(defun muse-mode-maybe () - "Maybe turn Emacs Muse mode on for this file." - (let ((project (muse-project-of-file))) - (and project - (funcall (or (muse-get-keyword :major-mode (cadr project) t) - 'muse-mode))))) - -;;; Enhanced list editing - -(defun muse-on-blank-line () - "See if point is on a blank line" - (save-excursion - (beginning-of-line) - (looking-at (concat "[" muse-regexp-blank "]*$")))) - -(defun muse-get-paragraph-start () - "Return the start of the current paragraph. This function will -return nil if there are no prior paragraphs and the beginning of -the line if point is on a blank line." - (let ((para-start (concat "^[" muse-regexp-blank "]*$"))) - ;; search back to start of paragraph - (save-excursion - (save-match-data - (if (not (muse-on-blank-line)) - (re-search-backward para-start nil t) - (line-beginning-position)))))) - -(defun muse-insert-thing () - "Prompt for something to insert into the current buffer." - (interactive) - (message "Insert:\nl link\nt Muse tag\nu URL") - (let (key cmd) - (let ((overriding-local-map muse-insert-map)) - (setq key (read-key-sequence nil))) - (if (commandp (setq cmd (lookup-key muse-insert-map key))) - (progn (message "") - (call-interactively cmd)) - (message "Not inserting anything")))) - -;;;###autoload -(defun muse-insert-list-item () - "Insert a list item at the current point, taking into account -your current list type and indentation level." - (interactive) - (let ((newitem " - ") - (itemno nil) - (pstart (muse-get-paragraph-start)) - (list-item (format muse-list-item-regexp - (concat "[" muse-regexp-blank "]*")))) - ;; search backwards for start of current item - (save-excursion - (when (re-search-backward list-item pstart t) - ;; save the matching item - (setq newitem (match-string 0)) - ;; see what type it is - (if (string-match "::" (match-string 0)) - ;; is a definition, replace the term - (setq newitem (concat " " - (read-string "Term: ") - " :: ")) - ;; see if it's a numbered list - (when (string-match "[0-9]+" newitem) - ;; is numbered, so increment - (setq itemno (1+ - (string-to-number - (match-string 0 newitem)))) - (setq newitem (replace-match - (number-to-string itemno) - nil nil newitem)))))) - ;; insert the new item - (insert (concat "\n" newitem)))) - -(defun muse-alter-list-item-indentation (operation) - "Alter the indentation of the current list item. -Valid values of OPERATION are 'increase and 'decrease." - (let ((pstart (muse-get-paragraph-start)) - (list-item (format muse-list-item-regexp - (concat "[" muse-regexp-blank "]*"))) - beg move-func indent) - ;; search backwards until start of paragraph to see if we are on a - ;; current item - (save-excursion - (if (or (progn (goto-char (muse-line-beginning-position)) - ;; we are on an item - (looking-at list-item)) - ;; not on item, so search backwards - (re-search-backward list-item pstart t)) - (let ((beg (point))) - ;; we are on an item - (setq indent (buffer-substring (match-beginning 0) - (match-beginning 1))) - (muse-forward-list-item (muse-list-item-type (match-string 1)) - (concat "[" muse-regexp-blank "]*") - t) - (save-restriction - (narrow-to-region beg (point)) - (goto-char (point-min)) - (let ((halt nil)) - (while (< (point) (point-max)) - ;; increase or decrease the indentation - (unless halt - (cond ((eq operation 'increase) - (insert " ")) - ((eq operation 'decrease) - (if (looking-at " ") - ;; we have enough space, so delete it - (delete-region (match-beginning 0) - (match-end 0)) - (setq halt t))))) - (forward-line 1))))) - ;; we are not on an item, so warn - (message "You are not on a list item."))))) - -;;;###autoload -(defun muse-increase-list-item-indentation () - "Increase the indentation of the current list item." - (interactive) - (muse-alter-list-item-indentation 'increase)) - -;;;###autoload -(defun muse-decrease-list-item-indentation () - "Decrease the indentation of the current list item." - (interactive) - (muse-alter-list-item-indentation 'decrease)) - -;;; Support page name completion using pcomplete - -(defun muse-mode-completions () - "Return a list of possible completions names for this buffer." - (let ((project (muse-project-of-file))) - (if project - (while (pcomplete-here - (mapcar 'car (muse-project-file-alist project))))))) - -(defun muse-mode-current-word () - (let ((end (point))) - (save-excursion - (save-restriction - (skip-chars-backward (concat "^\\[\n" muse-regexp-blank)) - (narrow-to-region (point) end)) - (pcomplete-parse-buffer-arguments)))) - -;;; Navigate/visit links or URLs. Use TAB, S-TAB and RET (or mouse-2). - -(defun muse-link-at-point (&optional pos) - "Return link text if a URL or link is at point." - (let ((case-fold-search nil) - (inhibit-point-motion-hooks t) - (here (or pos (point)))) - ;; if we are using muse-colors, we can just use link properties to - ;; determine whether we are on a link - (if (featurep 'muse-colors) - (when (get-text-property here 'muse-link) - (save-excursion - (when (and (not (bobp)) - (get-text-property (1- here) 'muse-link)) - (goto-char (or (previous-single-property-change here 'muse-link) - (point-min)))) - (if (looking-at muse-explicit-link-regexp) - (progn - (goto-char (match-beginning 1)) - (muse-handle-explicit-link)) - (muse-handle-implicit-link)))) - ;; use fallback method to find a link - (when (or (null pos) - (and (char-after pos) - (not (eq (char-syntax (char-after pos)) ?\ )))) - (save-excursion - (goto-char here) - ;; check for explicit link here or before point - (if (or (looking-at muse-explicit-link-regexp) - (and - (re-search-backward "\\[\\[\\|\\]\\]" - (muse-line-beginning-position) - t) - (string= (or (match-string 0) "") "[[") - (looking-at muse-explicit-link-regexp))) - (progn - (goto-char (match-beginning 1)) - (muse-handle-explicit-link)) - (goto-char here) - ;; check for bare URL or other link type - (skip-chars-backward (concat "^'\"<>{}(\n" muse-regexp-blank)) - (and (looking-at muse-implicit-link-regexp) - (muse-handle-implicit-link)))))))) - -(defun muse-make-link (link &optional desc) - "Return a link to LINK with DESC as the description." - (when (string-match muse-explicit-link-regexp link) - (unless desc (setq desc (muse-get-link-desc link))) - (setq link (muse-get-link link))) - (if (and desc - link - (not (string= desc "")) - (not (string= link desc))) - (concat "[[" (muse-link-escape link) "][" (muse-link-escape desc) "]]") - (concat "[[" (or (muse-link-escape link) "") "]]"))) - -;;;###autoload -(defun muse-insert-relative-link-to-file () - "Insert a relative link to a file, with optional description, at point." - ;; Perhaps the relative location should be configurable, so that the - ;; file search would start in the publishing directory and then - ;; insert the link relative to the publishing directory - (interactive) - (insert - (muse-make-link (file-relative-name (read-file-name "Link: ")) - (read-string "Text: ")))) - -(defcustom muse-insert-url-initial-input "http://" - "The string to insert before reading a URL interactively. -This is used by the `muse-insert-url' command." - :type 'string - :group 'muse-mode) - -(defun muse-insert-url () - "Insert a URL, with optional description, at point." - (interactive) - (insert - (muse-make-link (read-string "URL: " muse-insert-url-initial-input) - (read-string "Text: ")))) - -;;;###autoload -(defun muse-edit-link-at-point () - "Edit the current link. -Do not rename the page originally referred to." - (interactive) - (if (muse-link-at-point) - (let ((link (muse-link-unescape (muse-get-link))) - (desc (muse-link-unescape (muse-get-link-desc)))) - (replace-match - (save-match-data - (muse-make-link - (read-string "Link: " link) - (read-string "Text: " desc))) - t t)) - (error "There is no valid link at point"))) - -(defun muse-visit-link-default (link &optional other-window) - "Visit the URL or link named by LINK. -If ANCHOR is specified, search for it after opening LINK. - -This is the default function to call when visiting links; it is -used by `muse-visit-link' if you have not specified :visit-link -in `muse-project-alist'." - (if (string-match muse-url-regexp link) - (muse-browse-url link) - (let (anchor - base-buffer) - (when (string-match "#" link) - (setq anchor (substring link (match-beginning 0)) - link (if (= (match-beginning 0) 0) - ;; If there is an anchor but no link, default - ;; to the current page. - nil - (substring link 0 (match-beginning 0))))) - (when link - (setq base-buffer (get-buffer link)) - (if (and base-buffer (not (buffer-file-name base-buffer))) - ;; If file is temporary (no associated file), just switch to - ;; the buffer - (if other-window - (switch-to-buffer-other-window base-buffer) - (switch-to-buffer base-buffer)) - (let ((project (muse-project-of-file))) - (if project - (muse-project-find-file link project - (and other-window - 'find-file-other-window)) - (if other-window - (find-file-other-window link) - (find-file link)))))) - (when anchor - (let ((pos (point)) - (regexp (concat "^\\W*" (regexp-quote anchor) "\\b")) - last) - (goto-char (point-min)) - (while (and (setq last (re-search-forward regexp nil t)) - (muse-link-at-point))) - (unless last - (goto-char pos) - (message "Could not find anchor `%s'" anchor))))))) - -(defun muse-visit-link (link &optional other-window) - "Visit the URL or link named by LINK." - (let ((visit-link-function - (muse-get-keyword :visit-link (cadr (muse-project-of-file)) t))) - (if visit-link-function - (funcall visit-link-function link other-window) - (muse-visit-link-default link other-window)))) - -;;;###autoload -(defun muse-browse-result (style &optional other-window) - "Visit the current page's published result." - (interactive - (list (muse-project-get-applicable-style buffer-file-name - (cddr muse-current-project)) - current-prefix-arg)) - (setq style (muse-style style)) - (muse-project-publish-this-file nil style) - (let* ((output-dir (muse-style-element :path style)) - (output-suffix (muse-style-element :osuffix style)) - (output-path (muse-publish-output-file buffer-file-name output-dir - style)) - (target (if output-suffix - (concat (muse-path-sans-extension output-path) - output-suffix) - output-path)) - (muse-current-output-style (list :base (car style) - :path output-dir))) - (if (not (file-readable-p target)) - (error "Cannot open output file '%s'" target) - (if other-window - (find-file-other-window target) - (let ((func (muse-style-element :browser style t))) - (if func - (funcall func target) - (message "The %s publishing style does not support browsing." - style))))))) - -;;;###autoload -(defun muse-follow-name-at-point (&optional other-window) - "Visit the link at point." - (interactive "P") - (let ((link (muse-link-at-point))) - (if link - (muse-visit-link link other-window) - (error "There is no valid link at point")))) - -;;;###autoload -(defun muse-follow-name-at-point-other-window () - "Visit the link at point in other window." - (interactive) - (muse-follow-name-at-point t)) - -(defun muse-follow-name-at-mouse (event &optional other-window) - "Visit the link at point, or yank text if none is found." - (interactive "eN") - (unless - (save-excursion - (cond ((fboundp 'event-window) ; XEmacs - (set-buffer (window-buffer (event-window event))) - (and (funcall (symbol-function 'event-point) event) - (goto-char (funcall (symbol-function 'event-point) - event)))) - ((fboundp 'posn-window) ; Emacs - (set-buffer (window-buffer (posn-window (event-start event)))) - (goto-char (posn-point (event-start event))))) - (let ((link (muse-link-at-point))) - (when link - (muse-visit-link link other-window) - t))) - ;; Fall back to normal binding for this event - (call-interactively - (lookup-key (current-global-map) (this-command-keys))))) - -(defun muse-follow-name-at-mouse-other-window (event) - "Visit the link at point" - (interactive "e") - ;; throw away the old window position, since other-window will - ;; change it anyway - (select-window (car (cadr event))) - (muse-follow-name-at-mouse event t)) - -;;;###autoload -(defun muse-next-reference () - "Move forward to next Muse link or URL, cycling if necessary." - (interactive) - (let ((pos)) - (save-excursion - (when (get-text-property (point) 'muse-link) - (goto-char (or (next-single-property-change (point) 'muse-link) - (point-max)))) - - (setq pos (next-single-property-change (point) 'muse-link)) - - (when (not pos) - (if (get-text-property (point-min) 'muse-link) - (setq pos (point-min)) - (setq pos (next-single-property-change (point-min) 'muse-link))))) - - (when pos - (goto-char pos)))) - -;;;###autoload -(defun muse-previous-reference () - "Move backward to the next Muse link or URL, cycling if necessary. -In case of Emacs x <= 21 and ignoring of intangible properties (see -`muse-mode-intangible-links'). - -This function is not entirely accurate, but it's close enough." - (interactive) - (let ((pos)) - (save-excursion - - ;; Hack: The user perceives the two cases of point ("|") - ;; position (1) "|[[" and (2) "[[|" or "][|" as "point is at - ;; start of link". But in the sense of the function - ;; "previous-single-property-change" these two cases are - ;; different. The following code aligns these two cases. Emacs - ;; 21: If the intangible property is ignored case (2) is more - ;; complicate and this hack only solves the problem partially. - ;; - (when (and (get-text-property (point) 'muse-link) - (muse-looking-back "\\[\\|\\]")) - (goto-char (or (previous-single-property-change (point) 'muse-link) - (point-min)))) - - (when (eq (point) (point-min)) - (goto-char (point-max))) - - (setq pos (previous-single-property-change (point) 'muse-link)) - - (when (not pos) - (if (get-text-property (point-min) 'muse-link) - (setq pos (point-min)) - (setq pos (previous-single-property-change (point-max) - 'muse-link))))) - - (when pos - (if (get-text-property pos 'muse-link) - (goto-char pos) - (goto-char (or (previous-single-property-change pos 'muse-link) - (point-min))))))) - -;;;###autoload -(defun muse-what-changed () - "Show the unsaved changes that have been made to the current file." - (interactive) - (diff-backup buffer-file-name)) - - -;;; Find text in project pages, or pages referring to the current page - -(defvar muse-search-history nil) - -(defun muse-grep (string &optional grep-command-no-shadow) - "Grep for STRING in the project directories. -GREP-COMMAND if passed will supplant `muse-grep-command'." - ;; careful - grep-command leaks into compile, so we call it - ;; -no-shadow instead - (require 'compile) - (let* ((str (or grep-command-no-shadow muse-grep-command)) - (muse-directories (mapcar - (lambda (thing) - (car (cadr thing))) - muse-project-alist)) - (dirs (mapconcat (lambda (dir) - (shell-quote-argument - (expand-file-name dir))) - muse-directories " "))) - (if (string= dirs "") - (muse-display-warning - "No directories were found in the current project; aborting search") - (while (string-match "%W" str) - (setq str (replace-match string t t str))) - (while (string-match "%D" str) - (setq str (replace-match dirs t t str))) - (if (fboundp 'compilation-start) - (compilation-start str nil (lambda (&rest args) "*search*") - grep-regexp-alist) - (and (fboundp 'compile-internal) - (compile-internal str "No more search hits" "search" - nil grep-regexp-alist)))))) - -;;;###autoload -(defun muse-search-with-command (text) - "Search for the given TEXT string in the project directories -using the specified command." - (interactive - (list (let ((str (concat muse-grep-command)) pos) - (when (string-match "%W" str) - (setq pos (match-beginning 0)) - (unless (featurep 'xemacs) - (setq pos (1+ pos))) - (setq str (replace-match "" t t str))) - (read-from-minibuffer "Search command: " - (cons str pos) nil nil - 'muse-search-history)))) - (muse-grep nil text)) - -;;;###autoload -(defun muse-search () - "Search for the given TEXT using the default grep command." - (interactive) - (muse-grep (read-string "Search: "))) - -;;;###autoload -(defun muse-find-backlinks () - "Grep for the current pagename in all the project directories." - (interactive) - (muse-grep (muse-page-name))) - - -;;; Generate an index of all known Muse pages - -(defun muse-generate-index (&optional as-list exclude-private) - "Generate an index of all Muse pages." - (let ((index (muse-index-as-string as-list exclude-private))) - (with-current-buffer (get-buffer-create "*Muse Index*") - (erase-buffer) - (insert index) - (current-buffer)))) - -;;;###autoload -(defun muse-index () - "Display an index of all known Muse pages." - (interactive) - (message "Generating Muse index...") - (let ((project (muse-project))) - (with-current-buffer (muse-generate-index) - (goto-char (point-min)) - (muse-mode) - (setq muse-current-project project) - (pop-to-buffer (current-buffer)))) - (message "Generating Muse index...done")) - -(defun muse-index-as-string (&optional as-list exclude-private exclude-current) - "Generate an index of all Muse pages. -If AS-LIST is non-nil, insert a dash and spaces before each item. -If EXCLUDE-PRIVATE is non-nil, exclude files that have private permissions. -If EXCLUDE-CURRENT is non-nil, exclude the current file from the output." - (let ((files (sort (copy-alist (muse-project-file-alist)) - (function - (lambda (l r) - (string-lessp (car l) (car r))))))) - (when (and exclude-current (muse-page-name)) - (setq files (delete (assoc (muse-page-name) files) files))) - (with-temp-buffer - (while files - (unless (and exclude-private - (muse-project-private-p (cdar files))) - (insert (if as-list " - " "") "[[" (caar files) "]]\n")) - (setq files (cdr files))) - (buffer-string)))) - -;;; Insert tags interactively on C-c TAB t - -(defvar muse-tag-history nil - "List of recently-entered tags; used by `muse-insert-tag'. -If you want a tag to start as the default, you may manually set -this variable to a list.") - -(defvar muse-custom-tags nil - "Keep track of any new tags entered in `muse-insert-tag'. -If there are (X)HTML tags that you use frequently with that -function, you might want to set this manually.") - -;;;###autoload -(defun muse-insert-tag (tag) - "Insert a tag interactively with a blank line after it." - (interactive - (list - (funcall - muse-completing-read-function - (concat "Tag: " - (when muse-tag-history - (concat "(default: " (car muse-tag-history) ") "))) - (progn - (require 'muse-publish) - (mapcar 'list (nconc (mapcar 'car muse-publish-markup-tags) - muse-custom-tags))) - nil nil nil 'muse-tag-history - (car muse-tag-history)))) - (when (equal tag "") - (setq tag (car muse-tag-history))) - (unless (interactive-p) - (require 'muse-publish)) - (let ((tag-entry (assoc tag muse-publish-markup-tags)) - (options "")) - ;; Add to custom list if no entry exists - (unless tag-entry - (add-to-list 'muse-custom-tags tag)) - ;; Get option - (when (nth 2 tag-entry) - (setq options (read-string "Option: "))) - (unless (equal options "") - (setq options (concat " " options))) - ;; Insert the tag, closing if necessary - (when tag (insert (concat "<" tag options ">"))) - (when (nth 1 tag-entry) - (insert (concat "\n\n\n")) - (forward-line -2)))) - -;;; Muse list edit minor mode - -(defvar muse-list-edit-minor-mode-map - (let ((map (make-sparse-keymap))) - (define-key map [(meta return)] 'muse-l-e-m-m-insert-list-item) - (define-key map [(control ?>)] 'muse-l-e-m-m-increase-list-item-indent) - (define-key map [(control ?<)] 'muse-l-e-m-m-decrease-list-item-indent) - - map) - "Keymap used by Muse list edit minor mode.") - -(defvar muse-l-e-m-m-list-item-regexp - (concat "^%s\\(\\([^\n" muse-regexp-blank "].*?\\)?::" - "\\(?:[" muse-regexp-blank "]+\\|$\\)" - "\\|[" muse-regexp-blank "]?[-*+][" muse-regexp-blank "]*" - "\\|[" muse-regexp-blank "][0-9]+\\.[" muse-regexp-blank "]*\\)") - "Regexp used to match the beginning of a list item. -This is used by `muse-list-edit-minor-mode'. -The '%s' will be replaced with a whitespace regexp when publishing.") - -(defun muse-l-e-m-m-insert-list-item () - "Insert a list item at the current point, taking into account -your current list type and indentation level." - (interactive) - (let ((muse-list-item-regexp muse-l-e-m-m-list-item-regexp)) - (call-interactively 'muse-insert-list-item))) - -(defun muse-l-e-m-m-increase-list-item-indent () - "Increase the indentation of the current list item." - (interactive) - (let ((muse-list-item-regexp muse-l-e-m-m-list-item-regexp)) - (call-interactively 'muse-increase-list-item-indentation))) - -(defun muse-l-e-m-m-decrease-list-item-indent () - "Decrease the indentation of the current list item." - (interactive) - (let ((muse-list-item-regexp muse-l-e-m-m-list-item-regexp)) - (call-interactively 'muse-decrease-list-item-indentation))) - -(defvar muse-l-e-m-m-data nil - "A list of data that was changed by Muse list edit minor mode.") -(make-variable-buffer-local 'muse-l-e-m-m-data) - -;;;###autoload -(define-minor-mode muse-list-edit-minor-mode - "This is a global minor mode for editing files with lists. -It is meant to be used with other major modes, and not with Muse mode. - -Interactively, with no prefix argument, toggle the mode. -With universal prefix ARG turn mode on. -With zero or negative ARG turn mode off. - -This minor mode provides the Muse keybindings for editing lists, -and support for filling lists properly. - -It recognizes not only Muse-style lists, which use the \"-\" -character or numbers, but also lists that use asterisks or plus -signs. This should make the minor mode generally useful. - -Definition lists and footnotes are also recognized. - -Note that list items may omit leading spaces, for compatibility -with modes that set `left-margin', such as -`debian-changelog-mode'. - -\\{muse-list-edit-minor-mode-map}" - :init-value nil - :lighter "" - :keymap muse-list-edit-minor-mode-map - :global nil - :group 'muse-mode - (if (not muse-list-edit-minor-mode) - ;; deactivate - (when muse-l-e-m-m-data - (setq adaptive-fill-regexp (cdr (assoc "a-f-r" muse-l-e-m-m-data)) - paragraph-start (cdr (assoc "p-s" muse-l-e-m-m-data)) - fill-prefix (cdr (assoc "f-p" muse-l-e-m-m-data))) - (setq muse-l-e-m-m-data nil)) - ;; activate - (unless muse-l-e-m-m-data - ;; save previous fill-related data so we can restore it later - (setq muse-l-e-m-m-data - (list (cons "a-f-r" adaptive-fill-regexp) - (cons "p-s" paragraph-start) - (cons "f-p" fill-prefix)))) - ;; make fill work nicely with item lists - (let ((regexp (concat "\\s-*\\([-*+]\\|[0-9]+\\.\\)\\s-+" - "\\|\\[[0-9]+\\]\\s-*" - "\\|.*\\s-*::\\s-+"))) - (set (make-local-variable 'adaptive-fill-regexp) - (concat regexp "\\|\\s-*")) - (set (make-local-variable 'paragraph-start) - (concat paragraph-start "\\|" regexp))) - ;; force fill-prefix to be nil, because if it is a string that has - ;; initial spaces, it messes up fill-paragraph's algorithm - (set (make-local-variable 'fill-prefix) nil))) - -(defun turn-on-muse-list-edit-minor-mode () - "Unconditionally turn on Muse list edit minor mode." - (muse-list-edit-minor-mode 1)) - -(defun turn-off-muse-list-edit-minor-mode () - "Unconditionally turn off Muse list edit minor mode." - (muse-list-edit-minor-mode -1)) - -;;; muse-mode.el ends here diff --git a/elpa/muse-3.20/muse-pkg.el b/elpa/muse-3.20/muse-pkg.el deleted file mode 100644 index 6ff6560..0000000 --- a/elpa/muse-3.20/muse-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -(define-package "muse" "3.20" - "Authoring and publishing tool") diff --git a/elpa/muse-3.20/muse-poem.el b/elpa/muse-3.20/muse-poem.el deleted file mode 100644 index bd08b7e..0000000 --- a/elpa/muse-3.20/muse-poem.el +++ /dev/null @@ -1,263 +0,0 @@ -;;; muse-poem.el --- publish a poem to LaTex or PDF - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; This file specifies a form for recording poetry. It is as follows. -;; -;; Title -;; -;; -;; Body of poem -;; -;; -;; Annotations, history, notes, etc. -;; -;; The `muse-poem' module makes it easy to attractively publish and -;; reference poems in this format, using the "memoir" module for LaTeX -;; publishing. It will also markup poems for every other output -;; style, though none are nearly as pretty. -;; -;; Once a poem is written in this format, just publish it to PDF using -;; the "poem-pdf" style. To make an inlined reference to a poem that -;; you've written -- for example, from a blog page -- there is a -;; "poem" tag defined by this module: -;; -;; -;; -;; Let's assume the template above was called "name.of.poem.page"; -;; then the above tag would result in this inclusion: -;; -;; ** Title -;; -;; > Body of poem -;; -;; I use this module for publishing all of the poems on my website, -;; which are at: http://www.newartisans.com/johnw/poems.html. - -;;; Contributors: - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse Poem Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-latex) -(require 'muse-project) - -(defgroup muse-poem nil - "Rules for marking up a Muse file as a LaTeX article." - :group 'muse-latex) - -(defcustom muse-poem-latex-header - "\\documentclass[14pt,oneside]{memoir} - -\\usepackage[english]{babel} -\\usepackage[latin1]{inputenc} -\\usepackage[T1]{fontenc} - -\\setlength{\\beforepoemtitleskip}{-5.0ex} - -\\begin{document} - -\\pagestyle{empty} - -\\renewcommand{\\poemtoc}{section} -\\settocdepth{section} - -\\mbox{} -\\vfill - -\\poemtitle{(muse-publishing-directive \"title\")} - -\\settowidth{\\versewidth}{muse-poem-longest-line}\n\n" - "Header used for publishing LaTeX poems. This may be text or a filename." - :type 'string - :group 'muse-poem) - -(defcustom muse-poem-latex-footer "\n\\vfill -\\mbox{} - -\\end{document}" - "Footer used for publishing LaTeX files. This may be text or a filename." - :type 'string - :group 'muse-poem) - -(defcustom muse-poem-markup-strings - '((begin-verse . "\\begin{verse}[\\versewidth]\n") - (verse-space . "\\vin ")) - "Strings used for marking up poems. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles." - :type '(alist :key-type symbol :value-type string) - :group 'muse-poem) - -(defcustom muse-chapbook-latex-header - "\\documentclass{book} - -\\usepackage[english]{babel} -\\usepackage[latin1]{inputenc} -\\usepackage[T1]{fontenc} - -\\setlength{\\beforepoemtitleskip}{-5.0ex} - -\\begin{document} - -\\title{(muse-publishing-directive \"title\")} -\\author{(muse-publishing-directive \"author\")} -\\date{(muse-publishing-directive \"date\")} - -\\maketitle - -\\tableofcontents - -\\renewcommand{\\poemtoc}{section} -\\settocdepth{section}\n" - "Header used for publishing a book of poems in LaTeX form. -This may be text or a filename." - :type 'string - :group 'muse-poem) - -(defcustom muse-chapbook-latex-footer "\n\\end{document}" - "Footer used for publishing a book of poems in LaTeX form. -This may be text or a filename." - :type 'string - :group 'muse-poem) - -(defvar muse-poem-longest-line "") - -(defcustom muse-poem-chapbook-strings - '((begin-verse . "\\newpage -\\mbox{} -\\vfill - -\\poemtitle{(muse-publishing-directive \"title\")} - -\\settowidth{\\versewidth}{muse-poem-longest-line} - -\\begin{verse}[\\versewidth]\n") - (end-verse . "\n\\end{verse}\n\\vfill\n\\mbox{}") - (verse-space . "\\vin ")) - "Strings used for marking up books of poems. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles." - :type '(alist :key-type symbol :value-type string) - :group 'muse-poem) - -(defun muse-poem-prepare-buffer () - (goto-char (point-min)) - (insert "#title ") - (forward-line 1) - (delete-region (point) (1+ (muse-line-end-position))) - (insert "\n") - (let ((beg (point)) end line) - (if (search-forward "\n\n\n" nil t) - (progn - (setq end (copy-marker (match-beginning 0) t)) - (replace-match "\n\n") - (delete-region (point) (point-max))) - (goto-char (point-max)) - (setq end (point)) - (insert "\n")) - (goto-char (1+ beg)) - (set (make-local-variable 'muse-poem-longest-line) "") - (while (< (point) end) - (setq line (buffer-substring-no-properties (point) - (muse-line-end-position))) - (if (> (length line) (length muse-poem-longest-line)) - (setq muse-poem-longest-line line)) - (forward-line 1)) - nil)) - -(defvar muse-poem-tag '("poem" nil t nil muse-poem-markup-tag)) - -(defun muse-poem-markup-tag (beg end attrs) - "This markup tag allows a poem to be included from another project page. -The form of usage is: - " - (let ((page (cdr (assoc (cdr (assoc "title" attrs)) - (muse-project-file-alist)))) - beg end) - (if (null page) - (insert " *Reference to\n unknown poem \"" - (cdr (assoc "title" attrs)) "\".*\n") - (setq beg (point)) - (insert - (muse-with-temp-buffer - (muse-insert-file-contents page) - (goto-char (point-min)) - (if (assoc "nohead" attrs) - (progn - (forward-line 3) - (delete-region (point-min) (point))) - (insert "** ") - (search-forward "\n\n\n") - (replace-match "\n\n")) - (if (search-forward "\n\n\n" nil t) - (setq end (match-beginning 0)) - (setq end (point-max))) - (buffer-substring-no-properties (point-min) end))) - (setq end (point-marker)) - (goto-char beg) - (unless (assoc "nohead" attrs) - (forward-line 2)) - (while (< (point) end) - (insert "> ") - (forward-line 1)) - (set-marker end nil)))) - -(put 'muse-poem-markup-tag 'muse-dangerous-tag t) - -(add-to-list 'muse-publish-markup-tags muse-poem-tag) - -;;; Register the Muse POEM Publishers - -(muse-derive-style "poem-latex" "latex" - :before 'muse-poem-prepare-buffer - :strings 'muse-poem-markup-strings - :header 'muse-poem-latex-header - :footer 'muse-poem-latex-footer) - -(muse-derive-style "poem-pdf" "pdf" - :before 'muse-poem-prepare-buffer - :strings 'muse-poem-markup-strings - :header 'muse-poem-latex-header - :footer 'muse-poem-latex-footer) - -(muse-derive-style "chapbook-latex" "latex" - :before 'muse-poem-prepare-buffer - :strings 'muse-poem-chapbook-strings - :header 'muse-chapbook-latex-header - :footer 'muse-chapbook-latex-footer) - -(muse-derive-style "chapbook-pdf" "pdf" - :before 'muse-poem-prepare-buffer - :strings 'muse-poem-chapbook-strings - :header 'muse-chapbook-latex-header - :footer 'muse-chapbook-latex-footer) - -(provide 'muse-poem) - -;;; muse-poem.el ends here diff --git a/elpa/muse-3.20/muse-project.el b/elpa/muse-3.20/muse-project.el deleted file mode 100644 index 7489706..0000000 --- a/elpa/muse-3.20/muse-project.el +++ /dev/null @@ -1,973 +0,0 @@ -;;; muse-project.el --- handle Muse projects - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;;; Contributors: - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse Project Maintainance -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(provide 'muse-project) - -(require 'muse) -(require 'muse-publish) -(require 'cus-edit) - -(defgroup muse-project nil - "Options controlling the behavior of Muse project handling." - :group 'muse) - -(defcustom muse-before-project-publish-hook nil - "A hook run before a project is published. -Each function is passed the project object, a cons with the format - (PROJNAME . SETTINGS)" - :type 'hook - :group 'muse-project) - -(defcustom muse-after-project-publish-hook nil - "A hook run after a project is published. -Each function is passed the project object, a cons with the format - (PROJNAME . SETTINGS)" - :type 'hook - :group 'muse-project) - -(defvar muse-project-alist-using-customize nil - "Used internally by Muse to indicate whether `muse-project-alist' -has been modified via the customize interface.") -(make-variable-buffer-local 'muse-project-alist-using-customize) - -(defmacro with-muse-project (project &rest body) - `(progn - (unless (muse-project ,project) - (error "Can't find project %s" ,project)) - (with-temp-buffer - (muse-mode) - (setq muse-current-project (muse-project ,project)) - (muse-project-set-variables) - ,@body))) - -(put 'with-muse-project 'lisp-indent-function 0) -(put 'with-muse-project 'edebug-form-spec '(sexp body)) - -(defun muse-project-alist-get (sym) - "Turn `muse-project-alist' into something we can customize easily." - (when (boundp sym) - (setq muse-project-alist-using-customize t) - (let* ((val (copy-alist (symbol-value sym))) - (head val)) - (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) t) - (setq head (cdr head))) - ((symbolp (car head)) - (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))) - -(defun muse-project-alist-set (sym val) - "Turn customized version of `muse-project-alist' into something -Muse can make use of." - (set sym val) - (when muse-project-alist-using-customize - ;; Make sure the unescaped version is written to .emacs - (put sym 'saved-value (list (custom-quote val))) - ;; Perform unescaping - (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 (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 'default - "A widget that defines a Muse project." - :format "\n%v" - :value-create 'muse-widget-type-value-create - :value-get 'muse-widget-child-value-get - :value-delete 'ignore - :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 :tag ":book-funcall" ":book-funcall") - (choice (function) - (sexp :tag "Unknown"))) - (list :tag "Book part" - (const :tag ":book-part" ":book-part") - (string :tag "Name")) - (list :tag "Book style" - (const :tag ":book-style" ":book-style") - (string :tag "Style")) - (list :tag "Default file" - (const :tag ":default" ":default") - (string :tag "File")) - (list :tag "End of book" - (const :tag ":book-end" ":book-end") - (const t)) - (list :tag "Force publishing" - (const :tag ":force-publish" ":force-publish") - (repeat (string :tag "File"))) - (list :tag "Major mode" - (const :tag ":major-mode" ":major-mode") - (choice (function :tag "Mode") - (sexp :tag "Unknown"))) - (list :tag "New chapter" - (const :tag ":book-chapter" ":book-chapter") - (string :tag "Name")) - (list :tag "No chapters" - (const :tag ":nochapters" ":nochapters") - (const t)) - (list :tag "Project-level publishing function" - (const :tag ":publish-project" - ":publish-project") - (choice (function :tag "Function") - (sexp :tag "Unknown"))) - (list :tag "Set variables" - (const :tag ":set" ":set") - (repeat (list :inline t - (symbol :tag "Variable") - (sexp :tag "Setting")))) - (list :tag "Visit links using" - (const :tag ":visit-link" ":visit-link") - (choice (function) - (sexp :tag "Unknown"))))) - (repeat :tag "Output 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 "Timestamps file" - (const :tag ":timestamps" ":timestamps") - (file)) - (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 '(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) - -;; Make it easier to specify a muse-project-alist entry - -(defcustom muse-project-ignore-regexp - (concat "\\`\\(#.*#\\|.*,v\\|.*~\\|\\.\\.?\\|\\.#.*\\|,.*\\)\\'\\|" - "/\\(CVS\\|RCS\\|\\.arch-ids\\|{arch}\\|,.*\\|\\.svn\\|" - "\\.hg\\|\\.git\\|\\.bzr\\|_darcs\\)\\(/\\|\\'\\)") - "A regexp matching files to be ignored in Muse directories. - -You should set `case-fold-search' to nil before using this regexp -in code." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-project-publish-private-files t - "If this is non-nil, files will be published even if their permissions -are set so that no one else on the filesystem can read them. - -Set this to nil if you would like to indicate that some files -should not be published by manually doing \"chmod o-rwx\" on -them. - -This setting has no effect under Windows (that is, all files are -published regardless of permissions) because Windows lacks the -needed filesystem attributes." - :type 'boolean - :group 'muse-project) - -(defun muse-project-recurse-directory (base) - "Recusively retrieve all of the directories underneath BASE. -A list of these directories is returned. - -Directories starting with \".\" will be ignored, as well as those -which match `muse-project-ignore-regexp'." - (let ((case-fold-search nil) - list dir) - (when (and (file-directory-p base) - (not (string-match muse-project-ignore-regexp base))) - (dolist (file (directory-files base t "^[^.]")) - (when (and (file-directory-p file) - (not (string-match muse-project-ignore-regexp file))) - (setq dir (file-name-nondirectory file)) - (push dir list) - (nconc list (mapcar #'(lambda (item) - (concat dir "/" item)) - (muse-project-recurse-directory file))))) - list))) - -(defun muse-project-alist-styles (entry-dir output-dir style &rest other) - "Return a list of styles to use in a `muse-project-alist' entry. -ENTRY-DIR is the top-level directory of the project. -OUTPUT-DIR is where Muse files are published, keeping directory structure. -STYLE is the publishing style to use. - -OTHER contains other definitions to add to each style. It is optional. - -For an example of the use of this function, see -`examples/mwolson/muse-init.el' from the Muse distribution." - (let ((fnd (file-name-nondirectory entry-dir))) - (when (string= fnd "") - ;; deal with cases like "foo/" that have a trailing slash - (setq fnd (file-name-nondirectory (substring entry-dir 0 -1)))) - (cons `(:base ,style :path ,(if (muse-file-remote-p output-dir) - output-dir - (expand-file-name output-dir)) - :include ,(concat "/" fnd "/[^/]+$") - ,@other) - (mapcar (lambda (dir) - `(:base ,style - :path ,(expand-file-name dir output-dir) - :include ,(concat "/" dir "/[^/]+$") - ,@other)) - (muse-project-recurse-directory entry-dir))))) - -(defun muse-project-alist-dirs (entry-dir) - "Return a list of directories to use in a `muse-project-alist' entry. -ENTRY-DIR is the top-level directory of the project. - -For an example of the use of this function, see -`examples/mwolson/muse-init.el' from the Muse distribution." - (cons (expand-file-name entry-dir) - (mapcar (lambda (dir) (expand-file-name dir entry-dir)) - (muse-project-recurse-directory entry-dir)))) - -;; Constructing the file-alist - -(defvar muse-project-file-alist nil - "This variable is automagically constructed as needed.") - -(defvar muse-project-file-alist-hook nil - "Functions that are to be exectuted immediately after updating -`muse-project-file-alist'.") - -(defvar muse-current-project nil - "Project we are currently visiting.") -(make-variable-buffer-local 'muse-current-project) -(defvar muse-current-project-global nil - "Project we are currently visiting. This is used to propagate the value -of `muse-current-project' into a new buffer during publishing.") - -(defvar muse-current-output-style nil - "The output style that we are currently using for publishing files.") - -(defsubst muse-project (&optional project) - "Resolve the given PROJECT into a full Muse project, if it is a string." - (if (null project) - (or muse-current-project - (muse-project-of-file)) - (if (stringp project) - (assoc project muse-project-alist) - (muse-assert (consp project)) - project))) - -(defun muse-project-page-file (page project &optional no-check-p) - "Return a filename if PAGE exists within the given Muse PROJECT." - (setq project (muse-project project)) - (if (null page) - ;; if not given a page, return the first directory instead - (let ((pats (cadr project))) - (catch 'done - (while pats - (if (symbolp (car pats)) - (setq pats (cddr pats)) - (throw 'done (file-name-as-directory (car pats))))))) - (let ((dir (file-name-directory page)) - (expanded-path nil)) - (when dir - (setq expanded-path (concat (expand-file-name - page - (file-name-directory (muse-current-file))) - (when muse-file-extension - (concat "." muse-file-extension)))) - (setq page (file-name-nondirectory page))) - (let ((files (muse-collect-alist - (muse-project-file-alist project no-check-p) - page)) - (matches nil)) - (if dir - (catch 'done - (save-match-data - (dolist (file files) - (if (and expanded-path - (string= expanded-path (cdr file))) - (throw 'done (cdr file)) - (let ((pos (string-match (concat (regexp-quote dir) "\\'") - (file-name-directory - (cdr file))))) - (when pos - (setq matches (cons (cons pos (cdr file)) - matches))))))) - ;; if we haven't found an exact match, pick a candidate - (car (muse-sort-by-rating matches))) - (dolist (file files) - (setq matches (cons (cons (length (cdr file)) (cdr file)) - matches))) - (car (muse-sort-by-rating matches '<))))))) - -(defun muse-project-private-p (file) - "Return non-nil if NAME is a private page with PROJECT." - (unless (or muse-under-windows-p - muse-project-publish-private-files) - (setq file (file-truename file)) - (if (file-attributes file) ; don't publish if no attributes exist - (or (when (eq ?- (aref (nth 8 (file-attributes - (file-name-directory file))) 7)) - (message (concat - "The " (file-name-directory file) - " directory must be readable by others" - " in order for its contents to be published."))) - (eq ?- (aref (nth 8 (file-attributes file)) 7))) - t))) - -(defun muse-project-file-entries (path) - (let* ((names (list t)) - (lnames names) - (case-fold-search nil)) - (cond - ((file-directory-p path) - (dolist (file (directory-files - path t (when (and muse-file-extension - (not (string= muse-file-extension ""))) - (concat "." muse-file-extension "\\'")))) - (unless (or (string-match muse-project-ignore-regexp file) - (string-match muse-project-ignore-regexp - (file-name-nondirectory file)) - (file-directory-p file)) - (setcdr lnames - (cons (cons (muse-page-name file) file) nil)) - (setq lnames (cdr lnames))))) - ((file-readable-p path) - (setcdr lnames - (cons (cons (muse-page-name path) path) nil)) - (setq lnames (cdr lnames))) - (t ; regexp - (muse-assert (file-name-directory path)) - (dolist (file (directory-files - (file-name-directory path) t - (file-name-nondirectory path))) - (unless (or (string-match muse-project-ignore-regexp file) - (string-match muse-project-ignore-regexp - (file-name-nondirectory file))) - (setcdr lnames - (cons (cons (muse-page-name file) file) nil)) - (setq lnames (cdr lnames)))))) - (cdr names))) - -(defvar muse-updating-file-alist-p nil - "Make sure that recursive calls to `muse-project-file-alist' are bounded.") - -(defun muse-project-determine-last-mod (project &optional no-check-p) - "Return the most recent last-modified timestamp of dirs in PROJECT." - (let ((last-mod nil)) - (unless (or muse-under-windows-p no-check-p) - (let ((pats (cadr project))) - (while pats - (if (symbolp (car pats)) - (setq pats (cddr pats)) - (let* ((fnd (file-name-directory (car pats))) - (dir (cond ((file-directory-p (car pats)) - (car pats)) - ((and (not (file-readable-p (car pats))) - fnd - (file-directory-p fnd)) - fnd)))) - (when dir - (let ((mod-time (nth 5 (file-attributes dir)))) - (when (or (null last-mod) - (and mod-time - (muse-time-less-p last-mod mod-time))) - (setq last-mod mod-time))))) - (setq pats (cdr pats)))))) - last-mod)) - -(defun muse-project-file-alist (&optional project no-check-p) - "Return member filenames for the given Muse PROJECT. -Also, update the `muse-project-file-alist' variable. - -On UNIX, this alist is only updated if one of the directories' -contents have changed. On Windows, it is always reread from -disk. - -If NO-CHECK-P is non-nil, do not update the alist, just return -the current one." - (setq project (muse-project project)) - (when (and project muse-project-alist) - (let* ((file-alist (assoc (car project) muse-project-file-alist)) - (last-mod (muse-project-determine-last-mod project no-check-p))) - ;; Either return the currently known list, or read it again from - ;; disk - (if (or (and no-check-p (cadr file-alist)) - muse-updating-file-alist-p - (not (or muse-under-windows-p - (null (cddr file-alist)) - (null last-mod) - (muse-time-less-p (cddr file-alist) last-mod)))) - (cadr file-alist) - (if file-alist - (setcdr (cdr file-alist) last-mod) - (setq file-alist (cons (car project) (cons nil last-mod)) - muse-project-file-alist - (cons file-alist muse-project-file-alist))) - ;; Read in all of the file entries - (let ((muse-updating-file-alist-p t)) - (prog1 - (save-match-data - (setcar - (cdr file-alist) - (let* ((names (list t)) - (pats (cadr project))) - (while pats - (if (symbolp (car pats)) - (setq pats (cddr pats)) - (nconc names (muse-project-file-entries (car pats))) - (setq pats (cdr pats)))) - (cdr names)))) - (run-hooks 'muse-project-file-alist-hook))))))) - -(defun muse-project-add-to-alist (file &optional project) - "Make sure FILE is added to `muse-project-file-alist'. - -It works by either calling the `muse-project-file-alist' function -if a directory has been modified since we last checked, or -manually forcing the file entry to exist in the alist. This -works around an issue where if several files being saved at the -same time, only the first one will make it into the alist. It is -meant to be called by `muse-project-after-save-hook'. - -The project of the file is determined by either the PROJECT -argument, or `muse-project-of-file' if PROJECT is not specified." - (setq project (or (muse-project project) (muse-project-of-file file))) - (when (and project muse-project-alist) - (let* ((file-alist (assoc (car project) muse-project-file-alist)) - (last-mod (muse-project-determine-last-mod project))) - ;; Determine whether we need to call this - (if (or (null (cddr file-alist)) - (null last-mod) - (muse-time-less-p (cddr file-alist) last-mod)) - ;; The directory will show up as modified, so go ahead and - ;; call `muse-project-file-alist' - (muse-project-file-alist project) - ;; It is not showing as modified, so forcefully add the - ;; current file to the project file-alist - (let ((muse-updating-file-alist-p t)) - (prog1 - (save-match-data - (setcar (cdr file-alist) - (nconc (muse-project-file-entries file) - (cadr file-alist)))) - (run-hooks 'muse-project-file-alist-hook))))))) - -(defun muse-project-of-file (&optional pathname) - "Determine which project the given PATHNAME relates to. -If PATHNAME is nil, the current buffer's filename is used." - (if (and (null pathname) muse-current-project) - muse-current-project - (unless pathname (setq pathname (muse-current-file))) - (save-match-data - (when (and (stringp pathname) - muse-project-alist - (not (string= pathname "")) - (not (let ((case-fold-search nil)) - (or (string-match muse-project-ignore-regexp - pathname) - (string-match muse-project-ignore-regexp - (file-name-nondirectory - pathname)))))) - (let* ((file (file-truename pathname)) - (dir (file-name-directory file)) - found rating matches) - (catch 'found - (dolist (project-entry muse-project-alist) - (let ((pats (cadr project-entry))) - (while pats - (if (symbolp (car pats)) - (setq pats (cddr pats)) - (let ((tname (file-truename (car pats)))) - (cond ((or (string= tname file) - (string= (file-name-as-directory tname) dir)) - (throw 'found project-entry)) - ((string-match (concat "\\`" (regexp-quote tname)) - file) - (setq matches (cons (cons (match-end 0) - project-entry) - matches))))) - (setq pats (cdr pats)))))) - ;; if we haven't found an exact match, pick a candidate - (car (muse-sort-by-rating matches)))))))) - -(defun muse-project-after-save-hook () - "Update Muse's file-alist if we are saving a Muse file." - (let ((project (muse-project-of-file))) - (when project - (muse-project-add-to-alist (buffer-file-name) project)))) - -(add-hook 'after-save-hook 'muse-project-after-save-hook) - -(defun muse-read-project (prompt &optional no-check-p no-assume) - "Read a project name from the minibuffer, if it can't be figured - out." - (if (null muse-project-alist) - (error "There are no Muse projects defined; see `muse-project-alist'") - (or (unless no-check-p - (muse-project-of-file)) - (if (and (not no-assume) - (= 1 (length muse-project-alist))) - (car muse-project-alist) - (assoc (funcall muse-completing-read-function - prompt muse-project-alist) - muse-project-alist))))) - -(defvar muse-project-page-history nil) - -(defun muse-read-project-file (project prompt &optional default) - (let* ((file-list (muse-delete-dups - (mapcar #'(lambda (a) (list (car a))) - (muse-project-file-alist project)))) - (name (funcall muse-completing-read-function - prompt file-list nil nil nil - 'muse-project-page-history default))) - (cons name (muse-project-page-file name project)))) - -;;;###autoload -(defun muse-project-find-file (name project &optional command directory) - "Open the Muse page given by NAME in PROJECT. -If COMMAND is non-nil, it is the function used to visit the file. -If DIRECTORY is non-nil, it is the directory in which the page -will be created if it does not already exist. Otherwise, the -first directory within the project's fileset is used." - (interactive - (let* ((project (muse-read-project "Find in project: " - current-prefix-arg)) - (default (muse-get-keyword :default (cadr project))) - (entry (muse-read-project-file - project (if default - (format "Find page: (default: %s) " - default) - "Find page: ") - default))) - (list entry project))) - (setq project (muse-project project)) - (let ((project-name (car project))) - (unless (interactive-p) - (setq project (muse-project project) - name (cons name (muse-project-page-file name project)))) - ;; If we're given a relative or absolute filename, open it as-is - (if (and (car name) - (save-match-data - (or (string-match "\\`\\.+/" (car name)) - (string-match muse-file-regexp (car name)) - (string-match muse-image-regexp (car name))))) - (setcdr name (car name)) - ;; At this point, name is (PAGE . FILE). - (unless (cdr name) - (let ((pats (cadr project))) - (while (and pats (null directory)) - (if (symbolp (car pats)) - (setq pats (cddr pats)) - (if (file-directory-p (car pats)) - (setq directory (car pats) pats nil) - (setq pats (cdr pats)))))) - (when directory - (let ((filename (expand-file-name (car name) directory))) - (when (and muse-file-extension - (not (string= muse-file-extension "")) - (not (file-exists-p (car name)))) - (setq filename (concat filename "." muse-file-extension))) - (unless (file-exists-p directory) - (make-directory directory t)) - (setcdr name filename))))) - ;; Open the file - (if (cdr name) - (funcall (or command 'find-file) (cdr name)) - (error "There is no page %s in project %s" - (car name) project-name)))) - -(defun muse-project-choose-style (closure test styles) - "Run TEST on STYLES and return first style where TEST yields non-nil. -TEST should take two arguments. The first is CLOSURE, which is -passed verbatim. The second if the current style to consider. - -If no style passes TEST, return the first style." - (or (catch 'winner - (dolist (style styles) - (when (funcall test closure style) - (throw 'winner style)))) - (car styles))) - -(defun muse-project-choose-style-by-link-suffix (given-suffix style) - "If the given STYLE has a link-suffix that equals GIVEN-SUFFIX, -return non-nil." - (let ((link-suffix (or (muse-style-element :link-suffix style) - (muse-style-element :suffix style)))) - (and (stringp link-suffix) - (string= given-suffix link-suffix)))) - -(defun muse-project-applicable-styles (file styles) - "Given STYLES, return a list of the ones that are considered for FILE. -The name of a project may be used for STYLES." - (when (stringp styles) - (setq styles (cddr (muse-project styles)))) - (when (and file styles) - (let ((used-styles nil)) - (dolist (style styles) - (let ((include-regexp (muse-style-element :include style)) - (exclude-regexp (muse-style-element :exclude style)) - (rating nil)) - (when (and (or (and (null include-regexp) - (null exclude-regexp)) - (if include-regexp - (setq rating (string-match include-regexp file)) - (not (string-match exclude-regexp file)))) - (file-exists-p file) - (not (muse-project-private-p file))) - (setq used-styles (cons (cons rating style) used-styles))))) - (muse-sort-by-rating (nreverse used-styles))))) - -(defun muse-project-get-applicable-style (file styles) - "Choose a style from the STYLES that FILE can publish to. -The user is prompted if several styles are found." - (muse-publish-get-style - (mapcar (lambda (style) - (cons (muse-get-keyword :base style) style)) - (muse-project-applicable-styles file styles)))) - -(defun muse-project-resolve-directory (page local-style remote-style) - "Figure out the directory part of the path that provides a link to PAGE. -LOCAL-STYLE is the style of the current Muse file, and -REMOTE-STYLE is the style associated with PAGE. - -If REMOTE-STYLE has a :base-url element, concatenate it and PAGE. -Otherwise, return a relative link." - (let ((prefix (muse-style-element :base-url remote-style))) - (if prefix - (concat prefix page) - (file-relative-name (expand-file-name - (file-name-nondirectory page) - (muse-style-element :path remote-style)) - (expand-file-name - (muse-style-element :path local-style)))))) - -(defun muse-project-resolve-link (page local-style remote-styles) - "Return a published link from the output path of one file to another file. - -The best match for PAGE is determined by comparing the link -suffix of the given local style and that of the remote styles. - -The remote styles are usually populated by -`muse-project-applicable-styles'. - -If no remote style is found, return PAGE verbatim - -If PAGE has a :base-url associated with it, return the -concatenation of the :base-url value and PAGE. - -Otherwise, return a relative path from the directory of -LOCAL-STYLE to the best directory among REMOTE-STYLES." - (let ((link-suffix (or (muse-style-element :link-suffix local-style) - (muse-style-element :suffix local-style))) - remote-style) - (if (not (stringp link-suffix)) - (setq remote-style (car remote-styles)) - (setq remote-style (muse-project-choose-style - link-suffix - #'muse-project-choose-style-by-link-suffix - remote-styles))) - (if (null remote-style) - page - (setq page (muse-project-resolve-directory - page local-style remote-style)) - (concat (file-name-directory page) - (muse-publish-link-name page remote-style))))) - -(defun muse-project-current-output-style (&optional file project) - (or muse-current-output-style - (progn - (unless file (setq file (muse-current-file))) - (unless project (setq project (muse-project-of-file file))) - (car (muse-project-applicable-styles file (cddr project)))))) - -(defun muse-project-link-page (page) - (let ((project (muse-project-of-file))) - (muse-project-resolve-link page - (muse-project-current-output-style) - (muse-project-applicable-styles - (muse-project-page-file page project) - (cddr project))))) - -(defun muse-project-publish-file-default (file style output-dir force) - ;; ensure the publishing location is available - (unless (file-exists-p output-dir) - (message "Creating publishing directory %s" output-dir) - (make-directory output-dir t)) - ;; publish the member file! - (muse-publish-file file style output-dir force)) - -(defun muse-project-publish-file (file styles &optional force) - (setq styles (muse-project-applicable-styles file styles)) - (let (published) - (dolist (style styles) - (if (or (not (listp style)) - (not (cdr style))) - (muse-display-warning - (concat "Skipping malformed muse-project-alist style." - "\nPlease double-check your configuration,")) - (let ((output-dir (muse-style-element :path style)) - (muse-current-output-style style) - (fun (or (muse-style-element :publish style t) - 'muse-project-publish-file-default))) - (when (funcall fun file style output-dir force) - (setq published t))))) - published)) - -;;;###autoload -(defun muse-project-publish-this-file (&optional force style) - "Publish the currently-visited file according to `muse-project-alist', -prompting if more than one style applies. - -If FORCE is given, publish the file even if it is up-to-date. - -If STYLE is given, use that publishing style rather than -prompting for one." - (interactive (list current-prefix-arg)) - (let ((muse-current-project (muse-project-of-file))) - (if (not muse-current-project) - ;; file is not part of a project, so fall back to muse-publish - (if (interactive-p) (call-interactively 'muse-publish-this-file) - (muse-publish-this-file style nil force)) - (unless style - (setq style (muse-project-get-applicable-style - buffer-file-name (cddr muse-current-project)))) - (let* ((output-dir (muse-style-element :path style)) - (muse-current-project-global muse-current-project) - (muse-current-output-style (list :base (car style) - :path output-dir)) - (fun (or (muse-style-element :publish style t) - 'muse-project-publish-file-default))) - (unless (funcall fun buffer-file-name style output-dir force) - (message (concat "The published version is up-to-date; use" - " C-u C-c C-t to force an update."))))))) - -(defun muse-project-save-buffers (&optional project) - (setq project (muse-project project)) - (when project - (save-excursion - (map-y-or-n-p - (function - (lambda (buffer) - (and (buffer-modified-p buffer) - (not (buffer-base-buffer buffer)) - (or (buffer-file-name buffer) - (progn - (set-buffer buffer) - (and buffer-offer-save - (> (buffer-size) 0)))) - (with-current-buffer buffer - (let ((proj (muse-project-of-file))) - (and proj (string= (car proj) - (car project))))) - (if (buffer-file-name buffer) - (format "Save file %s? " - (buffer-file-name buffer)) - (format "Save buffer %s? " - (buffer-name buffer)))))) - (function - (lambda (buffer) - (set-buffer buffer) - (save-buffer))) - (buffer-list) - '("buffer" "buffers" "save") - (if (boundp 'save-some-buffers-action-alist) - save-some-buffers-action-alist))))) - -(defun muse-project-publish-default (project styles &optional force) - "Publish the pages of PROJECT that need publishing." - (setq project (muse-project project)) - (let ((published nil)) - ;; publish all files in the project, for each style; the actual - ;; publishing will only happen if the files are newer than the - ;; last published output, or if the file is listed in - ;; :force-publish. Files in :force-publish will not trigger the - ;; "All pages need to be published" message. - (let ((forced-files (muse-get-keyword :force-publish (cadr project))) - (file-alist (muse-project-file-alist project))) - (dolist (pair file-alist) - (when (muse-project-publish-file (cdr pair) styles force) - (setq forced-files (delete (car pair) forced-files)) - (setq published t))) - (dolist (file forced-files) - (muse-project-publish-file (cdr (assoc file file-alist)) styles t))) - ;; run hook after publishing ends - (run-hook-with-args 'muse-after-project-publish-hook project) - ;; notify the user that everything is now done - (if published - (message "All pages in %s have been published." (car project)) - (message "No pages in %s need publishing at this time." - (car project))))) - -;;;###autoload -(defun muse-project-publish (project &optional force) - "Publish the pages of PROJECT that need publishing." - (interactive (list (muse-read-project "Publish project: " nil t) - current-prefix-arg)) - (setq project (muse-project project)) - (let ((styles (cddr project)) - (muse-current-project project) - (muse-current-project-global project)) - ;; determine the style from the project, or else ask - (unless styles - (setq styles (list (muse-publish-get-style)))) - (unless project - (error "Cannot find a project to publish")) - ;; prompt to save any buffers related to this project - (muse-project-save-buffers project) - ;; run hook before publishing begins - (run-hook-with-args 'muse-before-project-publish-hook project) - ;; run the project-level publisher - (let ((fun (or (muse-get-keyword :publish-project (cadr project) t) - 'muse-project-publish-default))) - (funcall fun project styles force)))) - -(defun muse-project-batch-publish () - "Publish Muse files in batch mode." - (let ((muse-batch-publishing-p t) - force) - (if (string= "--force" (or (car command-line-args-left) "")) - (setq force t - command-line-args-left (cdr command-line-args-left))) - (if command-line-args-left - (dolist (project command-line-args-left) - (message "Publishing project %s ..." project) - (muse-project-publish project force)) - (message "No projects specified.")))) - -(eval-when-compile - (put 'make-local-hook 'byte-compile nil)) - -(defun muse-project-set-variables () - "Load project-specific variables." - (when (and muse-current-project-global (null muse-current-project)) - (setq muse-current-project muse-current-project-global)) - (let ((vars (muse-get-keyword :set (cadr muse-current-project))) - sym custom-set var) - (while vars - (setq sym (car vars)) - (setq custom-set (or (get sym 'custom-set) 'set)) - (setq var (if (eq (get sym 'custom-type) 'hook) - (make-local-hook sym) - (make-local-variable sym))) - (funcall custom-set var (car (cdr vars))) - (setq vars (cdr (cdr vars)))))) - -(custom-add-option 'muse-before-publish-hook 'muse-project-set-variables) -(add-to-list 'muse-before-publish-hook 'muse-project-set-variables) - -(defun muse-project-delete-output-files (project) - (interactive - (list (muse-read-project "Remove all output files for project: " nil t))) - (setq project (muse-project project)) - (let ((file-alist (muse-project-file-alist project)) - (styles (cddr project)) - output-file path) - (dolist (entry file-alist) - (dolist (style styles) - (setq output-file - (and (setq path (muse-style-element :path style)) - (expand-file-name - (concat (muse-style-element :prefix style) - (car entry) - (or (muse-style-element :osuffix style) - (muse-style-element :suffix style))) - path))) - (if output-file - (muse-delete-file-if-exists output-file)))))) - -;;; muse-project.el ends here diff --git a/elpa/muse-3.20/muse-protocols.el b/elpa/muse-3.20/muse-protocols.el deleted file mode 100644 index 5e1061c..0000000 --- a/elpa/muse-3.20/muse-protocols.el +++ /dev/null @@ -1,251 +0,0 @@ -;;; muse-protocols.el --- URL protocols that Muse recognizes - -;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; Author: Brad Collins (brad AT chenla DOT org) - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; Here's an example for adding a protocol for the site yubnub, a Web -;; Command line service. -;; -;; (add-to-list 'muse-url-protocols '("yubnub://" muse-browse-url-yubnub -;; muse-resolve-url-yubnub)) -;; -;; (defun muse-resolve-url-yubnub (url) -;; "Resolve a yubnub URL." -;; ;; Remove the yubnub:// -;; (when (string-match "\\`yubnub://\\(.+\\)" url) -;; (match-string 1))) -;; -;; (defun muse-browse-url-yubnub (url) -;; "If this is a yubnub URL-command, jump to it." -;; (setq url (muse-resolve-url-yubnub url)) -;; (browse-url (concat "http://yubnub.org/parser/parse?command=" -;; url))) - -;;; Contributors: - -;; Phillip Lord (Phillip.Lord AT newcastle DOT ac DOT uk) provided a -;; handler for DOI URLs. - -;; Stefan Schlee fixed a bug with handling of colons at the end of -;; URLs. - -;; Valery V. Vorotyntsev contribued the woman:// protocol handler and -;; simplified `muse-browse-url-man'. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse URL Protocols -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'info) -(require 'muse-regexps) - -(defvar muse-url-regexp nil - "A regexp used to match URLs within a Muse page. -This is autogenerated from `muse-url-protocols'.") - -(defun muse-update-url-regexp (sym value) - (setq muse-url-regexp - (concat "\\<\\(" (mapconcat 'car value "\\|") "\\)" - "[^][" muse-regexp-blank "\"'()<>^`{}\n]*" - "[^][" muse-regexp-blank "\"'()<>^`{}.,;:\n]+")) - (set sym value)) - -(defcustom muse-url-protocols - '(("[uU][rR][lL]:" muse-browse-url-url identity) - ("info://" muse-browse-url-info nil) - ("man://" muse-browse-url-man nil) - ("woman://" muse-browse-url-woman nil) - ("google://" muse-browse-url-google muse-resolve-url-google) - ("http:/?/?" browse-url identity) - ("https:/?/?" browse-url identity) - ("ftp:/?/?" browse-url identity) - ("gopher://" browse-url identity) - ("telnet://" browse-url identity) - ("wais://" browse-url identity) - ("file://?" browse-url identity) - ("dict:" muse-browse-url-dict muse-resolve-url-dict) - ("doi:" muse-browse-url-doi muse-resolve-url-doi) - ("news:" browse-url identity) - ("snews:" browse-url identity) - ("mailto:" browse-url identity)) - "A list of (PROTOCOL BROWSE-FUN RESOLVE-FUN) used to match URL protocols. -PROTOCOL describes the first part of the URL, including the -\"://\" part. This may be a regexp. - -BROWSE-FUN should accept URL as an argument and open the URL in -the current window. - -RESOLVE-FUN should accept URL as an argument and return the final -URL, or nil if no URL should be included." - :type '(repeat (list :tag "Protocol" - (string :tag "Regexp") - (function :tag "Browse") - (choice (function :tag "Resolve") - (const :tag "Don't resolve" nil)))) - :set 'muse-update-url-regexp - :group 'muse) - -(add-hook 'muse-update-values-hook - (lambda () - (muse-update-url-regexp 'muse-url-protocols muse-url-protocols))) - -(defcustom muse-wikipedia-country "en" - "Indicate the 2-digit country code that we use for Wikipedia -queries." - :type 'string - :options '("de" "en" "es" "fr" "it" "pl" "pt" "ja" "nl" "sv") - :group 'muse) - -(defun muse-protocol-find (proto list) - "Return the first element of LIST whose car matches the regexp PROTO." - (catch 'found - (dolist (item list) - (when (string-match (concat "\\`" (car item)) proto) - (throw 'found item))))) - -;;;###autoload -(defun muse-browse-url (url &optional other-window) - "Handle URL with the function specified in `muse-url-protocols'. -If OTHER-WINDOW is non-nil, open in a different window." - (interactive (list (read-string "URL: ") - current-prefix-arg)) - ;; Strip text properties - (when (fboundp 'set-text-properties) - (set-text-properties 0 (length url) nil url)) - (when other-window - (switch-to-buffer-other-window (current-buffer))) - (when (string-match muse-url-regexp url) - (let* ((proto (match-string 1 url)) - (entry (muse-protocol-find proto muse-url-protocols))) - (when entry - (funcall (cadr entry) url))))) - -(defun muse-resolve-url (url &rest ignored) - "Resolve URL with the function specified in `muse-url-protocols'." - (when (string-match muse-url-regexp url) - (let* ((proto (match-string 1 url)) - (entry (muse-protocol-find proto muse-url-protocols))) - (when entry - (let ((func (car (cddr entry)))) - (if func - (setq url (funcall func url)) - (setq url nil)))))) - url) - -(defun muse-protocol-add (protocol browse-function resolve-function) - "Add PROTOCOL to `muse-url-protocols'. PROTOCOL may be a regexp. - -BROWSE-FUNCTION should be a function that visits a URL in the -current buffer. - -RESOLVE-FUNCTION should be a function that transforms a URL for -publishing or returns nil if not linked." - (add-to-list 'muse-url-protocols - (list protocol browse-function resolve-function)) - (muse-update-url-regexp 'muse-url-protocols - muse-url-protocols)) - -(defun muse-browse-url-url (url) - "Call `muse-protocol-browse-url' to browse URL. -This is used when we are given something like -\"URL:http://example.org/\". - -If you're looking for a good example for how to make a custom URL -handler, look at `muse-browse-url-dict' instead." - (when (string-match "\\`[uU][rR][lL]:\\(.+\\)" url) - (muse-browse-url (match-string 1 url)))) - -(defun muse-resolve-url-dict (url) - "Return the Wikipedia link corresponding with the given URL." - (when (string-match "\\`dict:\\(.+\\)" url) - (concat "http://" muse-wikipedia-country ".wikipedia.org/" - "wiki/Special:Search?search=" (match-string 1 url)))) - -(defun muse-browse-url-dict (url) - "If this is a Wikipedia URL, browse it." - (let ((dict-url (muse-resolve-url-dict url))) - (when dict-url - (browse-url dict-url)))) - -(defun muse-resolve-url-doi (url) - "Return the URL through DOI proxy server." - (when (string-match "\\`doi:\\(.+\\)" url) - (concat "http://dx.doi.org/" - (match-string 1 url)))) - -(defun muse-browse-url-doi (url) - "If this is a DOI URL, browse it. - -DOI's (digitial object identifiers) are a standard identifier -used in the publishing industry." - (let ((doi-url (muse-resolve-url-doi url))) - (when doi-url - (browse-url doi-url)))) - -(defun muse-resolve-url-google (url) - "Return the correct Google search string." - (when (string-match "\\`google:/?/?\\(.+\\)" url) - (concat "http://www.google.com/search?q=" - (match-string 1 url)))) - -(defun muse-browse-url-google (url) - "If this is a Google URL, jump to it." - (let ((google-url (muse-resolve-url-google url))) - (when google-url - (browse-url google-url)))) - -(defun muse-browse-url-info (url) - "If this in an Info URL, jump to it." - (require 'info) - (cond - ((string-match "\\`info://\\([^#\n]+\\)#\\(.+\\)" url) - (Info-find-node (match-string 1 url) - (match-string 2 url))) - ((string-match "\\`info://\\([^#\n]+\\)" url) - (Info-find-node (match-string 1 url) - "Top")) - ((string-match "\\`info://(\\([^)\n]+\\))\\(.+\\)" url) - (Info-find-node (match-string 1 url) (match-string 2 url))) - ((string-match "\\`info://\\(.+\\)" url) - (Info-find-node (match-string 1 url) "Top")))) - -(defun muse-browse-url-man (url) - "If this in a manpage URL, jump to it." - (require 'man) - (when (string-match "\\`man://\\([^(]+\\(([^)]+)\\)?\\)" url) - (man (match-string 1 url)))) - -(defun muse-browse-url-woman (url) - "If this is a WoMan URL, jump to it." - (require 'woman) - (when (string-match "\\`woman://\\(.+\\)" url) - (woman (match-string 1 url)))) - -(provide 'muse-protocols) - -;;; muse-protocols.el ends here diff --git a/elpa/muse-3.20/muse-publish.el b/elpa/muse-3.20/muse-publish.el deleted file mode 100644 index ec6e176..0000000 --- a/elpa/muse-3.20/muse-publish.el +++ /dev/null @@ -1,2193 +0,0 @@ -;;; muse-publish.el --- base publishing implementation - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;;; Contributors: - -;; Yann Hodique (yann DOT hodique AT gmail DOT com) fixed an -;; unnecessary URL description transform in `muse-publish-url'. - -;; Peter K. Lee (saint AT corenova DOT com) provided the -;; `muse-style-elements-list' function. - -;; Jim Ottaway (j DOT ottaway AT lse DOT ac DOT uk) provided a -;; reference implementation for nested lists, as well as some code for -;; the "style" element of the tag. - -;; Deus Max (deusmax AT gmail DOT com) provided the tag. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(provide 'muse-publish) - -(require 'muse) -(require 'muse-regexps) - -(defgroup muse-publish nil - "Options controlling the general behavior of Muse publishing." - :group 'muse) - -(defcustom muse-before-publish-hook nil - "A hook run in the buffer to be published, before it is done." - :type 'hook - :group 'muse-publish) - -(defcustom muse-after-publish-hook nil - "A hook run in the buffer to be published, after it is done." - :type 'hook - :group 'muse-publish) - -(defcustom muse-publish-url-transforms - '(muse-resolve-url) - "A list of functions used to prepare URLs for publication. -Each is passed the URL. The transformed URL should be returned." - :type 'hook - :options '(muse-resolve-url) - :group 'muse-publish) - -(defcustom muse-publish-desc-transforms - '(muse-publish-strip-URL) - "A list of functions used to prepare URL desciptions for publication. -Each is passed the description. The modified description should -be returned." - :type 'hook - :options '(muse-publish-strip-URL) - :group 'muse-publish) - -(defcustom muse-publish-date-format "%B %e, %Y" - "Format string for the date, used by `muse-publish-markup-buffer'. -See `format-time-string' for details on the format options." - :type 'string - :group 'muse-publish) - -(defcustom muse-publish-comments-p nil - "If nil, remove comments before publishing. -If non-nil, publish comments using the markup of the current style." - :type 'boolean - :group 'muse-publish) - -(defcustom muse-publish-report-threshhold 100000 - "If a file is this size or larger, report publishing progress." - :type 'integer - :group 'muse-publish) - -(defcustom muse-publish-markup-regexps - `(;; Remove leading and trailing whitespace from the file - (1000 "\\(\\`\n+\\|\n+\\'\\)" 0 "") - - ;; Remove trailing whitespace from all lines - (1100 ,(concat "[" muse-regexp-blank "]+$") 0 "") - - ;; Handle any leading #directives - (1200 "\\`#\\([a-zA-Z-]+\\)\\s-+\\(.+\\)\n+" 0 directive) - - ;; commented lines - (1250 ,(concat "^;\\(?:[" muse-regexp-blank "]+\\(.+\\)\\|$\\|'\\)") - 0 comment) - - ;; markup tags - (1300 muse-tag-regexp 0 tag) - - ;; prevent emphasis characters in explicit links from being marked - (1400 muse-explicit-link-regexp 0 muse-publish-mark-link) - - ;; emphasized or literal text - (1600 ,(concat "\\(^\\|[-[" muse-regexp-blank - "<('`\"\n]\\)\\(=[^=" muse-regexp-blank - "\n]\\|_[^_" muse-regexp-blank - "\n]\\|\\*+[^*" muse-regexp-blank - "\n]\\)") - 2 word) - - ;; headings, outline-mode style - (1700 "^\\(\\*+\\)\\s-+" 0 heading) - - ;; ellipses - (1800 "\\.\\.\\.\\." 0 enddots) - (1850 "\\.\\.\\." 0 dots) - - ;; horizontal rule, or section separator - (1900 "^----+" 0 rule) - - ;; non-breaking space - (1950 "~~" 0 no-break-space) - - ;; beginning of footnotes section - (2000 "^Footnotes:?\\s-*" 0 fn-sep) - ;; footnote definition/reference (def if at beginning of line) - (2100 "\\[\\([1-9][0-9]*\\)\\]" 0 footnote) - - ;; unnumbered List items begin with a -. numbered list items - ;; begin with number and a period. definition lists have a - ;; leading term separated from the body with ::. centered - ;; paragraphs begin with at least six columns of whitespace; any - ;; other whitespace at the beginning indicates a blockquote. The - ;; reason all of these rules are handled here, is so that - ;; blockquote detection doesn't interfere with indented list - ;; members. - (2200 ,(format muse-list-item-regexp (concat "[" muse-regexp-blank "]*")) - 0 list) - - ;; support table.el style tables - (2300 ,(concat "^" muse-table-el-border-regexp "\n" - "\\(\\(" muse-table-el-line-regexp "\n\\)+" - "\\(" muse-table-el-border-regexp "\\)" - "\\(\n\\|\\'\\)\\)+") - 0 table-el) - - ;; simple table markup is supported, nothing fancy. use | to - ;; separate cells, || to separate header cells, and ||| for footer - ;; cells - (2350 ,(concat "\\(\\([" muse-regexp-blank "]*\n\\)?" - "\\(\\(?:" muse-table-line-regexp "\\|" - muse-table-hline-regexp "\\)\\(?:\n\\|\\'\\)\\)\\)+") - 0 table) - - ;; blockquote and centered text - (2400 ,(concat "^\\([" muse-regexp-blank "]+\\).+") 0 quote) - - ;; the emdash ("--" or "---") - (2500 ,(concat "\\(^\\|[" muse-regexp-blank "]*\\)---?\\($\\|[" - muse-regexp-blank "]*\\)") - 0 emdash) - - ;; "verse" text is indicated the same way as a quoted e-mail - ;; response: "> text", where text may contain initial whitespace - ;; (see below). - (2600 ,(concat "^[" muse-regexp-blank "]*> ") 0 verse) - - ;; define anchor points - (2700 "^\\(\\W*\\)#\\(\\S-+\\)\\s-*" 0 anchor) - - ;; replace links in the buffer (links to other pages) - (2900 muse-explicit-link-regexp 0 link) - - ;; bare URLs - (3000 muse-url-regexp 0 url) - - ;; bare email addresses - (3500 - "\\([^[]\\)[-a-zA-Z0-9._]+@\\([-a-zA-z0-9_]+\\.\\)+[a-zA-Z0-9]+" 0 email) - ) - "List of markup rules for publishing a page with Muse. -The rules given in this variable are invoked first, followed by -whatever rules are specified by the current style. - -Each member of the list is either a function, or a list of the form: - - (REGEXP/SYMBOL TEXT-BEGIN-GROUP REPLACEMENT-TEXT/FUNCTION/SYMBOL) - -REGEXP is a regular expression, or symbol whose value is a regular -expression, which is searched for using `re-search-forward'. -TEXT-BEGIN-GROUP is the matching group within that regexp which -denotes the beginning of the actual text to be marked up. -REPLACEMENT-TEXT is a string that will be passed to `replace-match'. -If it is not a string, but a function, it will be called to determine -what the replacement text should be (it must return a string). If it -is a symbol, the value of that symbol should be a string. - -The replacements are done in order, one rule at a time. Writing -the regular expressions can be a tricky business. Note that case -is never ignored. `case-fold-search' is always bound to nil -while processing the markup rules." - :type '(repeat (choice - (list :tag "Markup rule" - integer - (choice regexp symbol) - integer - (choice string function symbol)) - function)) - :group 'muse-publish) - -(defcustom muse-publish-markup-functions - '((directive . muse-publish-markup-directive) - (comment . muse-publish-markup-comment) - (anchor . muse-publish-markup-anchor) - (tag . muse-publish-markup-tag) - (word . muse-publish-markup-word) - (emdash . muse-publish-markup-emdash) - (enddots . muse-publish-markup-enddots) - (dots . muse-publish-markup-dots) - (rule . muse-publish-markup-rule) - (no-break-space . muse-publish-markup-no-break-space) - (heading . muse-publish-markup-heading) - (footnote . muse-publish-markup-footnote) - (fn-sep . muse-publish-markup-fn-sep) - (list . muse-publish-markup-list) - (quote . muse-publish-markup-quote) - (verse . muse-publish-markup-verse) - (table . muse-publish-markup-table) - (table-el . muse-publish-markup-table-el) - (email . muse-publish-markup-email) - (link . muse-publish-markup-link) - (url . muse-publish-markup-url)) - "An alist of style types to custom functions for that kind of text. - -Each member of the list is of the form: - - (SYMBOL FUNCTION) - -SYMBOL describes the type of text to associate with this rule. -`muse-publish-markup-regexps' maps regexps to these symbols. - -FUNCTION is the function to use to mark up this kind of rule if -no suitable function is found through the :functions tag of the -current style." - :type '(alist :key-type symbol :value-type function) - :group 'muse-publish) - -(defcustom muse-publish-markup-tags - '(("contents" nil t nil muse-publish-contents-tag) - ("verse" t nil nil muse-publish-verse-tag) - ("example" t nil nil muse-publish-example-tag) - ("src" t t nil muse-publish-src-tag) - ("code" t nil nil muse-publish-code-tag) - ("quote" t nil t muse-publish-quote-tag) - ("literal" t t nil muse-publish-literal-tag) - ("verbatim" t nil nil muse-publish-verbatim-tag) - ("br" nil nil nil muse-publish-br-tag) - ("lisp" t t nil muse-publish-lisp-tag) - ("class" t t nil muse-publish-class-tag) - ("div" t t nil muse-publish-div-tag) - ("command" t t nil muse-publish-command-tag) - ("perl" t t nil muse-publish-perl-tag) - ("php" t t nil muse-publish-php-tag) - ("python" t t nil muse-publish-python-tag) - ("ruby" t t nil muse-publish-ruby-tag) - ("comment" t nil nil muse-publish-comment-tag) - ("include" nil t nil muse-publish-include-tag) - ("markup" t t nil muse-publish-mark-up-tag) - ("cite" t t nil muse-publish-cite-tag)) - "A list of tag specifications, for specially marking up text. -XML-style tags are the best way to add custom markup to Muse. -This is easily accomplished by customizing this list of markup tags. - -For each entry, the name of the tag is given, whether it expects -a closing tag, whether it takes an optional set of attributes, -whether it is nestable, and a function that performs whatever -action is desired within the delimited region. - -The tags themselves are deleted during publishing, before the -function is called. The function is called with three arguments, -the beginning and end of the region surrounded by the tags. If -properties are allowed, they are passed as a third argument in -the form of an alist. The `end' argument to the function is -always a marker. - -Point is always at the beginning of the region within the tags, when -the function is called. Wherever point is when the function finishes -is where tag markup will resume. - -These tag rules are processed once at the beginning of markup, and -once at the end, to catch any tags which may have been inserted -in-between." - :type '(repeat (list (string :tag "Markup tag") - (boolean :tag "Expect closing tag" :value t) - (boolean :tag "Parse attributes" :value nil) - (boolean :tag "Nestable" :value nil) - function)) - :group 'muse-publish) - -(defcustom muse-publish-markup-header-footer-tags - '(("lisp" t t nil muse-publish-lisp-tag) - ("markup" t t nil muse-publish-mark-up-tag)) - "Tags used when publishing headers and footers. -See `muse-publish-markup-tags' for details." - :type '(repeat (list (string :tag "Markup tag") - (boolean :tag "Expect closing tag" :value t) - (boolean :tag "Parse attributes" :value nil) - (boolean :tag "Nestable" :value nil) - function)) - :group 'muse-publish) - -(defcustom muse-publish-markup-specials nil - "A table of characters which must be represented specially." - :type '(alist :key-type character :value-type string) - :group 'muse-publish) - -(defcustom muse-publish-enable-local-variables nil - "If non-nil, interpret local variables in a file when publishing." - :type 'boolean - :group 'muse-publish) - -(defcustom muse-publish-enable-dangerous-tags t - "If non-nil, publish tags like and that can -call external programs or expose sensitive information. -Otherwise, ignore tags like this. - -This is useful to set to nil when the file to publish is coming -from an untrusted source." - :type 'boolean - :group 'muse-publish) - -(defvar muse-publishing-p nil - "This is set to t while a page is being published.") -(defvar muse-batch-publishing-p nil - "This is set to t while a page is being batch published.") -(defvar muse-inhibit-before-publish-hook nil - "This is set to t when publishing a file rather than just a buffer. -It is used by `muse-publish-markup-buffer'.") -(defvar muse-publishing-styles nil - "The publishing styles that Muse recognizes. -This is automatically generated when loading publishing styles.") -(defvar muse-publishing-current-file nil - "The file that is currently being published.") -(defvar muse-publishing-current-output-path nil - "The path where the current file will be published to.") -(defvar muse-publishing-current-style nil - "The style of the file that is currently being published.") -(defvar muse-publishing-directives nil - "An alist of publishing directives from the top of a file.") -(defvar muse-publish-generate-contents nil - "Non-nil if a table of contents should be generated. -If non-nil, it is a cons cell specifying (MARKER . DEPTH), to -tell where the was seen, and to what depth the -contents were requested.") -(defvar muse-publishing-last-position nil - "Last position of the point when publishing. -This is used to make sure that publishing doesn't get stalled.") - -(defvar muse-publish-inhibit-style-hooks nil - "If non-nil, do not call the :before or :before-end hooks when publishing.") - -(defvar muse-publish-use-header-footer-tags nil - "If non-nil, use `muse-publish-markup-header-footer-tags' for looking up -tags. Otherwise, use `muse-publish-markup-tags'.") - -(defvar muse-inhibit-style-tags nil - "If non-nil, do not search for style-specific tags. -This is used when publishing headers and footers.") - -;; Functions for handling style information - -(defsubst muse-style (&optional style) - "Resolve the given STYLE into a Muse style, if it is a string." - (if (null style) - muse-publishing-current-style - (if (stringp style) - (assoc style muse-publishing-styles) - (muse-assert (consp style)) - style))) - -(defun muse-define-style (name &rest elements) - (let ((entry (assoc name muse-publishing-styles))) - (if entry - (setcdr entry elements) - (setq muse-publishing-styles - (cons (append (list name) elements) - muse-publishing-styles))))) - -(defun muse-derive-style (new-name base-name &rest elements) - (apply 'muse-define-style new-name - (append elements (list :base base-name)))) - -(defsubst muse-get-keyword (keyword list &optional direct) - (let ((value (cadr (memq keyword list)))) - (if (and (not direct) (symbolp value)) - (symbol-value value) - value))) - -(defun muse-style-elements-list (elem &optional style) - "Return a list all references to ELEM in STYLE, including base styles. -If STYLE is not specified, use current style." - (let (base elements) - (while style - (setq style (muse-style style)) - (setq elements (append elements - (muse-get-keyword elem style))) - (setq style (muse-get-keyword :base style))) - elements)) - -(defun muse-style-element (elem &optional style direct) - "Search for ELEM in STYLE, including base styles. -If STYLE is not specified, use current style." - (setq style (muse-style style)) - (let ((value (muse-get-keyword elem style direct))) - (if value - value - (let ((base (muse-get-keyword :base style))) - (if base - (muse-style-element elem base direct)))))) - -(defun muse-style-derived-p-1 (base style) - "Internal function used by `muse-style-derived-p'." - (if (and (stringp style) - (string= style base)) - t - (setq style (muse-style style)) - (let ((value (muse-get-keyword :base style))) - (when value - (muse-style-derived-p base value))))) - -(defun muse-style-derived-p (base &optional style) - "Return non-nil if STYLE is equal to or derived from BASE, -non-nil otherwise. - -BASE should be a string." - (unless style - (setq style (muse-style))) - (when (and (consp style) - (stringp (car style))) - (setq style (car style))) - (muse-style-derived-p-1 base style)) - -(defun muse-find-markup-element (keyword ident style) - (let ((def (assq ident (muse-style-element keyword style)))) - (if def - (cdr def) - (let ((base (muse-style-element :base style))) - (if base - (muse-find-markup-element keyword ident base)))))) - -(defun muse-markup-text (ident &rest args) - "Insert ARGS into the text markup associated with IDENT. -If the markup text has sections like %N%, this will be replaced -with the N-1th argument in ARGS. After that, `format' is applied -to the text with ARGS as parameters." - (let ((text (muse-find-markup-element :strings ident (muse-style)))) - (if (and text args) - (progn - (let (start repl-text) - (while (setq start (string-match "%\\([1-9][0-9]*\\)%" text start)) - ;; escape '%' in the argument text, since we will be - ;; using format on it - (setq repl-text (muse-replace-regexp-in-string - "%" "%%" - (nth (1- (string-to-number - (match-string 1 text))) args) - t t) - start (+ start (length repl-text)) - text (replace-match repl-text t t text)))) - (apply 'format text args)) - (or text "")))) - -(defun muse-insert-markup (&rest args) - (let ((beg (point))) - (apply 'insert args) - (muse-publish-mark-read-only beg (point)))) - -(defun muse-find-markup-tag (keyword tagname style) - (let ((def (assoc tagname (muse-style-element keyword style)))) - (or def - (let ((base (muse-style-element :base style))) - (if base - (muse-find-markup-tag keyword tagname base)))))) - -(defun muse-markup-tag-info (tagname &rest args) - (let ((tag-info (and (not muse-inhibit-style-tags) - (muse-find-markup-tag :tags tagname (muse-style))))) - (or tag-info - (assoc tagname - (if muse-publish-use-header-footer-tags - muse-publish-markup-header-footer-tags - muse-publish-markup-tags))))) - -(defsubst muse-markup-function (category) - (let ((func (muse-find-markup-element :functions category (muse-style)))) - (or func - (cdr (assq category muse-publish-markup-functions))))) - -;; Publishing routines - -(defun muse-publish-markup (name rules) - (let* ((case-fold-search nil) - (inhibit-read-only t) - (limit (* (length rules) (point-max))) - (verbose (and muse-publish-report-threshhold - (> (point-max) muse-publish-report-threshhold))) - (base 0)) - (while rules - (goto-char (point-min)) - (let ((regexp (nth 1 (car rules))) - (group (nth 2 (car rules))) - (repl (nth 3 (car rules))) - pos) - (setq muse-publishing-last-position nil) - (if (symbolp regexp) - (setq regexp (symbol-value regexp))) - (if (and verbose (not muse-batch-publishing-p)) - (message "Publishing %s...%d%%" name - (* (/ (float (+ (point) base)) limit) 100))) - (while (and regexp (progn - (when (and (get-text-property (point) 'read-only) - (> (point) (point-min))) - (goto-char (or (next-single-property-change - (point) 'read-only) - (point-max)))) - (setq pos (re-search-forward regexp nil t)))) - (if (and verbose (not muse-batch-publishing-p)) - (message "Publishing %s...%d%%" name - (* (/ (float (+ (point) base)) limit) 100))) - (unless (and (> (- (match-end 0) (match-beginning 0)) 0) - (match-beginning group) - (get-text-property (match-beginning group) 'read-only)) - (let* (func - (text (cond - ((and (symbolp repl) - (setq func (muse-markup-function repl))) - (funcall func)) - ((functionp repl) - (funcall repl)) - ((symbolp repl) - (symbol-value repl)) - (t repl)))) - (if (stringp text) - (replace-match text t)))) - (if (and muse-publishing-last-position - (= pos muse-publishing-last-position)) - (if (eobp) - (setq regexp nil) - (forward-char 1))) - (setq muse-publishing-last-position pos))) - (setq rules (cdr rules) - base (+ base (point-max)))) - (if (and verbose (not muse-batch-publishing-p)) - (message "Publishing %s...done" name)))) - -(defun muse-insert-file-or-string (file-or-string &optional title) - (let ((beg (point)) end) - (if (and (not (string-equal file-or-string "")) - (not (string-match "\n" file-or-string)) - (file-readable-p file-or-string)) - (setq end (+ beg - (cadr (muse-insert-file-contents file-or-string)))) - (insert file-or-string) - (setq end (point))) - (save-restriction - (narrow-to-region beg end) - (remove-text-properties (point-min) (point-max) - '(read-only nil rear-nonsticky nil)) - (goto-char (point-min)) - (let ((muse-inhibit-style-tags t) - (muse-publish-use-header-footer-tags t)) - (muse-publish-markup (or title "") - '((100 muse-tag-regexp 0 - muse-publish-markup-tag))))))) - -(defun muse-style-run-hooks (keyword style &rest args) - (catch 'handled - (let ((cache nil)) - (while (and style - (setq style (muse-style style))) - (let ((func (muse-style-element keyword style t))) - (when (and func - (not (member func cache))) - (setq cache (cons func cache)) - (when (apply func args) - (throw 'handled t)))) - (setq style (muse-style-element :base style)))))) - -(defun muse-publish-markup-region (beg end &optional title style) - "Apply the given STYLE's markup rules to the given region. -TITLE is used when indicating the publishing progress; it may be nil. - -The point is guaranteed to be at END if the routine terminates -normally." - (unless title (setq title "")) - (unless style - (or (setq style muse-publishing-current-style) - (error "Cannot find any publishing styles to use"))) - (save-restriction - (narrow-to-region beg end) - (let ((muse-publish-generate-contents nil)) - (unless muse-publish-inhibit-style-hooks - (muse-style-run-hooks :before style)) - (muse-publish-markup - title - (sort (copy-alist (append muse-publish-markup-regexps - (muse-style-elements-list :regexps style))) - (function - (lambda (l r) - (< (car l) (car r)))))) - (unless muse-publish-inhibit-style-hooks - (muse-style-run-hooks :before-end style)) - (muse-publish-escape-specials (point-min) (point-max) nil 'document)) - (goto-char (point-max)))) - -(defun muse-publish-markup-buffer (title style) - "Apply the given STYLE's markup rules to the current buffer." - (setq style (muse-style style)) - (let ((style-header (muse-style-element :header style)) - (style-footer (muse-style-element :footer style)) - (muse-publishing-current-style style) - (muse-publishing-directives - (list (cons "title" title) - (cons "author" (user-full-name)) - (cons "date" (format-time-string - muse-publish-date-format - (if muse-publishing-current-file - (nth 5 (file-attributes - muse-publishing-current-file)) - (current-time)))))) - (muse-publishing-p t) - (inhibit-read-only t)) - (run-hooks 'muse-update-values-hook) - (unless muse-inhibit-before-publish-hook - (run-hooks 'muse-before-publish-hook)) - (muse-publish-markup-region (point-min) (point-max) title style) - (goto-char (point-min)) - (when style-header - (muse-insert-file-or-string style-header title)) - (goto-char (point-max)) - (when style-footer - (muse-insert-file-or-string style-footer title)) - (muse-style-run-hooks :after style) - (run-hooks 'muse-after-publish-hook))) - -(defun muse-publish-markup-string (string &optional style) - "Markup STRING using the given STYLE's markup rules." - (setq style (muse-style style)) - (muse-with-temp-buffer - (insert string) - (let ((muse-publishing-current-style style) - (muse-publishing-p t)) - (muse-publish-markup "*string*" (muse-style-element :rules style))) - (buffer-string))) - -;; Commands for publishing files - -(defun muse-publish-get-style (&optional styles) - (unless styles (setq styles muse-publishing-styles)) - (if (= 1 (length styles)) - (car styles) - (when (catch 'different - (let ((first (car (car styles)))) - (dolist (style (cdr styles)) - (unless (equal first (car style)) - (throw 'different t))))) - (setq styles (muse-collect-alist - styles - (funcall muse-completing-read-function - "Publish with style: " styles nil t)))) - (if (or (= 1 (length styles)) - (not (muse-get-keyword :path (car styles)))) - (car styles) - (setq styles (mapcar (lambda (style) - (cons (muse-get-keyword :path style) - style)) - styles)) - (cdr (assoc (funcall muse-completing-read-function - "Publish to directory: " styles nil t) - styles))))) - -(defsubst muse-publish-get-output-dir (style) - (let ((default-directory (or (muse-style-element :path style) - default-directory))) - (muse-read-directory-name "Publish to directory: " nil default-directory))) - -(defsubst muse-publish-get-info () - (let ((style (muse-publish-get-style))) - (list style (muse-publish-get-output-dir style) - current-prefix-arg))) - -(defsubst muse-publish-output-name (&optional file style) - (setq style (muse-style style)) - (concat (muse-style-element :prefix style) - (muse-page-name file) - (muse-style-element :suffix style))) - -(defsubst muse-publish-output-file (file &optional output-dir style) - (setq style (muse-style style)) - (if output-dir - (expand-file-name (muse-publish-output-name file style) output-dir) - (concat (file-name-directory file) - (muse-publish-output-name file style)))) - -(defsubst muse-publish-link-name (&optional file style) - "Take FILE and add :prefix and either :link-suffix or :suffix from STYLE. -We assume that FILE is a Muse file. - -We call `muse-page-name' on FILE to remove the directory part of -FILE and any extensions that are in `muse-ignored-extensions'." - (setq style (muse-style style)) - (concat (muse-style-element :prefix style) - (muse-page-name file) - (or (muse-style-element :link-suffix style) - (muse-style-element :suffix style)))) - -(defsubst muse-publish-link-file (file &optional style) - "Turn FILE into a URL. - -If FILE exists on the system as-is, return it without -modification. In the case of wanting to link to Muse files when -`muse-file-extension' is nil, you should load muse-project.el. - -Otherwise, assume that it is a Muse file and call -`muse-publish-link-name' to add :prefix, :link-suffix, :suffix, -and removing ignored file extensions, but preserving the -directory part of FILE." - (setq style (muse-style style)) - (if (file-exists-p file) - file - (concat (file-name-directory file) - (muse-publish-link-name file style)))) - -(defsubst muse-publish-link-page (page) - "Turn PAGE into a URL. - -This is called by `muse-publish-classify-url' to figure out what -a link to another file or Muse page should look like. - -If muse-project.el is loaded, call `muse-project-link-page' for this. -Otherwise, call `muse-publish-link-file'." - (if (fboundp 'muse-project-link-page) - (muse-project-link-page page) - (muse-publish-link-file page))) - -(defmacro muse-publish-ensure-block (beg &optional end) - "Ensure that block-level markup at BEG is published with at least one -preceding blank line. BEG must be an unquoted symbol that contains a -position or marker. BEG is modified to be the new position. -The point is left at the new value of BEG. - -Additionally, make sure that BEG is placed on a blank line. - -If END is given, make sure that it is placed on a blank line. In -order to achieve this, END must be an unquoted symbol that -contains a marker. This is the case with Muse tag functions." - `(progn - (goto-char ,beg) - (cond ((not (bolp)) (insert "\n\n")) - ((eq (point) (point-min)) nil) - ((prog2 (backward-char) (bolp) (forward-char)) nil) - (t (insert "\n"))) - (unless (and (bolp) (eolp)) - (insert "\n") - (backward-char)) - (setq ,beg (point)) - (when (markerp ,end) - (goto-char ,end) - (unless (and (bolp) (eolp)) - (insert-before-markers "\n"))) - (goto-char ,beg))) - -;;;###autoload -(defun muse-publish-region (beg end &optional title style) - "Apply the given STYLE's markup rules to the given region. -The result is placed in a new buffer that includes TITLE in its name." - (interactive "r") - (when (interactive-p) - (unless title (setq title (read-string "Title: "))) - (unless style (setq style (muse-publish-get-style)))) - (let ((text (buffer-substring beg end)) - (buf (generate-new-buffer (concat "*Muse: " title "*")))) - (with-current-buffer buf - (insert text) - (muse-publish-markup-buffer title style) - (goto-char (point-min)) - (let ((inhibit-read-only t)) - (remove-text-properties (point-min) (point-max) - '(rear-nonsticky nil read-only nil)))) - (pop-to-buffer buf))) - -;;;###autoload -(defun muse-publish-file (file style &optional output-dir force) - "Publish the given FILE in a particular STYLE to OUTPUT-DIR. -If the argument FORCE is nil, each file is only published if it is -newer than the published version. If the argument FORCE is non-nil, -the file is published no matter what." - (interactive (cons (read-file-name "Publish file: ") - (muse-publish-get-info))) - (let ((style-name style)) - (setq style (muse-style style)) - (unless style - (error "There is no style '%s' defined" style-name))) - (let* ((output-path (muse-publish-output-file file output-dir style)) - (output-suffix (muse-style-element :osuffix style)) - (muse-publishing-current-file file) - (muse-publishing-current-output-path output-path) - (target (if output-suffix - (concat (muse-path-sans-extension output-path) - output-suffix) - output-path)) - (threshhold (nth 7 (file-attributes file)))) - (if (not threshhold) - (message "Please save %s before publishing" file) - (when (or force (file-newer-than-file-p file target)) - (if (and muse-publish-report-threshhold - (> threshhold - muse-publish-report-threshhold)) - (message "Publishing %s ..." file)) - (muse-with-temp-buffer - (muse-insert-file-contents file) - (run-hooks 'muse-before-publish-hook) - (when muse-publish-enable-local-variables - (hack-local-variables)) - (let ((muse-inhibit-before-publish-hook t)) - (muse-publish-markup-buffer (muse-page-name file) style)) - (when (muse-write-file output-path) - (muse-style-run-hooks :final style file output-path target))) - t)))) - -;;;###autoload -(defun muse-publish-this-file (style output-dir &optional force) - "Publish the currently-visited file. -Prompt for both the STYLE and OUTPUT-DIR if they are not -supplied." - (interactive (muse-publish-get-info)) - (setq style (muse-style style)) - (if buffer-file-name - (let ((muse-current-output-style (list :base (car style) - :path output-dir))) - (unless (muse-publish-file buffer-file-name style output-dir force) - (message (concat "The published version is up-to-date; use" - " C-u C-c C-T to force an update.")))) - (message "This buffer is not associated with any file"))) - -(defun muse-batch-publish-files () - "Publish Muse files in batch mode." - (let ((muse-batch-publishing-p t) - (font-lock-verbose nil) - muse-current-output-style - style output-dir) - ;; don't activate VC when publishing files - (setq vc-handled-backends nil) - (setq style (car command-line-args-left) - command-line-args-left (cdr command-line-args-left) - output-dir (car command-line-args-left) - output-dir - (if (string-match "\\`--output-dir=" output-dir) - (prog1 - (substring output-dir (match-end 0)) - (setq command-line-args-left (cdr command-line-args-left)))) - muse-current-output-style (list :base style :path output-dir)) - (setq auto-mode-alist - (delete (cons (concat "\\." muse-file-extension "\\'") - 'muse-mode-choose-mode) - auto-mode-alist)) - (dolist (file command-line-args-left) - (muse-publish-file file style output-dir t)))) - -;; Default publishing rules - -(defun muse-publish-section-close (depth) - "Seach forward for the closing tag of given DEPTH." - (let (not-end) - (save-excursion - (while (and (setq not-end (re-search-forward - (concat "^\\*\\{1," (number-to-string depth) - "\\}\\s-+") - nil t)) - (get-text-property (match-beginning 0) 'read-only))) - (if not-end - (forward-line 0) - (goto-char (point-max))) - (cond ((not (eq (char-before) ?\n)) - (insert "\n\n")) - ((not (eq (char-before (1- (point))) ?\n)) - (insert "\n"))) - (muse-insert-markup (muse-markup-text 'section-close depth)) - (insert "\n")))) - -(defun muse-publish-markup-directive (&optional name value) - (unless name (setq name (match-string 1))) - (unless value (setq value (match-string 2))) - (let ((elem (assoc name muse-publishing-directives))) - (if elem - (setcdr elem value) - (setq muse-publishing-directives - (cons (cons name value) - muse-publishing-directives)))) - ;; Make sure we don't ever try to move the point forward (past the - ;; beginning of buffer) while we're still searching for directives. - (setq muse-publishing-last-position nil) - (delete-region (match-beginning 0) (match-end 0))) - -(defsubst muse-publishing-directive (name) - (cdr (assoc name muse-publishing-directives))) - -(defmacro muse-publish-get-and-delete-attr (attr attrs) - "Delete attribute ATTR from ATTRS only once, destructively. - -This function returns the matching attribute value, if found." - (let ((last (make-symbol "last")) - (found (make-symbol "found")) - (vals (make-symbol "vals"))) - `(let ((,vals ,attrs)) - (if (string= (caar ,vals) ,attr) - (prog1 (cdar ,vals) - (setq ,attrs (cdr ,vals))) - (let ((,last ,vals) - (,found nil)) - (while ,vals - (setq ,vals (cdr ,vals)) - (when (string= (caar ,vals) ,attr) - (setq ,found (cdar ,vals)) - (setcdr ,last (cdr ,vals)) - (setq ,vals nil)) - (setq ,last ,vals)) - ,found))))) - -(defun muse-publish-markup-anchor () - (unless (get-text-property (match-end 1) 'muse-link) - (let ((text (muse-markup-text 'anchor (match-string 2)))) - (unless (string= text "") - (save-match-data - (skip-chars-forward (concat muse-regexp-blank "\n")) - (muse-insert-markup text))) - (match-string 1)))) - -(defun muse-publish-markup-comment () - (if (null muse-publish-comments-p) - "" - (goto-char (match-end 0)) - (muse-insert-markup (muse-markup-text 'comment-end)) - (if (match-beginning 1) - (progn - (muse-publish-mark-read-only (match-beginning 1) (match-end 1)) - (delete-region (match-beginning 0) (match-beginning 1))) - (delete-region (match-beginning 0) (match-end 0))) - (goto-char (match-beginning 0)) - (muse-insert-markup (muse-markup-text 'comment-begin)))) - -(defun muse-publish-markup-tag () - (let ((tag-info (muse-markup-tag-info (match-string 1)))) - (when (and tag-info - (not (get-text-property (match-beginning 0) 'read-only)) - (nth 4 tag-info) - (or muse-publish-enable-dangerous-tags - (not (get (nth 4 tag-info) 'muse-dangerous-tag)))) - (let ((closed-tag (match-string 3)) - (start (match-beginning 0)) - (beg (point)) - end attrs) - (when (nth 2 tag-info) - (let ((attrstr (match-string 2))) - (while (and attrstr - (string-match (concat "\\([^" - muse-regexp-blank - "=\n]+\\)\\(=\"\\" - "([^\"]+\\)\"\\)?") - attrstr)) - (let ((attr (cons (downcase - (muse-match-string-no-properties 1 attrstr)) - (muse-match-string-no-properties 3 attrstr)))) - (setq attrstr (replace-match "" t t attrstr)) - (if attrs - (nconc attrs (list attr)) - (setq attrs (list attr))))))) - (if (and (cadr tag-info) (not closed-tag)) - (if (muse-goto-tag-end (car tag-info) (nth 3 tag-info)) - (delete-region (match-beginning 0) (point)) - (setq tag-info nil))) - (when tag-info - (setq end (point-marker)) - (delete-region start beg) - (goto-char start) - (let ((args (list start end))) - (if (nth 2 tag-info) - (nconc args (list attrs))) - (let ((muse-inhibit-style-tags nil)) - ;; remove the inhibition - (apply (nth 4 tag-info) args))) - (set-marker end nil))))) - nil) - -(defun muse-publish-escape-specials (beg end &optional ignore-read-only context) - "Escape specials from BEG to END using style-specific :specials. -If IGNORE-READ-ONLY is non-nil, ignore the read-only property. -CONTEXT is used to figure out what kind of specials to escape. - -The following contexts exist in Muse. -'underline _underlined text_ -'literal =monospaced text= or region (monospaced, escaped) -'emphasis *emphasized text* -'email email@example.com -'url http://example.com -'url-desc [[...][description of an explicit link]] -'image [[image.png]] -'example region (monospaced, block context, escaped) -'verbatim region (escaped) -'footnote footnote text -'document normal text" - (let ((specials (muse-style-element :specials nil t))) - (cond ((functionp specials) - (setq specials (funcall specials context))) - ((symbolp specials) - (setq specials (symbol-value specials)))) - (if (functionp specials) - (funcall specials beg end ignore-read-only) - (save-excursion - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - (while (< (point) (point-max)) - (if (and (not ignore-read-only) - (get-text-property (point) 'read-only)) - (goto-char (or (next-single-property-change (point) 'read-only) - (point-max))) - (let ((repl (or (assoc (char-after) specials) - (assoc (char-after) - muse-publish-markup-specials)))) - (if (null repl) - (forward-char 1) - (delete-char 1) - (insert-before-markers (cdr repl))))))))))) - -(defun muse-publish-markup-word () - (let* ((beg (match-beginning 2)) - (end (1- (match-end 2))) - (leader (buffer-substring-no-properties beg end)) - open-tag close-tag mark-read-only loc context) - (cond - ((string= leader "_") - (setq context 'underline - open-tag (muse-markup-text 'begin-underline) - close-tag (muse-markup-text 'end-underline))) - ((string= leader "=") - (setq context 'literal - open-tag (muse-markup-text 'begin-literal) - close-tag (muse-markup-text 'end-literal)) - (setq mark-read-only t)) - (t - (let ((l (length leader))) - (setq context 'emphasis) - (cond - ((= l 1) (setq open-tag (muse-markup-text 'begin-emph) - close-tag (muse-markup-text 'end-emph))) - ((= l 2) (setq open-tag (muse-markup-text 'begin-more-emph) - close-tag (muse-markup-text 'end-more-emph))) - ((= l 3) (setq open-tag (muse-markup-text 'begin-most-emph) - close-tag (muse-markup-text 'end-most-emph))) - (t (setq context nil)))))) - (if (and context - (not (get-text-property beg 'muse-link)) - (setq loc (search-forward leader nil t)) - (or (eobp) (not (eq (char-syntax (char-after loc)) ?w))) - (not (eq (char-syntax (char-before (point))) ?\ )) - (not (get-text-property (point) 'muse-link))) - (progn - (replace-match "") - (delete-region beg end) - (setq end (point-marker)) - (muse-insert-markup close-tag) - (goto-char beg) - (muse-insert-markup open-tag) - (setq beg (point)) - (when mark-read-only - (muse-publish-escape-specials beg end t context) - (muse-publish-mark-read-only beg end)) - (set-marker end nil)) - (backward-char)) - nil)) - -(defun muse-publish-markup-emdash () - (unless (get-text-property (match-beginning 0) 'muse-link) - (let ((prespace (match-string 1)) - (postspace (match-string 2))) - (delete-region (match-beginning 0) (match-end 0)) - (muse-insert-markup (muse-markup-text 'emdash prespace postspace)) - (when (eq (char-after) ?\<) - (insert ?\n))))) - -(defun muse-publish-markup-enddots () - (unless (get-text-property (match-beginning 0) 'muse-link) - (delete-region (match-beginning 0) (match-end 0)) - (muse-insert-markup (muse-markup-text 'enddots)))) - -(defun muse-publish-markup-dots () - (unless (get-text-property (match-beginning 0) 'muse-link) - (delete-region (match-beginning 0) (match-end 0)) - (muse-insert-markup (muse-markup-text 'dots)))) - -(defun muse-publish-markup-rule () - (unless (get-text-property (match-beginning 0) 'muse-link) - (delete-region (match-beginning 0) (match-end 0)) - (muse-insert-markup (muse-markup-text 'rule)))) - -(defun muse-publish-markup-no-break-space () - (unless (get-text-property (match-beginning 0) 'muse-link) - (delete-region (match-beginning 0) (match-end 0)) - (muse-insert-markup (muse-markup-text 'no-break-space)))) - -(defun muse-publish-markup-heading () - (let* ((len (length (match-string 1))) - (start (muse-markup-text - (cond ((= len 1) 'section) - ((= len 2) 'subsection) - ((= len 3) 'subsubsection) - (t 'section-other)) - len)) - (end (muse-markup-text - (cond ((= len 1) 'section-end) - ((= len 2) 'subsection-end) - ((= len 3) 'subsubsection-end) - (t 'section-other-end)) - len))) - (delete-region (match-beginning 0) (match-end 0)) - (muse-insert-markup start) - (end-of-line) - (when end - (muse-insert-markup end)) - (forward-line 1) - (unless (eq (char-after) ?\n) - (insert "\n")) - (muse-publish-section-close len))) - -(defvar muse-publish-footnotes nil) - -(defun muse-publish-markup-footnote () - "Scan ahead and snarf up the footnote body." - (cond - ((get-text-property (match-beginning 0) 'muse-link) - nil) - ((= (muse-line-beginning-position) (match-beginning 0)) - "") - (t - (let ((footnote (save-match-data - (string-to-number (match-string 1)))) - (oldtext (match-string 0)) - footnotemark) - (delete-region (match-beginning 0) (match-end 0)) - (save-excursion - (when (re-search-forward (format "^\\[%d\\]\\s-+" footnote) nil t) - (let* ((start (match-beginning 0)) - (beg (goto-char (match-end 0))) - (end (save-excursion - (if (search-forward "\n\n" nil t) - (copy-marker (match-beginning 0)) - (goto-char (point-max)) - (skip-chars-backward "\n") - (point-marker))))) - (while (re-search-forward - (concat "^[" muse-regexp-blank "]+\\([^\n]\\)") - end t) - (replace-match "\\1" t)) - (let ((footnotemark-cmd (muse-markup-text 'footnotemark)) - (footnotemark-end-cmd (muse-markup-text 'footnotemark-end))) - (if (string= "" footnotemark-cmd) - (setq footnotemark - (concat (muse-markup-text 'footnote) - (muse-publish-escape-specials-in-string - (buffer-substring-no-properties beg end) - 'footnote) - (muse-markup-text 'footnote-end))) - (setq footnotemark (format footnotemark-cmd footnote - footnotemark-end-cmd)) - (unless muse-publish-footnotes - (set (make-local-variable 'muse-publish-footnotes) - (make-vector 256 nil))) - (unless (aref muse-publish-footnotes footnote) - (setq footnotemark - (concat - footnotemark - (concat (format (muse-markup-text 'footnotetext) - footnote) - (buffer-substring-no-properties beg end) - (muse-markup-text 'footnotetext-end)))) - (aset muse-publish-footnotes footnote footnotemark)))) - (goto-char end) - (skip-chars-forward "\n") - (delete-region start (point)) - (set-marker end nil)))) - (if footnotemark - (muse-insert-markup footnotemark) - (insert oldtext)))))) - -(defun muse-publish-markup-fn-sep () - (delete-region (match-beginning 0) (match-end 0)) - (muse-insert-markup (muse-markup-text 'fn-sep))) - -(defun muse-insert-markup-end-list (&rest args) - (let ((beg (point))) - (apply 'insert args) - (add-text-properties beg (point) '(muse-end-list t)) - (muse-publish-mark-read-only beg (point)))) - -(defun muse-publish-determine-dl-indent (continue indent-sym determine-sym) - ;; If the caller doesn't know how much indentation to use, figure it - ;; out ourselves. It is assumed that `muse-forward-list-item' has - ;; been called just before this to set the match data. - (when (and continue - (symbol-value determine-sym)) - (save-match-data - ;; snarf all leading whitespace - (let ((indent (and (match-beginning 2) - (buffer-substring (match-beginning 1) - (match-beginning 2))))) - (when (and indent - (not (string= indent ""))) - (set indent-sym indent) - (set determine-sym nil)))))) - -(defun muse-publish-surround-dl (indent post-indent) - (let* ((beg-item (muse-markup-text 'begin-dl-item)) - (end-item (muse-markup-text 'end-dl-item)) - (beg-ddt (muse-markup-text 'begin-ddt)) ;; term - (end-ddt (muse-markup-text 'end-ddt)) - (beg-dde (muse-markup-text 'begin-dde)) ;; definition - (end-dde (muse-markup-text 'end-dde)) - (continue t) - (no-terms t) - beg) - (while continue - ;; envelope this as one term+definitions unit -- HTML does not - ;; need this, but DocBook and Muse's custom XML format do - (muse-insert-markup beg-item) - (when (looking-at muse-dl-term-regexp) - ;; find the term and wrap it with published markup - (setq beg (point) - no-terms nil) - (goto-char (match-end 1)) - (delete-region (point) (match-end 0)) - (muse-insert-markup-end-list end-ddt) - ;; if definition is immediately after term, move to next line - (unless (eq (char-after) ?\n) - (insert ?\n)) - (save-excursion - (goto-char beg) - (delete-region (point) (match-beginning 1)) - (muse-insert-markup beg-ddt))) - ;; handle pathological edge case where there is no term -- I - ;; would prefer to just disallow this, but people seem to want - ;; this behavior - (when (and no-terms - (looking-at (concat "[" muse-regexp-blank "]*::" - "[" muse-regexp-blank "]*"))) - (delete-region (point) (match-end 0)) - ;; but only do this once - (setq no-terms nil)) - (setq beg (point) - ;; move past current item - continue (muse-forward-list-item 'dl-term indent)) - (save-restriction - (narrow-to-region beg (point)) - (goto-char (point-min)) - ;; publish each definition that we find, defaulting to an - ;; empty definition if none are found - (muse-publish-surround-text beg-dde end-dde - (lambda (indent) - (muse-forward-list-item 'dl-entry indent)) - indent post-indent - #'muse-publish-determine-dl-indent) - (goto-char (point-max)) - (skip-chars-backward (concat muse-regexp-blank "\n")) - (muse-insert-markup-end-list end-item) - (when continue - (goto-char (point-max))))))) - -(defun muse-publish-strip-list-indentation (list-item empty-line indent post-indent) - (let ((list-nested nil) - (indent-found nil)) - (while (< (point) (point-max)) - (when (and (looking-at list-item) - (not (or (get-text-property - (muse-list-item-critical-point) 'read-only) - (get-text-property - (muse-list-item-critical-point) 'muse-link)))) - ;; if we encounter a list item, allow no post-indent space - (setq list-nested t)) - (when (and (not (looking-at empty-line)) - (looking-at (concat indent "\\(" - (or (and list-nested "") - post-indent) - "\\)"))) - ;; if list is not nested, remove indentation - (unless indent-found - (setq post-indent (match-string 1) - indent-found t)) - (replace-match "")) - (forward-line 1)))) - -(defun muse-publish-surround-text (beg-tag end-tag move-func &optional indent post-indent determine-indent-func list-item) - (unless list-item - (setq list-item (format muse-list-item-regexp - (concat "[" muse-regexp-blank "]*")))) - (let ((continue t) - (empty-line (concat "^[" muse-regexp-blank "]*\n")) - (determine-indent (if determine-indent-func t nil)) - (new-indent indent) - (first t) - beg) - (unless indent - (setq indent (concat "[" muse-regexp-blank "]+"))) - (if post-indent - (setq post-indent (concat " \\{0," (number-to-string post-indent) - "\\}")) - (setq post-indent "")) - (while continue - (if (or (not end-tag) (string= end-tag "")) - ;; if no end of list item markup exists, treat the beginning - ;; of list item markup as it if it were the end -- this - ;; prevents multiple-level lists from being confused - (muse-insert-markup-end-list beg-tag) - (muse-insert-markup beg-tag)) - (setq beg (point) - ;; move past current item; continue is non-nil if there - ;; are more like items to be processed - continue (if (and determine-indent-func first) - (funcall move-func (concat indent post-indent)) - (funcall move-func indent))) - (when determine-indent-func - (funcall determine-indent-func continue 'new-indent 'determine-indent)) - (when continue - ;; remove list markup if we encountered another item of the - ;; same type - (replace-match "" t t nil 1)) - (save-restriction - ;; narrow to current item - (narrow-to-region beg (point)) - (goto-char (point-min)) - (if (looking-at empty-line) - ;; if initial line is blank, move to first non-blank line - (while (progn (forward-line 1) - (and (< (point) (point-max)) - (looking-at empty-line)))) - ;; otherwise, move to second line of text - (forward-line 1)) - ;; strip list indentation - (muse-publish-strip-list-indentation list-item empty-line - indent post-indent) - (skip-chars-backward (concat muse-regexp-blank "\n")) - (muse-insert-markup-end-list end-tag) - (when determine-indent-func - (setq indent new-indent)) - (when first - (setq first nil)) - (when continue - (goto-char (point-max))))))) - -(defun muse-publish-ensure-blank-line () - "Make sure that a blank line exists on the line before point." - (let ((pt (point-marker))) - (beginning-of-line) - (cond ((eq (point) (point-min)) nil) - ((prog2 (backward-char) (bolp) (forward-char)) nil) - (t (insert-before-markers "\n"))) - (goto-char pt) - (set-marker pt nil))) - -(defun muse-publish-markup-list () - "Markup a list entry. -This function works by marking up items of the same list level -and type, respecting the end-of-list property." - (let* ((str (match-string 1)) - (type (muse-list-item-type str)) - (indent (buffer-substring (muse-line-beginning-position) - (match-beginning 1))) - (post-indent (length str))) - (cond - ((or (get-text-property (muse-list-item-critical-point) 'read-only) - (get-text-property (muse-list-item-critical-point) 'muse-link)) - nil) - ((eq type 'ul) - (unless (eq (char-after (match-end 1)) ?-) - (delete-region (match-beginning 0) (match-end 0)) - (muse-publish-ensure-blank-line) - (muse-insert-markup (muse-markup-text 'begin-uli)) - (save-excursion - (muse-publish-surround-text - (muse-markup-text 'begin-uli-item) - (muse-markup-text 'end-uli-item) - (lambda (indent) - (muse-forward-list-item 'ul indent)) - indent post-indent) - (muse-insert-markup-end-list (muse-markup-text 'end-uli))) - (forward-line 1))) - ((eq type 'ol) - (delete-region (match-beginning 0) (match-end 0)) - (muse-publish-ensure-blank-line) - (muse-insert-markup (muse-markup-text 'begin-oli)) - (save-excursion - (muse-publish-surround-text - (muse-markup-text 'begin-oli-item) - (muse-markup-text 'end-oli-item) - (lambda (indent) - (muse-forward-list-item 'ol indent)) - indent post-indent) - (muse-insert-markup-end-list (muse-markup-text 'end-oli))) - (forward-line 1)) - (t - (goto-char (match-beginning 0)) - (muse-publish-ensure-blank-line) - (muse-insert-markup (muse-markup-text 'begin-dl)) - (save-excursion - (muse-publish-surround-dl indent post-indent) - (muse-insert-markup-end-list (muse-markup-text 'end-dl))) - (forward-line 1)))) - nil) - -(defun muse-publish-markup-quote () - "Markup a quoted paragraph. -The reason this function is so funky, is to prevent text properties -like read-only from being inadvertently deleted." - (let* ((ws (match-string 1)) - (centered (>= (string-width ws) 6)) - (begin-elem (if centered 'begin-center 'begin-quote-item)) - (end-elem (if centered 'end-center 'end-quote-item))) - (replace-match "" t t nil 1) - (unless centered - (muse-insert-markup (muse-markup-text 'begin-quote))) - (muse-publish-surround-text (muse-markup-text begin-elem) - (muse-markup-text end-elem) - (function (lambda (indent) - (muse-forward-paragraph) - nil))) - (unless centered - (muse-insert-markup (muse-markup-text 'end-quote))))) - -(defun muse-publish-markup-leading-space (markup-space multiple) - (let (count) - (when (and markup-space - (>= (setq count (skip-chars-forward " ")) 0)) - (delete-region (muse-line-beginning-position) (point)) - (while (> count 0) - (muse-insert-markup markup-space) - (setq count (- count multiple)))))) - -(defun muse-publish-markup-verse () - (let ((leader (match-string 0))) - (goto-char (match-beginning 0)) - (muse-insert-markup (muse-markup-text 'begin-verse)) - (while (looking-at leader) - (replace-match "") - (muse-publish-markup-leading-space (muse-markup-text 'verse-space) 2) - (let ((beg (point))) - (end-of-line) - (cond - ((bolp) - (let ((text (muse-markup-text 'empty-verse-line))) - (when text (muse-insert-markup text)))) - ((save-excursion - (save-match-data - (forward-line 1) - (or (looking-at (concat leader "[" - muse-regexp-blank - "]*$")) - (not (looking-at leader))))) - (let ((begin-text (muse-markup-text 'begin-last-stanza-line)) - (end-text (muse-markup-text 'end-last-stanza-line))) - (when end-text (muse-insert-markup end-text)) - (goto-char beg) - (when begin-text (muse-insert-markup begin-text)) - (end-of-line))) - (t - (let ((begin-text (muse-markup-text 'begin-verse-line)) - (end-text (muse-markup-text 'end-verse-line))) - (when end-text (muse-insert-markup end-text)) - (goto-char beg) - (when begin-text (muse-insert-markup begin-text)) - (end-of-line)))) - (forward-line 1)))) - (muse-insert-markup (muse-markup-text 'end-verse)) - (insert ?\n)) - -(defun muse-publish-trim-table (table) - "Remove completely blank columns from table, if at start or end of row." - ;; remove first - (catch 'found - (dolist (row (cdr table)) - (let ((el (cadr row))) - (when (and (stringp el) (not (string= el ""))) - (throw 'found t)))) - (dolist (row (cdr table)) - (setcdr row (cddr row))) - (setcar table (1- (car table)))) - ;; remove last - (catch 'found - (dolist (row (cdr table)) - (let ((el (car (last row)))) - (when (and (stringp el) (not (string= el ""))) - (throw 'found t)))) - (dolist (row (cdr table)) - (setcdr (last row 2) nil)) - (setcar table (1- (car table)))) - table) - -(defun muse-publish-table-fields (beg end) - "Parse given region as a table, returning a cons cell. -The car is the length of the longest row. - -The cdr is a list of the fields of the table, with the first -element indicating the type of the row: - 1: body, 2: header, 3: footer, hline: separator. - -The existing region will be removed, except for initial blank lines." - (unless (muse-publishing-directive "disable-tables") - (let ((longest 0) - (left 0) - (seen-hline nil) - fields field-list) - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - (while (looking-at (concat "^[" muse-regexp-blank "]*$")) - (forward-line 1)) - (setq beg (point)) - (while (= left 0) - (cond - ((looking-at muse-table-hline-regexp) - (when field-list ; skip if at the beginning of table - (if seen-hline - (setq field-list (cons (cons 'hline nil) field-list)) - (dolist (field field-list) - ;; the preceding fields are header lines - (setcar field 2)) - (setq seen-hline t)))) - ((looking-at muse-table-line-regexp) - (setq fields (cons (length (match-string 1)) - (mapcar #'muse-trim-whitespace - (split-string (match-string 0) - muse-table-field-regexp))) - field-list (cons fields field-list) - longest (max (length fields) longest)) - ;; strip initial bars, if they exist - (let ((first (cadr fields))) - (when (and first (string-match "\\`|+\\s-*" first)) - (setcar (cdr fields) (replace-match "" t t first)))))) - (setq left (forward-line 1)))) - (delete-region beg end) - (if (= longest 0) - (cons 0 nil) - ;; if the last line was an hline, remove it - (when (eq (caar field-list) 'hline) - (setq field-list (cdr field-list))) - (muse-publish-trim-table (cons (1- longest) (nreverse field-list))))))) - -(defun muse-publish-markup-table () - "Style does not support tables.\n") - -(defun muse-publish-table-el-table (variant) - "Publish table.el-style tables in the format given by VARIANT." - (when (condition-case nil - (progn (require 'table) - t) - (error nil)) - (let ((muse-buf (current-buffer))) - (save-restriction - (narrow-to-region (match-beginning 0) (match-end 0)) - (goto-char (point-min)) - (forward-line 1) - (when (search-forward "|" nil t) - (with-temp-buffer - (let ((temp-buf (current-buffer))) - (with-current-buffer muse-buf - (table-generate-source variant temp-buf)) - (with-current-buffer muse-buf - (delete-region (point-min) (point-max)) - (insert-buffer-substring temp-buf) - (muse-publish-mark-read-only (point-min) (point-max)))))))))) - -(defun muse-publish-markup-table-el () - "Mark up table.el-style tables." - (cond ((muse-style-derived-p 'html) - (muse-publish-table-el-table 'html)) - ((muse-style-derived-p 'latex) - (muse-publish-table-el-table 'latex)) - ((muse-style-derived-p 'docbook) - (muse-publish-table-el-table 'cals)) - (t "Style does not support table.el tables.\n"))) - -(defun muse-publish-escape-specials-in-string (string &optional context) - "Escape specials in STRING using style-specific :specials. -CONTEXT is used to figure out what kind of specials to escape. - -See the documentation of the `muse-publish-escape-specials' -function for the list of available contexts." - (unless string - (setq string "")) - (let ((specials (muse-style-element :specials nil t))) - (cond ((functionp specials) - (setq specials (funcall specials context))) - ((symbolp specials) - (setq specials (symbol-value specials)))) - (if (functionp specials) - (funcall specials string) - (apply (function concat) - (mapcar - (lambda (ch) - (let ((repl (or (assoc ch specials) - (assoc ch muse-publish-markup-specials)))) - (if (null repl) - (char-to-string ch) - (cdr repl)))) - (append string nil)))))) - -(defun muse-publish-markup-email () - (let* ((beg (match-end 1)) - (addr (buffer-substring-no-properties beg (match-end 0)))) - (setq addr (muse-publish-escape-specials-in-string addr 'email)) - (goto-char beg) - (delete-region beg (match-end 0)) - (if (or (eq (char-before (match-beginning 0)) ?\") - (eq (char-after (match-end 0)) ?\")) - (insert addr) - (insert (format (muse-markup-text 'email-addr) addr addr))) - (muse-publish-mark-read-only beg (point)))) - -(defun muse-publish-classify-url (target) - "Transform anchors and get published name, if TARGET is a page. -The return value is two linked cons cells. The car is the type -of link, the cadr is the page name, and the cddr is the anchor." - (save-match-data - (cond ((or (null target) (string= target "")) - nil) - ((string-match "\\`[uU][rR][lL]:\\(.+\\)\\'" target) - (cons 'url (cons (match-string 1 target) nil))) - ((string-match muse-image-regexp target) - (cons 'image (cons target nil))) - ((string-match muse-url-regexp target) - (cons 'url (cons target nil))) - ((string-match muse-file-regexp target) - (cons 'file (cons target nil))) - ((string-match "#" target) - (if (eq (aref target 0) ?\#) - (cons 'anchor-ref (cons nil (substring target 1))) - (cons 'link-and-anchor - ;; match-data is changed by - ;; `muse-publish-link-page' or descendants. - (cons (save-match-data - (muse-publish-link-page - (substring target 0 (match-beginning 0)))) - (substring target (match-end 0)))))) - (t - (cons 'link (cons (muse-publish-link-page target) nil)))))) - -(defun muse-publish-url-desc (desc explicit) - (when desc - (dolist (transform muse-publish-desc-transforms) - (setq desc (save-match-data - (when desc (funcall transform desc explicit))))) - (setq desc (muse-link-unescape desc)) - (muse-publish-escape-specials-in-string desc 'url-desc))) - -(defun muse-publish-url (url &optional desc orig-url explicit) - "Resolve a URL into its final form." - (let ((unesc-url url) - (unesc-orig-url orig-url) - (unesc-desc desc) - type anchor) - ;; Transform URL - (dolist (transform muse-publish-url-transforms) - (setq url (save-match-data (when url (funcall transform url explicit))))) - ;; Classify URL - (let ((target (muse-publish-classify-url url))) - (setq type (car target) - url (if (eq type 'image) - (muse-publish-escape-specials-in-string (cadr target) - 'image) - (muse-publish-escape-specials-in-string (cadr target) 'url)) - anchor (muse-publish-escape-specials-in-string - (cddr target) 'url))) - ;; Transform description - (if desc - (setq desc (muse-publish-url-desc desc explicit)) - (when orig-url - (setq orig-url (muse-publish-url-desc orig-url explicit)))) - ;; Act on URL classification - (cond ((eq type 'anchor-ref) - (muse-markup-text 'anchor-ref anchor (or desc orig-url))) - ((and unesc-desc (string-match muse-image-regexp unesc-desc)) - (let ((ext (or (file-name-extension desc) ""))) - (setq desc (muse-publish-escape-specials-in-string unesc-desc - 'image)) - (setq desc (muse-path-sans-extension desc)) - (muse-markup-text 'image-link url desc ext))) - ((string= url "") - desc) - ((eq type 'image) - (let ((ext (or (file-name-extension url) ""))) - (setq url (muse-path-sans-extension url)) - (if desc - (muse-markup-text 'image-with-desc url ext desc) - (muse-markup-text 'image url ext)))) - ((eq type 'link-and-anchor) - (muse-markup-text 'link-and-anchor url anchor - (or desc orig-url) - (muse-path-sans-extension url))) - ((eq type 'link) - (muse-markup-text 'link url (or desc orig-url))) - (t - (or (and (or desc - ;; compare the not-escaped versions of url and - ;; orig-url - (not (string= unesc-url unesc-orig-url))) - (let ((text (muse-markup-text 'url-and-desc url - (or desc orig-url)))) - (and (not (string= text "")) - text))) - (muse-markup-text 'url url (or desc orig-url))))))) - -(defun muse-publish-insert-url (url &optional desc orig-url explicit) - "Resolve a URL into its final form." - (delete-region (match-beginning 0) (match-end 0)) - (let ((text (muse-publish-url url desc orig-url explicit))) - (when text - (muse-insert-markup text)))) - -(defun muse-publish-markup-link () - (let (desc explicit orig-link link) - (setq explicit (save-match-data - (if (string-match muse-explicit-link-regexp - (match-string 0)) - t nil))) - (setq orig-link (if explicit (match-string 1) (match-string 0))) - (setq desc (when explicit (match-string 2))) - (setq link (if explicit - (muse-handle-explicit-link orig-link) - (muse-handle-implicit-link orig-link))) - (when (and link - (or explicit - (not (or (eq (char-before (match-beginning 0)) ?\") - (eq (char-after (match-end 0)) ?\"))))) - ;; if explicit link has no user-provided description, treat it - ;; as if it were an implicit link - (when (and explicit (not desc)) - (setq explicit nil)) - (muse-publish-insert-url link desc orig-link explicit)))) - -(defun muse-publish-markup-url () - (unless (or (eq (char-before (match-beginning 0)) ?\") - (eq (char-after (match-end 0)) ?\")) - (let ((url (match-string 0))) - (muse-publish-insert-url url nil url)))) - -;; Default publishing tags - -(defcustom muse-publish-contents-depth 2 - "The number of heading levels to include with tags." - :type 'integer - :group 'muse-publish) - -(defun muse-publish-contents-tag (beg end attrs) - (set (make-local-variable 'muse-publish-generate-contents) - (cons (copy-marker (point) t) - (let ((depth (cdr (assoc "depth" attrs)))) - (or (and depth (string-to-number depth)) - muse-publish-contents-depth))))) - -(defun muse-publish-verse-tag (beg end) - (muse-publish-ensure-block beg end) - (save-excursion - (save-restriction - (narrow-to-region beg end) - (goto-char (point-min)) - (delete-char 1) - (while (< (point) (point-max)) - (insert "> ") - (forward-line)) - (if (eq ?\ (char-syntax (char-before))) - (delete-char -1))))) - -(defun muse-publish-mark-read-only (beg end) - "Add read-only properties to the given region." - (add-text-properties beg end '(rear-nonsticky (read-only) read-only t)) - nil) - -(defun muse-publish-mark-link (&optional beg end) - "Indicate that the given region is a Muse link, so that other -markup elements respect it. If a region is not specified, use -the 0th match data to determine it. - -This is usually applied to explicit links." - (unless beg (setq beg (match-beginning 0))) - (unless end (setq end (match-end 0))) - (add-text-properties beg end '(muse-link t)) - nil) - -(defun muse-publish-quote-tag (beg end) - (muse-publish-ensure-block beg) - (save-excursion - (save-restriction - (narrow-to-region beg end) - (let ((quote-regexp "^\\(<\\(/?\\)quote>\\)")) - (muse-insert-markup (muse-markup-text 'begin-quote)) - (while (progn - (unless (looking-at (concat "[" muse-regexp-blank "\n]*" - "")) - (muse-publish-surround-text - (muse-markup-text 'begin-quote-item) - (muse-markup-text 'end-quote-item) - (function - (lambda (indent) - (muse-forward-paragraph) - (goto-char (match-end 0)) - (and (< (point) (point-max)) - (not (looking-at quote-regexp))))) - nil nil nil - quote-regexp)) - (if (>= (point) (point-max)) - t - (and (search-forward "" nil t) - (muse-goto-tag-end "quote" t) - (progn (forward-line 1) t) - (< (point) (point-max)))))) - (goto-char (point-max)) - (muse-insert-markup (muse-markup-text 'end-quote)))))) - -(defun muse-publish-code-tag (beg end) - (muse-publish-escape-specials beg end nil 'literal) - (goto-char beg) - (insert (muse-markup-text 'begin-literal)) - (goto-char end) - (insert (muse-markup-text 'end-literal)) - (muse-publish-mark-read-only beg (point))) - -(defun muse-publish-cite-tag (beg end attrs) - (let* ((type (muse-publish-get-and-delete-attr "type" attrs)) - (citetag (cond ((string-equal type "author") - 'begin-cite-author) - ((string-equal type "year") - 'begin-cite-year) - (t - 'begin-cite)))) - (goto-char beg) - (insert (muse-markup-text citetag (muse-publishing-directive "bibsource"))) - (goto-char end) - (insert (muse-markup-text 'end-cite)) - (muse-publish-mark-read-only beg (point)))) - -(defun muse-publish-src-tag (beg end attrs) - (muse-publish-example-tag beg end)) - -(defun muse-publish-example-tag (beg end) - (muse-publish-ensure-block beg end) - (muse-publish-escape-specials beg end nil 'example) - (goto-char beg) - (insert (muse-markup-text 'begin-example)) - (goto-char end) - (insert (muse-markup-text 'end-example)) - (muse-publish-mark-read-only beg (point))) - -(defun muse-publish-literal-tag (beg end attrs) - "Ensure that the text between BEG and END is not interpreted later on. - -ATTRS is an alist of attributes. - -If it contains a \"style\" element, delete the region if the -current style is neither derived from nor equal to this style. - -If it contains both a \"style\" element and an \"exact\" element -with the value \"t\", delete the region only if the current style -is exactly this style." - (let* ((style (cdr (assoc "style" attrs))) - (exact (cdr (assoc "exact" attrs))) - (exactp (and (stringp exact) (string= exact "t")))) - (if (or (not style) - (and exactp (equal (muse-style style) - muse-publishing-current-style)) - (and (not exactp) (muse-style-derived-p style))) - (muse-publish-mark-read-only beg end) - (delete-region beg end) - (when (and (bolp) (eolp) (not (eobp))) - (delete-char 1))))) - -(put 'muse-publish-literal-tag 'muse-dangerous-tag t) - -(defun muse-publish-verbatim-tag (beg end) - (muse-publish-escape-specials beg end nil 'verbatim) - (muse-publish-mark-read-only beg end)) - -(defun muse-publish-br-tag (beg end) - "Insert a line break." - (delete-region beg end) - (muse-insert-markup (muse-markup-text 'line-break))) - -(defalias 'muse-publish-class-tag 'ignore) -(defalias 'muse-publish-div-tag 'ignore) - -(defun muse-publish-call-tag-on-buffer (tag &optional attrs) - "Transform the current buffer as if it were surrounded by the tag TAG. -If attributes ATTRS are given, pass them to the tag function." - (let ((tag-info (muse-markup-tag-info tag))) - (when tag-info - (let* ((end (progn (goto-char (point-max)) (point-marker))) - (args (list (point-min) end)) - (muse-inhibit-style-tags nil)) - (when (nth 2 tag-info) - (nconc args (list attrs))) - (apply (nth 4 tag-info) args) - (set-marker end nil))))) - -(defun muse-publish-examplify-buffer (&optional attrs) - "Transform the current buffer as if it were an region." - (muse-publish-call-tag-on-buffer "example" attrs)) - -(defun muse-publish-srcify-buffer (&optional attrs) - "Transform the current buffer as if it were a region." - (muse-publish-call-tag-on-buffer "src" attrs)) - -(defun muse-publish-versify-buffer (&optional attrs) - "Transform the current buffer as if it were a region." - (muse-publish-call-tag-on-buffer "verse" attrs) - (muse-publish-markup "" - `((100 ,(concat "^[" muse-regexp-blank "]*> ") 0 - muse-publish-markup-verse))) - (goto-char (point-min))) - -(defmacro muse-publish-markup-attribute (beg end attrs reinterp &rest body) - "Evaluate BODY within the bounds of BEG and END. -ATTRS is an alist. Only the \"markup\" element of ATTRS is acted -on. - -If it is omitted, publish the region with the normal Muse rules. -If RE-INTERP is specified, this is done immediately in a new -publishing process. Currently, RE-INTERP is specified only by -the tag. - -If \"nil\", do not mark up the region at all, but prevent it from -being further interpreted by Muse. - -If \"example\", treat the region as if it was surrounded by the - tag. - -If \"src\", treat the region as if it was surrounded by the - tag. - -If \"verse\", treat the region as if it was surrounded by the - tag, to preserve newlines. - -Otherwise, it should be the name of a function to call in the -narrowed region after evaluating BODY. The function should -take the ATTRS parameter. - -BEG is modified to be the start of the published markup." - (let ((attrs-sym (make-symbol "attrs")) - (markup (make-symbol "markup")) - (markup-function (make-symbol "markup-function"))) - `(let* ((,attrs-sym ,attrs) - (,markup (muse-publish-get-and-delete-attr "markup" ,attrs-sym))) - (save-restriction - (narrow-to-region ,beg ,end) - (goto-char (point-min)) - ,@body - (if (not ,markup) - (when ,reinterp - (muse-publish-markup-region (point-min) (point-max)) - (muse-publish-mark-read-only (point-min) (point-max)) - (goto-char (point-max))) - (let ((,markup-function (read ,markup))) - (cond ((eq ,markup-function 'example) - (setq ,markup-function #'muse-publish-examplify-buffer)) - ((eq ,markup-function 'src) - (setq ,markup-function #'muse-publish-srcify-buffer)) - ((eq ,markup-function 'verse) - (setq ,markup-function #'muse-publish-versify-buffer)) - ((and ,markup-function (not (functionp ,markup-function))) - (error "Invalid markup function `%s'" ,markup)) - (t nil)) - (if ,markup-function - (funcall ,markup-function ,attrs-sym) - (muse-publish-mark-read-only (point-min) (point-max)) - (goto-char (point-max))))))))) - -(put 'muse-publish-markup-attribute 'lisp-indent-function 4) -(put 'muse-publish-markup-attribute 'edebug-form-spec - '(sexp sexp sexp sexp body)) - -(defun muse-publish-lisp-tag (beg end attrs) - (muse-publish-markup-attribute beg end attrs nil - (save-excursion - (save-restriction - (let ((str (muse-eval-lisp - (prog1 - (concat "(progn " - (buffer-substring-no-properties (point-min) - (point-max)) - ")") - (delete-region (point-min) (point-max)) - (widen))))) - (set-text-properties 0 (length str) nil str) - (insert str)))))) - -(put 'muse-publish-lisp-tag 'muse-dangerous-tag t) - -(defun muse-publish-command-tag (beg end attrs) - (muse-publish-markup-attribute beg end attrs nil - (while (looking-at "\\s-*$") - (forward-line)) - (let ((interp (muse-publish-get-and-delete-attr "interp" attrs))) - (if interp - (shell-command-on-region (point) (point-max) interp t t) - (shell-command - (prog1 - (buffer-substring-no-properties (point) (point-max)) - (delete-region (point-min) (point-max))) - t))) - ;; make sure there is a newline at end - (goto-char (point-max)) - (forward-line 0) - (unless (looking-at "\\s-*$") - (goto-char (point-max)) - (insert ?\n)) - (goto-char (point-min)))) - -(put 'muse-publish-command-tag 'muse-dangerous-tag t) - -(defun muse-publish-perl-tag (beg end attrs) - (muse-publish-command-tag beg end - (cons (cons "interp" (executable-find "perl")) - attrs))) - -(put 'muse-publish-perl-tag 'muse-dangerous-tag t) - -(defun muse-publish-php-tag (beg end attrs) - (muse-publish-command-tag beg end - (cons (cons "interp" (executable-find "php")) - attrs))) - -(put 'muse-publish-php-tag 'muse-dangerous-tag t) - -(defun muse-publish-python-tag (beg end attrs) - (muse-publish-command-tag beg end - (cons (cons "interp" (executable-find "python")) - attrs))) - -(put 'muse-publish-python-tag 'muse-dangerous-tag t) - -(defun muse-publish-ruby-tag (beg end attrs) - (muse-publish-command-tag beg end - (cons (cons "interp" (executable-find "ruby")) - attrs))) - -(put 'muse-publish-ruby-tag 'muse-dangerous-tag t) - -(defun muse-publish-comment-tag (beg end) - (if (null muse-publish-comments-p) - (delete-region beg end) - (goto-char end) - (muse-insert-markup (muse-markup-text 'comment-end)) - (muse-publish-mark-read-only beg end) - (goto-char beg) - (muse-insert-markup (muse-markup-text 'comment-begin)))) - -(defun muse-publish-include-tag (beg end attrs) - "Include the named file at the current location during publishing. - - - -The `markup' attribute controls how this file is marked up after -being inserted. See `muse-publish-markup-attribute' for an -explanation of how it works." - (let ((filename (muse-publish-get-and-delete-attr "file" attrs)) - (muse-publishing-directives (copy-alist muse-publishing-directives))) - (if filename - (setq filename (expand-file-name - filename - (file-name-directory muse-publishing-current-file))) - (error "No file attribute specified in tag")) - (muse-publish-markup-attribute beg end attrs t - (muse-insert-file-contents filename)))) - -(put 'muse-publish-include-tag 'muse-dangerous-tag t) - -(defun muse-publish-mark-up-tag (beg end attrs) - "Run an Emacs Lisp function on the region delimted by this tag. - - - -The optional \"function\" attribute controls how this section is -marked up. If used, it should be the name of a function to call -with the buffer narrowed to the delimited region. Note that no -further marking-up will be performed on this region. - -If \"function\" is omitted, use the standard Muse markup function. -This is useful for marking up content in headers and footers. - -The optional \"style\" attribute causes the region to be deleted -if the current style is neither derived from nor equal to this -style. - -If both a \"style\" attribute and an \"exact\" attribute are -provided, and \"exact\" is \"t\", delete the region only if the -current style is exactly this style." - (let* ((style (cdr (assoc "style" attrs))) - (exact (cdr (assoc "exact" attrs))) - (exactp (and (stringp exact) (string= exact "t")))) - (if (or (not style) - (and exactp (equal (muse-style style) - muse-publishing-current-style)) - (and (not exactp) (muse-style-derived-p style))) - (let* ((function (cdr (assoc "function" attrs))) - (muse-publish-use-header-footer-tags nil) - (markup-function (and function (intern-soft function)))) - (if (and markup-function (functionp markup-function)) - (save-restriction - (narrow-to-region beg end) - (funcall markup-function) - (goto-char (point-max))) - (let ((muse-publish-inhibit-style-hooks t)) - (muse-publish-markup-region beg end))) - (muse-publish-mark-read-only beg (point))) - (delete-region beg end)))) - -(put 'muse-publish-mark-up-tag 'muse-dangerous-tag t) - -;; Miscellaneous helper functions - -(defun muse-publish-strip-URL (string &rest ignored) - "If the text \"URL:\" exists at the beginning of STRING, remove it. -The text is removed regardless of whether and part of it is uppercase." - (save-match-data - (if (string-match "\\`[uU][rR][lL]:\\(.+\\)\\'" string) - (match-string 1 string) - string))) - -(defun muse-publish-markup-type (category default-func) - (let ((rule (muse-find-markup-element :overrides category (muse-style)))) - (funcall (or rule default-func)))) - -(defun muse-published-buffer-contents (buffer) - (with-current-buffer buffer - (goto-char (point-min)) - (let ((beg (and (search-forward "Emacs Muse begins here") - (muse-line-end-position))) - (end (and (search-forward "Emacs Muse ends here") - (muse-line-beginning-position)))) - (buffer-substring-no-properties beg end)))) - -(defun muse-published-contents (file) - (when (file-readable-p file) - (muse-with-temp-buffer - (muse-insert-file-contents file) - (muse-published-buffer-contents (current-buffer))))) - -(defun muse-publish-transform-output - (file temp-file output-path name gen-func &rest cleanup-exts) - "Transform the given TEMP-FILE into the OUTPUT-PATH, using GEN-FUNC." - (setq file (muse-page-name file)) - (message "Generating %s output for %s..." name file) - (if (not (funcall gen-func temp-file output-path)) - (message "Generating %s from %s...failed" name file) - (message "Generating %s output for %s...done" name file) - (muse-delete-file-if-exists temp-file) - (dolist (ext cleanup-exts) - (muse-delete-file-if-exists - (expand-file-name (concat file ext) - (file-name-directory output-path)))) - (message "Wrote %s" output-path))) - -(defun muse-publish-read-only (string) - (let ((end (1- (length string)))) - (add-text-properties 0 end - '(rear-nonsticky (read-only) read-only t) - string) - string)) - -;;; muse-publish.el ends here diff --git a/elpa/muse-3.20/muse-regexps.el b/elpa/muse-3.20/muse-regexps.el deleted file mode 100644 index ad3ce3f..0000000 --- a/elpa/muse-3.20/muse-regexps.el +++ /dev/null @@ -1,270 +0,0 @@ -;;; muse-regexps.el --- define regexps used by Muse - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; This file is the part of the Muse project that describes regexps -;; that are used throughout the project. - -;;; Contributors: - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse Regular Expressions -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(defgroup muse-regexp nil - "Regular expressions used in publishing and syntax highlighting." - :group 'muse) - -;;; Deal with the lack of character classes for regexps in Emacs21 and -;;; XEmacs - -(defcustom muse-regexp-use-character-classes 'undecided - "Indicate whether to use extended character classes like [:space:]. -If 'undecided, Muse will use them if your emacs is known to support them. - -Emacs 22 and Emacs 21.3.50 are known to support them. XEmacs -does not support them. - -Emacs 21.2 or higher support them, but with enough annoying edge -cases that the sanest default is to leave them disabled." - :type '(choice (const :tag "Yes" t) - (const :tag "No" nil) - (const :tag "Let Muse decide" undecided)) - :group 'muse-regexp) - -(defvar muse-regexp-emacs-revision - (save-match-data - (and (string-match "^[0-9]+\\.[0-9]+\\.\\([0-9]+\\)" - emacs-version) - (match-string 1 emacs-version) - (string-to-number (match-string 1 emacs-version)))) - "The revision number of this version of Emacs.") - -(defun muse-extreg-usable-p () - "Return non-nil if extended character classes can be used, -nil otherwise. - -This is used when deciding the initial values of the muse-regexp -options." - (cond - ((eq muse-regexp-use-character-classes t) - t) - ((eq muse-regexp-use-character-classes nil) - nil) - ((featurep 'xemacs) nil) ; unusable on XEmacs - ((> emacs-major-version 21) t) ; usable if > 21 - ((< emacs-major-version 21) nil) - ((< emacs-minor-version 3) nil) - ;; don't use if version is of format 21.x - ((null muse-regexp-emacs-revision) nil) - ;; only trust 21.3.50 or higher - ((>= muse-regexp-emacs-revision 50) t) - (t nil))) - -(defcustom muse-regexp-blank - (if (muse-extreg-usable-p) - "[:blank:]" - " \t") - "Regexp to use in place of \"[:blank:]\". -This should be something that matches spaces and tabs. - -It is like a regexp, but should be embeddable inside brackets. -Muse will detect the appropriate value correctly most of -the time." - :type 'string - :options '("[:blank:]" " \t") - :group 'muse-regexp) - -(defcustom muse-regexp-alnum - (if (muse-extreg-usable-p) - "[:alnum:]" - "A-Za-z0-9") - "Regexp to use in place of \"[:alnum:]\". -This should be something that matches all letters and numbers. - -It is like a regexp, but should be embeddable inside brackets. -muse will detect the appropriate value correctly most of -the time." - :type 'string - :options '("[:alnum:]" "A-Za-z0-9") - :group 'muse-regexp) - -(defcustom muse-regexp-lower - (if (muse-extreg-usable-p) - "[:lower:]" - "a-z") - "Regexp to use in place of \"[:lower:]\". -This should match all lowercase characters. - -It is like a regexp, but should be embeddable inside brackets. -muse will detect the appropriate value correctly most of -the time." - :type 'string - :options '("[:lower:]" "a-z") - :group 'muse-regexp) - -(defcustom muse-regexp-upper - (if (muse-extreg-usable-p) - "[:upper:]" - "A-Z") - "Regexp to use in place of \"[:upper:]\". -This should match all uppercase characters. - -It is like a regexp, but should be embeddable inside brackets. -muse will detect the appropriate value correctly most of -the time." - :type 'string - :options '("[:upper:]" "A-Z") - :group 'muse-regexp) - -;;; Regexps used to define Muse publishing syntax - -(defcustom muse-list-item-regexp - (concat "^%s\\(\\([^\n" muse-regexp-blank "].*?\\)?::" - "\\(?:[" muse-regexp-blank "]+\\|$\\)" - "\\|[" muse-regexp-blank "]-[" muse-regexp-blank "]*" - "\\|[" muse-regexp-blank "][0-9]+\\.[" muse-regexp-blank "]*\\)") - "Regexp used to match the beginning of a list item. -The '%s' will be replaced with a whitespace regexp when publishing." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-ol-item-regexp (concat "\\`[" muse-regexp-blank "]+[0-9]+\\.") - "Regexp used to match an ordered list item." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-ul-item-regexp (concat "\\`[" muse-regexp-blank "]+-") - "Regexp used to match an unordered list item." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-dl-term-regexp - (concat "[" muse-regexp-blank "]*\\(.+?\\)[" - muse-regexp-blank "]+::\\(?:[" muse-regexp-blank "]+\\|$\\)") - "Regexp used to match a definition list term. -The first match string must contain the term." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-dl-entry-regexp (concat "\\`[" muse-regexp-blank "]*::") - "Regexp used to match a definition list entry." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-table-field-regexp - (concat "[" muse-regexp-blank "]+\\(|+\\)\\(?:[" - muse-regexp-blank "]\\|$\\)") - "Regexp used to match table separators when publishing." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-table-line-regexp (concat ".*" muse-table-field-regexp ".*") - "Regexp used to match a table line when publishing." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-table-hline-regexp (concat "[" muse-regexp-blank - "]*|[-+]+|[" muse-regexp-blank - "]*") - "Regexp used to match a horizontal separator line in a table." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-table-el-border-regexp (concat "[" muse-regexp-blank "]*" - "\\+\\(-*\\+\\)+" - "[" muse-regexp-blank "]*") - "Regexp used to match the beginning and end of a table.el-style table." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-table-el-line-regexp (concat "[" muse-regexp-blank "]*" - "|\\(.*|\\)*" - "[" muse-regexp-blank "]*") - "Regexp used to match a table line of a table.el-style table." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-tag-regexp - (concat "<\\([^/" muse-regexp-blank "\n][^" muse-regexp-blank - "\n]*\\)\\(\\s-+[^<>]+[^\n]\\)?\\(/\\)?>") - "A regexp used to find XML-style tags within a buffer when publishing. -Group 1 should be the tag name, group 2 the properties, and group -3 the optional immediate ending slash." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-explicit-link-regexp - "\\[\\[\\([^][\n]+\\)\\]\\(?:\\[\\([^][\n]+\\)\\]\\)?\\]" - "Regexp used to match [[target][description]] links. -Paren group 1 must match the URL, and paren group 2 the description." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-implicit-link-regexp - (concat "\\([^" muse-regexp-blank "\n]+\\)") - "Regexp used to match an implicit link. -An implicit link is the largest block of text to be checked for -URLs and bare WikiNames by the `muse-link-at-point' function. -Paren group 1 is the text to be checked. - -URLs are checked by default. To get WikiNames, load -muse-wiki.el. - -This is only used when you are using muse-mode.el, but not -muse-colors.el. - -If the above applies, and you want to match things with spaces in -them, you will have to modify this." - :type 'regexp - :group 'muse-regexp) - -;;; Regexps used to determine file types - -(defcustom muse-file-regexp - (concat "\\`[~/]\\|\\?\\|/\\'\\|\\." - "\\(html?\\|pdf\\|mp3\\|el\\|zip\\|txt\\|tar\\)" - "\\(\\.\\(gz\\|bz2\\)\\)?\\'") - "A link matching this regexp will be regarded as a link to a file." - :type 'regexp - :group 'muse-regexp) - -(defcustom muse-image-regexp - "\\.\\(eps\\|gif\\|jp\\(e?g\\)\\|p\\(bm\\|ng\\)\\|tiff\\|x\\([bp]m\\)\\)\\'" - "A link matching this regexp will be published inline as an image. -For example: - - [[./wife.jpg][A picture of my wife]] - -If you omit the description, the alt tag of the resulting HTML -buffer will be the name of the file." - :type 'regexp - :group 'muse-regexp) - -(provide 'muse-regexps) - -;;; muse-regexps.el ends here diff --git a/elpa/muse-3.20/muse-texinfo.el b/elpa/muse-3.20/muse-texinfo.el deleted file mode 100644 index 4ad0092..0000000 --- a/elpa/muse-3.20/muse-texinfo.el +++ /dev/null @@ -1,346 +0,0 @@ -;;; muse-texinfo.el --- publish entries to Texinfo format or PDF - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;;; Contributors: - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse Texinfo Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-publish) -(require 'muse-latex) -(require 'texnfo-upd) - -(defgroup muse-texinfo nil - "Rules for marking up a Muse file as a Texinfo article." - :group 'muse-publish) - -(defcustom muse-texinfo-process-natively nil - "If non-nil, use the Emacs `texinfmt' module to make Info files." - :type 'boolean - :require 'texinfmt - :group 'muse-texinfo) - -(defcustom muse-texinfo-extension ".texi" - "Default file extension for publishing Texinfo files." - :type 'string - :group 'muse-texinfo) - -(defcustom muse-texinfo-info-extension ".info" - "Default file extension for publishing Info files." - :type 'string - :group 'muse-texinfo) - -(defcustom muse-texinfo-pdf-extension ".pdf" - "Default file extension for publishing PDF files." - :type 'string - :group 'muse-texinfo) - -(defcustom muse-texinfo-header - "\\input texinfo @c -*-texinfo-*- - -@setfilename (concat (muse-page-name) \".info\") -@settitle (muse-publishing-directive \"title\") - -@documentencoding iso-8859-1 - -@iftex -@finalout -@end iftex - -@titlepage -@title (muse-publishing-directive \"title\") -@author (muse-publishing-directive \"author\") -@end titlepage - -(and muse-publish-generate-contents \"@contents\") - -@node Top, Overview, , (dir) -@top Overview -@c Page published by Emacs Muse begins here\n\n" - "Text to prepend to a Muse page being published as Texinfo. -This may be text or a filename. -It may contain markup tags." - :type 'string - :group 'muse-texinfo) - -(defcustom muse-texinfo-footer - "\n@c Page published by Emacs Muse ends here -@bye\n" - "Text to append to a Muse page being published as Texinfo. -This may be text or a filename. -It may contain markup tags." - :type 'string - :group 'muse-texinfo) - -(defcustom muse-texinfo-markup-regexps nil - "List of markup rules for publishing a Muse page to Texinfo. -For more on the structure of this list, see `muse-publish-markup-regexps'." - :type '(repeat (choice - (list :tag "Markup rule" - integer - (choice regexp symbol) - integer - (choice string function symbol)) - function)) - :group 'muse-texinfo) - -(defcustom muse-texinfo-markup-functions - '((table . muse-texinfo-markup-table) - (heading . muse-texinfo-markup-heading)) - "An alist of style types to custom functions for that kind of text. -For more on the structure of this list, see -`muse-publish-markup-functions'." - :type '(alist :key-type symbol :value-type function) - :group 'muse-texinfo) - -(defcustom muse-texinfo-markup-strings - '((image-with-desc . "@center @image{%1%, , , %3%, %2%}@*\n@center %3%") - (image . "@noindent @image{%s, , , , %s}") - (image-link . "@uref{%s, %s.%s}") - (anchor-ref . "@ref{%s, %s}") - (url . "@uref{%s, %s}") - (link . "@ref{Top, %2%, , %1%, }") - (link-and-anchor . "@ref{%3%, %2%, , %1%, %3%}") - (email-addr . "@email{%s}") - (anchor . "@anchor{%s} ") - (emdash . "---") - (comment-begin . "@ignore\n") - (comment-end . "\n@end ignore\n") - (rule . "@sp 1") - (no-break-space . "@w{ }") - (line-break . "@*") - (enddots . "@enddots{}") - (dots . "@dots{}") - (section . "@chapter ") - (subsection . "@section ") - (subsubsection . "@subsection ") - (section-other . "@subsubheading ") - (footnote . "@footnote{") - (footnote-end . "}") - (begin-underline . "_") - (end-underline . "_") - (begin-literal . "@samp{") - (end-literal . "}") - (begin-emph . "@emph{") - (end-emph . "}") - (begin-more-emph . "@strong{") - (end-more-emph . "}") - (begin-most-emph . "@strong{@emph{") - (end-most-emph . "}}") - (begin-verse . "@display\n") - (end-verse-line . "") - (verse-space . "@ @ ") - (end-verse . "\n@end display") - (begin-example . "@example\n") - (end-example . "\n@end example") - (begin-center . "@quotation\n") - (end-center . "\n@end quotation") - (begin-quote . "@quotation\n") - (end-quote . "\n@end quotation") - (begin-cite . "") - (begin-cite-author . "") - (begin-cite-year . "") - (end-cite . "") - (begin-uli . "@itemize @bullet\n") - (end-uli . "\n@end itemize") - (begin-uli-item . "@item\n") - (begin-oli . "@enumerate\n") - (end-oli . "\n@end enumerate") - (begin-oli-item . "@item\n") - (begin-dl . "@table @strong\n") - (end-dl . "\n@end table") - (begin-ddt . "@item ")) - "Strings used for marking up text. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles." - :type '(alist :key-type symbol :value-type string) - :group 'muse-texinfo) - -(defcustom muse-texinfo-markup-specials - '((?@ . "@@") - (?{ . "@{") - (?} . "@}")) - "A table of characters which must be represented specially." - :type '(alist :key-type character :value-type string) - :group 'muse-texinfo) - -(defcustom muse-texinfo-markup-specials-url - '((?@ . "@@") - (?{ . "@{") - (?} . "@}") - (?, . "@comma{}")) - "A table of characters which must be represented specially. -These are applied to URLs." - :type '(alist :key-type character :value-type string) - :group 'muse-texinfo) - -(defun muse-texinfo-decide-specials (context) - "Determine the specials to escape, depending on CONTEXT." - (cond ((memq context '(underline literal emphasis email url url-desc image - footnote)) - muse-texinfo-markup-specials-url) - (t muse-texinfo-markup-specials))) - -(defun muse-texinfo-markup-table () - (let* ((table-info (muse-publish-table-fields (match-beginning 0) - (match-end 0))) - (row-len (car table-info)) - (field-list (cdr table-info))) - (when table-info - (muse-insert-markup "@multitable @columnfractions") - (dotimes (field row-len) - (muse-insert-markup " " (number-to-string (/ 1.0 row-len)))) - (dolist (fields field-list) - (let ((type (car fields))) - (unless (eq type 'hline) - (setq fields (cdr fields)) - (if (= type 2) - (muse-insert-markup "\n@headitem ") - (muse-insert-markup "\n@item ")) - (insert (car fields)) - (setq fields (cdr fields)) - (dolist (field fields) - (muse-insert-markup " @tab ") - (insert field))))) - (muse-insert-markup "\n@end multitable") - (insert ?\n)))) - -(defun muse-texinfo-remove-links (string) - "Remove explicit links from STRING, replacing them with the link -description. - -If no description exists for the link, use the link itself." - (let ((start nil)) - (while (setq start (string-match muse-explicit-link-regexp string - start)) - (setq string - (replace-match (or (match-string 2 string) - (match-string 1 string)) - t t string))) - string)) - -(defun muse-texinfo-protect-wikiwords (start end) - "Protect all wikiwords from START to END from further processing." - (and (boundp 'muse-wiki-wikiword-regexp) - (featurep 'muse-wiki) - (save-excursion - (goto-char start) - (while (re-search-forward muse-wiki-wikiword-regexp end t) - (muse-publish-mark-read-only (match-beginning 0) - (match-end 0)))))) - -(defun muse-texinfo-markup-heading () - (save-excursion - (muse-publish-markup-heading)) - (let* ((eol (muse-line-end-position)) - (orig-heading (buffer-substring (point) eol)) - (beg (point))) - (delete-region (point) eol) - ;; don't allow links to be published in headings - (insert (muse-texinfo-remove-links orig-heading)) - (muse-texinfo-protect-wikiwords beg (point)))) - -(defun muse-texinfo-munge-buffer () - (muse-latex-fixup-dquotes) - (texinfo-insert-node-lines (point-min) (point-max) t) - (texinfo-all-menus-update t)) - -(defun muse-texinfo-pdf-browse-file (file) - (shell-command (concat "open " file))) - -(defun muse-texinfo-info-generate (file output-path final-target) - ;; The version of `texinfmt.el' that comes with Emacs 21 doesn't - ;; support @documentencoding, so hack it in. - (when (and (not (featurep 'xemacs)) - (eq emacs-major-version 21)) - (put 'documentencoding 'texinfo-format - 'texinfo-discard-line-with-args)) - ;; Most versions of `texinfmt.el' do not support @headitem, so hack - ;; it in. - (unless (get 'headitem 'texinfo-format) - (put 'headitem 'texinfo-format 'texinfo-multitable-item)) - (muse-publish-transform-output - file output-path final-target "Info" - (function - (lambda (file output-path) - (if muse-texinfo-process-natively - (save-window-excursion - (save-excursion - (find-file file) - (let ((inhibit-read-only t)) - (texinfo-format-buffer)) - (save-buffer) - (kill-buffer (current-buffer)) - (let ((buf (get-file-buffer file))) - (with-current-buffer buf - (set-buffer-modified-p nil) - (kill-buffer (current-buffer)))) - t)) - (let ((result (shell-command - (concat "makeinfo --enable-encoding --output=" - output-path " " file)))) - (if (or (not (numberp result)) - (eq result 0)) - t - nil))))))) - -(defun muse-texinfo-pdf-generate (file output-path final-target) - (let ((muse-latex-pdf-program "pdftex") - (muse-latex-pdf-cruft '(".aux" ".cp" ".fn" ".ky" ".log" ".pg" ".toc" - ".tp" ".vr"))) - (muse-latex-pdf-generate file output-path final-target))) - -;;; Register the Muse TEXINFO Publishers - -(muse-define-style "texi" - :suffix 'muse-texinfo-extension - :regexps 'muse-texinfo-markup-regexps - :functions 'muse-texinfo-markup-functions - :strings 'muse-texinfo-markup-strings - :specials 'muse-texinfo-decide-specials - :after 'muse-texinfo-munge-buffer - :header 'muse-texinfo-header - :footer 'muse-texinfo-footer - :browser 'find-file) - -(muse-derive-style "info" "texi" - :final 'muse-texinfo-info-generate - :link-suffix 'muse-texinfo-info-extension - :osuffix 'muse-texinfo-info-extension - :browser 'info) - -(muse-derive-style "info-pdf" "texi" - :final 'muse-texinfo-pdf-generate - :link-suffix 'muse-texinfo-pdf-extension - :osuffix 'muse-texinfo-pdf-extension - :browser 'muse-texinfo-pdf-browse-file) - -(provide 'muse-texinfo) - -;;; muse-texinfo.el ends here diff --git a/elpa/muse-3.20/muse-wiki.el b/elpa/muse-3.20/muse-wiki.el deleted file mode 100644 index e2cd3a2..0000000 --- a/elpa/muse-3.20/muse-wiki.el +++ /dev/null @@ -1,498 +0,0 @@ -;;; muse-wiki.el --- wiki features for Muse - -;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; Author: Yann Hodique -;; Keywords: - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;;; Contributors: - -;; Per B. Sederberg (per AT med DOT upenn DOT edu) made it so that all -;; files in a Muse project can become implicit links. - -;;; Code: - -(require 'muse-regexps) -(require 'muse-mode) - -(eval-when-compile - (require 'muse-colors)) - -(defgroup muse-wiki nil - "Options controlling the behavior of Emacs Muse Wiki features." - :group 'muse-mode) - -(defcustom muse-wiki-use-wikiword t - "Whether to use color and publish bare WikiNames." - :type 'boolean - :group 'muse-wiki) - -(defcustom muse-wiki-allow-nonexistent-wikiword nil - "Whether to color bare WikiNames that don't have an existing file." - :type 'boolean - :group 'muse-wiki) - -(defcustom muse-wiki-match-all-project-files nil - "If non-nil, Muse will color and publish implicit links to any -file in your project, regardless of whether its name is a WikiWord." - :type 'boolean - :group 'muse-wiki) - -(defcustom muse-wiki-ignore-implicit-links-to-current-page nil - "If non-nil, Muse will not recognize implicit links to the current -page, both when formatting and publishing." - :type 'boolean - :group 'muse-wiki) - -(defvar muse-wiki-project-file-regexp nil - "Regexp used to match the files in the current project. - -This is set by `muse-wiki-update-project-file-regexp' automatically -when `muse-wiki-match-all-project-files' is non-nil.") -(make-variable-buffer-local 'muse-wiki-project-file-regexp) - -(defun muse-wiki-update-project-file-regexp () - "Update a local copy of `muse-wiki-project-file-regexp' to include -all the files in the project." - ;; see if the user wants to match project files - (when muse-wiki-match-all-project-files - (let ((files (mapcar #'car (muse-project-file-alist (muse-project))))) - (setq muse-wiki-project-file-regexp - (when files - (concat "\\(" - ;; include all files from the project - (regexp-opt files 'words) - "\\)")))) - ;; update coloring setup - (when (featurep 'muse-colors) - (muse-colors-define-highlighting 'muse-mode muse-colors-markup)))) - -(add-hook 'muse-update-values-hook - 'muse-wiki-update-project-file-regexp) -(add-hook 'muse-project-file-alist-hook - 'muse-wiki-update-project-file-regexp) - -(defcustom muse-wiki-wikiword-regexp - (concat "\\<\\(\\(?:[" muse-regexp-upper - "]+[" muse-regexp-lower "]+\\)\\(?:[" - muse-regexp-upper "]+[" muse-regexp-lower "]+\\)+\\)") - "Regexp used to match WikiWords." - :set (function - (lambda (sym value) - (set sym value) - (when (featurep 'muse-colors) - (muse-colors-define-highlighting 'muse-mode muse-colors-markup)))) - :type 'regexp - :group 'muse-wiki) - -(defcustom muse-wiki-ignore-bare-project-names nil - "Determine whether project names without a page specifer are links. - -If non-nil, project names without a page specifier will not be -considered links. - -When nil, project names without a specifier are highlighted and -they link to the default page of the project that they name." - :type 'boolean - :group 'muse-wiki) - -(defvar muse-wiki-interwiki-regexp nil - "Regexp that matches all interwiki links. - -This is automatically generated by setting `muse-wiki-interwiki-alist'. -It can also be set by calling `muse-wiki-update-interwiki-regexp'.") - -(defcustom muse-wiki-interwiki-delimiter "#\\|::" - "Delimiter regexp used for InterWiki links. - -If you use groups, use only shy groups." - :type 'regexp - :group 'muse-wiki) - -(defcustom muse-wiki-interwiki-replacement ": " - "Regexp used for replacing `muse-wiki-interwiki-delimiter' in -InterWiki link descriptions. - -If you want this replacement to happen, you must add -`muse-wiki-publish-pretty-interwiki' to -`muse-publish-desc-transforms'." - :type 'regexp - :group 'muse-wiki) - -(eval-when-compile - (defvar muse-wiki-interwiki-alist)) - -(defun muse-wiki-project-files-with-spaces (&optional project) - "Return a list of files in PROJECT that have spaces." - (setq project (muse-project project)) - (let ((flist nil)) - (save-match-data - (dolist (entry (muse-project-file-alist project)) - (when (string-match " " (car entry)) - (setq flist (cons (car entry) flist))))) - flist)) - -(defun muse-wiki-update-interwiki-regexp () - "Update the value of `muse-wiki-interwiki-regexp' based on -`muse-wiki-interwiki-alist' and `muse-project-alist'." - (if (null muse-project-alist) - (setq muse-wiki-interwiki-regexp nil) - (let ((old-value muse-wiki-interwiki-regexp)) - (setq muse-wiki-interwiki-regexp - (concat "\\<\\(" (regexp-opt (mapcar #'car muse-project-alist)) - (when muse-wiki-interwiki-alist - (let ((interwiki-rules - (mapcar #'car muse-wiki-interwiki-alist))) - (when interwiki-rules - (concat "\\|" (regexp-opt interwiki-rules))))) - "\\)\\(?:\\(" muse-wiki-interwiki-delimiter - "\\)\\(" - (when muse-wiki-match-all-project-files - ;; append the files from the project - (let ((files nil)) - (dolist (proj muse-project-alist) - (setq files - (nconc (muse-wiki-project-files-with-spaces - (car proj)) - files))) - (when files - (concat (regexp-opt files) "\\|")))) - "\\sw+\\)\\(#\\S-+\\)?\\)?\\>")) - (when (and (featurep 'muse-colors) - (not (string= old-value muse-wiki-interwiki-regexp))) - (muse-colors-define-highlighting 'muse-mode muse-colors-markup))))) - -(defcustom muse-wiki-interwiki-alist - '(("EmacsWiki" . "http://www.emacswiki.org/cgi-bin/wiki/")) - "A table of WikiNames that refer to external entities. - -The format of this table is an alist, or series of cons cells. -Each cons cell must be of the form: - - (WIKINAME . STRING-OR-FUNCTION) - -The second part of the cons cell may either be a STRING, which in most -cases should be a URL, or a FUNCTION. If a function, it will be -called with one argument: the tag applied to the Interwiki name, or -nil if no tag was used. If the cdr was a STRING and a tag is used, -the tag is simply appended. - -Here are some examples: - - (\"JohnWiki\" . \"http://alice.dynodns.net/wiki?\") - -Referring to [[JohnWiki::EmacsModules]] then really means: - - http://alice.dynodns.net/wiki?EmacsModules - -If a function is used for the replacement text, you can get creative -depending on what the tag is. Tags may contain any alphabetic -character, any number, % or _. If you need other special characters, -use % to specify the hex code, as in %2E. All browsers should support -this." - :type '(repeat (cons (string :tag "WikiName") - (choice (string :tag "URL") function))) - :set (function - (lambda (sym value) - (set sym value) - (muse-wiki-update-interwiki-regexp))) - :group 'muse-wiki) - -(add-hook 'muse-update-values-hook - 'muse-wiki-update-interwiki-regexp) - -(defun muse-wiki-resolve-project-page (&optional project page) - "Return the published path from the current page to PAGE of PROJECT. - -If PAGE is not specified, use the value of :default in PROJECT. - -If PROJECT is not specified, default to the current project. If -no project is current, use the first project of -`muse-projects-alist'. - -Note that PAGE can have several output directories. If this is -the case, we will use the first one that matches our current -style and has the same link suffix, ignoring the others. If no -style has the same link suffix as the current publishing style, -use the first style we find." - (setq project (or (and project - (muse-project project)) - (muse-project) - (car muse-project-alist)) - page (or page (muse-get-keyword :default (cadr project)))) - (let* ((page-path (and muse-project-alist - (muse-project-page-file page project))) - (remote-styles (and page-path (muse-project-applicable-styles - page-path (cddr project)))) - (local-style (muse-project-current-output-style))) - (cond ((and remote-styles local-style muse-publishing-p) - (muse-project-resolve-link page local-style remote-styles)) - ((not muse-publishing-p) - (if page-path - page-path - (when muse-wiki-allow-nonexistent-wikiword - ;; make a path to a nonexistent file in project - (setq page-path (expand-file-name - page (car (cadr project)))) - (if (and muse-file-extension - (not (string= muse-file-extension ""))) - (concat page-path "." muse-file-extension) - page-path))))))) - -(defun muse-wiki-handle-implicit-interwiki (&optional string) - "If STRING or point has an interwiki link, resolve it to a filename. - -Match string 0 is set to the link." - (when (and muse-wiki-interwiki-regexp - (if string (string-match muse-wiki-interwiki-regexp string) - (looking-at muse-wiki-interwiki-regexp))) - (let* ((project (match-string 1 string)) - (subst (cdr (assoc project muse-wiki-interwiki-alist))) - (word (match-string 3 string)) - (anchor (if (match-beginning 4) - (match-string 4 string) - ""))) - (if subst - (if (functionp subst) - (and (setq word (funcall subst word)) - (concat word anchor)) - (concat subst word anchor)) - (and (assoc project muse-project-alist) - (or word (not muse-wiki-ignore-bare-project-names)) - (setq word (muse-wiki-resolve-project-page project word)) - (concat word anchor)))))) - -(defun muse-wiki-handle-explicit-interwiki (&optional string) - "If STRING or point has an interwiki link, resolve it to a filename." - (let ((right-pos (if string (length string) (match-end 1)))) - (when (and muse-wiki-interwiki-regexp - (if string (string-match muse-wiki-interwiki-regexp string) - (save-restriction - (narrow-to-region (point) right-pos) - (looking-at muse-wiki-interwiki-regexp)))) - (let* ((project (match-string 1 string)) - (subst (cdr (assoc project muse-wiki-interwiki-alist))) - (anchor (and (match-beginning 4) - (match-string 4 string))) - (word (when (match-end 2) - (cond (anchor (match-string 3 string)) - (string (substring string (match-end 2))) - (right-pos (buffer-substring (match-end 2) - right-pos)) - (t nil))))) - (if (and (null word) - right-pos - (not (= right-pos (match-end 1)))) - ;; if only a project name was found, it must take up the - ;; entire string or link - nil - (unless anchor - (if (or (null word) - (not (string-match "#[^#]+\\'" word))) - (setq anchor "") - (setq anchor (match-string 0 word)) - (setq word (substring word 0 (match-beginning 0))))) - (if subst - (if (functionp subst) - (and (setq word (funcall subst word)) - (concat word anchor)) - (concat subst word anchor)) - (and (assoc project muse-project-alist) - (or word (not muse-wiki-ignore-bare-project-names)) - (setq word (muse-wiki-resolve-project-page project word)) - (concat word anchor)))))))) - -(defun muse-wiki-handle-wikiword (&optional string) - "If STRING or point has a WikiWord, return it. - -Match 1 is set to the WikiWord." - (when (and (or (and muse-wiki-match-all-project-files - muse-wiki-project-file-regexp - (if string - (string-match muse-wiki-project-file-regexp string) - (looking-at muse-wiki-project-file-regexp))) - (and muse-wiki-use-wikiword - (if string - (string-match muse-wiki-wikiword-regexp string) - (looking-at muse-wiki-wikiword-regexp)))) - (cond - (muse-wiki-allow-nonexistent-wikiword - t) - ((and muse-wiki-ignore-implicit-links-to-current-page - (string= (match-string 1 string) (muse-page-name))) - nil) - ((and (muse-project-of-file) - (muse-project-page-file - (match-string 1 string) muse-current-project t)) - t) - ((file-exists-p (match-string 1 string)) - t) - (t nil))) - (match-string 1 string))) - -;;; Prettifications - -(defcustom muse-wiki-publish-small-title-words - '("the" "and" "at" "on" "of" "for" "in" "an" "a") - "Strings that should be downcased in a page title. - -This is used by `muse-wiki-publish-pretty-title', which must be -called manually." - :type '(repeat string) - :group 'muse-wiki) - -(defcustom muse-wiki-hide-nop-tag t - "If non-nil, hide tags when coloring a Muse buffer." - :type 'boolean - :group 'muse-wiki) - -(defun muse-wiki-publish-pretty-title (&optional title explicit) - "Return a pretty version of the given TITLE. - -If EXPLICIT is non-nil, TITLE will be returned unmodified." - (unless title (setq title (or (muse-publishing-directive "title") ""))) - (if (or explicit - (save-match-data (string-match muse-url-regexp title))) - title - (save-match-data - (let ((case-fold-search nil)) - (while (string-match (concat "\\([" muse-regexp-lower - "]\\)\\([" muse-regexp-upper - "0-9]\\)") - title) - (setq title (replace-match "\\1 \\2" t nil title))) - (let* ((words (split-string title)) - (w (cdr words))) - (while w - (if (member (downcase (car w)) - muse-wiki-publish-small-title-words) - (setcar w (downcase (car w)))) - (setq w (cdr w))) - (mapconcat 'identity words " ")))))) - -(defun muse-wiki-publish-pretty-interwiki (desc &optional explicit) - "Replace instances of `muse-wiki-interwiki-delimiter' with -`muse-wiki-interwiki-replacement'." - (if (or explicit - (save-match-data (string-match muse-url-regexp desc))) - desc - (muse-replace-regexp-in-string muse-wiki-interwiki-delimiter - muse-wiki-interwiki-replacement - desc))) - -;;; Coloring setup - -(defun muse-wiki-colors-nop-tag (beg end) - "Inhibit the colorization of inhibit links just after the tag. - -Example: WikiWord" - (when muse-wiki-hide-nop-tag - (add-text-properties beg (+ beg 5) - '(invisible muse intangible t))) - (unless (> (+ beg 6) (point-max)) - (add-text-properties (+ beg 5) (+ beg 6) - '(muse-no-implicit-link t)))) - -(defun muse-colors-wikiword-separate () - (add-text-properties (match-beginning 0) (match-end 0) - '(invisible muse intangible t))) - -(defun muse-wiki-insinuate-colors () - (add-to-list 'muse-colors-tags - '("nop" nil nil nil muse-wiki-colors-nop-tag) - t) - (add-to-list 'muse-colors-markup - '(muse-wiki-interwiki-regexp t muse-colors-implicit-link) - t) - (add-to-list 'muse-colors-markup - '(muse-wiki-wikiword-regexp t muse-colors-implicit-link) - t) - (add-to-list 'muse-colors-markup - '(muse-wiki-project-file-regexp t muse-colors-implicit-link) - t) - (add-to-list 'muse-colors-markup - '("''''" ?\' muse-colors-wikiword-separate) - nil) - (muse-colors-define-highlighting 'muse-mode muse-colors-markup)) - -(eval-after-load "muse-colors" '(muse-wiki-insinuate-colors)) - -;;; Publishing setup - -(defun muse-wiki-publish-nop-tag (beg end) - "Inhibit the colorization of inhibit links just after the tag. - -Example: WikiWord" - (unless (= (point) (point-max)) - (muse-publish-mark-read-only (point) (+ (point) 1)))) - -(defun muse-wiki-insinuate-publish () - (add-to-list 'muse-publish-markup-tags - '("nop" nil nil nil muse-wiki-publish-nop-tag) - t) - (add-to-list 'muse-publish-markup-regexps - '(3100 muse-wiki-interwiki-regexp 0 link) - t) - (add-to-list 'muse-publish-markup-regexps - '(3200 muse-wiki-wikiword-regexp 0 link) - t) - (add-to-list 'muse-publish-markup-regexps - '(3250 muse-wiki-project-file-regexp 0 link) - t) - (add-to-list 'muse-publish-markup-regexps - '(3300 "''''" 0 "") - t) - (custom-add-option 'muse-publish-desc-transforms - 'muse-wiki-publish-pretty-interwiki) - (custom-add-option 'muse-publish-desc-transforms - 'muse-wiki-publish-pretty-title)) - -(eval-after-load "muse-publish" '(muse-wiki-insinuate-publish)) - -;;; Insinuate link handling - -(custom-add-option 'muse-implicit-link-functions - 'muse-wiki-handle-implicit-interwiki) -(custom-add-option 'muse-implicit-link-functions - 'muse-wiki-handle-wikiword) - -(custom-add-option 'muse-explicit-link-functions - 'muse-wiki-handle-explicit-interwiki) - -(add-to-list 'muse-implicit-link-functions - 'muse-wiki-handle-implicit-interwiki t) -(add-to-list 'muse-implicit-link-functions - 'muse-wiki-handle-wikiword t) - -(add-to-list 'muse-explicit-link-functions - 'muse-wiki-handle-explicit-interwiki t) - -;;; Obsolete functions - -(defun muse-wiki-update-custom-values () - (muse-display-warning - (concat "Please remove `muse-wiki-update-custom-values' from" - " `muse-mode-hook'. Its use is now deprecated."))) - -(provide 'muse-wiki) -;;; muse-wiki.el ends here diff --git a/elpa/muse-3.20/muse-xml-common.el b/elpa/muse-3.20/muse-xml-common.el deleted file mode 100644 index 75869ca..0000000 --- a/elpa/muse-3.20/muse-xml-common.el +++ /dev/null @@ -1,201 +0,0 @@ -;;; muse-xml-common.el --- common routines for XML-like publishing styles - -;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;;; Contributors: - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse XML Publishing - Common Elements -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-publish) -(require 'muse-regexps) - -(defcustom muse-xml-encoding-map - '((iso-8859-1 . "iso-8859-1") - (iso-2022-jp . "iso-2022-jp") - (utf-8 . "utf-8") - (japanese-iso-8bit . "euc-jp") - (chinese-big5 . "big5") - (mule-utf-8 . "utf-8") - (chinese-iso-8bit . "gb2312") - (chinese-gbk . "gbk")) - "An alist mapping Emacs coding systems to appropriate XML charsets. -Use the base name of the coding system (i.e. without the -unix)." - :type '(alist :key-type coding-system :value-type string) - :group 'muse-xml) - -(defun muse-xml-transform-content-type (content-type default) - "Using `muse-xml-encoding-map', try and resolve an Emacs coding -system to an associated XML coding system. -If no match is found, the DEFAULT charset is used instead." - (let ((match (and (fboundp 'coding-system-base) - (assoc (coding-system-base content-type) - muse-xml-encoding-map)))) - (if match - (cdr match) - default))) - -(defcustom muse-xml-markup-specials - '((?\" . """) - (?\< . "<") - (?\> . ">") - (?\& . "&")) - "A table of characters which must be represented specially." - :type '(alist :key-type character :value-type string) - :group 'muse-xml) - -(defcustom muse-xml-markup-specials-url-extra - '((?\" . """) - (?\< . "<") - (?\> . ">") - (?\& . "&") - (?\ . "%20") - (?\n . "%0D%0A")) - "A table of characters which must be represented specially. -These are extra characters that are escaped within URLs." - :type '(alist :key-type character :value-type string) - :group 'muse-xml) - -(defun muse-xml-decide-specials (context) - "Determine the specials to escape, depending on CONTEXT." - (cond ((memq context '(email url image)) - 'muse-xml-escape-url) - ((eq context 'url-extra) - muse-xml-markup-specials-url-extra) - (t muse-xml-markup-specials))) - -(defun muse-xml-escape-url (str) - "Convert to character entities any non-alphanumeric characters -outside a few punctuation symbols, that risk being misinterpreted -if not escaped." - (when str - (setq str (muse-publish-escape-specials-in-string str 'url-extra)) - (let (pos code len ch) - (save-match-data - (while (setq pos (string-match (concat "[^-" - muse-regexp-alnum - "/:._=@\\?~#%\"\\+<>()&;]") - str pos)) - (setq ch (aref str pos) - code (concat "&#" (int-to-string - (cond ((fboundp 'char-to-ucs) - (char-to-ucs ch)) - ((fboundp 'char-to-int) - (char-to-int ch)) - (t ch))) - ";") - len (length code) - str (concat (substring str 0 pos) - code - (when (< pos (length str)) - (substring str (1+ pos) nil))) - pos (+ len pos))) - str)))) - -(defun muse-xml-markup-anchor () - (unless (get-text-property (match-end 1) 'muse-link) - (let ((text (muse-markup-text 'anchor (match-string 2)))) - (save-match-data - (skip-chars-forward (concat muse-regexp-blank "\n")) - (when (looking-at (concat "<\\([^" muse-regexp-blank "/>\n]+\\)>")) - (goto-char (match-end 0))) - (muse-insert-markup text))) - (match-string 1))) - -(defun muse-xml-sort-table (table) - "Sort the given table structure so that it validates properly." - ;; Note that the decision matrix must have a nil diagonal, or else - ;; elements with the same type will be reversed with respect to each - ;; other. - (let ((decisions '((nil nil nil) ; body < header, body < footer - (t nil t) ; header stays where it is - (t nil nil)))) ; footer < header - (sort table #'(lambda (l r) - (and (integerp (car l)) (integerp (car r)) - (nth (1- (car r)) - (nth (1- (car l)) decisions))))))) - -(defun muse-xml-markup-table (&optional attributes) - "Publish the matched region into a table. -If a string ATTRIBUTES is given, pass it to the markup string begin-table." - (let* ((table-info (muse-publish-table-fields (match-beginning 0) - (match-end 0))) - (row-len (car table-info)) - (supports-group (not (string= (muse-markup-text 'begin-table-group - row-len) - ""))) - (field-list (muse-xml-sort-table (cdr table-info))) - last-part) - (when table-info - (let ((beg (point))) - (muse-publish-ensure-block beg)) - (muse-insert-markup (muse-markup-text 'begin-table (or attributes ""))) - (muse-insert-markup (muse-markup-text 'begin-table-group row-len)) - (dolist (fields field-list) - (let* ((type (car fields)) - (part (cond ((eq type 'hline) nil) - ((= type 1) "tbody") - ((= type 2) "thead") - ((= type 3) "tfoot"))) - (col (cond ((eq type 'hline) nil) - ((= type 1) "td") - ((= type 2) "th") - ((= type 3) "td")))) - (setq fields (cdr fields)) - (unless (and part last-part (string= part last-part)) - (when last-part - (muse-insert-markup " \n") - (when (eq type 'hline) - ;; horizontal separators are represented by closing - ;; the current table group and opening a new one - (muse-insert-markup (muse-markup-text 'end-table-group)) - (muse-insert-markup (muse-markup-text 'begin-table-group - row-len)))) - (when part - (muse-insert-markup " <" part ">\n")) - (setq last-part part)) - (unless (eq type 'hline) - (muse-insert-markup (muse-markup-text 'begin-table-row)) - (dolist (field fields) - (muse-insert-markup (muse-markup-text 'begin-table-entry col)) - (insert field) - (muse-insert-markup (muse-markup-text 'end-table-entry col))) - (muse-insert-markup (muse-markup-text 'end-table-row))))) - (when last-part - (muse-insert-markup " \n")) - (muse-insert-markup (muse-markup-text 'end-table-group)) - (muse-insert-markup (muse-markup-text 'end-table)) - (insert ?\n)))) - -(defun muse-xml-prepare-buffer () - (set (make-local-variable 'muse-publish-url-transforms) - (cons 'muse-xml-escape-string muse-publish-url-transforms))) - -(provide 'muse-xml-common) - -;;; muse-xml-common.el ends here diff --git a/elpa/muse-3.20/muse-xml.el b/elpa/muse-3.20/muse-xml.el deleted file mode 100644 index 9f26ade..0000000 --- a/elpa/muse-3.20/muse-xml.el +++ /dev/null @@ -1,274 +0,0 @@ -;;; muse-xml.el --- publish XML files - -;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; Author: Michael Olson -;; Date: Sat 23-Jul-2005 - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; James Clarke's nxml-mode can be used for editing and validating -;; Muse-generated XML files. If you are in nxml-mode use the command -;; C-c C-s C-f to point to the schema in `contrib/muse.rnc', which -;; comes with Muse. Say yes if you are asked if you want to copy the -;; file to your location. C-c C-s C-a can then be used to reload the -;; schema if you make changes to the file. - -;;; Contributors: - -;; Peter K. Lee (saint AT corenova DOT com) made the initial -;; implementation of planner-publish.el, which was heavily borrowed -;; from. - -;; Brad Collins (brad AT chenla DOT org) provided a Compact RelaxNG -;; schema. - -;;; Code: - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Muse XML Publishing -;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; - -(require 'muse-publish) -(require 'muse-regexps) -(require 'muse-xml-common) - -(defgroup muse-xml nil - "Options controlling the behavior of Muse XML publishing. -See `muse-xml' for more information." - :group 'muse-publish) - -(defcustom muse-xml-extension ".xml" - "Default file extension for publishing XML files." - :type 'string - :group 'muse-xml) - -(defcustom muse-xml-header - " - (muse-xml-encoding)\"?> - - - <lisp>(muse-publishing-directive \"title\")</lisp> - (muse-publishing-directive \"author\") - (muse-style-element :maintainer) - (muse-publishing-directive \"date\") - - \n" - "Header used for publishing XML files. -This may be text or a filename." - :type 'string - :group 'muse-xml) - -(defcustom muse-xml-footer " - -\n" - "Footer used for publishing XML files. -This may be text or a filename." - :type 'string - :group 'muse-xml) - -(defcustom muse-xml-markup-regexps - `(;; Beginning of doc, end of doc, or plain paragraph separator - (10000 ,(concat "\\(\\(\n\\(?:[" muse-regexp-blank "]*\n\\)*" - "\\([" muse-regexp-blank "]*\n\\)\\)" - "\\|\\`\\s-*\\|\\s-*\\'\\)") - ;; this is somewhat repetitive because we only require the - ;; line just before the paragraph beginning to be not - ;; read-only - 3 muse-xml-markup-paragraph)) - "List of markup rules for publishing a Muse page to XML. -For more on the structure of this list, see `muse-publish-markup-regexps'." - :type '(repeat (choice - (list :tag "Markup rule" - integer - (choice regexp symbol) - integer - (choice string function symbol)) - function)) - :group 'muse-xml) - -(defcustom muse-xml-markup-functions - '((anchor . muse-xml-markup-anchor) - (table . muse-xml-markup-table)) - "An alist of style types to custom functions for that kind of text. -For more on the structure of this list, see -`muse-publish-markup-functions'." - :type '(alist :key-type symbol :value-type function) - :group 'muse-xml) - -(defcustom muse-xml-markup-strings - '((image-with-desc . "%s") - (image . "") - (image-link . "%s.%s") - (anchor-ref . "%s") - (url . "%s") - (link . "%s") - (link-and-anchor . "%s") - (email-addr . "%s") - (anchor . "\n") - (emdash . "%s--%s") - (comment-begin . "") - (rule . "
    ") - (fn-sep . "
    \n") - (no-break-space . " ") - (line-break . "
    ") - (enddots . "....") - (dots . "...") - (section . "
    ") - (section-end . "") - (subsection . "
    ") - (subsection-end . "") - (subsubsection . "
    ") - (subsubsection-end . "") - (section-other . "
    ") - (section-other-end . "") - (section-close . "
    ") - (footnote . "") - (footnote-end . "") - (begin-underline . "") - (end-underline . "") - (begin-literal . "") - (end-literal . "") - (begin-emph . "") - (end-emph . "") - (begin-more-emph . "") - (end-more-emph . "") - (begin-most-emph . "") - (end-most-emph . "") - (begin-verse . "\n") - (begin-verse-line . "") - (end-verse-line . "") - (empty-verse-line . "") - (begin-last-stanza-line . "") - (end-last-stanza-line . "") - (end-verse . "") - (begin-example . "") - (end-example . "") - (begin-center . "

    \n") - (end-center . "\n

    ") - (begin-quote . "
    \n") - (end-quote . "\n
    ") - (begin-cite . "") - (begin-cite-author . "") - (begin-cite-year . "") - (end-cite . "") - (begin-quote-item . "

    ") - (end-quote-item . "

    ") - (begin-uli . "\n") - (end-uli . "\n") - (begin-uli-item . "") - (end-uli-item . "") - (begin-oli . "\n") - (end-oli . "\n") - (begin-oli-item . "") - (end-oli-item . "") - (begin-dl . "\n") - (end-dl . "\n") - (begin-dl-item . "\n") - (end-dl-item . "\n") - (begin-ddt . "") - (end-ddt . "") - (begin-dde . "") - (end-dde . "") - (begin-table . "\n") - (end-table . "") - (begin-table-row . " \n") - (end-table-row . " \n") - (begin-table-entry . " <%s>") - (end-table-entry . "\n")) - "Strings used for marking up text. -These cover the most basic kinds of markup, the handling of which -differs little between the various styles." - :type '(alist :key-type symbol :value-type string) - :group 'muse-xml) - -(defcustom muse-xml-encoding-default 'utf-8 - "The default Emacs buffer encoding to use in published files. -This will be used if no special characters are found." - :type 'symbol - :group 'muse-xml) - -(defcustom muse-xml-charset-default "utf-8" - "The default XML charset to use if no translation is -found in `muse-xml-encoding-map'." - :type 'string - :group 'muse-xml) - -(defun muse-xml-encoding () - (muse-xml-transform-content-type - (or (and (boundp 'buffer-file-coding-system) - buffer-file-coding-system) - muse-xml-encoding-default) - muse-xml-charset-default)) - -(defun muse-xml-markup-paragraph () - (let ((end (copy-marker (match-end 0) t))) - (goto-char (match-beginning 0)) - (when (save-excursion - (save-match-data - (and (not (get-text-property (max (point-min) (1- (point))) - 'muse-no-paragraph)) - (re-search-backward "<\\(/?\\)p[ >]" nil t) - (not (string-equal (match-string 1) "/"))))) - (when (get-text-property (1- (point)) 'muse-end-list) - (goto-char (previous-single-property-change (1- (point)) - 'muse-end-list))) - (muse-insert-markup "

    ")) - (goto-char end)) - (cond - ((eobp) - (unless (bolp) - (insert "\n"))) - ((get-text-property (point) 'muse-no-paragraph) - (forward-char 1) - nil) - ((eq (char-after) ?\<) - (when (looking-at (concat "<\\(format\\|code\\|link\\|image" - "\\|anchor\\|footnote\\)[ >]")) - (muse-insert-markup "

    "))) - (t - (muse-insert-markup "

    ")))) - -(defun muse-xml-finalize-buffer () - (when (boundp 'buffer-file-coding-system) - (when (memq buffer-file-coding-system '(no-conversion undecided-unix)) - ;; make it agree with the default charset - (setq buffer-file-coding-system muse-xml-encoding-default)))) - -;;; Register the Muse XML Publisher - -(muse-define-style "xml" - :suffix 'muse-xml-extension - :regexps 'muse-xml-markup-regexps - :functions 'muse-xml-markup-functions - :strings 'muse-xml-markup-strings - :specials 'muse-xml-decide-specials - :after 'muse-xml-finalize-buffer - :header 'muse-xml-header - :footer 'muse-xml-footer - :browser 'find-file) - -(provide 'muse-xml) - -;;; muse-xml.el ends here diff --git a/elpa/muse-3.20/muse.el b/elpa/muse-3.20/muse.el deleted file mode 100644 index 4d4a0b9..0000000 --- a/elpa/muse-3.20/muse.el +++ /dev/null @@ -1,881 +0,0 @@ -;;; muse.el --- an authoring and publishing tool for Emacs - -;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. - -;; Emacs Lisp Archive Entry -;; Filename: muse.el -;; Version: 3.20 -;; Date: Sun 31 Jan-2010 -;; Keywords: hypermedia -;; Author: John Wiegley -;; Maintainer: Michael Olson -;; Description: An authoring and publishing tool for Emacs -;; URL: http://mwolson.org/projects/EmacsMuse.html -;; Compatibility: Emacs21 XEmacs21 Emacs22 - -;; This file is part of Emacs Muse. It is not part of GNU Emacs. - -;; Emacs Muse is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published -;; by the Free Software Foundation; either version 3, or (at your -;; option) any later version. - -;; Emacs Muse 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 Emacs Muse; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -;; Boston, MA 02110-1301, USA. - -;;; Commentary: - -;; Muse is a tool for easily authoring and publishing documents. It -;; allows for rapid prototyping of hyperlinked text, which may then be -;; exported to multiple output formats -- such as HTML, LaTeX, -;; Texinfo, etc. - -;; The markup rules used by Muse are intended to be very friendly to -;; people familiar with Emacs. See the included manual for more -;; information. - -;;; Contributors: - -;;; Code: - -;; Indicate that this version of Muse supports nested tags -(provide 'muse-nested-tags) - -(defvar muse-version "3.20" - "The version of Muse currently loaded") - -(defun muse-version (&optional insert) - "Display the version of Muse that is currently loaded. -If INSERT is non-nil, insert the text instead of displaying it." - (interactive "P") - (if insert - (insert muse-version) - (message muse-version))) - -(defgroup muse nil - "Options controlling the behavior of Muse. -The markup used by Muse is intended to be very friendly to people -familiar with Emacs." - :group 'hypermedia) - -(defvar muse-under-windows-p (memq system-type '(ms-dos windows-nt))) - -(provide 'muse) - -(condition-case nil - (require 'derived) - (error nil)) -(require 'wid-edit) -(require 'muse-regexps) - -(defvar muse-update-values-hook nil - "Hook for values that are automatically generated. -This is to be used by add-on modules for Muse. -It is run just before colorizing or publishing a buffer.") - -(defun muse-update-values () - "Update various values that are automatically generated. - -Call this after changing `muse-project-alist'." - (interactive) - (run-hooks 'muse-update-values-hook) - (dolist (buffer (buffer-list)) - (when (buffer-live-p buffer) - (with-current-buffer buffer - (when (derived-mode-p 'muse-mode) - (and (boundp 'muse-current-project) - (fboundp 'muse-project-of-file) - (setq muse-current-project nil) - (setq muse-current-project (muse-project-of-file)))))))) - -;; Default file extension - -;; By default, use the .muse file extension. -;;;###autoload (add-to-list 'auto-mode-alist '("\\.muse\\'" . muse-mode-choose-mode)) - -;; We need to have this at top-level, as well, so that any Muse or -;; Planner documents opened during init will just work. -(add-to-list 'auto-mode-alist '("\\.muse\\'" . muse-mode-choose-mode)) - -(eval-when-compile - (defvar muse-ignored-extensions)) - -(defvar muse-ignored-extensions-regexp nil - "A regexp of extensions to omit from the ending of a Muse page name. -This is autogenerated from `muse-ignored-extensions'.") - -(defun muse-update-file-extension (sym val) - "Update the value of `muse-file-extension'." - (let ((old (and (boundp sym) (symbol-value sym)))) - (set sym val) - (when (and (featurep 'muse-mode) - (or (not (stringp val)) - (not (stringp old)) - (not (string= old val)))) - ;; remove old auto-mode-alist association - (when (and (boundp sym) (stringp old)) - (setq auto-mode-alist - (delete (cons (concat "\\." old "\\'") - 'muse-mode-choose-mode) - auto-mode-alist))) - ;; associate the new file extension with muse-mode - (when (stringp val) - (add-to-list 'auto-mode-alist - (cons (concat "\\." val "\\'") - 'muse-mode-choose-mode))) - ;; update the ignored extensions regexp - (when (fboundp 'muse-update-ignored-extensions-regexp) - (muse-update-ignored-extensions-regexp - 'muse-ignored-extensions muse-ignored-extensions))))) - -(defcustom muse-file-extension "muse" - "File extension of Muse files. Omit the period at the beginning. -If you don't want Muse files to have an extension, set this to nil." - :type '(choice - (const :tag "None" nil) - (string)) - :set 'muse-update-file-extension - :group 'muse) - -(defcustom muse-completing-read-function 'completing-read - "Function to call when prompting user to choose between a list of options. -This should take the same arguments as `completing-read'." - :type 'function - :group 'muse) - -(defun muse-update-ignored-extensions-regexp (sym val) - "Update the value of `muse-ignored-extensions-regexp'." - (set sym val) - (if val - (setq muse-ignored-extensions-regexp - (concat "\\.\\(" - (regexp-quote (or muse-file-extension "")) "\\|" - (mapconcat 'identity val "\\|") - "\\)\\'")) - (setq muse-ignored-extensions-regexp - (if muse-file-extension - (concat "\\.\\(" muse-file-extension "\\)\\'") - nil)))) - -(add-hook 'muse-update-values-hook - (lambda () - (muse-update-ignored-extensions-regexp - 'muse-ignored-extensions muse-ignored-extensions))) - -(defcustom muse-ignored-extensions '("bz2" "gz" "[Zz]") - "A list of extensions to omit from the ending of a Muse page name. -These are regexps. - -Don't put a period at the beginning of each extension unless you -understand that it is part of a regexp." - :type '(repeat (regexp :tag "Extension")) - :set 'muse-update-ignored-extensions-regexp - :group 'muse) - -(defun muse-update-file-extension-after-init () - ;; This is short, but it has to be a function, otherwise Emacs21 - ;; does not load it properly when running after-init-hook - (unless (string= muse-file-extension "muse") - (let ((val muse-file-extension) - (muse-file-extension "muse")) - (muse-update-file-extension 'muse-file-extension val)))) - -;; Once the user's init file has been processed, determine whether -;; they want a file extension -(add-hook 'after-init-hook 'muse-update-file-extension-after-init) - -;; URL protocols - -(require 'muse-protocols) - -;; Helper functions - -(defsubst muse-delete-file-if-exists (file) - (when (file-exists-p file) - (delete-file file) - (message "Removed %s" file))) - -(defsubst muse-time-less-p (t1 t2) - "Say whether time T1 is less than time T2." - (or (< (car t1) (car t2)) - (and (= (car t1) (car t2)) - (< (nth 1 t1) (nth 1 t2))))) - -(eval-when-compile - (defvar muse-publishing-current-file nil)) - -(defun muse-current-file () - "Return the name of the currently visited or published file." - (or (and (boundp 'muse-publishing-current-file) - muse-publishing-current-file) - (buffer-file-name) - (concat default-directory (buffer-name)))) - -(defun muse-page-name (&optional name) - "Return the canonical form of a Muse page name. - -What this means is that the directory part of NAME is removed, -and the file extensions in `muse-ignored-extensions' are also -removed from NAME." - (save-match-data - (unless (and name (not (string= name ""))) - (setq name (muse-current-file))) - (if name - (let ((page (file-name-nondirectory name))) - (if (and muse-ignored-extensions-regexp - (string-match muse-ignored-extensions-regexp page)) - (replace-match "" t t page) - page))))) - -(defun muse-display-warning (message) - "Display the given MESSAGE as a warning." - (if (fboundp 'display-warning) - (display-warning 'muse message - (if (featurep 'xemacs) - 'warning - :warning)) - (let ((buf (get-buffer-create "*Muse warnings*"))) - (with-current-buffer buf - (goto-char (point-max)) - (insert "Warning (muse): " message) - (unless (bolp) - (newline))) - (display-buffer buf) - (sit-for 0)))) - -(defun muse-eval-lisp (form) - "Evaluate the given form and return the result as a string." - (require 'pp) - (save-match-data - (condition-case err - (let ((object (eval (read form)))) - (cond - ((stringp object) object) - ((and (listp object) - (not (eq object nil))) - (let ((string (pp-to-string object))) - (substring string 0 (1- (length string))))) - ((numberp object) - (number-to-string object)) - ((eq object nil) "") - (t - (pp-to-string object)))) - (error - (muse-display-warning (format "%s: Error evaluating %s: %s" - (muse-page-name) form err)) - "; INVALID LISP CODE")))) - -(defmacro muse-with-temp-buffer (&rest body) - "Create a temporary buffer, and evaluate BODY there like `progn'. -See also `with-temp-file' and `with-output-to-string'. - -Unlike `with-temp-buffer', this will never attempt to save the -temp buffer. It is meant to be used along with -`insert-file-contents' or `muse-insert-file-contents'. - -The undo feature will be disabled in the new buffer. - -If `debug-on-error' is set to t, keep the buffer around for -debugging purposes rather than removing it." - (let ((temp-buffer (make-symbol "temp-buffer"))) - `(let ((,temp-buffer (generate-new-buffer " *muse-temp*"))) - (buffer-disable-undo ,temp-buffer) - (unwind-protect - (if debug-on-error - (with-current-buffer ,temp-buffer - ,@body) - (condition-case err - (with-current-buffer ,temp-buffer - ,@body) - (error - (if (and (boundp 'muse-batch-publishing-p) - muse-batch-publishing-p) - (progn - (message "%s: Error occured: %s" - (muse-page-name) err) - (backtrace)) - (muse-display-warning - (format (concat "An error occurred while publishing" - " %s:\n %s\n\nSet debug-on-error to" - " `t' if you would like a backtrace.") - (muse-page-name) err)))))) - (when (buffer-live-p ,temp-buffer) - (with-current-buffer ,temp-buffer - (set-buffer-modified-p nil)) - (unless debug-on-error (kill-buffer ,temp-buffer))))))) - -(put 'muse-with-temp-buffer 'lisp-indent-function 0) -(put 'muse-with-temp-buffer 'edebug-form-spec '(body)) - -(defun muse-insert-file-contents (filename &optional visit) - "Insert the contents of file FILENAME after point. -Do character code conversion and end-of-line conversion, but none -of the other unnecessary things like format decoding or -`find-file-hook'. - -If VISIT is non-nil, the buffer's visited filename -and last save file modtime are set, and it is marked unmodified. -If visiting and the file does not exist, visiting is completed -before the error is signaled." - (let ((format-alist nil) - (after-insert-file-functions nil) - (inhibit-file-name-handlers - (append '(jka-compr-handler image-file-handler epa-file-handler) - inhibit-file-name-handlers)) - (inhibit-file-name-operation 'insert-file-contents)) - (insert-file-contents filename visit))) - -(defun muse-write-file (filename &optional nomessage) - "Write current buffer into file FILENAME. -Unlike `write-file', this does not visit the file, try to back it -up, or interact with vc.el in any way. - -If the file was not written successfully, return nil. Otherwise, -return non-nil. - -If the NOMESSAGE argument is non-nil, suppress the \"Wrote file\" -message." - (when nomessage (setq nomessage 'nomessage)) - (let ((backup-inhibited t) - (buffer-file-name filename) - (buffer-file-truename (file-truename filename))) - (save-current-buffer - (save-restriction - (widen) - (if (not (file-writable-p buffer-file-name)) - (prog1 nil - (muse-display-warning - (format "Cannot write file %s:\n %s" buffer-file-name - (let ((dir (file-name-directory buffer-file-name))) - (if (not (file-directory-p dir)) - (if (file-exists-p dir) - (format "%s is not a directory" dir) - (format "No directory named %s exists" dir)) - (if (not (file-exists-p buffer-file-name)) - (format "Directory %s write-protected" dir) - "File is write-protected")))))) - (let ((coding-system-for-write - (or (and (boundp 'save-buffer-coding-system) - save-buffer-coding-system) - coding-system-for-write))) - (write-region (point-min) (point-max) buffer-file-name - nil nomessage)) - (when (boundp 'last-file-coding-system-used) - (when (boundp 'buffer-file-coding-system-explicit) - (setq buffer-file-coding-system-explicit - last-coding-system-used)) - (if save-buffer-coding-system - (setq save-buffer-coding-system last-coding-system-used) - (setq buffer-file-coding-system last-coding-system-used))) - t))))) - -(defun muse-collect-alist (list element &optional test) - "Collect items from LIST whose car is equal to ELEMENT. -If TEST is specified, use it to compare ELEMENT." - (unless test (setq test 'equal)) - (let ((items nil)) - (dolist (item list) - (when (funcall test element (car item)) - (setq items (cons item items)))) - items)) - -(defmacro muse-sort-with-closure (list predicate closure) - "Sort LIST, stably, comparing elements using PREDICATE. -Returns the sorted list. LIST is modified by side effects. -PREDICATE is called with two elements of list and CLOSURE. -PREDICATE should return non-nil if the first element should sort -before the second." - `(sort ,list (lambda (a b) (funcall ,predicate a b ,closure)))) - -(put 'muse-sort-with-closure 'lisp-indent-function 0) -(put 'muse-sort-with-closure 'edebug-form-spec '(form function-form form)) - -(defun muse-sort-by-rating (rated-list &optional test) - "Sort RATED-LIST according to the rating of each element. -The rating is stripped out in the returned list. -Default sorting is highest-first. - -If TEST if specified, use it to sort the list. The default test is '>." - (unless test (setq test '>)) - (mapcar (function cdr) - (muse-sort-with-closure - rated-list - (lambda (a b closure) - (let ((na (numberp (car a))) - (nb (numberp (car b)))) - (cond ((and na nb) (funcall closure (car a) (car b))) - (na (not nb)) - (t nil)))) - test))) - -(defun muse-escape-specials-in-string (specials string &optional reverse) - "Apply the transformations in SPECIALS to STRING. - -The transforms should form a fully reversible and non-ambiguous -syntax when STRING is parsed from left to right. - -If REVERSE is specified, reverse an already-escaped string." - (let ((rules (mapcar (lambda (rule) - (cons (regexp-quote (if reverse - (cdr rule) - (car rule))) - (if reverse (car rule) (cdr rule)))) - specials))) - (save-match-data - (with-temp-buffer - (insert string) - (goto-char (point-min)) - (while (not (eobp)) - (unless (catch 'found - (dolist (rule rules) - (when (looking-at (car rule)) - (replace-match (cdr rule) t t) - (throw 'found t)))) - (forward-char))) - (buffer-string))))) - -(defun muse-trim-whitespace (string) - "Return a version of STRING with no initial nor trailing whitespace." - (muse-replace-regexp-in-string - (concat "\\`[" muse-regexp-blank "]+\\|[" muse-regexp-blank "]+\\'") - "" string)) - -(defun muse-path-sans-extension (path) - "Return PATH sans final \"extension\". - -The extension, in a file name, is the part that follows the last `.', -except that a leading `.', if any, doesn't count. - -This differs from `file-name-sans-extension' in that it will -never modify the directory part of the path." - (concat (file-name-directory path) - (file-name-nondirectory (file-name-sans-extension path)))) - -;; The following code was extracted from cl - -(defun muse-const-expr-p (x) - (cond ((consp x) - (or (eq (car x) 'quote) - (and (memq (car x) '(function function*)) - (or (symbolp (nth 1 x)) - (and (eq (and (consp (nth 1 x)) - (car (nth 1 x))) 'lambda) 'func))))) - ((symbolp x) (and (memq x '(nil t)) t)) - (t t))) - -(put 'muse-assertion-failed 'error-conditions '(error)) -(put 'muse-assertion-failed 'error-message "Assertion failed") - -(defun muse-list* (arg &rest rest) - "Return a new list with specified args as elements, cons'd to last arg. -Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to -`(cons A (cons B (cons C D)))'." - (cond ((not rest) arg) - ((not (cdr rest)) (cons arg (car rest))) - (t (let* ((n (length rest)) - (copy (copy-sequence rest)) - (last (nthcdr (- n 2) copy))) - (setcdr last (car (cdr last))) - (cons arg copy))))) - -(defmacro muse-assert (form &optional show-args string &rest args) - "Verify that FORM returns non-nil; signal an error if not. -Second arg SHOW-ARGS means to include arguments of FORM in message. -Other args STRING and ARGS... are arguments to be passed to `error'. -They are not evaluated unless the assertion fails. If STRING is -omitted, a default message listing FORM itself is used." - (let ((sargs - (and show-args - (delq nil (mapcar - (function - (lambda (x) - (and (not (muse-const-expr-p x)) x))) - (cdr form)))))) - (list 'progn - (list 'or form - (if string - (muse-list* 'error string (append sargs args)) - (list 'signal '(quote muse-assertion-failed) - (muse-list* 'list (list 'quote form) sargs)))) - nil))) - -;; Compatibility functions - -(if (fboundp 'looking-back) - (defalias 'muse-looking-back 'looking-back) - (defun muse-looking-back (regexp &optional limit &rest ignored) - (save-excursion - (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t)))) - -(eval-and-compile - (if (fboundp 'line-end-position) - (defalias 'muse-line-end-position 'line-end-position) - (defun muse-line-end-position (&optional n) - (save-excursion (end-of-line n) (point)))) - - (if (fboundp 'line-beginning-position) - (defalias 'muse-line-beginning-position 'line-beginning-position) - (defun muse-line-beginning-position (&optional n) - (save-excursion (beginning-of-line n) (point)))) - - (if (fboundp 'match-string-no-properties) - (defalias 'muse-match-string-no-properties 'match-string-no-properties) - (defun muse-match-string-no-properties (num &optional string) - (match-string num string)))) - -(defun muse-replace-regexp-in-string (regexp replacement text &optional fixedcase literal) - "Replace REGEXP with REPLACEMENT in TEXT. - -Return a new string containing the replacements. - -If fourth arg FIXEDCASE is non-nil, do not alter case of replacement text. -If fifth arg LITERAL is non-nil, insert REPLACEMENT literally." - (cond - ((and (featurep 'xemacs) (fboundp 'replace-in-string)) - (and (fboundp 'replace-in-string) ; stupid byte-compiler warning - (replace-in-string text regexp replacement literal))) - ((fboundp 'replace-regexp-in-string) - (replace-regexp-in-string regexp replacement text fixedcase literal)) - (t (error (concat "Neither `replace-in-string' nor " - "`replace-regexp-in-string' was found"))))) - -(if (fboundp 'add-to-invisibility-spec) - (defalias 'muse-add-to-invisibility-spec 'add-to-invisibility-spec) - (defun muse-add-to-invisibility-spec (element) - "Add ELEMENT to `buffer-invisibility-spec'. -See documentation for `buffer-invisibility-spec' for the kind of elements -that can be added." - (if (eq buffer-invisibility-spec t) - (setq buffer-invisibility-spec (list t))) - (setq buffer-invisibility-spec - (cons element buffer-invisibility-spec)))) - -(if (fboundp 'read-directory-name) - (defalias 'muse-read-directory-name 'read-directory-name) - (defun muse-read-directory-name (prompt &optional dir default-dirname mustmatch initial) - "Read directory name - see `read-file-name' for details." - (unless dir - (setq dir default-directory)) - (read-file-name prompt dir (or default-dirname - (if initial (expand-file-name initial dir) - dir)) - mustmatch initial))) - -(defun muse-file-remote-p (file) - "Test whether FILE specifies a location on a remote system. -Return non-nil if the location is indeed remote. - -For example, the filename \"/user@host:/foo\" specifies a location -on the system \"/user@host:\"." - (cond ((fboundp 'file-remote-p) - (file-remote-p file)) - ((fboundp 'tramp-handle-file-remote-p) - (tramp-handle-file-remote-p file)) - ((and (boundp 'ange-ftp-name-format) - (string-match (car ange-ftp-name-format) file)) - t) - (t nil))) - -(if (fboundp 'delete-and-extract-region) - (defalias 'muse-delete-and-extract-region 'delete-and-extract-region) - (defun muse-delete-and-extract-region (start end) - "Delete the text between START and END and return it." - (prog1 (buffer-substring start end) - (delete-region start end)))) - -(if (fboundp 'delete-dups) - (defalias 'muse-delete-dups 'delete-dups) - (defun muse-delete-dups (list) - "Destructively remove `equal' duplicates from LIST. -Store the result in LIST and return it. LIST must be a proper list. -Of several `equal' occurrences of an element in LIST, the first -one is kept." - (let ((tail list)) - (while tail - (setcdr tail (delete (car tail) (cdr tail))) - (setq tail (cdr tail)))) - list)) - -;; Set face globally in a predictable fashion -(defun muse-copy-face (old new) - "Copy face OLD to NEW." - (if (featurep 'xemacs) - (copy-face old new 'all) - (copy-face old new))) - -;; 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-get-link (&optional target) - "Based on the match data, retrieve the link. -Use TARGET to get the string, if it is specified." - (muse-match-string-no-properties 1 target)) - -(defun muse-get-link-desc (&optional target) - "Based on the match data, retrieve the link description. -Use TARGET to get the string, if it is specified." - (muse-match-string-no-properties 2 target)) - -(defvar muse-link-specials - '(("[" . "%5B") - ("]" . "%5D") - ("%" . "%%")) - "Syntax used for escaping and unescaping links. -This allows brackets to occur in explicit links as long as you -use the standard Muse functions to create them.") - -(defun muse-link-escape (text) - "Escape characters in TEXT that conflict with the explicit link -regexp." - (when (stringp text) - (muse-escape-specials-in-string muse-link-specials text))) - -(defun muse-link-unescape (text) - "Un-escape characters in TEXT that conflict with the explicit -link regexp." - (when (stringp text) - (muse-escape-specials-in-string muse-link-specials text t))) - -(defun muse-handle-url (&optional string) - "If STRING or point has a URL, match and return it." - (if (if string (string-match muse-url-regexp string) - (looking-at muse-url-regexp)) - (match-string 0 string))) - -(defcustom muse-implicit-link-functions '(muse-handle-url) - "A list of functions to handle an implicit link. -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) - :group 'muse) - -(defun muse-handle-implicit-link (&optional link) - "Handle implicit links. If LINK is not specified, look at point. -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. - -This function modifies the match data so that match 0 is the -link. - -The match data is restored after each unsuccessful handler -function call. If LINK is specified, only restore at very end. - -This behavior is needed because the part of the buffer that -`muse-implicit-link-regexp' matches must be narrowed to the part -that is an accepted link." - (let ((funcs muse-implicit-link-functions) - (res nil) - (data (match-data t))) - (while funcs - (setq res (funcall (car funcs) link)) - (if res - (setq funcs nil) - (unless link (set-match-data data)) - (setq funcs (cdr funcs)))) - (when link (set-match-data data)) - res)) - -(defcustom muse-explicit-link-functions nil - "A list of functions to handle an explicit link. -An explicit link is one [[like][this]] or [[this]]." - :type 'hook - :group 'muse) - -(defun muse-handle-explicit-link (&optional link) - "Handle explicit links. If LINK is not specified, look at point. -An explicit link is one that looks [[like][this]] or [[this]]. - -The match data is preserved. If no handlers are able to process -LINK, return LINK (if specified) or the 1st match string. If -LINK is not specified, it is assumed that Muse has matched -against `muse-explicit-link-regexp' before calling this -function." - (let ((funcs muse-explicit-link-functions) - (res nil)) - (save-match-data - (while funcs - (setq res (funcall (car funcs) link)) - (if res - (setq funcs nil) - (setq funcs (cdr funcs))))) - (muse-link-unescape - (if res - res - (or link (muse-get-link)))))) - -;; Movement functions - -(defun muse-list-item-type (str) - "Determine the type of list given STR. -Returns either 'ul, 'ol, 'dl-term, 'dl-entry, or nil." - (save-match-data - (cond ((or (string= str "") - (< (length str) 2)) - nil) - ((string-match muse-dl-entry-regexp str) - 'dl-entry) - ((string-match muse-dl-term-regexp str) - 'dl-term) - ((string-match muse-ol-item-regexp str) - 'ol) - ((string-match muse-ul-item-regexp str) - 'ul) - (t nil)))) - -(defun muse-list-item-critical-point (&optional offset) - "Figure out where the important markup character for the -currently-matched list item is. - -If OFFSET is specified, it is the number of groupings outside of -the contents of `muse-list-item-regexp'." - (unless offset (setq offset 0)) - (if (match-end (+ offset 2)) - ;; at a definition list - (match-end (+ offset 2)) - ;; at a different kind of list - (match-beginning (+ offset 1)))) - -(defun muse-forward-paragraph (&optional pattern) - "Move forward safely by one paragraph, or according to PATTERN." - (when (get-text-property (point) 'muse-end-list) - (goto-char (next-single-property-change (point) 'muse-end-list))) - (setq pattern (if pattern - (concat "^\\(?:" pattern "\\|\n\\|\\'\\)") - "^\\s-*\\(\n\\|\\'\\)")) - (let ((next-list-end (or (next-single-property-change (point) 'muse-end-list) - (point-max)))) - (forward-line 1) - (if (re-search-forward pattern nil t) - (goto-char (match-beginning 0)) - (goto-char (point-max))) - (when (> (point) next-list-end) - (goto-char next-list-end)))) - -(defun muse-forward-list-item-1 (type empty-line indented-line) - "Determine whether a nested list item is after point." - (if (match-beginning 1) - ;; if we are given a dl entry, skip past everything on the same - ;; level, except for other dl entries - (and (eq type 'dl-entry) - (not (eq (char-after (match-beginning 2)) ?\:))) - ;; blank line encountered with no list item on the same - ;; level after it - (let ((beg (point))) - (forward-line 1) - (if (save-match-data - (and (looking-at indented-line) - (not (looking-at empty-line)))) - ;; found that this blank line is followed by some - ;; indentation, plus other text, so we'll keep - ;; going - t - (goto-char beg) - nil)))) - -(defun muse-forward-list-item (type indent &optional no-skip-nested) - "Move forward to the next item of TYPE. -Return non-nil if successful, nil otherwise. -The beginning indentation is given by INDENT. - -If NO-SKIP-NESTED is non-nil, do not skip past nested items. -Note that if you desire this behavior, you will also need to -provide a very liberal INDENT value, such as -\(concat \"[\" muse-regexp-blank \"]*\")." - (let* ((list-item (format muse-list-item-regexp indent)) - (empty-line (concat "^[" muse-regexp-blank "]*\n")) - (indented-line (concat "^" indent "[" muse-regexp-blank "]")) - (list-pattern (concat "\\(?:" empty-line "\\)?" - "\\(" list-item "\\)"))) - (while (progn - (muse-forward-paragraph list-pattern) - ;; make sure we don't go past boundary - (and (not (or (get-text-property (point) 'muse-end-list) - (>= (point) (point-max)))) - ;; move past markup that is part of another construct - (or (and (match-beginning 1) - (or (get-text-property - (muse-list-item-critical-point 1) 'muse-link) - (and (derived-mode-p 'muse-mode) - (get-text-property - (muse-list-item-critical-point 1) - 'face)))) - ;; skip nested items - (and (not no-skip-nested) - (muse-forward-list-item-1 type empty-line - indented-line)))))) - (cond ((or (get-text-property (point) 'muse-end-list) - (>= (point) (point-max))) - ;; at a list boundary, so stop - nil) - ((let ((str (when (match-beginning 2) - ;; get the entire line - (save-excursion - (goto-char (match-beginning 2)) - (buffer-substring (muse-line-beginning-position) - (muse-line-end-position)))))) - (and str (eq type (muse-list-item-type str)))) - ;; same type, so indicate that there are more items to be - ;; parsed - (goto-char (match-beginning 1))) - (t - (when (match-beginning 1) - (goto-char (match-beginning 1))) - ;; move to just before foreign list item markup - nil)))) - -(defun muse-goto-tag-end (tag nested) - "Move forward past the end of TAG. - -If NESTED is non-nil, look for other instances of this tag that -may be nested inside of this tag, and skip past them." - (if (not nested) - (search-forward (concat "") nil t) - (let ((nesting 1) - (tag-regexp (concat "\\(<\\(/?\\)" tag "\\([ >]\\)\\)")) - (match-found nil)) - (while (and (> nesting 0) - (setq match-found (re-search-forward tag-regexp nil t))) - ;; for the sake of font-locking code, skip matches in comments - (unless (get-text-property (match-beginning 0) 'muse-comment) - (if (string-equal (match-string 2) "/") - (and (string-equal (match-string 3) ">") - (setq nesting (1- nesting))) - (setq nesting (1+ nesting))))) - match-found))) - -;;; muse.el ends here diff --git a/elpa/muse-3.20/muse.info b/elpa/muse-3.20/muse.info deleted file mode 100644 index 28bd20d..0000000 --- a/elpa/muse-3.20/muse.info +++ /dev/null @@ -1,4656 +0,0 @@ -This is muse.info, produced by makeinfo version 4.13 from muse.texi. - -INFO-DIR-SECTION Emacs -START-INFO-DIR-ENTRY -* Muse: (muse). Authoring and publishing environment for Emacs. -END-INFO-DIR-ENTRY - - This manual is for Emacs Muse version 3.20. - - Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free -Software Foundation, Inc. - - Permission is granted to copy, distribute and/or modify this - document under the terms of the GNU Free Documentation License, - Version 1.2 or any later version published by the Free Software - Foundation; with no Invariant Sections, with the Front-Cover texts - being "A GNU Manual", and with the Back-Cover Texts as in (a) - below. A copy of the license is included in the section entitled - "GNU Free Documentation License" in this manual. - - (a) The FSF's Back-Cover Text is: "You have freedom to copy and - modify this GNU Manual, like GNU software. Copies published by - the Free Software Foundation raise funds for GNU development." - - This document is part of a collection distributed under the GNU - Free Documentation License. If you want to distribute this - document separately from the collection, you can do so by adding a - copy of the license to the document, as described in section 6 of - the license. - - All Emacs Lisp code contained in this document may be used, - distributed, and modified without restriction. - - -File: muse.info, Node: Top, Next: Preface, Prev: (dir), Up: (dir) - -Muse -**** - -This manual is for Emacs Muse version 3.20. - - Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free -Software Foundation, Inc. - - Permission is granted to copy, distribute and/or modify this - document under the terms of the GNU Free Documentation License, - Version 1.2 or any later version published by the Free Software - Foundation; with no Invariant Sections, with the Front-Cover texts - being "A GNU Manual", and with the Back-Cover Texts as in (a) - below. A copy of the license is included in the section entitled - "GNU Free Documentation License" in this manual. - - (a) The FSF's Back-Cover Text is: "You have freedom to copy and - modify this GNU Manual, like GNU software. Copies published by - the Free Software Foundation raise funds for GNU development." - - This document is part of a collection distributed under the GNU - Free Documentation License. If you want to distribute this - document separately from the collection, you can do so by adding a - copy of the license to the document, as described in section 6 of - the license. - - All Emacs Lisp code contained in this document may be used, - distributed, and modified without restriction. - -* Menu: - -* Preface:: About the documentation. -* Introduction:: What is Muse? -* Obtaining Muse:: How to get Muse releases and development - changes. -* Installation:: Compiling and installing Muse. -* Getting Started:: Setting up Muse and editing files. -* Projects:: Creating and managing Muse projects. -* Keystroke Summary:: Keys used in Muse mode. -* Markup Rules:: Rules for using markup. -* Publishing Styles:: Publishing various types of documents. -* Extending Muse:: Making your own publishing styles. -* Miscellaneous:: Miscellaneous add-ons, like a minor mode. -* Getting Help and Reporting Bugs:: -* History:: History of this document. -* Contributors:: Contributors to this documentation. -* GNU Free Documentation License:: The license for this documentation. -* Concept Index:: Search for terms. - - --- The Detailed Node Listing --- - -How to Get Muse Releases and Development Changes - -* Releases:: Released versions of Muse. -* Development:: Latest unreleased development changes. - -Getting Started - -* Loading Muse:: How to load Muse. -* Using Muse Mode:: How to edit files in Muse. -* Publishing Files Overview:: Publishing a single file or project. -* File Extensions:: Using a different file extension. - -Creating and Managing Muse Projects - -* Single Project:: A single-project example. -* Multiple Projects:: A multiple-project example. -* Projects and Subdirectories:: Publishing subdirectories in projects. -* Options for Projects:: Listing of available options for projects. - -Rules for Using Markup - -* Paragraphs:: Paragraphs: centering and quoting. -* Headings:: Levels of headings. -* Directives:: Directives at the beginning of a - document. -* Emphasizing Text:: Bold, italicized, and underlined text. -* Footnotes:: Making notes to be shown at the end. -* Verse:: Indicating poetic stanzas. -* Lists:: Lists of items. -* Tables:: Generation of data tables. -* Explicit Links:: Hyperlinks and email addresses with - descriptions. -* Implicit Links:: Bare URLs, WikiNames, and InterWiki - links. -* Images:: Publishing and displaying images. -* Horizontal Rules and Anchors:: Inserting a horizontal line or anchor. -* Embedded Lisp:: Evaluating Emacs Lisp code in documents - for extensibility. -* Citations:: Support for citing other resources. -* Comments:: Lines to omit from published output. -* Tag Summary:: Tags that Muse recognizes. - -Publishing Various Types of Documents - -* Blosxom:: Integrating Muse and pyblosxom.cgi. -* Book:: Publishing entries into a compilation. -* ConTeXt:: Publishing ConTeXt documents. -* DocBook:: Publishing in DocBook XML form. -* HTML:: Publishing in HTML or XHTML form. -* Ikiwiki:: Integrating with ikiwiki. -* Journal:: Keeping a journal or blog. -* LaTeX:: Publishing LaTeX documents. -* Poem:: Publish a poem to LaTeX or PDF. -* Texinfo:: Publish entries to Texinfo format or PDF. -* XML:: Publish entries to XML. - -Integrating Muse and pyblosxom.cgi - -* Blosxom Requirements:: Other tools needed for the Blosxom style. -* Blosxom Entries:: Format of a Blosxom entry and automation. -* Blosxom Options:: Blosxom styles and options provided. - -Making your own publishing styles - -* Markup Functions:: Specifying functions to mark up text. -* Markup Regexps:: Markup rules for publishing. -* Markup Strings:: Strings specific to a publishing style. -* Markup Tags:: Tag specifications for special markup. -* Style Elements:: Parameters used for defining styles. -* Deriving Styles:: Deriving a new style from an existing - one. - -Miscellaneous add-ons, like a minor mode - -* Muse List Edit Minor Mode:: Edit lists easily in other major modes. - - -File: muse.info, Node: Preface, Next: Introduction, Prev: Top, Up: Top - -1 About the documentation -************************* - -This document describes Muse, which was written by John Wiegley and is -now maintained by Michael Olson. Several versions of this manual are -available on-line. - - * PDF: http://mwolson.org/static/doc/muse.pdf - - * HTML (single file): http://mwolson.org/static/doc/muse.html - - * HTML (multiple files): http://mwolson.org/static/doc/muse/ - - -File: muse.info, Node: Introduction, Next: Obtaining Muse, Prev: Preface, Up: Top - -2 What is Muse? -*************** - -Emacs Muse (also known as "Muse" or "Emacs-Muse") is an authoring and -publishing environment for Emacs. It simplifies the process of writing -documents and publishing them to various output formats. - - Muse consists of two main parts: an enhanced text-mode for authoring -documents and navigating within Muse projects, and a set of publishing -styles for generating different kinds of output. - - What makes Muse distinct from other text-publishing systems is a -modular environment, with a rather simple core, in which "styles" are -derived from to create new styles. Much of Muse's overall -functionality is optional. For example, you can use the publisher -without the major-mode, or the mode without doing any publishing; or if -you don't load the Texinfo or LaTeX modules, those styles won't be -available. - - The Muse codebase is a departure from emacs-wiki.el version 2.44. The -code has been restructured and rewritten, especially its publishing -functions. The focus in this revision is on the authoring and -publishing aspects, and the "wikiness" has been removed as a default -behavior (available in the optional `muse-wiki' module). CamelCase -words are no longer special by default. - - One of the principal aims in the development of Muse is to make it -very easy to produce good-looking, standards-compliant documents. - - -File: muse.info, Node: Obtaining Muse, Next: Installation, Prev: Introduction, Up: Top - -3 How to Get Muse Releases and Development Changes -************************************************** - -* Menu: - -* Releases:: Released versions of Muse. -* Development:: Latest unreleased development changes. - - -File: muse.info, Node: Releases, Next: Development, Prev: Obtaining Muse, Up: Obtaining Muse - -3.1 Released versions of Muse -============================= - -Choose to install a release if you want to minimize risk. - - Errors are corrected in development first. User-visible changes -will be announced on the mailing list. *Note -Getting Help and Reporting Bugs::. - - Debian users can get Muse via apt-get. The `muse-el' package is -available both at Michael Olson's APT repository and the official Debian -repository. To make use of the former, add the following line to your -`/etc/apt/sources.list' file and run `apt-get install muse'. - - deb http://mwolson.org/debian/ ./ - - Ubuntu users can also get Muse via apt-get. The `muse-el' package -is available both at Michael Olson's APT repository and the official -Ubuntu repository. To make use of the former, add the following line to -your `/etc/apt/sources.list' file and run `apt-get install muse'. - - deb http://mwolson.org/ubuntu/ ./ - - The reason for making separate Debian and Ubuntu packages is that -this manual is under the GFDL, and Debian will not allow it to be -distributed in its main repository. Ubuntu, on the other hand, permits -this manual to be included with the `muse-el' package. - - Alternatively, you can download the latest release from -`http://download.gna.org/muse-el/' . - - -File: muse.info, Node: Development, Prev: Releases, Up: Obtaining Muse - -3.2 Latest unreleased development changes -========================================= - -Choose the development version if you want to live on the bleeding edge -of Muse development or try out new features before release. - - The git version control system allows you to keep up-to-date with the -latest changes to the development version of Muse. It also allows you -to contribute changes (via commits, if you are have developer access to -the repository, or via patches, otherwise). If you would like to -contribute to Muse development, it is highly recommended that you use -git. - - If you are new to git, you might find this tutorial helpful: -`http://www.kernel.org/pub/software/scm/git/docs/tutorial.html'. - - Downloading the Muse module with git and staying up-to-date involves -the following steps. - - 1. Install git. - - * Debian and Ubuntu: `apt-get install git-core'. - - * Windows: `http://git.or.cz/gitwiki/WindowsInstall'. - - * Other operating systems: download, compile, and install the - source from `http://www.kernel.org/pub/software/scm/git/', or - find a git package for your operating system. - - 2. Download the Muse development branch. - - If you have developer access to Muse, do: - - git clone ssh://repo.or.cz/srv/git/muse-el.git muse - - otherwise, do: - - git clone git://repo.or.cz/muse-el.git muse - - If you are behind a restrictive firewall, and do not have developer - access, then do the following instead: - - git clone http://repo.or.cz/r/muse-el.git muse - - 3. List upstream changes that are missing from your local copy. Do - this whenever you want to see whether new changes have been - committed to Muse. If you wish, you may skip this step and - proceed directly to the "update" step. - - # Change to the source directory you are interested in. - cd muse - - # Fetch new changes from the repository, but don't apply them yet - git fetch origin - - # Display log messages for the new changes - git log HEAD..origin - - "origin" is git's name for the location where you originally got - Muse from. You can change this location at any time by editing the - `.git/config' file in the directory where the Muse source was - placed. - - 4. Update to the latest version by pulling in any missing changes. - - cd muse - git pull origin - - git will show how many files changed, and will provide a visual - display for how many lines were changed in each file. - - - There are other ways to interact with the Muse repository. - - * Browse git repo: `http://repo.or.cz/w/muse-el.git' - - * Latest development snapshot: - `http://mwolson.org/static/dist/muse-latest.tar.gz' - - * Latest development snapshot (zip file): - `http://mwolson.org/static/dist/muse-latest.zip' - - The latest development snapshot can lag behind the git repo by as -much as 20 minutes, but never more than that. - -Becoming a Muse developer -------------------------- - -If you want commit access to the shared Muse repository, then register -an account at `http://repo.or.cz' (be sure to add an SSH key), and -contact the current maintainer at . It would be best -to send some patches to the mailing list -first, so that he knows that you know what you are doing. *Note -Getting Help and Reporting Bugs::, for instructions on subscribing to -the mailing list. - - You must also be willing to sign a copyright assignment for your -changes to Muse, since Muse is a GNU project. The current maintainer -will assist you in this process if you contact him. - - For information on committing changes to Muse and performing -development, please consult -`http://emacswiki.org/cgi-bin/wiki/MuseDevelopment'. - - -File: muse.info, Node: Installation, Next: Getting Started, Prev: Obtaining Muse, Up: Top - -4 Compiling and Installing Muse -******************************* - -Muse may be compiled and installed on your machine. - -Compilation ------------ - -This is an optional step, since Emacs Lisp source code does not -necessarily have to be byte-compiled. Byte-compilation may yield a very -slight speed increase. - - A working copy of Emacs or XEmacs is needed in order to compile Emacs -Muse. By default, the program that is installed with the name `emacs' -will be used. - - If you want to use the `xemacs' binary to perform the compilation, -you must copy `Makefile.defs.default' to `Makefile.defs' in the -top-level directory, and then edit `Makefile.defs' as follows. You can -put either a full path to an Emacs or XEmacs binary or just the command -name, as long as it is in the `PATH'. - - EMACS = xemacs - SITEFLAG = -no-site-file - # Edit the section as necessary - install_info = install-info --section "XEmacs 21.4" $(1).info \ - $(INFODIR)/dir || : - - Running `make' in the top-level directory should compile the Muse -source files in the `lisp' directory, and generate an autoloads file in -`lisp/muse-autoloads.el'. - -Installation ------------- - -Muse may be installed into your file hierarchy by doing the following. - - Copy `Makefile.defs.default' to `Makefile.defs' in the top-level -directory, if you haven't done so already. Then edit the -`Makefile.defs' file so that `ELISPDIR' points to where you want the -source and compiled Muse files to be installed and `INFODIR' indicates -where to put the Muse manual. You may use a combination of `DESTDIR' -and `PREFIX' to further determine where the installed files should be -placed. As mentioned earlier, you will want to edit `EMACS' and -`SITEFLAG' as shown in the Compilation section if you are using XEmacs. - - If you are installing Muse on a Debian or Ubuntu system, you might -want to change the value of `INSTALLINFO' as specified in -`Makefile.defs'. - - If you wish to install Muse to different locations than the defaults -specify, edit `Makefile.defs' accordingly. - - Run `make' as a normal user, if you haven't done so already. - - Run `make install' as the root user if you have chosen installation -locations that require root permissions. - -ELPA ----- - -For those used to installing software packages, there will be a `muse' -package available in the Emacs Lisp Package Archive (abbreviated -"ELPA") as of the 3.10 release of Muse. This package will be compiled -and installed automatically in a user-specific location. For more -information on ELPA, see `http://tromey.com/elpa/'. - - -File: muse.info, Node: Getting Started, Next: Projects, Prev: Installation, Up: Top - -5 Getting Started -***************** - -* Menu: - -* Loading Muse:: How to load Muse. -* Using Muse Mode:: How to edit files in Muse. -* Publishing Files Overview:: Publishing a single file or project. -* File Extensions:: Using a different file extension. - - -File: muse.info, Node: Loading Muse, Next: Using Muse Mode, Prev: Getting Started, Up: Getting Started - -5.1 How to Load Muse -==================== - -To use Muse, add the directory containing its files to your `load-path' -variable, in your `.emacs' file. Then, load in the authoring mode, and -the styles you wish to publish to. An example follows. - - (add-to-list 'load-path "") - - (require 'muse-mode) ; load authoring mode - - (require 'muse-html) ; load publishing styles I use - (require 'muse-latex) - (require 'muse-texinfo) - (require 'muse-docbook) - - (require 'muse-project) ; publish files in projects - - An easy way of seeing which settings are available and changing -settings is to use the Muse customization interface. To do this, type -`M-x customize-group muse RET'. Each of the options has its own -documentation. Options are grouped logically according to what effect -they have. - - -File: muse.info, Node: Using Muse Mode, Next: Publishing Files Overview, Prev: Loading Muse, Up: Getting Started - -5.2 How to Edit Files in Muse -============================= - -Muse Mode should automatically be activated when you visit a file with a -".muse" extension. One such file is `QuickStart.muse', which is -available in the `examples' directory of the Muse distribution. You -can tell that Muse Mode has been activated by checking for the text -"Muse" in your mode line. If Muse Mode has not been activated, you may -activate it by type `M-x muse-mode RET'. - - You will notice that Muse files are highlighted very simply. Links -are colored blue, headings are large and bold text, and tags -are colored in grey. - - There are several different ways to edit things like links, which -hide the underlying Muse markup. One way is to toggle font-locking off -by hitting `C-c C-l', which is also `M-x font-lock-mode', make changes, -and then hit `C-c C-l' again to toggle font-locking back on. Another -way is just to move into the text and edit it. Markup can also be -removed by normal deletion methods, though some side effects might -require a second deletion. - - For the particular case of editing links, it is easiest to move to -the link and do `C-c C-e', which is also `M-x muse-edit-link-at-point'. -This prompts you for the link and its description, using the previous -contents of the link as initial values. A link to another Muse file -may be created by hitting `C-c TAB l'. A link to a URL may be created -by hitting `C-c TAB u'. Links may be followed by hitting `RET' on them. - - If you want to add a new list item, this may by accomplished by -hitting `M-RET'. This will put a dash and some spaces on the screen. -The dash is the Muse markup that indicates a list item. It is also -possible to created "nested" lists with this command, by adjusting the -number of spaces in front of the dashes. If you have lists with long -lines, you can move to a list item and hit `M-q' to wrap it onto -multiple lines. - - -File: muse.info, Node: Publishing Files Overview, Next: File Extensions, Prev: Using Muse Mode, Up: Getting Started - -5.3 Publishing a Single File or Project -======================================= - -The command `M-x muse-project-publish-this-file' will publish the -current document to any available publishing style (a publishing style -is an output format, like HTML or Docbook), placing the output in the -current directory. If you are in Muse Mode, this command will be bound -to `C-c C-t'. If the file has been published recently, and its -contents have not changed, running `C-c C-t' again will not publish the -file. To force publishing in this case, do `C-u C-c C-t'. - - If you have set up projects and are visiting a file that is part of a -project, then `C-c C-t' will restrict the output formats to those which -are used by the project, and will automatically publish to the output -directory defined by the project. If you want to publish to a -different directory or use a different format, then use `C-c M-C-t', -which is also `M-x muse-publish-this-file'. - - If the currently opened file is part of a defined project in -`muse-project-alist', it (and the rest of the changed files in a -project) may be published using `C-c C-p'. - - -File: muse.info, Node: File Extensions, Prev: Publishing Files Overview, Up: Getting Started - -5.4 Using a Different File Extension -==================================== - -By default, Muse expects all project files to have the file extension -`.muse'. Files without this extension will not be associated with Muse -mode and will not be considered part of any project, even if they are -within a project directory. - - If you don't want to use `.muse', you can customize the extension by -setting the value of `muse-file-extension'. - - If you don't want to use any extension at all, and want Muse to -autodetect project files based on their location, then add the following -to your Muse settings file. - - (setq muse-file-extension nil - muse-mode-auto-p t) - - Note that if you chose to have `muse-file-extension' set to `nil', -you may have trouble if your `.emacs' file or other init scripts -attempt to visit a Muse file. (A very common example of this is if you -use Planner with Muse and run `(plan)' from your `.emacs'.) If you -wish to visit Muse files from your `.emacs', be sure to also add the -following additional code before any such visits happen: - - (add-hook 'find-file-hooks 'muse-mode-maybe) - - -File: muse.info, Node: Projects, Next: Keystroke Summary, Prev: Getting Started, Up: Top - -6 Creating and Managing Muse Projects -************************************* - -Often you will want to publish all the files within a directory to a -particular set of output styles automatically. To support, Muse allows -for the creation of "projects". - -* Menu: - -* Single Project:: A single-project example. -* Multiple Projects:: A multiple-project example. -* Projects and Subdirectories:: Publishing subdirectories in projects. -* Options for Projects:: Listing of available options for projects. - - -File: muse.info, Node: Single Project, Next: Multiple Projects, Prev: Projects, Up: Projects - -6.1 A Single-Project Example -============================ - -Here is a sample project, which may be defined in your `.emacs' file. - - (setq muse-project-alist - '(("Website" ("~/Pages" :default "index") - (:base "html" :path "~/public_html") - (:base "pdf" :path "~/public_html/pdf")))) - - The above defines a project named "website", whose files are located -in the directory `~/Pages'. The default page to visit is `index'. -When this project is published, each page will be output as HTML to the -directory `~/public_html', and as PDF to the directory -`~/public_html/pdf'. Within any project page, you may create a link to -other pages using the syntax `[[pagename]]'. - - If you would like to include only some files from a directory in a -Muse project, you may use a regexp in place of `~/Pages' in the example. - - -File: muse.info, Node: Multiple Projects, Next: Projects and Subdirectories, Prev: Single Project, Up: Projects - -6.2 A Multiple-Project Example -============================== - -It is possible to specify multiple projects. Here is an example of -three projects: a generic website, a projects area, and a day-planner -(the day-planner part requires Planner Mode--see -`http://wjsullivan.net/PlannerMode.html' to get it). - - (setq muse-project-alist - '(("Website" ("~/Pages" :default "index") - (:base "html" :path "~/public_html")) - (("Projects" ("~/Projects" :default "index") - (:base "xhtml" - :path "~/public_html/projects" - :exclude "/TopSecret") - (:base "pdf" - :path "~/public_html/projects/pdf" - :exclude "/TopSecret"))) - ("Plans" ("~/Plans" - :default "TaskPool" - :major-mode planner-mode - :visit-link planner-visit-link) - (:base "planner-xhtml" - :path "~/public_html/plans")))) - - The `:major-mode' attribute specifies which major to use when -visiting files in this directory. - - The `:visit-link' attribute specifies the function to call when -visiting links. - - The `:exclude' attribute has a regexp that matches files to never -publish. - - -File: muse.info, Node: Projects and Subdirectories, Next: Options for Projects, Prev: Multiple Projects, Up: Projects - -6.3 Publishing Subdirectories in Projects -========================================= - -If you want to publish a directory and all of its subdirectories, Muse -provides two convenience functions that together generate the proper -rules for you. Note that we use the backtick to begin this -muse-project-alist definition, rather than a single quote. - - (setq muse-project-alist - `(("Website" ("~/Pages" :default "index") - (:base "html" :path "~/public_html")) - ("Blog" (,@(muse-project-alist-dirs "~/Blog") - :default "index") - ;; Publish this directory and its subdirectories. Arguments - ;; are as follows. The above `muse-project-alist-dirs' part - ;; is also needed. - ;; 1. Source directory - ;; 2. Output directory - ;; 3. Publishing style - ;; remainder: Other things to put in every generated style - ,@(muse-project-alist-styles "~/Blog" - "~/public_html/blog" - "blosxom")))) - - The `muse-project-alist-dirs' function takes a directory and returns -it and all of its subdirectories in a list. - - The `muse-project-alist-styles' function is explained by the -comments above. - - The "blosxom" text is the name of another publishing style, much like -"html". *Note Blosxom::, for further information about it. You can -use any publishing style you like for the third argument to -`muse-project-alist-styles'. - - -File: muse.info, Node: Options for Projects, Prev: Projects and Subdirectories, Up: Projects - -6.4 Listing of Available Options for Projects -============================================= - -This is a listing of all of the various options (or, more accurately: -attributes) that may be specified in `muse-project-alist'. - - Each muse-project-alist entry looks like this: - - (PROJECT-NAME (SOURCES) - OUTPUTS) - - We refer to these names below. - - "Attributes", which compose SOURCES and OUTPUTS, are a pair of -values. The first value is a keyword, like `:default'. The second part -is the value associated with that keyword, such as the text "index". -If you are familiar with Emacs Lisp property lists, the concept is -similar to that, except that in the SOURCES section, single directories -can be interspersed with two-value attributes. - -Project Name ------------- - -This is a string that indicates the name of the project. It is -primarily used for publishing interwiki links with the `muse-wiki.el' -module. - -Sources -------- - -This part of a muse-project-alist entry consists of two-value -attributes, and also directory names. If you are publishing a book, the -order of directories and attributes is significant. - - The minimal content for the sources section is a list of directories. - -`:book-chapter' - Indicates a new chapter of a book. The text of the title of the - chapter comes immediately after this keyword. - -`:book-end' - Indicates the end of a book. Directories listed after this one are - ignored when publishing a book. The value "t" (without quotes) - should come immediately after this keyword. - -`:book-funcall' - A function to call while publishing a book. This is useful for - doing something just after a particular chapter. - -`:book-part' - Indicates the beginning of a new part of the book. The text of the - title should come immediately after this keyword. - -`:book-style' - Indicate a particular publishing style to use for this part of the - book. If this is specified, it should come just after a `:part' - attribute. - -`:default' - The default page to visit when browsing a project. Also, if you - are using the `muse-wiki.el' module, publishing a link to just a - project's name will cause it to link to this default file. - -`:force-publish' - This specifies a list of pages which should be published every - time a project is published (by using `C-c C-p', for example), - regardless of whether their contents have changed. This is useful - for updating Index pages, pages that use the tag, and - other pages that have dynamically-generated content. - -`:major-mode' - This specifies the major mode to use when visiting files in this - project. The default is `muse-mode'. - -`:nochapters' - This indicates that while publishing a book, do not automatically - create chapters. Values which may follow this are nil (the - default, which means that we automatically create chapters), or - non-nil, which means that we manually specify chapters with the - `:book-chapter' attribute, - -`:publish-project' - Indicates which function we should call when publishing a project. - -`:set' - This specifies a list of variables and values to set when - publishing a project. The list should be a property list, which - is in the form: - - (VAR1 VALUE1 VAR2 VALUE2 ...) - -`:visit-link' - Specifies the function to call when visiting a link. The default - is `muse-visit-link-default'. The arguments for that function - should be (1) the link and (2) whether to visit the link in a new - window. - - -Outputs -------- - -This part of a muse-project-alist entry is composed of lists of -attributes. Each list is called an "output style". - - The minimal content for an output style is a `:base' attribute and a -`:path' attribute. - -`:base' - Publishing style to use, such as "html", "docbook", or "pdf". - -`:base-url' - An external URL which can be used to access published files. This - is mainly used by the `muse-wiki' module when publishing links - between two separate projects, if the projects are served on - different domains. - - It is also used by the `muse-journal' module to create the RSS or - RDF output. - -`:exclude' - Exclude items matching a regexp from being published. The regexp - should usually begin with "/". - -`:include' - Only include items matching a regexp when publishing. The regexp - should usually begin with "/". - -`:path' - The directory in which to store published files. - -`:timestamps' - A file containing the timestamps (that is, time of creation) for - files in this project. It might eventually used by the - `muse-blosxom' module, but this option is not currently in use by - any Muse code. - - - -File: muse.info, Node: Keystroke Summary, Next: Markup Rules, Prev: Projects, Up: Top - -7 Keys Used in Muse Mode -************************ - -This is a summary of keystrokes available in every Muse buffer. - -`C-c C-a (`muse-index')' - Display an index of all known Muse pages. - -`C-c C-b (`muse-find-backlinks')' - Find all pages that link to this page. - -`C-c C-e (`muse-edit-link-at-point')' - Edit link at point. - -`C-c C-f (`muse-project-find-file')' - Open another Muse page. Prompt for the name. - -`C-c C-i l, C-c TAB l (`muse-insert-relative-link-to-file')' - Insert a link to a file interactively. - -`C-c C-i t, C-c TAB t (`muse-insert-tag')' - Insert a tag interactively. - -`C-c C-i u, C-c TAB u (`muse-insert-url')' - Insert a URL interactively. - -`C-c C-l (`font-lock-mode')' - Toggle font lock / highlighting for the current buffer. - -`C-c C-p (`muse-project-publish')' - Publish any Muse pages that have changed. - -`C-c C-s (`muse-search')' - Find text in all files of the current project. - -`C-c C-t (`muse-project-publish-this-file')' - Publish the currently-visited file. Prompt for the style if the - current file can be published using more than one style. - -`C-c C-S-t, or C-c C-M-t (`muse-publish-this-file')' - Publish the currently-visited file. Prompt for both the style and - output directory. - -`C-c C-v (`muse-browse-result')' - Show the published result of this page. - -`C-c = (`muse-what-changed')' - Diff this page against the last backup version. - -`TAB' - Move to the next Wiki reference. - -`S-TAB' - Move to the previous Wiki reference. - -`M-TAB' - Complete the name of a page from the current project at point. - -`M-RET' - Insert a new list item at point, indenting properly. - -`C-<' - Decrease the indentation of the list item at point. - -`C->' - Increase the indentation of the list item at point. - -`M-x muse-colors-toggle-inline-images RET' - Toggle display of inlined images on/off. - -`M-x muse-update-values RET' - Update various values that are automatically generated. - - Call this after changing `muse-project-alist'. - - -File: muse.info, Node: Markup Rules, Next: Publishing Styles, Prev: Keystroke Summary, Up: Top - -8 Rules for Using Markup -************************ - -A Muse document uses special, contextual markup rules to determine how -to format the output result. For example, if a paragraph is indented, -Muse assumes it should be quoted. - - There are not too many markup rules, and all of them strive to be as -simple as possible so that you can focus on document creation, rather -than formatting. - -* Menu: - -* Paragraphs:: Paragraphs: centering and quoting. -* Headings:: Levels of headings. -* Directives:: Directives at the beginning of a - document. -* Emphasizing Text:: Bold, italicized, and underlined text. -* Footnotes:: Making notes to be shown at the end. -* Verse:: Indicating poetic stanzas. -* Lists:: Lists of items. -* Tables:: Generation of data tables. -* Explicit Links:: Hyperlinks and email addresses with - descriptions. -* Implicit Links:: Bare URLs, WikiNames, and InterWiki - links. -* Images:: Publishing and displaying images. -* Horizontal Rules and Anchors:: Inserting a horizontal line or anchor. -* Embedded Lisp:: Evaluating Emacs Lisp code in documents - for extensibility. -* Citations:: Support for citing other resources. -* Comments:: Lines to omit from published output. -* Tag Summary:: Tags that Muse recognizes. - - -File: muse.info, Node: Paragraphs, Next: Headings, Prev: Markup Rules, Up: Markup Rules - -8.1 Paragraphs: centering and quoting -===================================== - -Paragraphs in Muse must be separated by a blank line. - -Centered paragraphs and quotations ----------------------------------- - -A line that begins with six or more columns of whitespace (either tabs -or spaces) indicates a centered paragraph. Alternatively, you can use -the

    tag to surround regions that are to be published as -centered paragraphs. - - But if a line begins with whitespace, though less than six columns, -it indicates a quoted paragraph. Alternatively, you can use the - tag to surround regions that are to be published as quoted -paragraphs. - -Literal paragraphs ------------------- - -The tag is used for examples, where whitespace should be -preserved, the text rendered in monospace, and any characters special -to the output style escaped. - - There is also the tag, which causes a marked block to be -entirely left alone. This can be used for inserting a hand-coded HTML -blocks into HTML output, for example. - - If you want some text to only be inserted when publishing to a -particular publishing style, use the `style' attribute for the - tag. An example follows. - - - A LaTeX-based style was used in the publishing of this document. - - - This will leave the region alone if the current publishing style is -"latex" or based on "latex", such as "pdf", and delete the region -otherwise. It is also possible to leave the text alone only for one -particular style, rather than its derivations, by adding `exact="t"' to -the tag. - -Line breaks ------------ - -If you need a line break, then use the `
    ' tag. Most of the time -this tag is unnecessary, because Muse will automatically detect -paragraphs by means of blank lines. If you want to preserve newlines in -several lines of text, then use verse markup instead (*note Verse::). - - -File: muse.info, Node: Headings, Next: Directives, Prev: Paragraphs, Up: Markup Rules - -8.2 Levels of headings -====================== - -A heading becomes a chapter or section in printed output - depending on -the style. To indicate a heading, start a new paragraph with one or -more asterices, followed by a space and the heading title. Then begin -another paragraph to enter the text for that section. - - All levels of headings will be published. Most publishing styles -only distinguish the between the first 4 levels, however. - - * First level - - ** Second level - - *** Third level - - **** Fourth level - - -File: muse.info, Node: Directives, Next: Emphasizing Text, Prev: Headings, Up: Markup Rules - -8.3 Directives at the beginning of a document -============================================= - -Directives are lines beginning with the `#' character that come before -any paragraphs or sections in the document. Directives are of the form -"#directive content of directive". You can use any combination of -uppercase and lowercase letters for directives, even if the directive -is not in the list below. - - The `muse-publishing-directive' function may be used in header and -footer text to access directives. For example, to access the `#title' -directive, use `(muse-publishing-directive "title")'. - - The following is a list of directives that Muse uses. - -`#author' - The author of this document. - - If this is not specified, Muse will attempt to figure it out from - the `user-full-name' variable. - -`#date' - The date that the document was last modified. - - This is used by publishing styles that are able to embed the date - information. - -`#desc' - A short description of this document. - - This is used by the `journal' publishing style to embed information - inside of an RSS/RDF feed. - -`#title' - The title of this document. - - If this is not specified, the name of the file is used. - - - -File: muse.info, Node: Emphasizing Text, Next: Footnotes, Prev: Directives, Up: Markup Rules - -8.4 Bold, italicized, and underlined text -========================================= - -To emphasize text, surround it with certain specially recognized -characters. - - *emphasis* - **strong emphasis** - ***very strong emphasis*** - _underlined_ - =verbatim and monospace= - - While editing a Muse document in Muse mode, these forms of emphasis -will be highlighted in a WYSIWYG manner. Each of these forms may span -multiple lines. - - Verbatim text will be colored as gray by default. To change this, -customize `muse-verbatim-face'. - - You can also use the tag to indicate verbatim and monospace -text. This is handy for regions that have an "=" in them. - - -File: muse.info, Node: Footnotes, Next: Verse, Prev: Emphasizing Text, Up: Markup Rules - -8.5 Making notes to be shown at the end -======================================= - -A footnote reference is simply a number in square brackets. To define -the footnote, place this definition at the bottom of your file. -`footnote-mode' can be used to greatly facilitate the creation of these -kinds of footnotes. - - Footnotes are defined by the same number in brackets occurring at the -beginning of a line. Use footnote-mode's `C-c ! a' command, to very -easily insert footnotes while typing. Use `C-x C-x' to return to the -point of insertion. - - -File: muse.info, Node: Verse, Next: Lists, Prev: Footnotes, Up: Markup Rules - -8.6 Indicating poetic stanzas -============================= - -Poetry requires that whitespace be preserved, but without resorting to -monospace. To indicate this, use the following markup, reminiscent of -email quotations. - - > A line of Emacs verse; - > forgive its being so terse. - - You can also use the tag, if you prefer. - - - A line of Emacs verse; - forgive its being so terse. - - - Multiple stanzas may be included in one set of tags, as -follows. - - - A line of Emacs verse; - forgive its being so terse. - - In terms of terse verse, - you could do worse. - - - -File: muse.info, Node: Lists, Next: Tables, Prev: Verse, Up: Markup Rules - -8.7 Lists of items -================== - -Lists are given using special characters at the beginning of a line. -Whitespace must occur before bullets or numbered items, to distinguish -from the possibility of those characters occurring in a real sentence. - - These are rendered as a bullet list. - - Normal text. - - - bullet item one - - bullet item two - - An enumerated list follows. - - Normal text. - - 1. Enum item one - 2. Enum item two - - Here is a definition list. - - Term1 :: - This is a first definition - And it has two lines; - no, make that three. - - Term2 :: This is a second definition - -Nested lists ------------- - -It is possible to nest lists of the same or different kinds. The -"level" of the list is determined by the amount of initial whitespace. - - Normal text. - - - Level 1, bullet item one - 1. Level 2, enum item one - 2. Level 2, enum item two - - Level 1, bullet item two - 1. Level 2, enum item three - 2. Level 2, enum item four - term :: definition - -Breaking list items -------------------- - -If you want to break up a line within any list type, just put one blank -line between the end of the previous line and the beginning of the next -line, using the same amount of initial indentation. - - - bullet item 1, line 1 - - bullet item 1, line 2 - - 1. Enum line 1 - - Enum line 2 - - - bullet item 2, line 1 - - bullet item 2, line 2 - - -File: muse.info, Node: Tables, Next: Explicit Links, Prev: Lists, Up: Markup Rules - -8.8 Generation of data tables -============================= - -Only very simple tables are supported. The syntax is as follows. - - Double bars || Separate header fields - - Single bars | Separate body fields - Here are more | body fields - - Triple bars ||| Separate footer fields - - Some publishing styles require header fields to come first, then -footer fields, and then the body fields. You can use any order for -these sections that you like, and Muse will re-order them for you at -publish-time. - - If you wish to disable table generation for one Muse file, add the -directive `#disable-tables t' to the top of the file. - -Other table formats -------------------- - -It is possible to publish very basic Orgtbl-mode style tables. - - | org | style | table | - |------+-------+-------| - | one | | one | - | two | two | | - | | three | three | - |------+-------+-------| - | more | stuff | | - - If you are used to the way that Org Mode publishes these tables, then -customize `muse-html-table-attributes' to the following, in order to get -a similar kind of output. - - border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides" - - `table.el' style tables are also supported, as long as `table.el' -itself supports outputting tables for a particular publishing style. -At the time of this writing, the "html", "latex", and "docbook" styles -are supported by `table.el'. Styles derived from these styles will -also work. - - +---+-----+---+ - | | one | 1 | - +---+-----+---+ - | b | two | | - +---+-----+---+ - | c | | 3 | - +---+-----+---+ - - -File: muse.info, Node: Explicit Links, Next: Implicit Links, Prev: Tables, Up: Markup Rules - -8.9 Hyperlinks and email addresses with descriptions -==================================================== - -A hyperlink can reference a URL, or another page within a Muse project. -In addition, descriptive text can be specified, which should be -displayed rather than the link text in output styles that supports link -descriptions. The syntax is as follows. - - [[link target][link description]] - [[link target without description]] - - Thus, the current maintainer's homepage for Muse can be found -`[[http://mwolson.org/projects/EmacsMuse.html][here]]', or at -`[[http://mwolson.org/projects/EmacsMuse.html]]'. - - -File: muse.info, Node: Implicit Links, Next: Images, Prev: Explicit Links, Up: Markup Rules - -8.10 Bare URLs, WikiNames, and InterWiki links -============================================== - -A URL or email address encountered in the input text is published as a -hyperlink. These kind of links are called "implicit links" because -they are not separated from the rest of the Muse document in any way. - - Some characters in URLs will prevent Muse from recognizing them as -implicit links. If you want to link to a URL containing spaces or any of -the characters "][,"'`()<>^", you will have to make the link explicit. -The punctuation characters ".,;:" are also not recognized as part of a -URL when they appear at its end. For information on how to make an -explicit link, see *note Hyperlinks and email addresses with -descriptions: Explicit Links. - - If the `muse-wiki' module is loaded, another form of implicit link -will be made available. WikiNames, which are typed in CamelCase, are -highlighted and published as links, provided that the file they refer -to exists. - - Customization of WikiName recognition may be accomplished by editing -the `muse-wiki-wikiword-regexp' option and subsequently running -`(muse-configure-highlighting 'muse-colors-markupmuse-colors-markup)'. -If you use the Customize interface, the latter will be done -automatically. - - The `muse-wiki' module also allows for InterWiki links. These are -similar to WikiWords, but they specify both the project and page of a -file. The names of your project entries in `muse-project-alist' will -be used as InterWiki names by default. Several examples follow. - - Blog::DocumentingMuse - Projects#EmacsMuse - Website - - In the first case, the interwiki delimiter is `::', `Blog' is the -project name, and `DocumentingMuse' is the page name. In the second -example, `#' is the interwiki delimiter. If the name of a project -occurs by itself in text, like the third case, it will be colorized and -published as a link to the default page of the given project. - - Customization of interwiki links may be accomplished by editing the -`muse-wiki-interwiki-alist' option. - - It is also possible to link to an anchor in an interwiki document. -This is called a "three-part link". Examples of this follow. - - Blog::DocumentingMuse#anchor1 - Projects#EmacsMuse#anchor2 - - -File: muse.info, Node: Images, Next: Horizontal Rules and Anchors, Prev: Implicit Links, Up: Markup Rules - -8.11 Publishing and displaying images -===================================== - -Image links ------------ - -Links to images may be used in either the target or the description, or -both. Thus, the following code will publish as a clickable image that -points to `http://mwolson.org/'. - - [[http://mwolson.org/][/static/logos/site-logo.png]] - - Normally, images in the link part will be inlined. - - If you want these images to be published as links instead, place the -text "URL:" immediately in front of the link text. An example follows. - - [[URL:http://mwolson.org/static/logos/site-logo.png]] - -Displaying images in Muse mode ------------------------------- - -If a link to a locally-available image is encountered in the link -description, Muse mode will attempt to display it if your version of -Emacs permits this. - - This behavior may be toggled with `C-c C-i', or disabled permanently -by setting the `muse-colors-inline-images' option to `nil'. - - The method for finding images may be altered by customizing the -`muse-colors-inline-image-method' option. One useful value for this -option is `muse-colors-use-publishing-directory', which tells Muse mode -to look in the directory where the current file will be published. The -default is to look in the current directory. Relative paths like -`../pics/' should work for either setting. - - Eventually, it is hoped that Muse will be able to copy images from -the a "source" directory to a publishing directory by customizing -`muse-project-alist', but this has not been implemented yet. - -Publishing simple images ------------------------- - -The following example will display correctly and publish correctly if a -PNG file called `TestLogo.png' exists in the `../pics/' directory. If -text is on the same line as the picture, it will remain so in the -output. - - [[../myimage.png]] - -Publishing images with captions -------------------------------- - -If you want to add a caption to an image, use the following syntax. -This will center the image (if the output format supports it) and add a -centered caption below the picture. Formats that do not support -centering the image will instead leave it against the left margin. - - [[../pics/mycat.png][My cat Dexter]] - - Images with captions may only occur in their own paragraphs, with no -text on the same line. Otherwise, the published output will not be -syntactically correct. - - -File: muse.info, Node: Horizontal Rules and Anchors, Next: Embedded Lisp, Prev: Images, Up: Markup Rules - -8.12 Inserting a horizontal line or anchor -========================================== - -Horizontal Rules ----------------- - -Four or more dashes indicate a horizontal rule. Be sure to put blank -lines around it, or it will be considered part of the proceeding or -following paragraph! - -Anchors -------- - -If you begin a line with "#anchor" - where "anchor" can be any word -that doesn't contain whitespace - it defines an anchor at that point -into the document. This point can be referenced using "page#anchor" as -the target in a Muse link. - - -File: muse.info, Node: Embedded Lisp, Next: Citations, Prev: Horizontal Rules and Anchors, Up: Markup Rules - -8.13 Evaluating Emacs Lisp code in documents for extensibility -============================================================== - -Arbitrary kinds of markup can be achieved using the tag. With -the tag, you may generate whatever output text you wish. The -inserted output will get marked up if the tag appears within the -main text of the document. - - (concat "This form gets " "inserted") - - Note that you should not use the `insert' command within a set of - tags, since the return value from the tags will be -automatically inserted into the document. - - It is also possible to treat the output as if it were surrounded by -the , , or tags, by specifying "example", "src", -or "verse" as the `markup' attribute of the tag. - - - (concat "Insert" " me") - - - Other languages also have tags that cause source code to be -evaluated. *Note Tag Summary::, for details. - - -File: muse.info, Node: Citations, Next: Comments, Prev: Embedded Lisp, Up: Markup Rules - -8.14 Support for citing other resources -======================================= - -Example -------- - -Here is an example of what citations look like in a Muse document. - - #bibsource REFDB - - * Title - ** Subtitle - - Some text before Miller1999 and after the citation. - - This is an author-only citation Miller1999. - - And this is a year-only citation Miller1999. - - Finally, this is a multi-head citation - Miller1999,Andrews2005. - -Overview --------- - -The `#bibsource' directive defines the source of the bibliographies. -The following sources are possible. - - * DocBook + RefDB: the string "REFDB" - - * LaTeX + bibtex: the name of an appropriate bibtex file - - * LaTeX + RefDB: if the input file is called "foo.muse", then set - this to "foo.bib" - - Citations are encoded as elements which enclose the citation -keys as they are defined in the bibliography file or database. In -multi-head citations, the citation keys have to be separated by colons -or semicolons. The `latex' and `docbook' styles translate these to the -proper separator automatically. - - The elements take an optional "type" attribute that defines -how the citation is rendered. If the attribute is missing, you'll get -a regular citation according to the bibliography style, e.g." (Miller -et al., 1999)". If the attribute is set to "author", only the name of -the author(s) will be rendered. Accordingly, "year" will cause the -year to be printed. This is useful to create citations like this: - - Miller et al. had already shown in a previous publication (1999) that - this is not going to work. - - Remember that refdb-mode (the Emacs interface to RefDB) can retrieve -references by simply marking the citation key and running the -`refdb-getref-by-field-on-region' command. Later versions of -`refdb-mode' will also allow to insert references as Muse citations -(which is already implemented for DocBook, TEI, and LaTeX documents). - - You may have noticed that there is no element to indicate the -position of the bibliography. The latter is always created at a valid -position close to the end of the document. The functions -`muse-docbook-bibliography' and `muse-latex-bibliography' are called in -the header or footer to generate this content, so it is possible to -change the exact position. - - -File: muse.info, Node: Comments, Next: Tag Summary, Prev: Citations, Up: Markup Rules - -8.15 Lines to omit from published output -======================================== - -Use the following syntax to indicate a comment. Comments will not be -published. - - ; Comment text goes here. - - That is, only a semi-colon at the beginning of a line, followed by a -literal space, will cause that line to be treated as a comment. - - You can alternatively surround the region with the tag. - - If you wish the comment to be published, but just commented out using -the comment syntax of the output format, then set -`muse-publish-comments-p' to non-nil. - - -File: muse.info, Node: Tag Summary, Prev: Comments, Up: Markup Rules - -8.16 Tags that Muse recognizes -============================== - -Muse has several built-in tags that may prove useful during publishing. -*Note muse-publish-markup-tags::, to see how to customize the tags that -Muse uses, as well as make your own tags. - - Only a small subset of these tags are available in header and footer -text. The `muse-publish-markup-header-footer-tags' option lists the -tags that are allowed in headers and footers. - -Syntax ------- - -If a tag takes arguments, it will look like this, where "tagname" is -the name of the tag. - - - - If you want the tag to look like it came straight from an XHTML -document, you can alternatively do the following. - - - - If a tag surrounds some text, it will look like this. - - Some text - - If a tag surrounds a large region, it will look like this. - - - Some text. - Some more text. - - -Tag listing ------------ - -This is the complete list of tags that Muse accepts, including those -that were mentioned in previous sections. - -`
    ' - Insert a line break. - - Muse will automatically detect paragraphs when publishing by means - of blank lines, so this tag is usually unnecessary. - -`' - Insert a citation to another source. - - This takes the argument `type', which indicates the type of - citation. The valid types are "author" and "year". If this - argument is omitted, include both author and year in the citation. - - The bibliography to use for the citation may be specified by the - `#bibsource' directive. - - *Note Citations::, for additional information. - -`' - If publishing to HTML, surround the given text with a tag. - It takes one argument called "name" that specifies the "class" - attribute of the tag. - - If publishing to a different format, do nothing extra to the text. - -`' - Treat the text surrounded by the tag as if they were enclosed in - equal signs, that is, make it monospace. - -`' - Run a command on the region, replacing the region with the result - of the command. The command is specified with the "interp" - argument. If no value for "interp" is given, pass the entire - region to the shell. - - The "markup" argument controls how this section is marked up. - - If it is omitted, publish the region with the normal Muse rules. - - If "nil", do not mark up the region at all, but prevent Muse from - further interpreting it. - - If "example", treat the region as if it was surrounded by the - tag. - - If "src", treat the included text as if it was surrounded by the - tag. You should also specify the "lang" attribute if doing - this. - - If "verse", treat the region as if it was surrounded by the - tag, to preserve newlines. - - Otherwise, it should be the name of a function to call, with the - buffer narrowed to the region. - -`' - Treat the entire region as a comment. If the option - MUSE-PUBLISH-COMMENTS-P is nil, delete the region, otherwise - publish it using the comment syntax of the current publishing - style. - -`' - Publish a Table of Contents. This will either be inserted - in-place or at the beginning of the document, depending on your - publishing style. It does not have a delimiting tag. - - By default, only 2 levels of headings will be included in the - generated Table of Contents. To change this globally, customize - the MUSE-PUBLISH-CONTENTS-DEPTH option. To change this only for - the current tag, use the "depth" argument. - -`
    ' - Insert a
    tag into HTML documents, and do not insert anything - special for other non-HTML publishing formats. - - If the "style" argument is provided, include it with the published -
    tag. Likewise for the "id" argument. - -`' - Publish the region in monospace, preserving the newlines in the - region. This is useful for snippets of code. - -`' - Insert the given file at the current location during publishing. - The basic use of this tag is as follows, replacing "included_file" - with the name of the file that you want to include. - - - - The "markup" argument controls how this section is marked up. - - If it is omitted, publish the included text with the normal Muse - rules. - - If "nil", do not mark up the included text at all. - - If "example", treat the included text as if it was surrounded by - the tag. - - If "src", treat the included text as if it was surrounded by the - tag. You should also specify the "lang" attribute if doing - this. - - If "verse", treat the included text as if it was surrounded by the - tag, to preserve newlines. - - Otherwise, it should be the name of a function to call after - inserting the file with the buffer narrowed to the section - inserted. - -`' - Evaluate the Emacs Lisp expressions between the initial and ending - tags. The result is then inserted into the document, so you do - not need to explicitly call `insert'. All text properties are - removed from the resulting text. - - This tag takes the "markup" argument. See the description of - for details. - -`' - Make sure that the text enclosed by this tag is published without - escaping it in any way. This is useful for inserting markup - directly into the published document, when Muse does not provide - the desired functionality. - -`' - Mark up the text between the initial and ending tags. The markup - command to use may be specified by the "function" argument. The - standard Muse markup routines are used by default if no "function" - argument is provided. - - This is useful for marking up regions in headers and footers. One - example that comes to mind is generating a published index of all - of the files in the current project by doing the following. - - (muse-index-as-string t t) - -`' - Run the `perl' language interpreter on the region, replacing the - region with the result of the command. - - This tag takes the "markup" argument. See the description of - for details. - -`' - Run the `python' language interpreter on the region, replacing the - region with the result of the command. - - This tag takes the "markup" argument. See the description of - for details. - -`' - Publish the region as a blockquote. This will either be inserted - in-place or at the beginning of the document, depending on your - publishing style. It does not have a delimiting tag. - -`' - Run the `ruby' language interpreter on the region, replacing the - region with the result of the command. - - This tag takes the "markup" argument. See the description of - for details. - -`' - Publish the region using htmlize. The language to use may be - specified by the "lang" attribute. - - Muse will look for a function named LANG-mode, where LANG is the - value of the "lang" attribute. - - This tag requires htmlize 1.34 or later in order to work. If this - is not satisfied, or the current publishing style is not - HTML-based, Muse will publish the region like an tag. - -`' - This is used when you want to prevent Muse from trying to - interpret some markup. Surround the markup in and - , and it will not be interpreted. - - This tag was used often in previous versions of Muse because they - did not support whole-document escaping of specials. Now, it will - only be needed for other tags, and perhaps footnotes as well. - -`' - Preserve the newlines in the region. In formats like HTML, - newlines are removed by default, hence the need for this tag. In - other publishing styles, this tag may cause the text to be - indented slightly in a way that looks nice for poetry and prose. - - - -File: muse.info, Node: Publishing Styles, Next: Extending Muse, Prev: Markup Rules, Up: Top - -9 Publishing Various Types of Documents -*************************************** - -One of the principle features of Muse is the ability to publish a simple -input text to a variety of different output styles. Muse also makes it -easy to create new styles, or derive from an existing style. - -* Menu: - -* Blosxom:: Integrating Muse and pyblosxom.cgi. -* Book:: Publishing entries into a compilation. -* ConTeXt:: Publishing ConTeXt documents. -* DocBook:: Publishing in DocBook XML form. -* HTML:: Publishing in HTML or XHTML form. -* Ikiwiki:: Integrating with ikiwiki. -* Journal:: Keeping a journal or blog. -* LaTeX:: Publishing LaTeX documents. -* Poem:: Publish a poem to LaTeX or PDF. -* Texinfo:: Publish entries to Texinfo format or PDF. -* XML:: Publish entries to XML. - - -File: muse.info, Node: Blosxom, Next: Book, Prev: Publishing Styles, Up: Publishing Styles - -9.1 Integrating Muse and pyblosxom.cgi -====================================== - -The Blosxom publishing style publishes a tree of categorised files to a -mirrored tree of stories to be served by blosxom.cgi or pyblosxom.cgi. -In other words, each blog entry corresponds with one file. - -* Menu: - -* Blosxom Requirements:: Other tools needed for the Blosxom style. -* Blosxom Entries:: Format of a Blosxom entry and automation. -* Blosxom Options:: Blosxom styles and options provided. - - -File: muse.info, Node: Blosxom Requirements, Next: Blosxom Entries, Prev: Blosxom, Up: Blosxom - -9.1.1 Other tools needed for the Blosxom style ----------------------------------------------- - -You will need to have `pyblosxom.cgi' or `blosxom.cgi' installed on a -machine that you have upload access to. - - The major difficulty in both of these programs is specifying the -date of the entries. Both programs rely on the file modification time -rather than any data contained in the entries themselves. A plugin is -needed in order for these programs to be able to get the correct date. - -PyBlosxom ---------- - -There are two different ways of accomplishing this in pyblosxom. The -first way involves gathering the timestamps (as specified by the -`#date' directive) into one file and then sending that file along with -published entries to the webserver. - - The second will read each file at render time and parse the -`#postdate' directive. Muse will translate the `#date' directive into -`#postdate' at publish time, so you don't have to do any extra work. - -Placing timestamps in one file -.............................. - -The following additional components are required in order to make the -date of blog entries display as something sensible. - - 1. A script to gather date directives from the entire blog tree into a - single file. The file must associate a blog entry with a date. - - 2. A plugin for (py)blosxom that reads this file. - - These 2 things are provided for `pyblosxom.cgi' in the -`contrib/pyblosxom' subdirectory. `getstamps.py' provides the former -service, while `hardcodedates.py' provides the latter service. - - Here is a sample listing from my `timestamps' file, which maps each -file to a date. This can really be in any format, as long as your -date-gathering script and your plugin can both understand it. - - 2005-04-01-14-16 personal/paper_cranes - 2005-03-21 personal/spring_break_over - 2004-10-24 personal/finished_free_culture - - The script `contrib/pyblosxom/make-blog' demonstrates how to call -`getstamps.py'. Note that you will need to set the current directory -to where your Muse files are, execute `getstamps.py', and then move the -generated timestamps file to your publishing directory. - -Getting timestamp from entry while rendering -............................................ - -Alternately, the pyblosxom metadate plugin may be used. On the plus -side, there is no need to run a script to gather the date. On the -downside, each entry is read twice rather than once when the page is -rendered. Set the value of `muse-blosxom-use-metadate' to non-nil to -enable adding a `#postdate' directive to all published files. You can -do this by: - - M-x customize-variable RET muse-blosxom-use-metadate RET - - With the metadate plugin installed in pyblosxom, the date set in this -directive will be used instead of the file's modification time. The -plugin is included with Muse at `contrib/pyblosxom/metadate.py'. - -Blosxom -------- - -It is also possible to use Blosxom, which is written in Perl, to serve -blog entries that were published with Muse. The steps are as follows. - - 1. Download and install blosxom from - `http://blosxom.sourceforge.net/'. - - 2. Install the metadate plugin. It is available in - `contrib/blosxom/metadate_0_0_3'. - - 3. Every time you make a new blog entry, change to the blosxom data - directory and execute the `contrib/blosxom/getstamps.pl' script. - This script has only recently been made, and may still have some - bugs, so use with caution. - - - -File: muse.info, Node: Blosxom Entries, Next: Blosxom Options, Prev: Blosxom Requirements, Up: Blosxom - -9.1.2 Format of a Blosxom entry and automation ----------------------------------------------- - -Each Blosxom file must include `#date yyyy-mm-dd', or optionally the -longer `#date yyyy-mm-dd-hh-mm', a title (using the `#title' -directive), plus whatever normal content is desired. - - The date directive is not used directly by `pyblosxom.cgi' or this -program. You need to have the two additional items from the former -section to make use of this feature. - - There is a function called `muse-blosxom-new-entry' that will -automate the process of making a new blog entry. To make use of it, do -the following. - - * Customize `muse-blosxom-base-directory' to the location that your - blog entries are stored. - - * Assign the `muse-blosxom-new-entry' function to a key sequence. I - use the following code to assign this function to `C-c p l''. - - (global-set-key "\C-cpl" 'muse-blosxom-new-entry) - - * You should create your directory structure ahead of time under - your base directory. These directories, which correspond with - category names, may be nested. - - * When you enter this key sequence, you will be prompted for the - category of your entry and its title. Upon entering this - information, a new file will be created that corresponds with the - title, but in lowercase letters and having special characters - converted to underscores. The title and date directives will be - inserted automatically. - - -File: muse.info, Node: Blosxom Options, Prev: Blosxom Entries, Up: Blosxom - -9.1.3 Blosxom styles and options provided ------------------------------------------ - -The following styles and options are available in the Blosxom publishing -style. - -Styles provided ---------------- - -`blosxom-html' - Publish Blosxom entries in HTML form. - -`blosxom-xhtml' - Publish Blosxom entries in XHTML form. - - -Options provided ----------------- - -`muse-blosxom-extension' - Default file extension for publishing Blosxom files. - -`muse-blosxom-header' - Header used for publishing Blosxom files. - - This may be text or a filename. - -`muse-blosxom-footer' - Footer used for publishing Blosxom files. - - This may be text or a filename. - -`muse-blosxom-base-directory' - Base directory of blog entries, used by `muse-blosxom-new-entry'. - - This is the top-level directory where your blog entries may be - found locally. - - - -File: muse.info, Node: Book, Next: ConTeXt, Prev: Blosxom, Up: Publishing Styles - -9.2 Publishing entries into a compilation -========================================= - -This publishing style is used to output "books" in LaTeX or PDF format. - - Each page will become a separate chapter in the book, unless the -style keyword `:nochapters' is used, in which case they are all run -together as if one giant chapter. - - One way of publishing a book is to make a project for it, add the -project to `muse-project-alist', and use the `book-pdf' style with a -very specific `:include' value to specify some page whose contents will -be checked for the values of `#title' and `#date', and whose name will -be used in the output file. Then to publish the book, visit the -aforementioned page and use `C-c C-t' or `C-c C-p' to trigger the -publishing process. An example `muse-project-alist' for this method -follows. - - (setq muse-project-alist - '(("MyNotes" (:nochapters t ; do automatically add chapters - :book-chapter "Computer Science" - "~/Notes/cs" - :book-chapter "Mathematics" - "~/Notes/math" - :book-chapter "Emacs" - "~/Notes/emacs" - :book-end t ; the rest will not be placed in the book - "~/Notes" ; so we can find the notes-anthology page - "~/Notes/private" - :force-publish ("index") - :default "index") - (:base "book-pdf" - :include "/notes-anthology[^/]*$" - :path "~/public_html/notes") - ;; other publishing styles for each directory go here, - ;; if desired - ))) - - In this example, there would be a file called -`~/Notes/notes-anthology.muse', which would contain just the following. -The resulting book would be published to -`~/public_html/notes/notes-anthology.pdf'. - - #title My Technology Ramblings - - Another way is to call the `muse-book-publish-project' function -manually, with a custom project entry. An example of this may be found -in John Wiegley's configuration file at `examples/johnw/muse-init.el', -in the `muse-publish-my-books' function. - -Styles provided ---------------- - -`book-latex' - Publish a book in LaTeX form. The header and footer are different - than the normal LaTeX publishing mode. - -`book-pdf' - Publish a book in PDF form. The header and footer are different - than the normal PDF publishing mode. - - -Options provided ----------------- - -`muse-book-before-publish-hook' - A hook run in the book buffer before it is marked up. - -`muse-book-after-publish-hook' - A hook run in the book buffer after it is marked up. - -`muse-book-latex-header' - Header used for publishing books to LaTeX. - - This may be text or a filename. - -`muse-book-latex-footer' - Footer used for publishing books to LaTeX. - - This may be text or a filename. - - - -File: muse.info, Node: ConTeXt, Next: DocBook, Prev: Book, Up: Publishing Styles - -9.3 Publishing ConTeXt documents -================================ - -This publishing style is capable of producing ConTeXt or PDF documents. - - If you wish to publish PDF documents based on ConTeXt, you will need -to have it installed. For Debian and Ubuntu, this can be accomplished -by installing the "texlive" package. - -Styles provided ---------------- - -`context' - Publish a ConTeXt document. - -`context-pdf' - Publish a PDF document, using an external ConTeXt document - conversion tool. - -`context-slides' - Produce slides from a ConTeXt document. - - Here is an example of a slide. - - * First Slide - - [[Some-sort-of-cute-image.png]] - - ** A subheading - - - A bullet point. - - Another bullet point. - - * Second Slide - - ... and so on - -`context-slides-pdf' - Publish a PDF document of ConTeXt slides. - - -Options provided ----------------- - -`muse-context-extension' - Default file extension for publishing ConTeXt files. - -`muse-context-pdf-extension' - Default file extension for publishing ConTeXt files to PDF. - -`muse-context-pdf-program' - The program that is called to generate PDF content from ConTeXt - content. - -`muse-context-pdf-cruft' - Extensions of files to remove after generating PDF output - successfully. - -`muse-context-header' - Header used for publishing ConTeXt files. - - This may be text or a filename. - -`muse-context-footer' - Footer used for publishing ConTeXt files. - - This may be text or a filename. - -`muse-context-markup-regexps' - List of markup regexps for identifying regions in a Muse page. - - For more on the structure of this list, *Note - muse-publish-markup-regexps::. - -`muse-context-markup-functions' - An alist of style types to custom functions for that kind of text. - - For more on the structure of this list, *Note - muse-publish-markup-functions::. - -`muse-context-markup-strings' - Strings used for marking up text. - - These cover the most basic kinds of markup, the handling of which - differs little between the various styles. - -`muse-context-slides-header' - Header for publishing a presentation (slides) using ConTeXt. - - Any of the predefined modules, which are available in the - tex/context/base directory, can be used by writing a "module" - directive at the top of the Muse file; if no such directive is - provided, module pre-01 is used. Alternatively, you can use your - own style ("mystyle", in this example) by replacing "\usemodule[]" - with "\input mystyle". - - This may be text or a filename. - -`muse-context-slides-markup-strings' - Strings used for marking up text in ConTeXt slides. - -`muse-context-markup-specials-document' - A table of characters which must be represented specially. These - are applied to the entire document, sans already-escaped regions. - -`muse-context-markup-specials-example' - A table of characters which must be represented specially. These - are applied to example> regions. - - With the default interpretation of regions, no specials - need to be escaped. - -`muse-context-markup-specials-literal' - A table of characters which must be represented specially. This - applies to =monospaced text= and regions. - -`muse-context-markup-specials-url' - A table of characters which must be represented specially. These - are applied to URLs. - -`muse-context-markup-specials-image' - A table of characters which must be represented specially. These - are applied to image filenames. - -`muse-context-permit-contents-tag' - If nil, ignore tags. Otherwise, insert table of - contents. - - Most of the time, it is best to have a table of contents on the - first page, with a new page immediately following. To make this - work with documents published in both HTML and ConTeXt, we need to - ignore the tag. - - If you don't agree with this, then set this option to non-nil, and - it will do what you expect. - - - -File: muse.info, Node: DocBook, Next: HTML, Prev: ConTeXt, Up: Publishing Styles - -9.4 Publishing in DocBook XML form -================================== - -This publishing style is used to generate DocBook XML files. - -Styles provided ---------------- - -`docbook' - Publish a file in Docbook form. - - -Options provided ----------------- - -This publishing style uses the same options for markup up special -characters as the "xml" publishing style. *Note XML::, for details. - -`muse-docbook-extension' - Default file extension for publishing DocBook XML files. - -`muse-docbook-header' - Header used for publishing DocBook XML files. - - This may be text or a filename. - -`muse-docbook-footer' - Footer used for publishing DocBook XML files. - - This may be text or a filename. - -`muse-docbook-markup-regexps' - List of markup rules for publishing a Muse page to DocBook XML. - -`muse-docbook-markup-functions' - An alist of style types to custom functions for that kind of text. - -`muse-docbook-markup-strings' - Strings used for marking up text. - - These cover the most basic kinds of markup, the handling of which - differs little between the various styles. - -`muse-docbook-encoding-default' - The default Emacs buffer encoding to use in published files. This - will be used if no special characters are found. - -`muse-docbook-charset-default' - The default DocBook XML charset to use if no translation is found - in `muse-xml-encoding-map'. - - - -File: muse.info, Node: HTML, Next: Ikiwiki, Prev: DocBook, Up: Publishing Styles - -9.5 Publishing in HTML or XHTML form -==================================== - -This publishing style is capable of producing HTML or XHTML documents. - -Styles provided ---------------- - -`html' - Supports publishing to HTML 4.0 and HTML 4.01, Strict or - Transitional. - -`xhtml' - Supports publishing to XHTML 1.0 and XHTML 1.1, Strict or - Transitional. - - -Options provided ----------------- - -If an HTML option does not have a corresponding XHTML option, it will -be used for both of these publishing styles. - - These publishing styles use the same options for markup up special -characters as the "xml" publishing style. *Note XML::, for details. - -`muse-html-extension' - Default file extension for publishing HTML files. - -`muse-xhtml-extension' - Default file extension for publishing XHTML files. - -`muse-html-style-sheet' - Store your stylesheet definitions here. - - This is used in `muse-html-header'. You can put raw CSS in here or - a tag to an external stylesheet. This text may contain - markup tags. - - If you are publishing to XHTML, then customize the - `muse-xhtml-style-sheet' option instead. - -`muse-xhtml-style-sheet' - Store your stylesheet definitions here. - - This is used in `muse-xhtml-header'. You can put raw CSS in here - or a tag to an external stylesheet. This text may contain - markup tags. - -`muse-html-header' - Header used for publishing HTML files. - - This may be text or a filename. - -`muse-html-footer' - Footer used for publishing HTML files. - - This may be text or a filename. - -`muse-xhtml-header' - Header used for publishing XHTML files. - - This may be text or a filename. - -`muse-xhtml-footer' - Footer used for publishing XHTML files. - - This may be text or a filename. - -`muse-html-anchor-on-word' - When true, anchors surround the closest word. - - This allows you to select them in a browser (i.e. for pasting), - but has the side-effect of marking up headers in multiple colors - if your header style is different from your link style. - -`muse-html-table-attributes' - The attribute to be used with HTML tags. - - If you want to make more-complicated tables in HTML, surround the - HTML with the literal tag, so that it does not get escaped. - -`muse-html-markup-regexps' - List of markup rules for publishing a Muse page to HTML. - -`muse-html-markup-functions' - An alist of style types to custom functions for that kind of text. - -`muse-html-markup-strings' - Strings used for marking up text as HTML. - - These cover the most basic kinds of markup, the handling of which - differs little between the various styles. - -`muse-xhtml-markup-strings' - Strings used for marking up text as XHTML. - - These cover the most basic kinds of markup, the handling of which - differs little between the various styles. - -`muse-html-markup-tags' - A list of tag specifications, for specially marking up HTML. - *Note muse-publish-markup-tags::, for more information. - -`muse-html-meta-http-equiv' - The http-equiv attribute used for the HTML tag. - -`muse-html-meta-content-type' - The content type used for the HTML tag. - - If you are striving for XHTML 1.1 compliance, you may want to - change this to "application/xhtml+xml". - -`muse-html-meta-content-encoding' - The charset to append to the HTML tag. - - If set to the symbol 'detect, use `muse-xml-encoding-map' to try - and determine the HTML charset from emacs's coding. If set to a - string, this string will be used to force a particular charset. - -`muse-html-charset-default' - The default HTML meta charset to use if no translation is found in - `muse-xml-encoding-map'. - -`muse-html-encoding-default' - The default Emacs buffer encoding to use in published files. This - will be used if no special characters are found. - - - -File: muse.info, Node: Ikiwiki, Next: Journal, Prev: HTML, Up: Publishing Styles - -9.6 Integrating with ikiwiki -============================ - -Note: Support for Ikiwiki is not yet complete. Use at your own risk. - - Ikiwiki is a wiki compiler (`http://ikiwiki.info/'). Emacs Muse can -(not yet) be used as a source format for Ikiwiki pages with the plugin -`IkiWiki::Plugin::muse'. - - The `lisp/muse-ikiwiki.el' file provides publishing functions and -styles for Ikiwiki. The plugin for Ikiwiki to recognize Muse files is -provided by the `contrib/ikiwiki/IkiWiki/Plugin/muse.pm' file. Two -sample init files are available in the `examples/ikiwiki' directory. -Configure your `ikiwiki.setup' file so that the `muse_init' variable -has the location of your Muse init file. - - If you are using CGI, The directory `contrib/ikiwiki/IkiWiki' must -be copied to the same directory as the CGI script that Ikiwiki -generates. When publishing your wiki, the PERL5LIB environment -variable must contain the path to the `contrib/ikiwiki/IkiWiki' -directory. - -Styles provided ---------------- - -`ikiwiki' - Supports publishing XHTML output that Ikiwiki can understand. - - -Options provided ----------------- - -`muse-ikiwiki-header' - Header used for publishing Ikiwiki output files. - - This may be text or a filename. - -`muse-ikiwiki-footer' - Footer used for publishing Ikiwiki output files. - - This may be text or a filename. - - -Other relevant options ----------------------- - -`muse-colors-evaluate-lisp-tags' - Specify whether to evaluate the contents of tags at display - time. If nil, don't evaluate them. If non-nil, evaluate them. - - The actual contents of the buffer are not changed, only the - displayed text. - -`muse-html-src-allowed-modes' - Modes that we allow the tag to colorize. If `t', permit the - tag to colorize any mode. - - If a list of mode names, such as `'("html" "latex")', and the lang - argument to is not in the list, then use fundamental mode - instead. - -`muse-publish-enable-dangerous-tags' - If non-nil, publish tags like and that can call - external programs or expose sensitive information. Otherwise, - ignore tags like this. - - This is useful to set to `nil' when the file to publish is coming - from an untrusted source. - - - -File: muse.info, Node: Journal, Next: LaTeX, Prev: Ikiwiki, Up: Publishing Styles - -9.7 Keeping a journal or blog -============================= - -The module facilitates the keeping and publication of a journal. When -publishing to HTML, it assumes the form of a web log, or blog. - - The input format for each entry is as follows. - - * 20040317: Title of entry - - text for the entry. - - - "You know who you are. It comes down to a simple gut check: You - either love what you do or you don't. Period." -- P. Bronson - - - The "qotd", or Quote of the Day, is entirely optional. When -generated to HTML, this entry is rendered as the following. - -
    -
    -

    Quote of the Day:

    -

    "You know who you are. It comes down to a simple gut - check: You either love what you do or you don't. Period." - -- P. Bronson

    -
    -
    -
    - -
    -

    Title of entry

    -
    -
    -
    -

    Text for the entry.

    -
    -
    -
    - - The plurality of "div" tags makes it possible to display the entries -in any form you wish, using a CSS style. - - Also, an .RDF file can be generated from your journal by publishing -it with the "rdf" style. It uses the first two sentences of the first -paragraph of each entry as its "description", and auto-generates tags -for linking to the various entries. - -muse-project-alist considerations ---------------------------------- - -If you wish to publish an RDF or RSS feed, it is important to include -the `:base-url' attribute in your `muse-project-alist' entry for your -Journal projects. An example follows. - - (setq muse-project-alist - '(("Journal" ("~/Journal/" - :default "journal") - (:base "journal-rss" - :base-url "http://example.org/journal/" - :path "~/public_html/journal")))) - -Styles provided ---------------- - -`journal-html' - Publish journal entries as an HTML document. - -`journal-xhtml' - Publish journal entries as an XHTML document. - -`journal-latex' - Publish journal entries as a LaTeX document. - -`journal-pdf' - Publish journal entries as a PDF document. - -`journal-book-latex' - Publish journal entries as a LaTeX book. - -`journal-book-pdf' - Publish journal entries as a PDF book. - -`journal-rdf' - Publish journal entries as an RDF file (RSS 1.0). - -`journal-rss' - Publish journal entries as an RSS file (RSS 2.0). - -`journal-rss-entry' - Used internally by `journal-rss' and `journal-rdf' for publishing - individual entries. - - -Options provided ----------------- - -`muse-journal-heading-regexp' - A regexp that matches a journal heading. - - Paren group 1 is the ISO date, group 2 is the optional category, - and group 3 is the optional heading for the entry. - -`muse-journal-date-format' - Date format to use for journal entries. - -`muse-journal-html-heading-regexp' - A regexp that matches a journal heading from an HTML document. - - Paren group 1 is the ISO date, group 2 is the optional category, - and group 3 is the optional heading for the entry. - -`muse-journal-html-entry-template' - Template used to publish individual journal entries as HTML. - - This may be text or a filename. - -`muse-journal-latex-section' - Template used to publish a LaTeX section. - -`muse-journal-latex-subsection' - Template used to publish a LaTeX subsection. - -`muse-journal-markup-tags' - A list of tag specifications, for specially marking up Journal - entries. - - *Note muse-publish-markup-tags::, for more information. - - This is used by `journal-latex' and its related styles, as well as - the `journal-rss-entry' style, which both `journal-rdf' and - `journal-rss' use. - -`muse-journal-rdf-extension' - Default file extension for publishing RDF (RSS 1.0) files. - -`muse-journal-rdf-base-url' - The base URL of the website referenced by the RDF file. - -`muse-journal-rdf-header' - Header used for publishing RDF (RSS 1.0) files. - - This may be text or a filename. - -`muse-journal-rdf-footer' - Footer used for publishing RDF (RSS 1.0) files. - - This may be text or a filename. - -`muse-journal-rdf-date-format' - Date format to use for RDF entries. - -`muse-journal-rdf-entry-template' - Template used to publish individual journal entries as RDF. - - This may be text or a filename. - -`muse-journal-rdf-summarize-entries' - If non-nil, include only summaries in the RDF file, not the full - data. - - The default is nil, because this annoys some subscribers. - -`muse-journal-rss-heading-regexp' - A regexp that matches a journal heading from an HTML document. - - Paren group 1 is the ISO date, group 2 is the optional category, - and group 3 is the optional heading for the entry. - -`muse-journal-rss-extension' - Default file extension for publishing RSS 2.0 files. - -`muse-journal-rss-base-url' - The base URL of the website referenced by the RSS file. - -`muse-journal-rss-header' - Header used for publishing RSS 2.0 files. - - This may be text or a filename. - -`muse-journal-rss-footer' - Footer used for publishing RSS 2.0 files. - - This may be text or a filename. - -`muse-journal-rss-date-format' - Date format to use for RSS 2.0 entries. - -`muse-journal-rss-entry-template' - Template used to publish individual journal entries as RSS 2.0. - - This may be text or a filename. - -`muse-journal-rss-enclosure-types-alist' - File types that are accepted as RSS enclosures. - - This is an alist that maps file extension to content type. - - Useful for podcasting. - -`muse-journal-rss-summarize-entries' - If non-nil, include only summaries in the RSS file, not the full - data. - - The default is nil, because this annoys some subscribers. - -`muse-journal-rss-markup-regexps' - List of markup rules for publishing a Muse journal page to RSS. - - For more information on the structure of this list, *Note - muse-publish-markup-regexps::. - -`muse-journal-rss-markup-functions' - An alist of style types to custom functions for that kind of text. - - For more on the structure of this list, *Note - muse-publish-markup-functions::. - - - -File: muse.info, Node: LaTeX, Next: Poem, Prev: Journal, Up: Publishing Styles - -9.8 Publishing LaTeX documents -============================== - -This publishing style is capable of producing LaTeX or PDF documents. - - If you wish to publish PDF documents, you will need to have a good -LaTeX installation. For Debian and Ubuntu, this can be accomplished by -installing the "tetex-bin" and "tetex-extra" packages. TeX fonts are -also a must. - - If your LaTeX installation has the file `grffile.sty', which may be -found in the `texlive-latex-recommended' package for Debian and Ubuntu, -then consider using it by adding the following to your header file. -This allows spaces in filenames to work. - - \usepackage{grffile} - -Styles provided ---------------- - -`latex' - Publish a LaTeX document. - -`pdf' - Publish a PDF document, using an external LaTeX document conversion - tool. - -`latexcjk' - Publish a LaTeX document with CJK (Chinese) encodings. - -`pdfcjk' - Publish a PDF document with CJK (Chinese) encodings, using an - external LaTeX document conversion tool. - -`slides' - Publish a LaTeX document that uses the Beamer extension. This is - suitable for producing slides. - - Here is an example of a slide. - - - Everything between the slide tags composes this slide. - - [[Some-sort-of-cute-image.png]] - - - A bullet point. - - Another bullet point. - - -`slides-pdf' - Publish a PDF document of slides, using the Beamer extension. - -`lecture-notes' - Publish a LaTeX document that uses the Beamer extension. This is - suitable for producing lecture notes. - - This can also use the tag. - -`lecture-notes-pdf' - Publish a PDF document of lecture notes, using the Beamer - extension. - - -Options provided ----------------- - -`muse-latex-extension' - Default file extension for publishing LaTeX files. - -`muse-latex-pdf-extension' - Default file extension for publishing LaTeX files to PDF. - -`muse-latex-pdf-browser' - The program to use when browsing a published PDF file. - - This should be a format string. - -`muse-latex-pdf-program' - The program that is called to generate PDF content from LaTeX - content. - -`muse-latex-pdf-cruft' - Extensions of files to remove after generating PDF output - successfully. - -`muse-latex-header' - Header used for publishing LaTeX files. - - This may be text or a filename. - -`muse-latex-footer' - Footer used for publishing LaTeX files. - - This may be text or a filename. - -`muse-latexcjk-header' - Header used for publishing LaTeX files (CJK). - - This may be text or a filename. - -`muse-latexcjk-footer' - Footer used for publishing LaTeX files (CJK). - - This may be text or a filename. - -`muse-latex-slides-header' - Header for publishing of slides using LaTeX. - - This may be text or a filename. - - You must have the Beamer extension for LaTeX installed for this to - work. - -`muse-latex-lecture-notes-header' - Header publishing of lecture notes using LaTeX. - - This may be text or a filename. - - You must have the Beamer extension for LaTeX installed for this to - work. - -`muse-latex-markup-regexps' - List of markup regexps for identifying regions in a Muse page. - - For more on the structure of this list, *Note - muse-publish-markup-regexps::. - -`muse-latex-markup-functions' - An alist of style types to custom functions for that kind of text. - - For more on the structure of this list, *Note - muse-publish-markup-functions::. - -`muse-latex-markup-strings' - Strings used for marking up text. - - These cover the most basic kinds of markup, the handling of which - differs little between the various styles. - -`muse-latex-slides-markup-tags' - A list of tag specifications, for specially marking up LaTeX - slides. - -`muse-latexcjk-encoding-map' - An alist mapping emacs coding systems to appropriate CJK codings. - Use the base name of the coding system (ie, without the -unix). - -`muse-latexcjk-encoding-default' - The default Emacs buffer encoding to use in published files. - - This will be used if no special characters are found. - -`muse-latex-markup-specials-document' - A table of characters which must be represented specially. These - are applied to the entire document, sans already-escaped regions. - -`muse-latex-markup-specials-example' - A table of characters which must be represented specially. These - are applied to example> regions. - - With the default interpretation of regions, no specials - need to be escaped. - -`muse-latex-markup-specials-literal' - A table of characters which must be represented specially. This - applies to =monospaced text= and regions. - -`muse-latex-markup-specials-url' - A table of characters which must be represented specially. These - are applied to URLs. - -`muse-latex-markup-specials-image' - A table of characters which must be represented specially. These - are applied to image filenames. - -`muse-latex-permit-contents-tag' - If nil, ignore tags. Otherwise, insert table of - contents. - - Most of the time, it is best to have a table of contents on the - first page, with a new page immediately following. To make this - work with documents published in both HTML and LaTeX, we need to - ignore the tag. - - If you don't agree with this, then set this option to non-nil, and - it will do what you expect. - - - -File: muse.info, Node: Poem, Next: Texinfo, Prev: LaTeX, Up: Publishing Styles - -9.9 Publish a poem to LaTeX or PDF -================================== - -The `muse-poem' module makes it easy to attractively publish and -reference poems in the following format, using the "memoir" module for -LaTeX publishing. It will also markup poems for every other output -style, though none are nearly as pretty. - - Title - - - Body of poem - - - Annotations, history, notes, etc. - - Once a poem is written in this format, just publish it to PDF using -the `poem-pdf' style. To make an inlined reference to a poem that -you've written - for example, from a blog page - there is a "poem" tag -defined by this module. - - - - Let's assume the template above was called `name.of.poem.page'; then -the above tag would result in this inclusion. - - ** Title - - > Body of poem - - John Wiegley uses this module for publishing all of the poems on his -website, which are at `http://www.newartisans.com/johnw/poems.html'. - -Styles provided ---------------- - -`poem-latex' - Publish a poem in LaTeX form. - -`poem-pdf' - Publish a poem to a PDF document. - -`chapbook-latex' - Publish a book of poems in LaTeX form. - -`chapbook-pdf' - Publish a book of poems to a PDF document. - - -Options provided ----------------- - -`muse-poem-latex-header' - Header used for publishing LaTeX poems. - - This may be text or a filename. - -`muse-poem-latex-footer' - Footer used for publishing LaTeX files. - - This may be text or a filename. - -`muse-poem-markup-strings' - Strings used for marking up poems. - - These cover the most basic kinds of markup, the handling of which - differs little between the various styles. - -`muse-chapbook-latex-header' - Header used for publishing a book of poems in LaTeX form. - - This may be text or a filename. - -`muse-chapbook-latex-footer' - Footer used for publishing a book of poems in LaTeX form. - - This may be text or a filename. - -`muse-poem-chapbook-strings' - Strings used for marking up books of poems. - - These cover the most basic kinds of markup, the handling of which - differs little between the various styles. - - - -File: muse.info, Node: Texinfo, Next: XML, Prev: Poem, Up: Publishing Styles - -9.10 Publish entries to Texinfo format or PDF -============================================= - -Rules for publishing a Muse file as a Texinfo article. - -Styles provided ---------------- - -`texi' - Publish a file in Texinfo form. - -`info' - Generate an Info file from a Muse file. - -`info-pdf' - Publish a file in PDF form. - - -Options provided ----------------- - -`muse-texinfo-process-natively' - If non-nil, use the Emacs `texinfmt' module to make Info files. - -`muse-texinfo-extension' - Default file extension for publishing Texinfo files. - -`muse-texinfo-info-extension' - Default file extension for publishing Info files. - -`muse-texinfo-pdf-extension' - Default file extension for publishing PDF files. - -`muse-texinfo-header' - Text to prepend to a Muse page being published as Texinfo. - - This may be text or a filename. It may contain markup tags. - -`muse-texinfo-footer' - Text to append to a Muse page being published as Texinfo. - - This may be text or a filename. It may contain markup tags. - -`muse-texinfo-markup-regexps' - List of markup rules for publishing a Muse page to Texinfo. - - For more on the structure of this list, *Note - muse-publish-markup-regexps::. - -`muse-texinfo-markup-functions' - An alist of style types to custom functions for that kind of text. - - For more on the structure of this list, *Note - muse-publish-markup-functions::. - -`muse-texinfo-markup-strings' - Strings used for marking up text. - - These cover the most basic kinds of markup, the handling of which - differs little between the various styles. - -`muse-texinfo-markup-specials' - A table of characters which must be represented specially. - -`muse-texinfo-markup-specials' - A table of characters which must be represented specially. These - are applied to URLs. - - - -File: muse.info, Node: XML, Prev: Texinfo, Up: Publishing Styles - -9.11 Publish entries to XML -=========================== - -Muse is capable of publishing XML documents, with the help of the -`muse-xml.el' module. - - A RelaxNG schema is available as part of the Muse distribution in the -`etc/muse.rnc' file. - -Styles provided ---------------- - -`xml' - Publish a file in XML form. - - -Options provided ----------------- - -`muse-xml-encoding-map' - An alist mapping Emacs coding systems to appropriate XML charsets. - Use the base name of the coding system (i.e. without the -unix). - -`muse-xml-markup-specials' - A table of characters which must be represented specially in all - XML-like markup formats. - -`muse-xml-markup-specials-url-extra' - A table of characters which must be represented specially in all - XML-like markup formats. - - These are extra characters that are escaped within URLs. - -`muse-xml-extension' - Default file extension used for publishing XML files. - -`muse-xml-header' - Header used for publishing XML files. - - This may be text or a filename. - -`muse-xml-footer' - Footer used for publishing XML files. - - This may be text or a filename. - -`muse-xml-markup-regexps' - List of markup rules for publishing a Muse page to XML. - - For more on the structure of this list, *Note - muse-publish-markup-regexps::. - -`muse-xml-markup-functions' - An alist of style types to custom functions for that kind of text. - - For more on the structure of this list, *Note - muse-publish-markup-functions::. - -`muse-xml-markup-strings' - Strings used for marking up text. - - These cover the most basic kinds of markup, the handling of which - differs little between the various styles. - -`muse-xml-encoding-default' - The default Emacs buffer encoding to use in published files. - - This will be used if no special characters are found. - -`muse-xml-charset-default' - The default XML charset to use if no translation is found in - `muse-xml-encoding-map'. - - - -File: muse.info, Node: Extending Muse, Next: Miscellaneous, Prev: Publishing Styles, Up: Top - -10 Making your own publishing styles -************************************ - -* Menu: - -* Markup Functions:: Specifying functions to mark up text. -* Markup Regexps:: Markup rules for publishing. -* Markup Strings:: Strings specific to a publishing style. -* Markup Tags:: Tag specifications for special markup. -* Style Elements:: Parameters used for defining styles. -* Deriving Styles:: Deriving a new style from an existing - one. - - -File: muse.info, Node: Markup Functions, Next: Markup Regexps, Up: Extending Muse - -10.1 Specifying functions to mark up text -========================================= - -`muse-publish-markup-functions' - - An alist of style types to custom functions for that kind of text. - - This is used by publishing styles to attempt to minimize the amount -of custom regexps that each has to define. `muse-publish' provides -rules for the most common types of markup. - - Each member of the list is of the following form. - - (SYMBOL FUNCTION) - - * SYMBOL Describes the type of text to associate with this rule. - `muse-publish-markup-regexps' maps regexps to these symbols. - - * FUNCTION Function to use to mark up this kind of rule if no - suitable function is found through the `:functions' tag of the - current style. - - -File: muse.info, Node: Markup Regexps, Next: Markup Strings, Prev: Markup Functions, Up: Extending Muse - -10.2 Markup rules for publishing -================================ - -`muse-publish-markup-regexps' - - List of markup rules for publishing a page with Muse. - - The rules given in this variable are invoked first, followed by -whatever rules are specified by the current style. - - Each member of the list is either a function, or a list of the -following form. - - (REGEXP/SYMBOL TEXT-BEGIN-GROUP REPLACEMENT-TEXT/FUNCTION/SYMBOL) - - * REGEXP A regular expression, or symbol whose value is a regular - expression, which is searched for using `re-search-forward'. - - * TEXT-BEGIN-GROUP The matching group within that regexp which - denotes the beginning of the actual text to be marked up. - - * REPLACEMENT-TEXT A string that will be passed to `replace-match'. - - If it is not a string, but a function, it will be called to - determine what the replacement text should be (it must return a - string). If it is a symbol, the value of that symbol should be a - string. - - The replacements are done in order, one rule at a time. Writing the -regular expressions can be a tricky business. Note that case is never -ignored. `case-fold-search' is always bound to nil while processing -the markup rules. - -Publishing order ----------------- - -This is the order that the publishing rules are consulted, by default. -This may be changed by customizing `muse-publish-markup-regexps'. - -`trailing and leading whitespace' - Remove trailing and leading whitespace from a file. - -`directive' - `#directive' - - This is only recognized at the beginning of a file. - -`comment' - `; a commented line' - -`tag' - `' - -`comment' - `; comment' - -`explicit links' - Prevent emphasis characters in explicit links from being marked up. - - Don't actually publish them here, just add a special no-emphasis - text property. - -`word' - Whitespace-delimited word, possibly with emphasis characters - - This function is responsible for marking up emphasis and escaping - some specials. - -`heading' - `** Heading' - - Outline-mode style headings. - -`enddots' - `....' - - These are ellipses with a dot at end. - -`dots' - `...' - - Ellipses. - -`rule' - `----' - - Horizontal rule or section separator. - -`no-break-space' - `~~' - - Prevent lines from being split before or after these characters. - -`line-break' - `
    ' - - Break a line at point. - -`fn-sep' - `Footnotes:' - - Beginning of footnotes section. - -`footnote' - `[1]' - - Footnote definition or reference. If at beginning of line, it is a - definition. - -`list' - * ` 1. ' - - * ` - ' - - * `term :: ' - - Numbered list, item list, or term definition list. - -`table-el' - `table.el' style tables - -`table' - `table | cells' - - Muse tables or orgtbl-mode style tables. - -`quote' - spaces before beginning of text - - Blockquotes. - -`emdash' - `--' - - 2-wide dash - -`verse' - `> verse text' - -`anchor' - `#anchor' - -`link' - `[[explicit][links]]' - -`url' - `http://example.com/' - -`email' - `bare-email@example.com' - - - -File: muse.info, Node: Markup Strings, Next: Markup Tags, Prev: Markup Regexps, Up: Extending Muse - -10.3 Strings specific to a publishing style -=========================================== - -"Markup strings" are strings used for marking up text for a particular -style. - - These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -Available markup strings ------------------------- - -`image-with-desc' - An image and a description. - - Argument 1: image without extension. Argument 2: image extension. - Argument 3: description. - -`image' - An inlined image. - - Argument 1: image without extension. Argument 2: image extension. - -`image-link' - An image with a link around it. - - Argument 1: link. Argument 2: image without extension. Argument - 3: image extension. - -`anchor-ref' - A reference to an anchor on the current page. - - Argument 1: anchor name. Argument 2: description if one exists, - or the original link otherwise. - -`url' - A URL without a description. - - Argument 1: URL. - -`link' - A link to a Muse page with a description. - - Argument 1: link. Argument 2: description if one exists, or the - original link otherwise. - -`link-and-anchor' - A link to a Muse page with an anchor, and a description. - - Argument 1: link. Argument 2: anchor name. Argument 3: - description if one exists, or the original link otherwise. - Argument 4: link without an extension. - -`email-addr' - A link to an email address. - - Argument 1: email address. Argument 2: email address. - -`anchor' - An anchor. - - Argument 1: name of anchor. - -`emdash' - A 2-length dash. - - Argument 1: Initial whitespace. Argument 2: Terminating - whitespace. - -`comment-begin' - Beginning of a comment. - -`comment-end' - End of a comment. - -`rule' - A horizontal line or space. - -`no-break-space' - A space that separates two words which are not to be separated. - -`footnote' - Beginning of footnote. - -`footnote-end' - End of footnote. - -`footnotemark' - Mark a reference for the current footnote. - - Argument 1: number of this footnote. - -`footnotemark-end' - End of a reference for the current footnote. - -`footnotetext' - Indicate the text of the current footnote. - - Argument 1: number of this footnote. - -`footnotetext-end' - End of a footnote text line. - -`fn-sep' - Text used to replace "Footnotes:" line. - -`dots' - 3 dots. - -`enddots' - 4 dots. - -`part' - Beginning of a part indicator line. This is used by book - publishing. - -`part-end' - End of a part indicator line. This is used by book publishing. - -`chapter' - Beginning of a chapter indicator line. This is used by book - publishing. - -`chapter-end' - End of a chapter indicator line. This is used by book publishing. - -`section' - Beginning of level 1 section indicator line. - - Argument 1: level of section; always 1. - -`section-end' - End of level 1 section indicator line. - - Argument 1: level of section; always 1. - -`subsection' - Beginning of level 2 section indicator line. - - Argument 1: level of section; always 2. - -`subsection-end' - End of level 2 section indicator line. - - Argument 1: level of section; always 2. - -`subsubsection' - Beginning of level 3 section indicator line. - - Argument 1: level of section; always 3. - -`subsubsection-end' - End of level 3 section indicator line. - - Argument 1: level of section; always 3. - -`section-other' - Beginning of section indicator line, where level is greater than 3. - - Argument 1: level of section. - -`section-other-end' - End of section indicator line, where level is greater than 3. - - Argument 1: level of section. - -`begin-underline' - Beginning of underlined text. - -`end-underline' - End of underlined text. - -`begin-literal' - Beginning of verbatim text. This includes tags and - =teletype text=. - -`end-literal' - End of verbatim text. This includes tags and =teletype - text=. - -`begin-emph' - Beginning of the first level of emphasized text. - -`end-emph' - End of the first level of emphasized text. - -`begin-more-emph' - Beginning of the second level of emphasized text. - -`end-more-emph' - End of the second level of emphasized text. - -`begin-most-emph' - Beginning of the third (and final) level of emphasized text. - -`end-most-emph' - End of the third (and final) level of emphasized text. - -`begin-verse' - Beginning of verse text. - -`verse-space' - String used to each space that is further indented than the - beginning of the verse. - -`begin-verse-line' - Beginning of a line of verse. - -`empty-verse-line' - End of a line of verse. - -`begin-last-stanza-line' - Beginning of the last line of a verse stanza. - -`end-last-stanza-line' - End of the last line of a verse stanza. - -`end-verse' - End of verse text. - -`begin-example' - Beginning of an example region. To make use of this, an - `' tag is needed. - -`end-example' - End of an example region. To make use of this, an `' tag - is needed. - -`begin-center' - Begin a centered line. - -`end-center' - End a centered line. - -`begin-quote' - Begin a quoted region. - -`end-quote' - End a quoted region. - -`begin-quote-item' - Begin a quote paragraph. - -`end-quote-item' - End a quote paragraph. - -`begin-uli' - Begin an unordered list. - -`end-uli' - End an unordered list. - -`begin-uli-item' - Begin an unordered list item. - -`end-uli-item' - End an unordered list item. - -`begin-oli' - Begin an ordered list. - -`end-oli' - End an ordered list. - -`begin-oli-item' - Begin an ordered list item. - -`end-oli-item' - End an ordered list item. - -`begin-dl' - Begin a definition list. - -`end-dl' - End a definition list. - -`begin-dl-item' - Begin a definition list item. - -`end-dl-item' - End a definition list item. - -`begin-ddt' - Begin a definition list term. - -`end-ddt' - End a definition list term. - -`begin-dde' - Begin a definition list entry. - -`end-dde' - End a definition list entry. - -`begin-table' - Begin a table. - -`end-table' - End a table. - -`begin-table-group' - Begin a table grouping. - -`end-table-group' - End a table grouping. - -`begin-table-row' - Begin a table row. - -`end-table-row' - End a table row. - -`begin-table-entry' - Begin a table entry. - -`end-table-entry' - End a table entry. - - - -File: muse.info, Node: Markup Tags, Next: Style Elements, Prev: Markup Strings, Up: Extending Muse - -10.4 Tag specifications for special markup -========================================== - -`muse-publish-markup-tags' - - A list of tag specifications, for specially marking up text. - - XML-style tags are the best way to add custom markup to Muse. This -is easily accomplished by customizing this list of markup tags. - - For each entry, the name of the tag is given, whether it expects a -closing tag and/or an optional set of attributes, whether it is -nestable, and a function that performs whatever action is desired within -the delimited region. - - The tags themselves are deleted during publishing, before the -function is called. The function is called with three arguments, the -beginning and end of the region surrounded by the tags. If properties -are allowed, they are passed as a third argument in the form of an -alist. The `end' argument to the function is always a marker. - - Point is always at the beginning of the region within the tags, when -the function is called. Wherever point is when the function finishes is -where tag markup will resume. - - These tag rules are processed once at the beginning of markup, and -once at the end, to catch any tags which may have been inserted -in-between. - - -File: muse.info, Node: Style Elements, Next: Deriving Styles, Prev: Markup Tags, Up: Extending Muse - -10.5 Parameters used for defining styles -======================================== - -Style elements are tags that define a style. Use either -`muse-define-style' or `muse-derive-style' (*note Deriving Styles::) to -create a new style. - - -- Function: muse-define-style name &rest elements - -Usable elements ---------------- - -`:suffix' - File extension to use for publishing files with this style. - -`:link-suffix' - File extension to use for publishing links to Muse files with this - style. - -`:osuffix' - File extension to use for publishing second-stage files with this - style. - - For example, PDF publishing generates a LaTeX file first, then a - PDF from that LaTeX file. - -`:regexps' - List of markup rules for publishing a page with Muse. *Note - muse-publish-markup-regexps::. - -`:functions' - An alist of style types to custom functions for that kind of text. - *Note muse-publish-markup-functions::. - -`:strings' - Strings used for marking up text with this style. - - These cover the most basic kinds of markup, the handling of which - differs little between the various styles. - -`:tags' - A list of tag specifications, used for handling extra tags. *Note - muse-publish-markup-tags::. - -`:specials' - A table of characters which must be represented specially. - -`:before' - A function that is to be executed on the newly-created publishing - buffer (or the current region) before any publishing occurs. - - This is used to set extra parameters that direct the publishing - process. - -`:before-end' - A function that is to be executed on the publishing buffer (or the - current region) immediately after applying all of the markup - regexps. - - This is used to fix the order of table elements (header, footer, - body) in XML-ish styles. - -`:after' - A function that is to be executed on the publishing buffer after - :before-end, and immediately after inserting the header and footer. - - This is used for generating the table of contents as well as - setting the file coding system. - -`:final' - A function that is to be executed after saving the published file, - but while still in its buffer. - - This is used for generating second-stage documents like PDF files - from just-published LaTeX files. - - The function must accept three arguments: the name of the muse - source file, the name of the just-published file, and the name of - the second-stage target file. The name of the second-stage target - file is the same as that of the just-published file if no - second-stage publishing is required. - -`:header' - Header used for publishing files of this style. - - This may be a variable, text, or a filename. It is inserted at the - beginning of a file, after evaluating the publishing markup. - -`:footer' - Footer used for publishing files of this style. - - This may be a variable, text, or a filename. It is inserted at - the end of a file, after evaluating the publishing markup. - -`:style-sheet' - Style sheet used for publishing files of this style. - - This may be a variable or text. It is used in the header of HTML - and XHTML based publishing styles. - -`:browser' - The function used to browse the published result of files of this - style. - - - -File: muse.info, Node: Deriving Styles, Prev: Style Elements, Up: Extending Muse - -10.6 Deriving a new style from an existing one -============================================== - -To create a new style from an existing one, use `muse-derive-style' as -follows. This is a good way to fix something you don't like about a -particular publishing style, or to personalize it. - - -- Function: muse-derive-style new-name base-name &rest elements - - The derived name is a string defining the new style, such as -"my-html". The base name must identify an existing style, such as -"html" - if you have loaded `muse-html'. The style parameters are the -same as those used to create a style, except that they override whatever -definitions exist in the base style. However, some definitions only -partially override. The following parameters support partial -overriding. - - *Note Style Elements::, for a complete list of all parameters. - -`:functions' - If a markup function is not found in the derived style's function - list, the base style's function list will be queried. - -`:regexps' - All regexps in the current style and the base style(s) will be - used. - -`:strings' - If a markup string is not found in the derived style's string - list, the base style's string list will be queried. - - - -File: muse.info, Node: Miscellaneous, Next: Getting Help and Reporting Bugs, Prev: Extending Muse, Up: Top - -11 Miscellaneous add-ons, like a minor mode -******************************************* - -* Menu: - -* Muse List Edit Minor Mode:: Edit lists easily in other major modes. - - -File: muse.info, Node: Muse List Edit Minor Mode, Up: Miscellaneous - -11.1 Edit lists easily in other major modes -=========================================== - -`muse-list-edit-minor-mode' is meant to be used with other major modes, -such as Message (for composing email) and debian-changelog-mode (for -editing debian/changelog files). - - It implements practically perfect support for editing and filling -lists. It can even handle nested lists. In addition to Muse-specific -list items ("-", numbers, definition lists, footnotes), it can also -handle items that begin with "*" or "+". Filling list items behaves in -the same way that it does in Muse, regardless of whether filladapt is -also enabled, which is the primary reason to use this tool. - -Installation ------------- - -To use it, add "(require 'muse-mode)" to your Emacs customization file -and add the function `turn-on-muse-list-edit-minor-mode' to any mode -hooks where you wish to enable this minor mode. - -Keybindings ------------ - -`muse-list-edit-minor-mode' uses the following keybindings. - -`M-RET (`muse-l-e-m-m-insert-list-item')' - Insert a new list item at point, using the indentation level of the - current list item. - -`C-< (`muse-l-e-m-m-decrease-list-item-indent')' - Decrease indentation of the current list item. - -`C-> (`muse-l-e-m-m-increase-list-item-indent')' - Increase indentation of the current list item. - - -Functions ---------- - - -- Function: muse-list-edit-minor-mode - This is a global minor mode for editing files with lists. It is - meant to be used with other major modes, and not with Muse mode. - - Interactively, with no prefix argument, toggle the mode. With - universal prefix ARG turn mode on. With zero or negative ARG turn - mode off. - - This minor mode provides the Muse keybindings for editing lists, - and support for filling lists properly. - - It recognizes not only Muse-style lists, which use the "-" - character or numbers, but also lists that use asterisks or plus - signs. This should make the minor mode generally useful. - - Definition lists and footnotes are also recognized. - - Note that list items may omit leading spaces, for compatibility - with modes that set `left-margin', such as `debian-changelog-mode'. - - -- Function: turn-on-muse-list-edit-minor-mode - Unconditionally turn on Muse list edit minor mode. - - -- Function: turn-off-muse-list-edit-minor-mode - Unconditionally turn off Muse list edit minor mode. - - -File: muse.info, Node: Getting Help and Reporting Bugs, Next: History, Prev: Miscellaneous, Up: Top - -12 Getting Help and Reporting Bugs -********************************** - -After you have read this guide, if you still have questions about Muse, -or if you have bugs to report, there are several places you can go. - - * `http://www.emacswiki.org/cgi-bin/wiki/EmacsMuse' is the - emacswiki.org page, and anyone may add tips, hints, or bug - descriptions to it. - - * `http://mwolson.org/projects/EmacsMuse.html' is the web page that - Michael Olson (the current maintainer) made for Muse. - - * Muse has several different mailing lists. - - `muse-el-announce' - Low-traffic list for Muse-related announcements. - - You can join this mailing list () - using the subscription form at - `http://mail.gna.org/listinfo/muse-el-announce/'. This - mailing list is also available via Gmane - (`http://gmane.org/'). The group is called - `gmane.emacs.muse.announce'. - - `muse-el-discuss' - Discussion, bugfixes, suggestions, tips, and the like for - Muse. This mailing list also includes the content of - muse-el-announce. - - You can join this mailing list () - using the subscription form at - `http://mail.gna.org/listinfo/muse-el-discuss/'. This mailing - list is also available via Gmane with the identifier - `gmane.emacs.muse.general'. - - `muse-el-logs' - Log messages for commits made to Muse. - - You can join this mailing list () using - the subscription form at - `http://mail.gna.org/listinfo/muse-el-logs/'. This mailing - list is also available via Gmane with the identifier - `gmane.emacs.muse.scm'. - - `muse-el-commits' - Generated bug reports for Emacs Muse. If you use our - bug-tracker at `https://gna.org/bugs/?group=muse-el', the bug - reports will be sent to this list automatically. - - You can join this mailing list () - using the subscription form at - `http://mail.gna.org/listinfo/muse-el-commits/'. This - mailing list is also available via Gmane with the identifier - `gmane.emacs.muse.cvs'. - - `muse-el-internationalization' - Discussion of translation of the Muse website and - documentation into many languages. - - You can join this mailing list - () using the - subscription form at - `http://mail.gna.org/listinfo/internationalization/'. This - mailing list is also available via Gmane with the identifier - `gmane.emacs.muse.internationalization'. - - - * You can visit the IRC Freenode channel `#emacs'. Many of the - contributors are frequently around and willing to answer your - questions. The `#muse' channel is also available for - Muse-specific help, and its current maintainer hangs out there. - - * The maintainer of Emacs Muse, Michael Olson, may be contacted at - . He can be rather slow at answering email, so - it is often better to use the muse-el-discuss mailing list. - - - -File: muse.info, Node: History, Next: Contributors, Prev: Getting Help and Reporting Bugs, Up: Top - -13 History of This Document -*************************** - - * 2004 John Wiegley started Muse upon realizing that EmacsWiki had - some serious limitations. Around February 2004, he started making - "emacs-wiki version 3.00 APLHA", which eventually became known as - Muse. - - Most of those who frequent the emacs-wiki mailing list continued - to use emacs-wiki, mainly because Planner hasn't been ported over - to it. - - As of 2004-12-01, Michael Olson became the maintainer of Muse, as - per John Wiegley's request. - - * 2005 Michael Olson overhauled this document and added many new - sections in preparation for the first release of Muse (3.01). - - - -File: muse.info, Node: Contributors, Next: GNU Free Documentation License, Prev: History, Up: Top - -14 Contributors to This Documentation -************************************* - -The first draft of this document was taken from the emacs-wiki texinfo -manual. Michael Olson adapted it for Muse and added most of its -content. - - John Sullivan did a majority of the work on the emacs-wiki texinfo -manual. - - While Sacha Chua maintained emacs-wiki, she worked quite a bit on the -emacs-wiki texinfo manual. - - -File: muse.info, Node: GNU Free Documentation License, Next: Concept Index, Prev: Contributors, Up: Top - -Appendix A GNU Free Documentation License -***************************************** - - Version 1.2, November 2002 - - Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - 0. PREAMBLE - - The purpose of this License is to make a manual, textbook, or other - functional and useful document "free" in the sense of freedom: to - assure everyone the effective freedom to copy and redistribute it, - with or without modifying it, either commercially or - noncommercially. Secondarily, this License preserves for the - author and publisher a way to get credit for their work, while not - being considered responsible for modifications made by others. - - This License is a kind of "copyleft," which means that derivative - works of the document must themselves be free in the same sense. - It complements the GNU General Public License, which is a copyleft - license designed for free software. - - We have designed this License in order to use it for manuals for - free software, because free software needs free documentation: a - free program should come with manuals providing the same freedoms - that the software does. But this License is not limited to - software manuals; it can be used for any textual work, regardless - of subject matter or whether it is published as a printed book. - We recommend this License principally for works whose purpose is - instruction or reference. - - - 1. APPLICABILITY AND DEFINITIONS - - This License applies to any manual or other work, in any medium, - that contains a notice placed by the copyright holder saying it - can be distributed under the terms of this License. Such a notice - grants a world-wide, royalty-free license, unlimited in duration, - to use that work under the conditions stated herein. The - "Document," below, refers to any such manual or work. Any member - of the public is a licensee, and is addressed as "you." You - accept the license if you copy, modify or distribute the work in a - way requiring permission under copyright law. - - A "Modified Version" of the Document means any work containing the - Document or a portion of it, either copied verbatim, or with - modifications and/or translated into another language. - - A "Secondary Section" is a named appendix or a front-matter - section of the Document that deals exclusively with the - relationship of the publishers or authors of the Document to the - Document's overall subject (or to related matters) and contains - nothing that could fall directly within that overall subject. - (Thus, if the Document is in part a textbook of mathematics, a - Secondary Section may not explain any mathematics.) The - relationship could be a matter of historical connection with the - subject or with related matters, or of legal, commercial, - philosophical, ethical or political position regarding them. - - The "Invariant Sections" are certain Secondary Sections whose - titles are designated, as being those of Invariant Sections, in - the notice that says that the Document is released under this - License. If a section does not fit the above definition of - Secondary then it is not allowed to be designated as Invariant. - The Document may contain zero Invariant Sections. If the Document - does not identify any Invariant Sections then there are none. - - The "Cover Texts" are certain short passages of text that are - listed, as Front-Cover Texts or Back-Cover Texts, in the notice - that says that the Document is released under this License. A - Front-Cover Text may be at most 5 words, and a Back-Cover Text may - be at most 25 words. - - A "Transparent" copy of the Document means a machine-readable copy, - represented in a format whose specification is available to the - general public, that is suitable for revising the document - straightforwardly with generic text editors or (for images - composed of pixels) generic paint programs or (for drawings) some - widely available drawing editor, and that is suitable for input to - text formatters or for automatic translation to a variety of - formats suitable for input to text formatters. A copy made in an - otherwise Transparent file format whose markup, or absence of - markup, has been arranged to thwart or discourage subsequent - modification by readers is not Transparent. An image format is - not Transparent if used for any substantial amount of text. A - copy that is not "Transparent" is called "Opaque." - - Examples of suitable formats for Transparent copies include plain - ASCII without markup, Texinfo input format, LaTeX input format, - SGML or XML using a publicly available DTD, and - standard-conforming simple HTML, PostScript or PDF designed for - human modification. Examples of transparent image formats include - PNG, XCF and JPG. Opaque formats include proprietary formats that - can be read and edited only by proprietary word processors, SGML - or XML for which the DTD and/or processing tools are not generally - available, and the machine-generated HTML, PostScript or PDF - produced by some word processors for output purposes only. - - The "Title Page" means, for a printed book, the title page itself, - plus such following pages as are needed to hold, legibly, the - material this License requires to appear in the title page. For - works in formats which do not have any title page as such, "Title - Page" means the text near the most prominent appearance of the - work's title, preceding the beginning of the body of the text. - - A section "Entitled XYZ" means a named subunit of the Document - whose title either is precisely XYZ or contains XYZ in parentheses - following text that translates XYZ in another language. (Here XYZ - stands for a specific section name mentioned below, such as - "Acknowledgements," "Dedications," "Endorsements," or "History.") - To "Preserve the Title" of such a section when you modify the - Document means that it remains a section "Entitled XYZ" according - to this definition. - - The Document may include Warranty Disclaimers next to the notice - which states that this License applies to the Document. These - Warranty Disclaimers are considered to be included by reference in - this License, but only as regards disclaiming warranties: any other - implication that these Warranty Disclaimers may have is void and - has no effect on the meaning of this License. - - 2. VERBATIM COPYING - - You may copy and distribute the Document in any medium, either - commercially or noncommercially, provided that this License, the - copyright notices, and the license notice saying this License - applies to the Document are reproduced in all copies, and that you - add no other conditions whatsoever to those of this License. You - may not use technical measures to obstruct or control the reading - or further copying of the copies you make or distribute. However, - you may accept compensation in exchange for copies. If you - distribute a large enough number of copies you must also follow - the conditions in section 3. - - You may also lend copies, under the same conditions stated above, - and you may publicly display copies. - - 3. COPYING IN QUANTITY - - If you publish printed copies (or copies in media that commonly - have printed covers) of the Document, numbering more than 100, and - the Document's license notice requires Cover Texts, you must - enclose the copies in covers that carry, clearly and legibly, all - these Cover Texts: Front-Cover Texts on the front cover, and - Back-Cover Texts on the back cover. Both covers must also clearly - and legibly identify you as the publisher of these copies. The - front cover must present the full title with all words of the - title equally prominent and visible. You may add other material - on the covers in addition. Copying with changes limited to the - covers, as long as they preserve the title of the Document and - satisfy these conditions, can be treated as verbatim copying in - other respects. - - If the required texts for either cover are too voluminous to fit - legibly, you should put the first ones listed (as many as fit - reasonably) on the actual cover, and continue the rest onto - adjacent pages. - - If you publish or distribute Opaque copies of the Document - numbering more than 100, you must either include a - machine-readable Transparent copy along with each Opaque copy, or - state in or with each Opaque copy a computer-network location from - which the general network-using public has access to download - using public-standard network protocols a complete Transparent - copy of the Document, free of added material. If you use the - latter option, you must take reasonably prudent steps, when you - begin distribution of Opaque copies in quantity, to ensure that - this Transparent copy will remain thus accessible at the stated - location until at least one year after the last time you - distribute an Opaque copy (directly or through your agents or - retailers) of that edition to the public. - - It is requested, but not required, that you contact the authors of - the Document well before redistributing any large number of - copies, to give them a chance to provide you with an updated - version of the Document. - - 4. MODIFICATIONS - - You may copy and distribute a Modified Version of the Document - under the conditions of sections 2 and 3 above, provided that you - release the Modified Version under precisely this License, with - the Modified Version filling the role of the Document, thus - licensing distribution and modification of the Modified Version to - whoever possesses a copy of it. In addition, you must do these - things in the Modified Version: - - A. Use in the Title Page (and on the covers, if any) a title - distinct from that of the Document, and from those of previous - versions (which should, if there were any, be listed in the - History section of the Document). You may use the same title - as a previous version if the original publisher of that version - gives permission. - B. List on the Title Page, as authors, one or more persons or - entities responsible for authorship of the modifications in the - Modified Version, together with at least five of the principal - authors of the Document (all of its principal authors, if it - has fewer than five), unless they release you from this - requirement. - C. State on the Title page the name of the publisher of the - Modified Version, as the publisher. - D. Preserve all the copyright notices of the Document. - E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices. - F. Include, immediately after the copyright notices, a license - notice giving the public permission to use the Modified Version - under the terms of this License, in the form shown in the - Addendum below. - G. Preserve in that license notice the full lists of Invariant - Sections and required Cover Texts given in the Document's - license notice. - H. Include an unaltered copy of this License. - I. Preserve the section Entitled "History," Preserve its Title, - and add to it an item stating at least the title, year, new - authors, and publisher of the Modified Version as given on the - Title Page. If there is no section Entitled "History" in the - Document, create one stating the title, year, authors, and - publisher of the Document as given on its Title Page, then add - an item describing the Modified Version as stated in the - previous sentence. - J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the "History" section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission. - K. For any section Entitled "Acknowledgements" or "Dedications," - Preserve the Title of the section, and preserve in the section all - the substance and tone of each of the contributor - acknowledgements and/or dedications given therein. - L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles. - M. Delete any section Entitled "Endorsements." Such a section - may not be included in the Modified Version. - N. Do not retitle any existing section to be Entitled - "Endorsements" or to conflict in title with any Invariant - Section. - O. Preserve any Warranty Disclaimers. - - If the Modified Version includes new front-matter sections or - appendices that qualify as Secondary Sections and contain no - material copied from the Document, you may at your option - designate some or all of these sections as invariant. To do this, - add their titles to the list of Invariant Sections in the Modified - Version's license notice. These titles must be distinct from any - other section titles. - - You may add a section Entitled "Endorsements," provided it contains - nothing but endorsements of your Modified Version by various - parties-for example, statements of peer review or that the text has - been approved by an organization as the authoritative definition - of a standard. - - You may add a passage of up to five words as a Front-Cover Text, - and a passage of up to 25 words as a Back-Cover Text, to the end - of the list of Cover Texts in the Modified Version. Only one - passage of Front-Cover Text and one of Back-Cover Text may be - added by (or through arrangements made by) any one entity. If the - Document already includes a cover text for the same cover, - previously added by you or by arrangement made by the same entity - you are acting on behalf of, you may not add another; but you may - replace the old one, on explicit permission from the previous - publisher that added the old one. - - The author(s) and publisher(s) of the Document do not by this - License give permission to use their names for publicity for or to - assert or imply endorsement of any Modified Version. - - 5. COMBINING DOCUMENTS - - You may combine the Document with other documents released under - this License, under the terms defined in section 4 above for - modified versions, provided that you include in the combination - all of the Invariant Sections of all of the original documents, - unmodified, and list them all as Invariant Sections of your - combined work in its license notice, and that you preserve all - their Warranty Disclaimers. - - The combined work need only contain one copy of this License, and - multiple identical Invariant Sections may be replaced with a single - copy. If there are multiple Invariant Sections with the same name - but different contents, make the title of each such section unique - by adding at the end of it, in parentheses, the name of the - original author or publisher of that section if known, or else a - unique number. Make the same adjustment to the section titles in - the list of Invariant Sections in the license notice of the - combined work. - - In the combination, you must combine any sections Entitled - "History" in the various original documents, forming one section - Entitled "History"; likewise combine any sections Entitled - "Acknowledgements," and any sections Entitled "Dedications." You - must delete all sections Entitled "Endorsements." - - 6. COLLECTIONS OF DOCUMENTS - - You may make a collection consisting of the Document and other - documents released under this License, and replace the individual - copies of this License in the various documents with a single copy - that is included in the collection, provided that you follow the - rules of this License for verbatim copying of each of the - documents in all other respects. - - You may extract a single document from such a collection, and - distribute it individually under this License, provided you insert - a copy of this License into the extracted document, and follow - this License in all other respects regarding verbatim copying of - that document. - - 7. AGGREGATION WITH INDEPENDENT WORKS - - A compilation of the Document or its derivatives with other - separate and independent documents or works, in or on a volume of - a storage or distribution medium, is called an "aggregate" if the - copyright resulting from the compilation is not used to limit the - legal rights of the compilation's users beyond what the individual - works permit. When the Document is included in an aggregate, this - License does not apply to the other works in the aggregate which - are not themselves derivative works of the Document. - - If the Cover Text requirement of section 3 is applicable to these - copies of the Document, then if the Document is less than one half - of the entire aggregate, the Document's Cover Texts may be placed - on covers that bracket the Document within the aggregate, or the - electronic equivalent of covers if the Document is in electronic - form. Otherwise they must appear on printed covers that bracket - the whole aggregate. - - 8. TRANSLATION - - Translation is considered a kind of modification, so you may - distribute translations of the Document under the terms of section - 4. Replacing Invariant Sections with translations requires special - permission from their copyright holders, but you may include - translations of some or all Invariant Sections in addition to the - original versions of these Invariant Sections. You may include a - translation of this License, and all the license notices in the - Document, and any Warranty Disclaimers, provided that you also - include the original English version of this License and the - original versions of those notices and disclaimers. In case of a - disagreement between the translation and the original version of - this License or a notice or disclaimer, the original version will - prevail. - - If a section in the Document is Entitled "Acknowledgements," - "Dedications," or "History," the requirement (section 4) to - Preserve its Title (section 1) will typically require changing the - actual title. - - 9. TERMINATION - - You may not copy, modify, sublicense, or distribute the Document - except as expressly provided for under this License. Any other - attempt to copy, modify, sublicense or distribute the Document is - void, and will automatically terminate your rights under this - License. However, parties who have received copies, or rights, - from you under this License will not have their licenses - terminated so long as such parties remain in full compliance. - - 10. FUTURE REVISIONS OF THIS LICENSE - - The Free Software Foundation may publish new, revised versions of - the GNU Free Documentation License from time to time. Such new - versions will be similar in spirit to the present version, but may - differ in detail to address new problems or concerns. See - http://www.gnu.org/copyleft/. - - Each version of the License is given a distinguishing version - number. If the Document specifies that a particular numbered - version of this License "or any later version" applies to it, you - have the option of following the terms and conditions either of - that specified version or of any later version that has been - published (not as a draft) by the Free Software Foundation. If - the Document does not specify a version number of this License, - you may choose any version ever published (not as a draft) by the - Free Software Foundation. - - -ADDENDUM: How to use this License for your documents -==================================================== - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and license -notices just after the title page: - - Copyright (C) YEAR YOUR NAME. - Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.2 - or any later version published by the Free Software Foundation; - with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. - A copy of the license is included in the section entitled ``GNU - Free Documentation License.'' - - If you have Invariant Sections, Front-Cover Texts and Back-Cover -Texts, replace the "with...Texts." line with this: - - with the Invariant Sections being LIST THEIR TITLES, with the - Front-Cover Texts being LIST, and with the Back-Cover Texts being - LIST. - - If you have Invariant Sections without Cover Texts, or some other -combination of the three, merge those two alternatives to suit the -situation. - - If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, to -permit their use in free software. - - -File: muse.info, Node: Concept Index, Prev: GNU Free Documentation License, Up: Top - -Index -***** - -[index] -* Menu: - -* #author: Directives. (line 18) -* #date: Directives. (line 24) -* #desc: Directives. (line 30) -* #title: Directives. (line 36) -* anchors: Horizontal Rules and Anchors. - (line 13) -* blog, journal style: Journal. (line 6) -* blog, one-file-per-entry style: Blosxom. (line 6) -* bugs, reporting: Getting Help and Reporting Bugs. - (line 6) -* citations: Citations. (line 6) -* comments: Comments. (line 6) -* compiling Muse: Installation. (line 11) -* contributors: Contributors. (line 6) -* dashes: Horizontal Rules and Anchors. - (line 6) -* Debian package for Muse: Releases. (line 12) -* developer, becoming: Development. (line 91) -* development: Development. (line 6) -* directives: Directives. (line 6) -* editing Muse files <1>: Publishing Files Overview. - (line 6) -* editing Muse files: Using Muse Mode. (line 6) -* ELPA package for Muse: Installation. (line 64) -* Email addresses: Implicit Links. (line 6) -* emphasizing text: Emphasizing Text. (line 6) -* examples: Paragraphs. (line 21) -* file extension, specifying: File Extensions. (line 6) -* footnotes: Footnotes. (line 6) -* git version control system, using: Development. (line 9) -* headings: Headings. (line 6) -* help, getting: Getting Help and Reporting Bugs. - (line 6) -* history, of Muse: History. (line 6) -* horizontal rules: Horizontal Rules and Anchors. - (line 6) -* HTML, inserting a raw block: Paragraphs. (line 28) -* HTML, rendering blocks in monospace: Paragraphs. (line 21) -* images: Images. (line 6) -* images, captions: Images. (line 53) -* images, displaying: Images. (line 22) -* images, inlined: Images. (line 43) -* images, local: Images. (line 22) -* images, without descriptions: Images. (line 43) -* inserting files at publish time: Tag Summary. (line 6) -* installing Muse: Installation. (line 38) -* inter-project links: Implicit Links. (line 29) -* InterWiki links: Implicit Links. (line 29) -* italicizing text: Emphasizing Text. (line 6) -* journal: Journal. (line 6) -* keystrokes: Keystroke Summary. (line 6) -* line breaks: Paragraphs. (line 46) -* links, explicit: Explicit Links. (line 6) -* links, implicit: Implicit Links. (line 6) -* links, raw: Implicit Links. (line 6) -* links, with images: Images. (line 6) -* links, with target on same page: Horizontal Rules and Anchors. - (line 13) -* lisp, and insert command: Embedded Lisp. (line 13) -* lisp, embedded: Embedded Lisp. (line 6) -* lists: Lists. (line 6) -* lists, breaking lines: Lists. (line 52) -* lists, bullets: Lists. (line 10) -* lists, definitions: Lists. (line 24) -* lists, enumerated: Lists. (line 17) -* lists, nested: Lists. (line 36) -* literal text: Paragraphs. (line 28) -* markup: Markup Rules. (line 6) -* monospace, rendering blocks: Paragraphs. (line 21) -* monospace, rendering words: Emphasizing Text. (line 6) -* muse-define-style: Style Elements. (line 11) -* muse-derive-style: Deriving Styles. (line 11) -* muse-list-edit-minor-mode: Muse List Edit Minor Mode. - (line 44) -* muse-project-alist, reference: Options for Projects. (line 6) -* muse-xml-encoding-map: XML. (line 22) -* paragraphs: Paragraphs. (line 6) -* paragraphs, centered: Paragraphs. (line 8) -* paragraphs, quoted: Paragraphs. (line 16) -* poetry: Verse. (line 6) -* projects: Projects. (line 6) -* projects, multiple: Multiple Projects. (line 6) -* projects, options: Options for Projects. (line 6) -* projects, single: Single Project. (line 6) -* projects, subdirectories: Projects and Subdirectories. - (line 6) -* publishing styles: Publishing Styles. (line 6) -* publishing styles, blosxom-html: Blosxom Options. (line 12) -* publishing styles, blosxom-xhtml: Blosxom Options. (line 15) -* publishing styles, book-latex: Book. (line 56) -* publishing styles, book-pdf: Book. (line 60) -* publishing styles, chapbook-latex: Poem. (line 45) -* publishing styles, chapbook-pdf: Poem. (line 48) -* publishing styles, context: ConTeXt. (line 15) -* publishing styles, context-pdf: ConTeXt. (line 18) -* publishing styles, context-slides: ConTeXt. (line 22) -* publishing styles, context-slides-pdf: ConTeXt. (line 40) -* publishing styles, deriving: Deriving Styles. (line 6) -* publishing styles, docbook: DocBook. (line 11) -* publishing styles, html: HTML. (line 11) -* publishing styles, ikiwiki: Ikiwiki. (line 28) -* publishing styles, info-pdf: Texinfo. (line 17) -* publishing styles, journal-book-latex: Journal. (line 82) -* publishing styles, journal-book-pdf: Journal. (line 85) -* publishing styles, journal-html: Journal. (line 70) -* publishing styles, journal-latex: Journal. (line 76) -* publishing styles, journal-pdf: Journal. (line 79) -* publishing styles, journal-rdf: Journal. (line 88) -* publishing styles, journal-rss: Journal. (line 91) -* publishing styles, journal-rss-entry: Journal. (line 94) -* publishing styles, journal-xhtml: Journal. (line 73) -* publishing styles, latex: LaTeX. (line 23) -* publishing styles, latexcjk: LaTeX. (line 30) -* publishing styles, lecture-notes: LaTeX. (line 55) -* publishing styles, lecture-notes-pdf: LaTeX. (line 61) -* publishing styles, pdf: LaTeX. (line 26) -* publishing styles, pdfcjk: LaTeX. (line 33) -* publishing styles, poem-latex: Poem. (line 39) -* publishing styles, poem-pdf: Poem. (line 42) -* publishing styles, RSS 1.0: Journal. (line 88) -* publishing styles, RSS 2.0: Journal. (line 91) -* publishing styles, slides: LaTeX. (line 37) -* publishing styles, slides-pdf: LaTeX. (line 52) -* publishing styles, texi: Texinfo. (line 14) -* publishing styles, xml: XML. (line 15) -* publishing, including markup in headers and footers: Tag Summary. - (line 6) -* publishing, inserting files: Tag Summary. (line 6) -* publishing, markup functions: Markup Functions. (line 6) -* publishing, markup regexps: Markup Regexps. (line 6) -* publishing, markup strings: Markup Strings. (line 6) -* publishing, markup tags: Markup Tags. (line 6) -* publishing, omitting lines: Comments. (line 6) -* publishing, rules: Markup Regexps. (line 6) -* publishing, style elements: Style Elements. (line 6) -* quotations: Paragraphs. (line 16) -* releases, Debian package: Releases. (line 12) -* releases, from source: Releases. (line 31) -* releases, Ubuntu package: Releases. (line 19) -* settings: Getting Started. (line 6) -* settings, init file: Loading Muse. (line 6) -* tables: Tables. (line 6) -* tables, orgtbl-mode style: Tables. (line 26) -* tables, simple: Tables. (line 6) -* tables, table.el style: Tables. (line 42) -* tags: Tag Summary. (line 6) -* tags, : Citations. (line 6) -* turn-off-muse-list-edit-minor-mode: Muse List Edit Minor Mode. - (line 67) -* turn-on-muse-list-edit-minor-mode: Muse List Edit Minor Mode. - (line 64) -* Ubuntu package for Muse: Releases. (line 19) -* underlining text: Emphasizing Text. (line 6) -* updating Muse with git: Development. (line 66) -* URLs: Implicit Links. (line 6) -* verbatim text: Emphasizing Text. (line 6) -* verses: Verse. (line 6) -* verses, multiple stanzas: Verse. (line 20) -* WikiNames: Implicit Links. (line 18) -* WYSIWYG: Emphasizing Text. (line 15) - - - -Tag Table: -Node: Top1427 -Node: Preface7398 -Node: Introduction7871 -Node: Obtaining Muse9320 -Node: Releases9657 -Node: Development11046 -Node: Installation14905 -Node: Getting Started17564 -Node: Loading Muse17946 -Node: Using Muse Mode18893 -Node: Publishing Files Overview20926 -Node: File Extensions22170 -Node: Projects23390 -Node: Single Project24012 -Node: Multiple Projects24962 -Node: Projects and Subdirectories26365 -Node: Options for Projects28048 -Node: Keystroke Summary32872 -Node: Markup Rules34991 -Node: Paragraphs36710 -Node: Headings38711 -Node: Directives39334 -Node: Emphasizing Text40654 -Node: Footnotes41431 -Node: Verse42068 -Node: Lists42812 -Node: Tables44361 -Node: Explicit Links46095 -Node: Implicit Links46810 -Node: Images49153 -Node: Horizontal Rules and Anchors51643 -Node: Embedded Lisp52291 -Node: Citations53387 -Node: Comments55871 -Node: Tag Summary56530 -Node: Publishing Styles64773 -Node: Blosxom65872 -Node: Blosxom Requirements66479 -Node: Blosxom Entries70014 -Node: Blosxom Options71577 -Node: Book72505 -Node: ConTeXt75564 -Node: DocBook79691 -Node: HTML81168 -Node: Ikiwiki85163 -Node: Journal87502 -Node: LaTeX94029 -Node: Poem99573 -Node: Texinfo101782 -Node: XML103699 -Node: Extending Muse105730 -Node: Markup Functions106367 -Ref: muse-publish-markup-functions106540 -Node: Markup Regexps107194 -Ref: muse-publish-markup-regexps107372 -Node: Markup Strings110379 -Node: Markup Tags116839 -Ref: muse-publish-markup-tags117032 -Node: Style Elements118151 -Node: Deriving Styles121558 -Node: Miscellaneous122857 -Node: Muse List Edit Minor Mode123142 -Node: Getting Help and Reporting Bugs125621 -Node: History128923 -Node: Contributors129706 -Node: GNU Free Documentation License130214 -Node: Concept Index152443 - -End Tag Table diff --git a/elpa/muse-3.20/texi/Makefile b/elpa/muse-3.20/texi/Makefile deleted file mode 100644 index 8f9f341..0000000 --- a/elpa/muse-3.20/texi/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -.PHONY: all info-only doc clean realclean distclean fullclean install -.PRECIOUS: %.info %.html - -DEFS = $(shell test -f ../Makefile.defs && echo ../Makefile.defs \ - || echo ../Makefile.defs.default) - -include $(DEFS) - -all: doc - -%.info: %.texi - makeinfo $< - -%.html: %.texi - makeinfo --html --no-split $< - -info-only: $(MANUAL).info - -doc: $(MANUAL).info $(MANUAL).html - -clean: ; - -distclean realclean fullclean: clean - -rm -f $(MANUAL).info $(MANUAL).html - -install: $(MANUAL).info - [ -d $(INFODIR) ] || install -d $(INFODIR) - install -m 0644 $(MANUAL).info $(INFODIR)/$(MANUAL) - $(call install_info,$(MANUAL)) diff --git a/elpa/muse-3.20/texi/dir-template b/elpa/muse-3.20/texi/dir-template deleted file mode 100644 index 08346cd..0000000 --- a/elpa/muse-3.20/texi/dir-template +++ /dev/null @@ -1,15 +0,0 @@ -This is the file .../info/dir, which contains the -topmost node of the Info hierarchy, called (dir)Top. -The first time you invoke Info you start off looking at this node. - -File: dir, Node: Top This is the top of the INFO tree - - This (the Directory node) gives a menu of major topics. - Typing "q" exits, "?" lists all Info commands, "d" returns here, - "h" gives a primer for first-timers, - "mEmacs" visits the Emacs manual, etc. - - In Emacs, you can click mouse button 2 on a menu item or cross reference - to select it. - -* Menu: diff --git a/elpa/muse-3.20/texi/doclicense.texi b/elpa/muse-3.20/texi/doclicense.texi deleted file mode 100644 index 83e9d6b..0000000 --- a/elpa/muse-3.20/texi/doclicense.texi +++ /dev/null @@ -1,416 +0,0 @@ -@c -*-texinfo-*- -@center Version 1.2, November 2002 - -@display -Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -@end display -@sp 1 -@enumerate 0 -@item -PREAMBLE - -The purpose of this License is to make a manual, textbook, or other -functional and useful document ``free'' in the sense of freedom: to -assure everyone the effective freedom to copy and redistribute it, -with or without modifying it, either commercially or noncommercially. -Secondarily, this License preserves for the author and publisher a way -to get credit for their work, while not being considered responsible -for modifications made by others. - -This License is a kind of ``copyleft,'' which means that derivative -works of the document must themselves be free in the same sense. It -complements the GNU General Public License, which is a copyleft -license designed for free software. - -We have designed this License in order to use it for manuals for free -software, because free software needs free documentation: a free -program should come with manuals providing the same freedoms that the -software does. But this License is not limited to software manuals; -it can be used for any textual work, regardless of subject matter or -whether it is published as a printed book. We recommend this License -principally for works whose purpose is instruction or reference. - -@sp 1 -@item -APPLICABILITY AND DEFINITIONS - -This License applies to any manual or other work, in any medium, that -contains a notice placed by the copyright holder saying it can be -distributed under the terms of this License. Such a notice grants a -world-wide, royalty-free license, unlimited in duration, to use that -work under the conditions stated herein. The ``Document,'' below, -refers to any such manual or work. Any member of the public is a -licensee, and is addressed as ``you.'' You accept the license if you -copy, modify or distribute the work in a way requiring permission -under copyright law. - -A ``Modified Version'' of the Document means any work containing the -Document or a portion of it, either copied verbatim, or with -modifications and/or translated into another language. - -A ``Secondary Section'' is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (Thus, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical -connection with the subject or with related matters, or of legal, -commercial, philosophical, ethical or political position regarding -them. - -The ``Invariant Sections'' are certain Secondary Sections whose titles -are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. If a -section does not fit the above definition of Secondary then it is not -allowed to be designated as Invariant. The Document may contain zero -Invariant Sections. If the Document does not identify any Invariant -Sections then there are none. - -The ``Cover Texts'' are certain short passages of text that are listed, -as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. A Front-Cover Text may -be at most 5 words, and a Back-Cover Text may be at most 25 words. - -A ``Transparent'' copy of the Document means a machine-readable copy, -represented in a format whose specification is available to the -general public, that is suitable for revising the document -straightforwardly with generic text editors or (for images composed of -pixels) generic paint programs or (for drawings) some widely available -drawing editor, and that is suitable for input to text formatters or -for automatic translation to a variety of formats suitable for input -to text formatters. A copy made in an otherwise Transparent file -format whose markup, or absence of markup, has been arranged to thwart -or discourage subsequent modification by readers is not Transparent. -An image format is not Transparent if used for any substantial amount -of text. A copy that is not ``Transparent'' is called ``Opaque.'' - - -Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML, PostScript or PDF designed for human modification. Examples of -transparent image formats include PNG, XCF and JPG. Opaque formats -include proprietary formats that can be read and edited only by -proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML, PostScript or PDF produced by some word -processors for output purposes only. - -The ``Title Page'' means, for a printed book, the title page itself, -plus such following pages as are needed to hold, legibly, the material -this License requires to appear in the title page. For works in -formats which do not have any title page as such, ``Title Page'' means -the text near the most prominent appearance of the work's title, -preceding the beginning of the body of the text. - -A section ``Entitled XYZ'' means a named subunit of the Document whose -title either is precisely XYZ or contains XYZ in parentheses following -text that translates XYZ in another language. (Here XYZ stands for a -specific section name mentioned below, such as ``Acknowledgements,'' -``Dedications,'' ``Endorsements,'' or ``History.'') To ``Preserve the Title'' -of such a section when you modify the Document means that it remains a -section ``Entitled XYZ'' according to this definition. - -The Document may include Warranty Disclaimers next to the notice which -states that this License applies to the Document. These Warranty -Disclaimers are considered to be included by reference in this -License, but only as regards disclaiming warranties: any other -implication that these Warranty Disclaimers may have is void and has -no effect on the meaning of this License. -@sp 1 -@item -VERBATIM COPYING - -You may copy and distribute the Document in any medium, either -commercially or noncommercially, provided that this License, the -copyright notices, and the license notice saying this License applies -to the Document are reproduced in all copies, and that you add no other -conditions whatsoever to those of this License. You may not use -technical measures to obstruct or control the reading or further -copying of the copies you make or distribute. However, you may accept -compensation in exchange for copies. If you distribute a large enough -number of copies you must also follow the conditions in section 3. - -You may also lend copies, under the same conditions stated above, and -you may publicly display copies. -@sp 1 -@item -COPYING IN QUANTITY - -If you publish printed copies (or copies in media that commonly have -printed covers) of the Document, numbering more than 100, and the -Document's license notice requires Cover Texts, you must enclose the -copies in covers that carry, clearly and legibly, all these Cover -Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on -the back cover. Both covers must also clearly and legibly identify -you as the publisher of these copies. The front cover must present -the full title with all words of the title equally prominent and -visible. You may add other material on the covers in addition. -Copying with changes limited to the covers, as long as they preserve -the title of the Document and satisfy these conditions, can be treated -as verbatim copying in other respects. - -If the required texts for either cover are too voluminous to fit -legibly, you should put the first ones listed (as many as fit -reasonably) on the actual cover, and continue the rest onto adjacent -pages. - -If you publish or distribute Opaque copies of the Document numbering -more than 100, you must either include a machine-readable Transparent -copy along with each Opaque copy, or state in or with each Opaque copy -a computer-network location from which the general network-using -public has access to download using public-standard network protocols -a complete Transparent copy of the Document, free of added material. -If you use the latter option, you must take reasonably prudent steps, -when you begin distribution of Opaque copies in quantity, to ensure -that this Transparent copy will remain thus accessible at the stated -location until at least one year after the last time you distribute an -Opaque copy (directly or through your agents or retailers) of that -edition to the public. - -It is requested, but not required, that you contact the authors of the -Document well before redistributing any large number of copies, to give -them a chance to provide you with an updated version of the Document. -@sp 1 -@item -MODIFICATIONS - -You may copy and distribute a Modified Version of the Document under -the conditions of sections 2 and 3 above, provided that you release -the Modified Version under precisely this License, with the Modified -Version filling the role of the Document, thus licensing distribution -and modification of the Modified Version to whoever possesses a copy -of it. In addition, you must do these things in the Modified Version: - -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission.@* -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has fewer than five), - unless they release you from this requirement.@* -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher.@* -D. Preserve all the copyright notices of the Document.@* -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices.@* -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below.@* -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice.@* -H. Include an unaltered copy of this License.@* -I. Preserve the section Entitled ``History,'' Preserve its Title, and add - to it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section Entitled ``History'' in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence.@* -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the ``History'' section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission.@* -K. For any section Entitled ``Acknowledgements'' or ``Dedications,'' - Preserve the Title of the section, and preserve in the section all - the substance and tone of each of the contributor acknowledgements - and/or dedications given therein.@* -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles.@* -M. Delete any section Entitled ``Endorsements.'' Such a section - may not be included in the Modified Version.@* -N. Do not retitle any existing section to be Entitled ``Endorsements'' - or to conflict in title with any Invariant Section.@* -O. Preserve any Warranty Disclaimers.@* -@sp 1 -If the Modified Version includes new front-matter sections or -appendices that qualify as Secondary Sections and contain no material -copied from the Document, you may at your option designate some or all -of these sections as invariant. To do this, add their titles to the -list of Invariant Sections in the Modified Version's license notice. -These titles must be distinct from any other section titles. - -You may add a section Entitled ``Endorsements,'' provided it contains -nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has -been approved by an organization as the authoritative definition of a -standard. - -You may add a passage of up to five words as a Front-Cover Text, and a -passage of up to 25 words as a Back-Cover Text, to the end of the list -of Cover Texts in the Modified Version. Only one passage of -Front-Cover Text and one of Back-Cover Text may be added by (or -through arrangements made by) any one entity. If the Document already -includes a cover text for the same cover, previously added by you or -by arrangement made by the same entity you are acting on behalf of, -you may not add another; but you may replace the old one, on explicit -permission from the previous publisher that added the old one. - -The author(s) and publisher(s) of the Document do not by this License -give permission to use their names for publicity for or to assert or -imply endorsement of any Modified Version. -@sp 1 -@item -COMBINING DOCUMENTS - -You may combine the Document with other documents released under this -License, under the terms defined in section 4 above for modified -versions, provided that you include in the combination all of the -Invariant Sections of all of the original documents, unmodified, and -list them all as Invariant Sections of your combined work in its -license notice, and that you preserve all their Warranty Disclaimers. - -The combined work need only contain one copy of this License, and -multiple identical Invariant Sections may be replaced with a single -copy. If there are multiple Invariant Sections with the same name but -different contents, make the title of each such section unique by -adding at the end of it, in parentheses, the name of the original -author or publisher of that section if known, or else a unique number. -Make the same adjustment to the section titles in the list of -Invariant Sections in the license notice of the combined work. - -In the combination, you must combine any sections Entitled ``History'' -in the various original documents, forming one section Entitled -``History''; likewise combine any sections Entitled ``Acknowledgements,'' -and any sections Entitled ``Dedications.'' You must delete all sections -Entitled ``Endorsements.'' -@sp 1 -@item -COLLECTIONS OF DOCUMENTS - -You may make a collection consisting of the Document and other documents -released under this License, and replace the individual copies of this -License in the various documents with a single copy that is included in -the collection, provided that you follow the rules of this License for -verbatim copying of each of the documents in all other respects. - -You may extract a single document from such a collection, and distribute -it individually under this License, provided you insert a copy of this -License into the extracted document, and follow this License in all -other respects regarding verbatim copying of that document. -@sp 1 -@item -AGGREGATION WITH INDEPENDENT WORKS - -A compilation of the Document or its derivatives with other separate -and independent documents or works, in or on a volume of a storage or -distribution medium, is called an ``aggregate'' if the copyright -resulting from the compilation is not used to limit the legal rights -of the compilation's users beyond what the individual works permit. -When the Document is included in an aggregate, this License does not -apply to the other works in the aggregate which are not themselves -derivative works of the Document. - -If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one half of -the entire aggregate, the Document's Cover Texts may be placed on -covers that bracket the Document within the aggregate, or the -electronic equivalent of covers if the Document is in electronic form. -Otherwise they must appear on printed covers that bracket the whole -aggregate. -@sp 1 -@item -TRANSLATION - -Translation is considered a kind of modification, so you may -distribute translations of the Document under the terms of section 4. -Replacing Invariant Sections with translations requires special -permission from their copyright holders, but you may include -translations of some or all Invariant Sections in addition to the -original versions of these Invariant Sections. You may include a -translation of this License, and all the license notices in the -Document, and any Warranty Disclaimers, provided that you also include -the original English version of this License and the original versions -of those notices and disclaimers. In case of a disagreement between -the translation and the original version of this License or a notice -or disclaimer, the original version will prevail. - -If a section in the Document is Entitled ``Acknowledgements,'' -``Dedications,'' or ``History,'' the requirement (section 4) to Preserve -its Title (section 1) will typically require changing the actual -title. -@sp 1 -@item -TERMINATION - -You may not copy, modify, sublicense, or distribute the Document except -as expressly provided for under this License. Any other attempt to -copy, modify, sublicense or distribute the Document is void, and will -automatically terminate your rights under this License. However, -parties who have received copies, or rights, from you under this -License will not have their licenses terminated so long as such -parties remain in full compliance. -@sp 1 -@item -FUTURE REVISIONS OF THIS LICENSE - -The Free Software Foundation may publish new, revised versions -of the GNU Free Documentation License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. See -http://www.gnu.org/copyleft/. - -Each version of the License is given a distinguishing version number. -If the Document specifies that a particular numbered version of this -License ``or any later version'' applies to it, you have the option of -following the terms and conditions either of that specified version or -of any later version that has been published (not as a draft) by the -Free Software Foundation. If the Document does not specify a version -number of this License, you may choose any version ever published (not -as a draft) by the Free Software Foundation. - -@end enumerate - -@unnumberedsec ADDENDUM: How to use this License for your documents - -To use this License in a document you have written, include a copy of -the License in the document and put the following copyright and -license notices just after the title page: - -@smallexample -@group -Copyright (C) @var{year} @var{your name}. -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.2 -or any later version published by the Free Software Foundation; -with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. -A copy of the license is included in the section entitled ``GNU -Free Documentation License.'' -@end group -@end smallexample - -If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, -replace the ``with...Texts.'' line with this: - -@smallexample -@group -with the Invariant Sections being @var{list their titles}, with the -Front-Cover Texts being @var{list}, and with the Back-Cover Texts being -@var{list}. -@end group -@end smallexample - -If you have Invariant Sections without Cover Texts, or some other -combination of the three, merge those two alternatives to suit the -situation. - -If your document contains nontrivial examples of program code, we -recommend releasing these examples in parallel under your choice of -free software license, such as the GNU General Public License, -to permit their use in free software. - -@ignore - arch-tag: c1679162-1d8a-4f02-bc52-2e71765f0165 -@end ignore diff --git a/elpa/muse-3.20/texi/muse.texi b/elpa/muse-3.20/texi/muse.texi deleted file mode 100644 index f62c030..0000000 --- a/elpa/muse-3.20/texi/muse.texi +++ /dev/null @@ -1,4247 +0,0 @@ -\input texinfo @c -*-texinfo-*- -@c %**start of header -@setfilename muse.info -@settitle Muse -@c %**end of header - -@dircategory Emacs -@direntry -* Muse: (muse). Authoring and publishing environment for Emacs. -@end direntry - -@syncodeindex fn cp - -@copying -This manual is for Emacs Muse version 3.20. - -Copyright @copyright{} 2004, 2005, 2006, 2007, -2008, 2009, 2010 Free Software Foundation, Inc. - -@quotation -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.2 or -any later version published by the Free Software Foundation; with no -Invariant Sections, with the Front-Cover texts being ``A GNU -Manual'', and with the Back-Cover Texts as in (a) below. A copy of the -license is included in the section entitled ``GNU Free Documentation -License'' in this manual. - -(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify -this GNU Manual, like GNU software. Copies published by the Free -Software Foundation raise funds for GNU development.'' - -This document is part of a collection distributed under the GNU Free -Documentation License. If you want to distribute this document -separately from the collection, you can do so by adding a copy of the -license to the document, as described in section 6 of the license. - -All Emacs Lisp code contained in this document may be used, distributed, -and modified without restriction. -@end quotation -@end copying - -@titlepage -@title Muse manual -@subtitle an authoring and publishing environment -@subtitle for GNU Emacs and XEmacs - -@c The following two commands -@c start the copyright page. -@page -@vskip 0pt plus 1filll -@insertcopying -@end titlepage - -@c So the toc is printed at the start -@contents - -@ifnottex -@node Top, Preface, (dir), (dir) -@comment node-name, next, previous, up -@top Muse - -@insertcopying -@end ifnottex - -@menu -* Preface:: About the documentation. -* Introduction:: What is Muse? -* Obtaining Muse:: How to get Muse releases and development - changes. -* Installation:: Compiling and installing Muse. -* Getting Started:: Setting up Muse and editing files. -* Projects:: Creating and managing Muse projects. -* Keystroke Summary:: Keys used in Muse mode. -* Markup Rules:: Rules for using markup. -* Publishing Styles:: Publishing various types of documents. -* Extending Muse:: Making your own publishing styles. -* Miscellaneous:: Miscellaneous add-ons, like a minor mode. -* Getting Help and Reporting Bugs:: -* History:: History of this document. -* Contributors:: Contributors to this documentation. -* GNU Free Documentation License:: The license for this documentation. -* Concept Index:: Search for terms. - -@detailmenu - --- The Detailed Node Listing --- - -How to Get Muse Releases and Development Changes - -* Releases:: Released versions of Muse. -* Development:: Latest unreleased development changes. - -Getting Started - -* Loading Muse:: How to load Muse. -* Using Muse Mode:: How to edit files in Muse. -* Publishing Files Overview:: Publishing a single file or project. -* File Extensions:: Using a different file extension. - -Creating and Managing Muse Projects - -* Single Project:: A single-project example. -* Multiple Projects:: A multiple-project example. -* Projects and Subdirectories:: Publishing subdirectories in projects. -* Options for Projects:: Listing of available options for projects. - -Rules for Using Markup - -* Paragraphs:: Paragraphs: centering and quoting. -* Headings:: Levels of headings. -* Directives:: Directives at the beginning of a - document. -* Emphasizing Text:: Bold, italicized, and underlined text. -* Footnotes:: Making notes to be shown at the end. -* Verse:: Indicating poetic stanzas. -* Lists:: Lists of items. -* Tables:: Generation of data tables. -* Explicit Links:: Hyperlinks and email addresses with - descriptions. -* Implicit Links:: Bare URLs, WikiNames, and InterWiki - links. -* Images:: Publishing and displaying images. -* Horizontal Rules and Anchors:: Inserting a horizontal line or anchor. -* Embedded Lisp:: Evaluating Emacs Lisp code in documents - for extensibility. -* Citations:: Support for citing other resources. -* Comments:: Lines to omit from published output. -* Tag Summary:: Tags that Muse recognizes. - -Publishing Various Types of Documents - -* Blosxom:: Integrating Muse and pyblosxom.cgi. -* Book:: Publishing entries into a compilation. -* ConTeXt:: Publishing ConTeXt documents. -* DocBook:: Publishing in DocBook XML form. -* HTML:: Publishing in HTML or XHTML form. -* Ikiwiki:: Integrating with ikiwiki. -* Journal:: Keeping a journal or blog. -* LaTeX:: Publishing LaTeX documents. -* Poem:: Publish a poem to LaTeX or PDF. -* Texinfo:: Publish entries to Texinfo format or PDF. -* XML:: Publish entries to XML. - -Integrating Muse and pyblosxom.cgi - -* Blosxom Requirements:: Other tools needed for the Blosxom style. -* Blosxom Entries:: Format of a Blosxom entry and automation. -* Blosxom Options:: Blosxom styles and options provided. - -Making your own publishing styles - -* Markup Functions:: Specifying functions to mark up text. -* Markup Regexps:: Markup rules for publishing. -* Markup Strings:: Strings specific to a publishing style. -* Markup Tags:: Tag specifications for special markup. -* Style Elements:: Parameters used for defining styles. -* Deriving Styles:: Deriving a new style from an existing - one. - -Miscellaneous add-ons, like a minor mode - -* Muse List Edit Minor Mode:: Edit lists easily in other major modes. - -@end detailmenu -@end menu - -@node Preface, Introduction, Top, Top -@comment node-name, next, previous, up -@chapter About the documentation - -This document describes Muse, which was written by John Wiegley and is -now maintained by Michael Olson. Several versions of this manual are -available on-line. - -@itemize @bullet -@item PDF: http://mwolson.org/static/doc/muse.pdf -@item HTML (single file): http://mwolson.org/static/doc/muse.html -@item HTML (multiple files): http://mwolson.org/static/doc/muse/ -@end itemize - -@node Introduction, Obtaining Muse, Preface, Top -@comment node-name, next, previous, up -@chapter What is Muse? - -Emacs Muse (also known as ``Muse'' or ``Emacs-Muse'') is an authoring -and publishing environment for Emacs. It simplifies the process of -writing documents and publishing them to various output formats. - -Muse consists of two main parts: an enhanced text-mode for authoring -documents and navigating within Muse projects, and a set of publishing -styles for generating different kinds of output. - -What makes Muse distinct from other text-publishing systems is a modular -environment, with a rather simple core, in which "styles" are derived -from to create new styles. Much of Muse's overall functionality is -optional. For example, you can use the publisher without the -major-mode, or the mode without doing any publishing; or if you don't -load the Texinfo or LaTeX modules, those styles won't be available. - -The Muse codebase is a departure from emacs-wiki.el version 2.44. The -code has been restructured and rewritten, especially its publishing -functions. The focus in this revision is on the authoring and -publishing aspects, and the "wikiness" has been removed as a default -behavior (available in the optional @file{muse-wiki} module). CamelCase -words are no longer special by default. - -One of the principal aims in the development of Muse is to make it very -easy to produce good-looking, standards-compliant documents. - -@node Obtaining Muse, Installation, Introduction, Top -@comment node-name, next, previous, up -@chapter How to Get Muse Releases and Development Changes - -@menu -* Releases:: Released versions of Muse. -* Development:: Latest unreleased development changes. -@end menu - -@node Releases, Development, Obtaining Muse, Obtaining Muse -@comment node-name, next, previous, up -@section Released versions of Muse - -Choose to install a release if you want to minimize risk. - -Errors are corrected in development first. User-visible changes will be -announced on the @email{muse-el-discuss@@gna.org} mailing list. -@xref{Getting Help and Reporting Bugs}. - -@cindex releases, Debian package -@cindex Debian package for Muse -Debian users can get Muse via apt-get. The @file{muse-el} package is -available both at Michael Olson's APT repository and the official Debian -repository. To make use of the former, add the following line to your -@file{/etc/apt/sources.list} file and run @code{apt-get install muse}. - -@example -deb http://mwolson.org/debian/ ./ -@end example - -@cindex releases, Ubuntu package -@cindex Ubuntu package for Muse -Ubuntu users can also get Muse via apt-get. The @file{muse-el} package -is available both at Michael Olson's APT repository and the official -Ubuntu repository. To make use of the former, add the following line to -your @file{/etc/apt/sources.list} file and run @code{apt-get install -muse}. - -@example -deb http://mwolson.org/ubuntu/ ./ -@end example - -The reason for making separate Debian and Ubuntu packages is that this -manual is under the GFDL, and Debian will not allow it to be distributed -in its main repository. Ubuntu, on the other hand, permits this manual -to be included with the @file{muse-el} package. - -@cindex releases, from source -Alternatively, you can download the latest release from -@uref{http://download.gna.org/muse-el/} . - -@node Development, , Releases, Obtaining Muse -@comment node-name, next, previous, up -@section Latest unreleased development changes -@cindex development - -Choose the development version if you want to live on the bleeding edge -of Muse development or try out new features before release. - -@cindex git version control system, using -The git version control system allows you to keep up-to-date with the -latest changes to the development version of Muse. It also allows you -to contribute changes (via commits, if you are have developer access to -the repository, or via patches, otherwise). If you would like to -contribute to Muse development, it is highly recommended that you use -git. - -If you are new to git, you might find this tutorial helpful: -@uref{http://www.kernel.org/pub/software/scm/git/docs/tutorial.html}. - -Downloading the Muse module with git and staying up-to-date involves -the following steps. - -@enumerate -@item Install git. - -@itemize @bullet -@item Debian and Ubuntu: @kbd{apt-get install git-core}. -@item Windows: @uref{http://git.or.cz/gitwiki/WindowsInstall}. -@item Other operating systems: download, compile, and install the source -from @uref{http://www.kernel.org/pub/software/scm/git/}, or find a git -package for your operating system. -@end itemize - -@item Download the Muse development branch. - -If you have developer access to Muse, do: - -@example -git clone ssh://repo.or.cz/srv/git/muse-el.git muse -@end example - -otherwise, do: - -@example -git clone git://repo.or.cz/muse-el.git muse -@end example - -If you are behind a restrictive firewall, and do not have developer -access, then do the following instead: - -@example -git clone http://repo.or.cz/r/muse-el.git muse -@end example - -@item List upstream changes that are missing from your local copy. -Do this whenever you want to see whether new changes have been committed -to Muse. If you wish, you may skip this step and proceed directly to -the ``update'' step. - -@example -# Change to the source directory you are interested in. -cd muse - -# Fetch new changes from the repository, but don't apply them yet -git fetch origin - -# Display log messages for the new changes -git log HEAD..origin -@end example - -``origin'' is git's name for the location where you originally got Muse -from. You can change this location at any time by editing the -@file{.git/config} file in the directory where the Muse source was -placed. - -@cindex updating Muse with git -@item Update to the latest version by pulling in any missing changes. - -@example -cd muse -git pull origin -@end example - -git will show how many files changed, and will provide a visual display -for how many lines were changed in each file. - -@end enumerate - -There are other ways to interact with the Muse repository. - -@itemize -@item Browse git repo: @uref{http://repo.or.cz/w/muse-el.git} -@item Latest development snapshot: @uref{http://mwolson.org/static/dist/muse-latest.tar.gz} -@item Latest development snapshot (zip file): @uref{http://mwolson.org/static/dist/muse-latest.zip} -@end itemize - -The latest development snapshot can lag behind the git repo by as much -as 20 minutes, but never more than that. - -@subheading Becoming a Muse developer -@cindex developer, becoming - -If you want commit access to the shared Muse repository, then register -an account at @uref{http://repo.or.cz} (be sure to add an SSH key), and -contact the current maintainer at @email{mwolson@@gnu.org}. It would be -best to send some patches to the @email{muse-el-discuss@@gna.org} -mailing list first, so that he knows that you know what you are doing. -@xref{Getting Help and Reporting Bugs}, for instructions on subscribing -to the mailing list. - -You must also be willing to sign a copyright assignment for your changes -to Muse, since Muse is a GNU project. The current maintainer will -assist you in this process if you contact him. - -For information on committing changes to Muse and performing -development, please consult -@uref{http://emacswiki.org/cgi-bin/wiki/MuseDevelopment}. - -@node Installation, Getting Started, Obtaining Muse, Top -@comment node-name, next, previous, up -@chapter Compiling and Installing Muse - -Muse may be compiled and installed on your machine. - -@subheading Compilation -@cindex compiling Muse - -This is an optional step, since Emacs Lisp source code does not -necessarily have to be byte-compiled. Byte-compilation may yield a very -slight speed increase. - -A working copy of Emacs or XEmacs is needed in order to compile Emacs -Muse. By default, the program that is installed with the name -@command{emacs} will be used. - -If you want to use the @command{xemacs} binary to perform the -compilation, you must copy @file{Makefile.defs.default} to -@file{Makefile.defs} in the top-level directory, and then edit -@file{Makefile.defs} as follows. You can put either a full path to an -Emacs or XEmacs binary or just the command name, as long as it is in the -@env{PATH}. - -@example -EMACS = xemacs -SITEFLAG = -no-site-file -# Edit the section as necessary -install_info = install-info --section "XEmacs 21.4" $(1).info \ - $(INFODIR)/dir || : -@end example - -Running @code{make} in the top-level directory should compile the Muse -source files in the @file{lisp} directory, and generate an autoloads -file in @file{lisp/muse-autoloads.el}. - -@subheading Installation -@cindex installing Muse - -Muse may be installed into your file hierarchy by doing the following. - -Copy @file{Makefile.defs.default} to @file{Makefile.defs} in the -top-level directory, if you haven't done so already. Then edit the -@file{Makefile.defs} file so that @env{ELISPDIR} points to where you -want the source and compiled Muse files to be installed and -@env{INFODIR} indicates where to put the Muse manual. You may use a -combination of @env{DESTDIR} and @env{PREFIX} to further determine where -the installed files should be placed. As mentioned earlier, you will -want to edit @env{EMACS} and @env{SITEFLAG} as shown in the Compilation -section if you are using XEmacs. - -If you are installing Muse on a Debian or Ubuntu system, you might want -to change the value of @env{INSTALLINFO} as specified in -@file{Makefile.defs}. - -If you wish to install Muse to different locations than the defaults -specify, edit @file{Makefile.defs} accordingly. - -Run @code{make} as a normal user, if you haven't done so already. - -Run @code{make install} as the root user if you have chosen installation -locations that require root permissions. - -@subheading ELPA -@cindex ELPA package for Muse - -For those used to installing software packages, there will be a -@code{muse} package available in the Emacs Lisp Package Archive -(abbreviated ``ELPA'') as of the 3.10 release of Muse. This package -will be compiled and installed automatically in a user-specific -location. For more information on ELPA, see -@uref{http://tromey.com/elpa/}. - -@node Getting Started, Projects, Installation, Top -@comment node-name, next, previous, up -@chapter Getting Started -@cindex settings - -@menu -* Loading Muse:: How to load Muse. -* Using Muse Mode:: How to edit files in Muse. -* Publishing Files Overview:: Publishing a single file or project. -* File Extensions:: Using a different file extension. -@end menu - -@node Loading Muse, Using Muse Mode, Getting Started, Getting Started -@comment node-name, next, previous, up -@section How to Load Muse -@cindex settings, init file - -To use Muse, add the directory containing its files to your -@code{load-path} variable, in your @file{.emacs} file. Then, load in -the authoring mode, and the styles you wish to publish to. An example -follows. - -@lisp -(add-to-list 'load-path "") - -(require 'muse-mode) ; load authoring mode - -(require 'muse-html) ; load publishing styles I use -(require 'muse-latex) -(require 'muse-texinfo) -(require 'muse-docbook) - -(require 'muse-project) ; publish files in projects -@end lisp - -An easy way of seeing which settings are available and changing settings -is to use the Muse customization interface. To do this, type -@kbd{M-x customize-group muse RET}. Each of the options has its own -documentation. Options are grouped logically according to what effect -they have. - -@node Using Muse Mode, Publishing Files Overview, Loading Muse, Getting Started -@comment node-name, next, previous, up -@section How to Edit Files in Muse -@cindex editing Muse files - -Muse Mode should automatically be activated when you visit a file with a -``.muse'' extension. One such file is @file{QuickStart.muse}, which is -available in the @file{examples} directory of the Muse distribution. -You can tell that Muse Mode has been activated by checking for the text -``Muse'' in your mode line. If Muse Mode has not been activated, you -may activate it by type @kbd{M-x muse-mode RET}. - -You will notice that Muse files are highlighted very simply. Links are -colored blue, headings are large and bold text, and @verb{||} -tags are colored in grey. - -There are several different ways to edit things like links, which hide -the underlying Muse markup. One way is to toggle font-locking off by -hitting @kbd{C-c C-l}, which is also @kbd{M-x font-lock-mode}, make -changes, and then hit @kbd{C-c C-l} again to toggle font-locking back -on. Another way is just to move into the text and edit it. Markup can -also be removed by normal deletion methods, though some side effects -might require a second deletion. - -For the particular case of editing links, it is easiest to move to the -link and do @kbd{C-c C-e}, which is also @kbd{M-x -muse-edit-link-at-point}. This prompts you for the link and its -description, using the previous contents of the link as initial values. -A link to another Muse file may be created by hitting @kbd{C-c TAB l}. -A link to a URL may be created by hitting @kbd{C-c TAB u}. Links may be -followed by hitting @kbd{RET} on them. - -If you want to add a new list item, this may by accomplished by hitting -@kbd{M-RET}. This will put a dash and some spaces on the screen. The -dash is the Muse markup that indicates a list item. It is also possible -to created ``nested'' lists with this command, by adjusting the number -of spaces in front of the dashes. If you have lists with long lines, -you can move to a list item and hit @kbd{M-q} to wrap it onto multiple -lines. - -@node Publishing Files Overview, File Extensions, Using Muse Mode, Getting Started -@comment node-name, next, previous, up -@section Publishing a Single File or Project -@cindex editing Muse files - -The command @kbd{M-x muse-project-publish-this-file} will publish the -current document to any available publishing style (a publishing style -is an output format, like HTML or Docbook), placing the output in the -current directory. If you are in Muse Mode, this command will be bound -to @kbd{C-c C-t}. If the file has been published recently, and its -contents have not changed, running @kbd{C-c C-t} again will not publish -the file. To force publishing in this case, do @kbd{C-u C-c C-t}. - -If you have set up projects and are visiting a file that is part of a -project, then @kbd{C-c C-t} will restrict the output formats to those -which are used by the project, and will automatically publish to the -output directory defined by the project. If you want to publish to a -different directory or use a different format, then use @kbd{C-c M-C-t}, -which is also @kbd{M-x muse-publish-this-file}. - -If the currently opened file is part of a defined project in -@code{muse-project-alist}, it (and the rest of the changed files in a -project) may be published using @kbd{C-c C-p}. - -@node File Extensions, , Publishing Files Overview, Getting Started -@comment node-name, next, previous, up -@section Using a Different File Extension -@cindex file extension, specifying - -By default, Muse expects all project files to have the file extension -@file{.muse}. Files without this extension will not be associated with -Muse mode and will not be considered part of any project, even if they -are within a project directory. - -If you don't want to use @file{.muse}, you can customize the extension -by setting the value of @code{muse-file-extension}. - -If you don't want to use any extension at all, and want Muse to -autodetect project files based on their location, then add the following -to your Muse settings file. - -@lisp -(setq muse-file-extension nil - muse-mode-auto-p t) -@end lisp - -Note that if you chose to have @code{muse-file-extension} set to -@code{nil}, you may have trouble if your @file{.emacs} file or other -init scripts attempt to visit a Muse file. (A very common example of -this is if you use Planner with Muse and run @code{(plan)} from your -@file{.emacs}.) If you wish to visit Muse files from your -@file{.emacs}, be sure to also add the following additional code before -any such visits happen: - -@lisp -(add-hook 'find-file-hooks 'muse-mode-maybe) -@end lisp - - -@node Projects, Keystroke Summary, Getting Started, Top -@comment node-name, next, previous, up -@chapter Creating and Managing Muse Projects -@cindex projects - -Often you will want to publish all the files within a directory to a -particular set of output styles automatically. To support, Muse -allows for the creation of "projects". - -@menu -* Single Project:: A single-project example. -* Multiple Projects:: A multiple-project example. -* Projects and Subdirectories:: Publishing subdirectories in projects. -* Options for Projects:: Listing of available options for projects. -@end menu - -@node Single Project, Multiple Projects, Projects, Projects -@comment node-name, next, previous, up -@section A Single-Project Example -@cindex projects, single - -Here is a sample project, which may be defined in your @file{.emacs} -file. - -@lisp -(setq muse-project-alist - '(("Website" ("~/Pages" :default "index") - (:base "html" :path "~/public_html") - (:base "pdf" :path "~/public_html/pdf")))) -@end lisp - -The above defines a project named "website", whose files are located -in the directory @file{~/Pages}. The default page to visit is -@file{index}. When this project is published, each page will be -output as HTML to the directory @file{~/public_html}, and as PDF to -the directory @file{~/public_html/pdf}. Within any project page, you -may create a link to other pages using the syntax @samp{[[pagename]]}. - -If you would like to include only some files from a directory in a Muse -project, you may use a regexp in place of @file{~/Pages} in the example. - -@node Multiple Projects, Projects and Subdirectories, Single Project, Projects -@comment node-name, next, previous, up -@section A Multiple-Project Example -@cindex projects, multiple - -It is possible to specify multiple projects. Here is an example of -three projects: a generic website, a projects area, and a day-planner -(the day-planner part requires Planner Mode---see -@uref{http://wjsullivan.net/PlannerMode.html} to get it). - -@lisp -(setq muse-project-alist - '(("Website" ("~/Pages" :default "index") - (:base "html" :path "~/public_html")) - (("Projects" ("~/Projects" :default "index") - (:base "xhtml" - :path "~/public_html/projects" - :exclude "/TopSecret") - (:base "pdf" - :path "~/public_html/projects/pdf" - :exclude "/TopSecret"))) - ("Plans" ("~/Plans" - :default "TaskPool" - :major-mode planner-mode - :visit-link planner-visit-link) - (:base "planner-xhtml" - :path "~/public_html/plans")))) -@end lisp - -The @option{:major-mode} attribute specifies which major to use when -visiting files in this directory. - -The @option{:visit-link} attribute specifies the function to call when -visiting links. - -The @option{:exclude} attribute has a regexp that matches files to never -publish. - -@node Projects and Subdirectories, Options for Projects, Multiple Projects, Projects -@comment node-name, next, previous, up -@section Publishing Subdirectories in Projects -@cindex projects, subdirectories - -If you want to publish a directory and all of its subdirectories, Muse -provides two convenience functions that together generate the proper -rules for you. Note that we use the backtick to begin this -muse-project-alist definition, rather than a single quote. - -@lisp -(setq muse-project-alist - `(("Website" ("~/Pages" :default "index") - (:base "html" :path "~/public_html")) - ("Blog" (,@@(muse-project-alist-dirs "~/Blog") - :default "index") - ;; Publish this directory and its subdirectories. Arguments - ;; are as follows. The above `muse-project-alist-dirs' part - ;; is also needed. - ;; 1. Source directory - ;; 2. Output directory - ;; 3. Publishing style - ;; remainder: Other things to put in every generated style - ,@@(muse-project-alist-styles "~/Blog" - "~/public_html/blog" - "blosxom")))) -@end lisp - -The @code{muse-project-alist-dirs} function takes a directory and -returns it and all of its subdirectories in a list. - -The @code{muse-project-alist-styles} function is explained by the -comments above. - -The ``blosxom'' text is the name of another publishing style, much like -``html''. @xref{Blosxom}, for further information about it. You can -use any publishing style you like for the third argument to -@code{muse-project-alist-styles}. - -@node Options for Projects, , Projects and Subdirectories, Projects -@comment node-name, next, previous, up -@section Listing of Available Options for Projects -@cindex projects, options -@cindex muse-project-alist, reference - -This is a listing of all of the various options (or, more accurately: -attributes) that may be specified in @code{muse-project-alist}. - -Each muse-project-alist entry looks like this: - -@example - (PROJECT-NAME (SOURCES) - OUTPUTS) -@end example - -We refer to these names below. - -``Attributes'', which compose SOURCES and OUTPUTS, are a pair of values. -The first value is a keyword, like @option{:default}. The second part -is the value associated with that keyword, such as the text ``index''. -If you are familiar with Emacs Lisp property lists, the concept is -similar to that, except that in the SOURCES section, single directories -can be interspersed with two-value attributes. - -@subheading Project Name - -This is a string that indicates the name of the project. It is -primarily used for publishing interwiki links with the -@file{muse-wiki.el} module. - -@subheading Sources - -This part of a muse-project-alist entry consists of two-value -attributes, and also directory names. If you are publishing a book, the -order of directories and attributes is significant. - -The minimal content for the sources section is a list of directories. - -@table @option - -@item :book-chapter -Indicates a new chapter of a book. The text of the title of the chapter -comes immediately after this keyword. - -@item :book-end -Indicates the end of a book. Directories listed after this one are -ignored when publishing a book. The value ``t'' (without quotes) should -come immediately after this keyword. - -@item :book-funcall -A function to call while publishing a book. This is useful for doing -something just after a particular chapter. - -@item :book-part -Indicates the beginning of a new part of the book. The text of the -title should come immediately after this keyword. - -@item :book-style -Indicate a particular publishing style to use for this part of the book. -If this is specified, it should come just after a @option{:part} -attribute. - -@item :default -The default page to visit when browsing a project. Also, if you are -using the @file{muse-wiki.el} module, publishing a link to just a -project's name will cause it to link to this default file. - -@item :force-publish -This specifies a list of pages which should be published every time a -project is published (by using @kbd{C-c C-p}, for example), regardless -of whether their contents have changed. This is useful for updating -Index pages, pages that use the @verb{||} tag, and other pages -that have dynamically-generated content. - -@item :major-mode -This specifies the major mode to use when visiting files in this -project. The default is @code{muse-mode}. - -@item :nochapters -This indicates that while publishing a book, do not automatically create -chapters. Values which may follow this are nil (the default, which -means that we automatically create chapters), or non-nil, which means -that we manually specify chapters with the @option{:book-chapter} -attribute, - -@item :publish-project -Indicates which function we should call when publishing a project. - -@item :set -This specifies a list of variables and values to set when publishing a -project. The list should be a property list, which is in the form: - -@example -(VAR1 VALUE1 VAR2 VALUE2 ...) -@end example - -@item :visit-link -Specifies the function to call when visiting a link. The default is -@code{muse-visit-link-default}. The arguments for that function should -be (1) the link and (2) whether to visit the link in a new window. - -@end table - -@subheading Outputs - -This part of a muse-project-alist entry is composed of lists of -attributes. Each list is called an ``output style''. - -The minimal content for an output style is a @option{:base} attribute -and a @option{:path} attribute. - -@table @option - -@item :base -Publishing style to use, such as ``html'', ``docbook'', or ``pdf''. - -@item :base-url -An external URL which can be used to access published files. This is -mainly used by the @file{muse-wiki} module when publishing links between -two separate projects, if the projects are served on different domains. - -It is also used by the @file{muse-journal} module to create the RSS or -RDF output. - -@item :exclude -Exclude items matching a regexp from being published. The regexp should -usually begin with "/". - -@item :include -Only include items matching a regexp when publishing. The regexp should -usually begin with "/". - -@item :path -The directory in which to store published files. - -@item :timestamps -A file containing the timestamps (that is, time of creation) for files -in this project. It might eventually used by the @file{muse-blosxom} -module, but this option is not currently in use by any Muse code. - -@end table - - -@node Keystroke Summary, Markup Rules, Projects, Top -@comment node-name, next, previous, up -@chapter Keys Used in Muse Mode -@cindex keystrokes - -This is a summary of keystrokes available in every Muse buffer. - -@table @kbd - -@item C-c C-a (`muse-index') -Display an index of all known Muse pages. - -@item C-c C-b (`muse-find-backlinks') -Find all pages that link to this page. - -@item C-c C-e (`muse-edit-link-at-point') -Edit link at point. - -@item C-c C-f (`muse-project-find-file') -Open another Muse page. Prompt for the name. - -@item C-c C-i l, C-c TAB l (`muse-insert-relative-link-to-file') -Insert a link to a file interactively. - -@item C-c C-i t, C-c TAB t (`muse-insert-tag') -Insert a tag interactively. - -@item C-c C-i u, C-c TAB u (`muse-insert-url') -Insert a URL interactively. - -@item C-c C-l (`font-lock-mode') -Toggle font lock / highlighting for the current buffer. - -@item C-c C-p (`muse-project-publish') -Publish any Muse pages that have changed. - -@item C-c C-s (`muse-search') -Find text in all files of the current project. - -@item C-c C-t (`muse-project-publish-this-file') -Publish the currently-visited file. Prompt for the style if the current -file can be published using more than one style. - -@item C-c C-S-t, or C-c C-M-t (`muse-publish-this-file') -Publish the currently-visited file. Prompt for both the style and -output directory. - -@item C-c C-v (`muse-browse-result') -Show the published result of this page. - -@item C-c = (`muse-what-changed') -Diff this page against the last backup version. - -@item TAB -Move to the next Wiki reference. - -@item S-TAB -Move to the previous Wiki reference. - -@item M-TAB -Complete the name of a page from the current project at point. - -@item M-RET -Insert a new list item at point, indenting properly. - -@item C-< -Decrease the indentation of the list item at point. - -@item C-> -Increase the indentation of the list item at point. - -@item M-x muse-colors-toggle-inline-images RET -Toggle display of inlined images on/off. - -@item M-x muse-update-values RET -Update various values that are automatically generated. - -Call this after changing @code{muse-project-alist}. -@end table - - -@node Markup Rules, Publishing Styles, Keystroke Summary, Top -@comment node-name, next, previous, up -@chapter Rules for Using Markup -@cindex markup - -A Muse document uses special, contextual markup rules to determine how -to format the output result. For example, if a paragraph is indented, -Muse assumes it should be quoted. - -There are not too many markup rules, and all of them strive to be as -simple as possible so that you can focus on document creation, rather -than formatting. - -@menu -* Paragraphs:: Paragraphs: centering and quoting. -* Headings:: Levels of headings. -* Directives:: Directives at the beginning of a - document. -* Emphasizing Text:: Bold, italicized, and underlined text. -* Footnotes:: Making notes to be shown at the end. -* Verse:: Indicating poetic stanzas. -* Lists:: Lists of items. -* Tables:: Generation of data tables. -* Explicit Links:: Hyperlinks and email addresses with - descriptions. -* Implicit Links:: Bare URLs, WikiNames, and InterWiki - links. -* Images:: Publishing and displaying images. -* Horizontal Rules and Anchors:: Inserting a horizontal line or anchor. -* Embedded Lisp:: Evaluating Emacs Lisp code in documents - for extensibility. -* Citations:: Support for citing other resources. -* Comments:: Lines to omit from published output. -* Tag Summary:: Tags that Muse recognizes. -@end menu - -@node Paragraphs, Headings, Markup Rules, Markup Rules -@comment node-name, next, previous, up -@section Paragraphs: centering and quoting -@cindex paragraphs - -Paragraphs in Muse must be separated by a blank line. - -@cindex paragraphs, centered -@subheading Centered paragraphs and quotations - -A line that begins with six or more columns of whitespace (either tabs -or spaces) indicates a centered paragraph. Alternatively, you can use -the @verb{|
    |} tag to surround regions that are to be published -as centered paragraphs. - -@cindex paragraphs, quoted -@cindex quotations -But if a line begins with whitespace, though less than six columns, it -indicates a quoted paragraph. Alternatively, you can use the -@verb{||} tag to surround regions that are to be published as -quoted paragraphs. - -@cindex examples -@cindex monospace, rendering blocks -@cindex HTML, rendering blocks in monospace -@subheading Literal paragraphs - -The @verb{||} tag is used for examples, where whitespace should -be preserved, the text rendered in monospace, and any characters special -to the output style escaped. - -@cindex literal text -@cindex HTML, inserting a raw block -There is also the @verb{||} tag, which causes a marked block to -be entirely left alone. This can be used for inserting a hand-coded -HTML blocks into HTML output, for example. - -If you want some text to only be inserted when publishing to a -particular publishing style, use the @option{style} attribute for the -@verb{||} tag. An example follows. - -@example - -A LaTeX-based style was used in the publishing of this document. - -@end example - -This will leave the region alone if the current publishing style is -``latex'' or based on ``latex'', such as ``pdf'', and delete the region -otherwise. It is also possible to leave the text alone only for one -particular style, rather than its derivations, by adding -@code{exact="t"} to the tag. - -@cindex line breaks -@subheading Line breaks - -If you need a line break, then use the @samp{
    } tag. Most of the -time this tag is unnecessary, because Muse will automatically detect -paragraphs by means of blank lines. If you want to preserve newlines in -several lines of text, then use verse markup instead (@pxref{Verse}). - -@node Headings, Directives, Paragraphs, Markup Rules -@comment node-name, next, previous, up -@section Levels of headings -@cindex headings - -A heading becomes a chapter or section in printed output -- depending on -the style. To indicate a heading, start a new paragraph with one or -more asterices, followed by a space and the heading title. Then begin -another paragraph to enter the text for that section. - -All levels of headings will be published. Most publishing styles only -distinguish the between the first 4 levels, however. - -@example -* First level - -** Second level - -*** Third level - -**** Fourth level -@end example - -@node Directives, Emphasizing Text, Headings, Markup Rules -@comment node-name, next, previous, up -@section Directives at the beginning of a document -@cindex directives - -Directives are lines beginning with the @samp{#} character that come -before any paragraphs or sections in the document. Directives are of -the form ``#directive content of directive''. You can use any -combination of uppercase and lowercase letters for directives, even if -the directive is not in the list below. - -The @code{muse-publishing-directive} function may be used in header and -footer text to access directives. For example, to access the -@code{#title} directive, use @code{(muse-publishing-directive "title")}. - -The following is a list of directives that Muse uses. - -@table @code -@cindex #author -@item #author -The author of this document. - -If this is not specified, Muse will attempt to figure it out from the -@code{user-full-name} variable. - -@cindex #date -@item #date -The date that the document was last modified. - -This is used by publishing styles that are able to embed the date -information. - -@cindex #desc -@item #desc -A short description of this document. - -This is used by the @code{journal} publishing style to embed information -inside of an RSS/RDF feed. - -@cindex #title -@item #title -The title of this document. - -If this is not specified, the name of the file is used. - -@end table - -@node Emphasizing Text, Footnotes, Directives, Markup Rules -@comment node-name, next, previous, up -@section Bold, italicized, and underlined text -@cindex emphasizing text -@cindex underlining text -@cindex italicizing text -@cindex verbatim text -@cindex monospace, rendering words - -To emphasize text, surround it with certain specially recognized -characters. - -@example -*emphasis* -**strong emphasis** -***very strong emphasis*** -_underlined_ -=verbatim and monospace= -@end example - -@cindex WYSIWYG -While editing a Muse document in Muse mode, these forms of emphasis will -be highlighted in a WYSIWYG manner. Each of these forms may span -multiple lines. - -Verbatim text will be colored as gray by default. To change this, -customize @code{muse-verbatim-face}. - -You can also use the @verb{||} tag to indicate verbatim and -monospace text. This is handy for regions that have an ``='' in them. - -@node Footnotes, Verse, Emphasizing Text, Markup Rules -@comment node-name, next, previous, up -@section Making notes to be shown at the end -@cindex footnotes - -A footnote reference is simply a number in square brackets. To define -the footnote, place this definition at the bottom of your file. -@samp{footnote-mode} can be used to greatly facilitate the creation of -these kinds of footnotes. - -Footnotes are defined by the same number in brackets occurring at the -beginning of a line. Use footnote-mode's @kbd{C-c ! a} command, to very -easily insert footnotes while typing. Use @kbd{C-x C-x} to return to -the point of insertion. - -@node Verse, Lists, Footnotes, Markup Rules -@comment node-name, next, previous, up -@section Indicating poetic stanzas -@cindex verses -@cindex poetry - -Poetry requires that whitespace be preserved, but without resorting to -monospace. To indicate this, use the following markup, reminiscent of -email quotations. - -@example -> A line of Emacs verse; -> forgive its being so terse. -@end example - -You can also use the @verb{||} tag, if you prefer. - -@example - -A line of Emacs verse; - forgive its being so terse. - -@end example - -@cindex verses, multiple stanzas -Multiple stanzas may be included in one set of @verb{||} tags, as -follows. - -@example - -A line of Emacs verse; - forgive its being so terse. - -In terms of terse verse, - you could do worse. - -@end example - -@node Lists, Tables, Verse, Markup Rules -@comment node-name, next, previous, up -@section Lists of items -@cindex lists - -Lists are given using special characters at the beginning of a line. -Whitespace must occur before bullets or numbered items, to distinguish -from the possibility of those characters occurring in a real sentence. - -@cindex lists, bullets -These are rendered as a bullet list. - -@example -Normal text. - - - bullet item one - - bullet item two -@end example - -@cindex lists, enumerated -An enumerated list follows. - -@example -Normal text. - - 1. Enum item one - 2. Enum item two -@end example - -@cindex lists, definitions -Here is a definition list. - -@example -Term1 :: - This is a first definition - And it has two lines; - no, make that three. - -Term2 :: This is a second definition -@end example - -@subheading Nested lists - -@cindex lists, nested -It is possible to nest lists of the same or different kinds. The -``level'' of the list is determined by the amount of initial whitespace. - -@example -Normal text. - - - Level 1, bullet item one - 1. Level 2, enum item one - 2. Level 2, enum item two - - Level 1, bullet item two - 1. Level 2, enum item three - 2. Level 2, enum item four - term :: definition -@end example - -@subheading Breaking list items - -@cindex lists, breaking lines -If you want to break up a line within any list type, just put one blank -line between the end of the previous line and the beginning of the next -line, using the same amount of initial indentation. - -@example - - bullet item 1, line 1 - - bullet item 1, line 2 - - 1. Enum line 1 - - Enum line 2 - - - bullet item 2, line 1 - - bullet item 2, line 2 -@end example - -@node Tables, Explicit Links, Lists, Markup Rules -@comment node-name, next, previous, up -@section Generation of data tables -@cindex tables - -@cindex tables, simple -Only very simple tables are supported. The syntax is as follows. - -@example -Double bars || Separate header fields - -Single bars | Separate body fields -Here are more | body fields - -Triple bars ||| Separate footer fields -@end example - -Some publishing styles require header fields to come first, then footer -fields, and then the body fields. You can use any order for these -sections that you like, and Muse will re-order them for you at -publish-time. - -If you wish to disable table generation for one Muse file, add the -directive @samp{#disable-tables t} to the top of the file. - -@subheading Other table formats - -@cindex tables, orgtbl-mode style -It is possible to publish very basic Orgtbl-mode style tables. - -@example -| org | style | table | -|------+-------+-------| -| one | | one | -| two | two | | -| | three | three | -|------+-------+-------| -| more | stuff | | -@end example - -If you are used to the way that Org Mode publishes these tables, then -customize `muse-html-table-attributes' to the following, in order to get -a similar kind of output. - -@example -border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides" -@end example - -@cindex tables, table.el style -@file{table.el} style tables are also supported, as long as -@file{table.el} itself supports outputting tables for a particular -publishing style. At the time of this writing, the ``html'', ``latex'', -and ``docbook'' styles are supported by @file{table.el}. Styles derived -from these styles will also work. - -@example -+---+-----+---+ -| | one | 1 | -+---+-----+---+ -| b | two | | -+---+-----+---+ -| c | | 3 | -+---+-----+---+ -@end example - -@node Explicit Links, Implicit Links, Tables, Markup Rules -@comment node-name, next, previous, up -@section Hyperlinks and email addresses with descriptions -@cindex links, explicit - -A hyperlink can reference a URL, or another page within a Muse -project. In addition, descriptive text can be specified, which should -be displayed rather than the link text in output styles that supports -link descriptions. The syntax is as follows. - -@example -[[link target][link description]] -[[link target without description]] -@end example - -Thus, the current maintainer's homepage for Muse can be found -@samp{[[http://mwolson.org/projects/EmacsMuse.html][here]]}, -or at @samp{[[http://mwolson.org/projects/EmacsMuse.html]]}. - -@node Implicit Links, Images, Explicit Links, Markup Rules -@comment node-name, next, previous, up -@section Bare URLs, WikiNames, and InterWiki links -@cindex links, implicit -@cindex links, raw - -@cindex URLs -@cindex Email addresses - -A URL or email address encountered in the input text is published as a -hyperlink. These kind of links are called @dfn{implicit links} because -they are not separated from the rest of the Muse document in any way. - -Some characters in URLs will prevent Muse from recognizing them as -implicit links. If you want to link to a URL containing spaces or any of -the characters ``][,"'`()<>^'', you will have to make the link -explicit. The punctuation characters ``.,;:'' are also not recognized as -part of a URL when they appear at its end. For information on how to -make an explicit link, see @ref{Explicit Links,,Hyperlinks and email -addresses with descriptions}. - -@cindex WikiNames -If the @command{muse-wiki} module is loaded, another form of implicit -link will be made available. WikiNames, which are typed in CamelCase, -are highlighted and published as links, provided that the file they -refer to exists. - -Customization of WikiName recognition may be accomplished by editing the -@code{muse-wiki-wikiword-regexp} option and subsequently running -@code{(muse-configure-highlighting 'muse-colors-markupmuse-colors-markup)}. -If you use the Customize interface, the latter will be done -automatically. - -@cindex InterWiki links -@cindex inter-project links -The @command{muse-wiki} module also allows for InterWiki links. These -are similar to WikiWords, but they specify both the project and page of -a file. The names of your project entries in @code{muse-project-alist} -will be used as InterWiki names by default. Several examples follow. - -@example -Blog::DocumentingMuse -Projects#EmacsMuse -Website -@end example - -In the first case, the interwiki delimiter is @samp{::}, @samp{Blog} is -the project name, and @samp{DocumentingMuse} is the page name. In the -second example, @samp{#} is the interwiki delimiter. If the name of a -project occurs by itself in text, like the third case, it will be -colorized and published as a link to the default page of the given -project. - -Customization of interwiki links may be accomplished by editing the -@code{muse-wiki-interwiki-alist} option. - -It is also possible to link to an anchor in an interwiki document. This -is called a ``three-part link''. Examples of this follow. - -@example -Blog::DocumentingMuse#anchor1 -Projects#EmacsMuse#anchor2 -@end example - -@node Images, Horizontal Rules and Anchors, Implicit Links, Markup Rules -@comment node-name, next, previous, up -@section Publishing and displaying images -@cindex images -@cindex links, with images -@subheading Image links - -Links to images may be used in either the target or the description, or -both. Thus, the following code will publish as a clickable image that -points to @url{http://mwolson.org/}. - -@example -[[http://mwolson.org/][/static/logos/site-logo.png]] -@end example - -Normally, images in the link part will be inlined. - -If you want these images to be published as links instead, place the -text ``URL:'' immediately in front of the link text. An example -follows. - -@example -[[URL:http://mwolson.org/static/logos/site-logo.png]] -@end example - -@cindex images, displaying -@cindex images, local -@subheading Displaying images in Muse mode -If a link to a locally-available image is encountered in the link -description, Muse mode will attempt to display it if your version of -Emacs permits this. - -This behavior may be toggled with @kbd{C-c C-i}, or disabled permanently -by setting the @code{muse-colors-inline-images} option to @code{nil}. - -The method for finding images may be altered by customizing the -@code{muse-colors-inline-image-method} option. One useful value for -this option is @code{muse-colors-use-publishing-directory}, which tells -Muse mode to look in the directory where the current file will be -published. The default is to look in the current directory. Relative -paths like @samp{../pics/} should work for either setting. - -Eventually, it is hoped that Muse will be able to copy images from the a -``source'' directory to a publishing directory by customizing -@code{muse-project-alist}, but this has not been implemented yet. - -@cindex images, without descriptions -@cindex images, inlined -@subheading Publishing simple images -The following example will display correctly and publish correctly if a -@acronym{PNG} file called @file{TestLogo.png} exists in the -@file{../pics/} directory. If text is on the same line as the picture, -it will remain so in the output. - -@example -[[../myimage.png]] -@end example - -@cindex images, captions -@subheading Publishing images with captions -If you want to add a caption to an image, use the following syntax. -This will center the image (if the output format supports it) and add a -centered caption below the picture. Formats that do not support -centering the image will instead leave it against the left margin. - -@example -[[../pics/mycat.png][My cat Dexter]] -@end example - -Images with captions may only occur in their own paragraphs, with no -text on the same line. Otherwise, the published output will not be -syntactically correct. - -@node Horizontal Rules and Anchors, Embedded Lisp, Images, Markup Rules -@comment node-name, next, previous, up -@section Inserting a horizontal line or anchor - -@cindex horizontal rules -@cindex dashes -@subheading Horizontal Rules - -Four or more dashes indicate a horizontal rule. Be sure to put blank -lines around it, or it will be considered part of the proceeding or -following paragraph! - -@cindex anchors -@cindex links, with target on same page -@subheading Anchors - -If you begin a line with "#anchor" -- where "anchor" can be any word -that doesn't contain whitespace -- it defines an anchor at that point -into the document. This point can be referenced using "page#anchor" as -the target in a Muse link. - -@node Embedded Lisp, Citations, Horizontal Rules and Anchors, Markup Rules -@comment node-name, next, previous, up -@section Evaluating Emacs Lisp code in documents for extensibility -@cindex lisp, embedded - -Arbitrary kinds of markup can be achieved using the @verb{||} tag. -With the @verb{||} tag, you may generate whatever output text you -wish. The inserted output will get marked up if the @verb{||} -tag appears within the main text of the document. - -@example -(concat "This form gets " "inserted") -@end example - -@cindex lisp, and insert command -Note that you should not use the @code{insert} command within a set of -@verb{||} tags, since the return value from the @verb{||} -tags will be automatically inserted into the document. - -It is also possible to treat the output as if it were surrounded by the -@verb{||}, @verb{||}, or @verb{||} tags, by -specifying ``example'', ``src'', or ``verse'' as the @option{markup} -attribute of the @verb{||} tag. - -@example - -(concat "Insert" " me") - -@end example - -Other languages also have tags that cause source code to be evaluated. -@xref{Tag Summary}, for details. - -@node Citations, Comments, Embedded Lisp, Markup Rules -@comment node-name, next, previous, up -@section Support for citing other resources -@cindex citations -@cindex tags, - -@subheading Example - -Here is an example of what citations look like in a Muse document. - -@example -#bibsource REFDB - -* Title -** Subtitle - -Some text before Miller1999 and after the citation. - -This is an author-only citation Miller1999. - -And this is a year-only citation Miller1999. - -Finally, this is a multi-head citation -Miller1999,Andrews2005. -@end example - -@subheading Overview - -The @code{#bibsource} directive defines the source of the -bibliographies. The following sources are possible. - -@itemize @bullet -@item DocBook + RefDB: -the string "REFDB" - -@item LaTeX + bibtex: -the name of an appropriate bibtex file - -@item LaTeX + RefDB: -if the input file is called "foo.muse", then set this to "foo.bib" -@end itemize - -Citations are encoded as @verb{||} elements which enclose the -citation keys as they are defined in the bibliography file or database. -In multi-head citations, the citation keys have to be separated by -colons or semicolons. The @code{latex} and @code{docbook} styles -translate these to the proper separator automatically. - -The @verb{||} elements take an optional ``type'' attribute that -defines how the citation is rendered. If the attribute is missing, -you'll get a regular citation according to the bibliography style, -e.g.'' (Miller et al., 1999)''. If the attribute is set to "author", -only the name of the author(s) will be rendered. Accordingly, "year" -will cause the year to be printed. This is useful to create citations -like this: - -@example -Miller et al. had already shown in a previous publication (1999) that -this is not going to work. -@end example - -Remember that refdb-mode (the Emacs interface to RefDB) can retrieve -references by simply marking the citation key and running the -@code{refdb-getref-by-field-on-region} command. Later versions of -@code{refdb-mode} will also allow to insert references as Muse citations -(which is already implemented for DocBook, TEI, and LaTeX documents). - -You may have noticed that there is no element to indicate the position -of the bibliography. The latter is always created at a valid position -close to the end of the document. The functions -@code{muse-docbook-bibliography} and @code{muse-latex-bibliography} are -called in the header or footer to generate this content, so it is -possible to change the exact position. - -@node Comments, Tag Summary, Citations, Markup Rules -@comment node-name, next, previous, up -@section Lines to omit from published output -@cindex comments -@cindex publishing, omitting lines - -Use the following syntax to indicate a comment. Comments will not be -published. - -@example -; Comment text goes here. -@end example - -That is, only a semi-colon at the beginning of a line, followed by a -literal space, will cause that line to be treated as a comment. - -You can alternatively surround the region with the @verb{||} -tag. - -If you wish the comment to be published, but just commented out using -the comment syntax of the output format, then set -@option{muse-publish-comments-p} to non-nil. - -@node Tag Summary, , Comments, Markup Rules -@comment node-name, next, previous, up -@section Tags that Muse recognizes -@cindex tags -@cindex inserting files at publish time -@cindex publishing, including markup in headers and footers -@cindex publishing, inserting files - -Muse has several built-in tags that may prove useful during publishing. -@xref{muse-publish-markup-tags}, to see how to customize the tags that -Muse uses, as well as make your own tags. - -Only a small subset of these tags are available in header and footer -text. The @code{muse-publish-markup-header-footer-tags} option lists -the tags that are allowed in headers and footers. - -@subheading Syntax - -If a tag takes arguments, it will look like this, where ``tagname'' is -the name of the tag. - -@example - -@end example - -If you want the tag to look like it came straight from an XHTML -document, you can alternatively do the following. - -@example - -@end example - -If a tag surrounds some text, it will look like this. - -@example -Some text -@end example - -If a tag surrounds a large region, it will look like this. - -@example - -Some text. -Some more text. - -@end example - -@subheading Tag listing - -This is the complete list of tags that Muse accepts, including those -that were mentioned in previous sections. - -@table @samp - -@item
    -Insert a line break. - -Muse will automatically detect paragraphs when publishing by means of -blank lines, so this tag is usually unnecessary. - -@item -Insert a citation to another source. - -This takes the argument @option{type}, which indicates the type of -citation. The valid types are "author" and "year". If this argument is -omitted, include both author and year in the citation. - -The bibliography to use for the citation may be specified by the -@option{#bibsource} directive. - -@xref{Citations}, for additional information. - -@item -If publishing to HTML, surround the given text with a @verb{||} -tag. It takes one argument called ``name'' that specifies the ``class'' -attribute of the @verb{||} tag. - -If publishing to a different format, do nothing extra to the text. - -@item -Treat the text surrounded by the tag as if they were enclosed in equal -signs, that is, make it monospace. - -@item -Run a command on the region, replacing the region with the result of the -command. The command is specified with the ``interp'' argument. If no -value for ``interp'' is given, pass the entire region to the shell. - -The ``markup'' argument controls how this section is marked up. - -If it is omitted, publish the region with the normal Muse rules. - -If "nil", do not mark up the region at all, but prevent Muse from -further interpreting it. - -If "example", treat the region as if it was surrounded by the -@verb{||} tag. - -If "src", treat the included text as if it was surrounded by the -@verb{||} tag. You should also specify the ``lang'' attribute if -doing this. - -If "verse", treat the region as if it was surrounded by the -@verb{||} tag, to preserve newlines. - -Otherwise, it should be the name of a function to call, with the buffer -narrowed to the region. - -@item -Treat the entire region as a comment. If the option -@var{muse-publish-comments-p} is nil, delete the region, otherwise -publish it using the comment syntax of the current publishing style. - -@item -Publish a Table of Contents. This will either be inserted in-place or -at the beginning of the document, depending on your publishing style. -It does not have a delimiting tag. - -By default, only 2 levels of headings will be included in the generated -Table of Contents. To change this globally, customize the -@var{muse-publish-contents-depth} option. To change this only for the -current tag, use the ``depth'' argument. - -@item
    -Insert a
    tag into HTML documents, and do not insert anything -special for other non-HTML publishing formats. - -If the ``style'' argument is provided, include it with the published -@verb{|
    |} tag. Likewise for the ``id'' argument. - -@item -Publish the region in monospace, preserving the newlines in the region. -This is useful for snippets of code. - -@item -Insert the given file at the current location during publishing. The -basic use of this tag is as follows, replacing ``included_file'' with -the name of the file that you want to include. - -@example - -@end example - -The ``markup'' argument controls how this section is marked up. - -If it is omitted, publish the included text with the normal Muse -rules. - -If "nil", do not mark up the included text at all. - -If "example", treat the included text as if it was surrounded by the -@verb{||} tag. - -If "src", treat the included text as if it was surrounded by the -@verb{||} tag. You should also specify the ``lang'' attribute if -doing this. - -If "verse", treat the included text as if it was surrounded by the -@verb{||} tag, to preserve newlines. - -Otherwise, it should be the name of a function to call after inserting -the file with the buffer narrowed to the section inserted. - -@item -Evaluate the Emacs Lisp expressions between the initial and ending tags. -The result is then inserted into the document, so you do not need to -explicitly call @code{insert}. All text properties are removed from the -resulting text. - -This tag takes the ``markup'' argument. See the description of -@verb{||} for details. - -@item -Make sure that the text enclosed by this tag is published without -escaping it in any way. This is useful for inserting markup directly -into the published document, when Muse does not provide the desired -functionality. - -@item -Mark up the text between the initial and ending tags. The markup -command to use may be specified by the ``function'' argument. The -standard Muse markup routines are used by default if no ``function'' -argument is provided. - -This is useful for marking up regions in headers and footers. One -example that comes to mind is generating a published index of all of the -files in the current project by doing the following. - -@example -(muse-index-as-string t t) -@end example - -@item -Run the @command{perl} language interpreter on the region, replacing the -region with the result of the command. - -This tag takes the ``markup'' argument. See the description of -@verb{||} for details. - -@item -Run the @command{python} language interpreter on the region, replacing -the region with the result of the command. - -This tag takes the ``markup'' argument. See the description of -@verb{||} for details. - -@item -Publish the region as a blockquote. This will either be inserted -in-place or at the beginning of the document, depending on your -publishing style. It does not have a delimiting tag. - -@item -Run the @command{ruby} language interpreter on the region, replacing the -region with the result of the command. - -This tag takes the ``markup'' argument. See the description of -@verb{||} for details. - -@item -Publish the region using htmlize. -The language to use may be specified by the ``lang'' attribute. - -Muse will look for a function named @var{lang}-mode, where @var{lang} is -the value of the ``lang'' attribute. - -This tag requires htmlize 1.34 or later in order to work. If this is -not satisfied, or the current publishing style is not HTML-based, Muse -will publish the region like an @verb{||} tag. - -@item -This is used when you want to prevent Muse from trying to interpret some -markup. Surround the markup in @verb{||} and -@verb{||}, and it will not be interpreted. - -This tag was used often in previous versions of Muse because they did -not support whole-document escaping of specials. Now, it will only be -needed for other tags, and perhaps footnotes as well. - -@item -Preserve the newlines in the region. In formats like HTML, newlines are -removed by default, hence the need for this tag. In other publishing -styles, this tag may cause the text to be indented slightly in a way -that looks nice for poetry and prose. - -@end table - -@node Publishing Styles, Extending Muse, Markup Rules, Top -@comment node-name, next, previous, up -@chapter Publishing Various Types of Documents -@cindex publishing styles - -One of the principle features of Muse is the ability to publish a simple -input text to a variety of different output styles. Muse also makes it -easy to create new styles, or derive from an existing style. - -@menu -* Blosxom:: Integrating Muse and pyblosxom.cgi. -* Book:: Publishing entries into a compilation. -* ConTeXt:: Publishing ConTeXt documents. -* DocBook:: Publishing in DocBook XML form. -* HTML:: Publishing in HTML or XHTML form. -* Ikiwiki:: Integrating with ikiwiki. -* Journal:: Keeping a journal or blog. -* LaTeX:: Publishing LaTeX documents. -* Poem:: Publish a poem to LaTeX or PDF. -* Texinfo:: Publish entries to Texinfo format or PDF. -* XML:: Publish entries to XML. -@end menu - -@node Blosxom, Book, Publishing Styles, Publishing Styles -@comment node-name, next, previous, up -@section Integrating Muse and pyblosxom.cgi -@cindex blog, one-file-per-entry style - -The Blosxom publishing style publishes a tree of categorised files to a -mirrored tree of stories to be served by blosxom.cgi or pyblosxom.cgi. -In other words, each blog entry corresponds with one file. - -@menu -* Blosxom Requirements:: Other tools needed for the Blosxom style. -* Blosxom Entries:: Format of a Blosxom entry and automation. -* Blosxom Options:: Blosxom styles and options provided. -@end menu - -@node Blosxom Requirements, Blosxom Entries, Blosxom, Blosxom -@comment node-name, next, previous, up -@subsection Other tools needed for the Blosxom style - -You will need to have @command{pyblosxom.cgi} or @command{blosxom.cgi} -installed on a machine that you have upload access to. - -The major difficulty in both of these programs is specifying the date of -the entries. Both programs rely on the file modification time rather -than any data contained in the entries themselves. A plugin is needed -in order for these programs to be able to get the correct date. - -@subheading PyBlosxom - -There are two different ways of accomplishing this in pyblosxom. The -first way involves gathering the timestamps (as specified by the -@code{#date} directive) into one file and then sending that file along -with published entries to the webserver. - -The second will read each file at render time and parse the -@code{#postdate} directive. Muse will translate the @code{#date} -directive into @code{#postdate} at publish time, so you don't have to do -any extra work. - -@subsubheading Placing timestamps in one file - -The following additional components are required in order to make the -date of blog entries display as something sensible. - -@enumerate -@item -A script to gather date directives from the entire blog tree into a -single file. The file must associate a blog entry with a date. - -@item -A plugin for (py)blosxom that reads this file. -@end enumerate - -These 2 things are provided for @command{pyblosxom.cgi} in the -@file{contrib/pyblosxom} subdirectory. @file{getstamps.py} provides the -former service, while @file{hardcodedates.py} provides the latter -service. - -Here is a sample listing from my @file{timestamps} file, which maps -each file to a date. This can really be in any format, as long as your -date-gathering script and your plugin can both understand it. - -@example -2005-04-01-14-16 personal/paper_cranes -2005-03-21 personal/spring_break_over -2004-10-24 personal/finished_free_culture -@end example - -The script @file{contrib/pyblosxom/make-blog} demonstrates how to call -@file{getstamps.py}. Note that you will need to set the current -directory to where your Muse files are, execute @file{getstamps.py}, and -then move the generated timestamps file to your publishing directory. - -@subsubheading Getting timestamp from entry while rendering - -Alternately, the pyblosxom metadate plugin may be used. On the plus -side, there is no need to run a script to gather the date. On the -downside, each entry is read twice rather than once when the page is -rendered. Set the value of @code{muse-blosxom-use-metadate} to non-nil -to enable adding a @code{#postdate} directive to all published files. -You can do this by: - -@example -M-x customize-variable RET muse-blosxom-use-metadate RET -@end example - -With the metadate plugin installed in pyblosxom, the date set in this -directive will be used instead of the file's modification time. The -plugin is included with Muse at @file{contrib/pyblosxom/metadate.py}. - -@subheading Blosxom - -It is also possible to use Blosxom, which is written in Perl, to serve -blog entries that were published with Muse. The steps are as follows. - -@enumerate -@item -Download and install blosxom from @url{http://blosxom.sourceforge.net/}. - -@item -Install the metadate plugin. It is available in -@file{contrib/blosxom/metadate_0_0_3}. - -@item -Every time you make a new blog entry, change to the blosxom data -directory and execute the @file{contrib/blosxom/getstamps.pl} script. -This script has only recently been made, and may still have some bugs, -so use with caution. - -@end enumerate - -@node Blosxom Entries, Blosxom Options, Blosxom Requirements, Blosxom -@comment node-name, next, previous, up -@subsection Format of a Blosxom entry and automation - -Each Blosxom file must include `#date yyyy-mm-dd', or optionally the -longer `#date yyyy-mm-dd-hh-mm', a title (using the @code{#title} -directive), plus whatever normal content is desired. - -The date directive is not used directly by @command{pyblosxom.cgi} or -this program. You need to have the two additional items from the former -section to make use of this feature. - -There is a function called @code{muse-blosxom-new-entry} that will -automate the process of making a new blog entry. To make use of it, do -the following. - -@itemize @bullet -@item -Customize @code{muse-blosxom-base-directory} to the location that your -blog entries are stored. - -@item -Assign the @code{muse-blosxom-new-entry} function to a key sequence. I -use the following code to assign this function to @kbd{C-c p l'}. - -@example -(global-set-key "\C-cpl" 'muse-blosxom-new-entry) -@end example - -@item -You should create your directory structure ahead of time under your base -directory. These directories, which correspond with category names, may -be nested. - -@item -When you enter this key sequence, you will be prompted for the category -of your entry and its title. Upon entering this information, a new file -will be created that corresponds with the title, but in lowercase -letters and having special characters converted to underscores. The -title and date directives will be inserted automatically. -@end itemize - -@node Blosxom Options, , Blosxom Entries, Blosxom -@comment node-name, next, previous, up -@subsection Blosxom styles and options provided - -The following styles and options are available in the Blosxom publishing -style. - -@subheading Styles provided - -@table @code - -@cindex publishing styles, blosxom-html -@item blosxom-html -Publish Blosxom entries in HTML form. - -@cindex publishing styles, blosxom-xhtml -@item blosxom-xhtml -Publish Blosxom entries in XHTML form. - -@end table - -@subheading Options provided - -@table @code - -@item muse-blosxom-extension -Default file extension for publishing Blosxom files. - -@item muse-blosxom-header -Header used for publishing Blosxom files. - -This may be text or a filename. - -@item muse-blosxom-footer -Footer used for publishing Blosxom files. - -This may be text or a filename. - -@item muse-blosxom-base-directory -Base directory of blog entries, used by @code{muse-blosxom-new-entry}. - -This is the top-level directory where your blog entries may be found -locally. - -@end table - -@node Book, ConTeXt, Blosxom, Publishing Styles -@comment node-name, next, previous, up -@section Publishing entries into a compilation - -This publishing style is used to output ``books'' in LaTeX or PDF -format. - -Each page will become a separate chapter in the book, unless the style -keyword @option{:nochapters} is used, in which case they are all run -together as if one giant chapter. - -One way of publishing a book is to make a project for it, add the -project to @code{muse-project-alist}, and use the @code{book-pdf} style -with a very specific @option{:include} value to specify some page whose -contents will be checked for the values of @code{#title} and -@code{#date}, and whose name will be used in the output file. Then to -publish the book, visit the aforementioned page and use @kbd{C-c C-t} or -@kbd{C-c C-p} to trigger the publishing process. An example -@code{muse-project-alist} for this method follows. - -@example -(setq muse-project-alist - '(("MyNotes" (:nochapters t ; do automatically add chapters - :book-chapter "Computer Science" - "~/Notes/cs" - :book-chapter "Mathematics" - "~/Notes/math" - :book-chapter "Emacs" - "~/Notes/emacs" - :book-end t ; the rest will not be placed in the book - "~/Notes" ; so we can find the notes-anthology page - "~/Notes/private" - :force-publish ("index") - :default "index") - (:base "book-pdf" - :include "/notes-anthology[^/]*$" - :path "~/public_html/notes") - ;; other publishing styles for each directory go here, - ;; if desired - ))) -@end example - -In this example, there would be a file called -@file{~/Notes/notes-anthology.muse}, which would contain just the -following. The resulting book would be published to -@file{~/public_html/notes/notes-anthology.pdf}. - -@example -#title My Technology Ramblings -@end example - -Another way is to call the @code{muse-book-publish-project} function -manually, with a custom project entry. An example of this may be found -in John Wiegley's configuration file at -@file{examples/johnw/muse-init.el}, in the @code{muse-publish-my-books} -function. - -@subheading Styles provided - -@table @code - -@cindex publishing styles, book-latex -@item book-latex -Publish a book in LaTeX form. The header and footer are different than -the normal LaTeX publishing mode. - -@cindex publishing styles, book-pdf -@item book-pdf -Publish a book in PDF form. The header and footer are different than -the normal PDF publishing mode. - -@end table - -@subheading Options provided - -@table @code - -@item muse-book-before-publish-hook -A hook run in the book buffer before it is marked up. - -@item muse-book-after-publish-hook -A hook run in the book buffer after it is marked up. - -@item muse-book-latex-header -Header used for publishing books to LaTeX. - -This may be text or a filename. - -@item muse-book-latex-footer -Footer used for publishing books to LaTeX. - -This may be text or a filename. - -@end table -@node ConTeXt, DocBook, Book, Publishing Styles -@comment node-name, next, previous, up -@section Publishing ConTeXt documents - -This publishing style is capable of producing ConTeXt or PDF documents. - -If you wish to publish PDF documents based on ConTeXt, you will need to -have it installed. For Debian and Ubuntu, this can be accomplished by -installing the ``texlive'' package. - -@subheading Styles provided - -@table @code - -@cindex publishing styles, context -@item context -Publish a ConTeXt document. - -@cindex publishing styles, context-pdf -@item context-pdf -Publish a PDF document, using an external ConTeXt document conversion -tool. - -@cindex publishing styles, context-slides -@item context-slides -Produce slides from a ConTeXt document. - -Here is an example of a slide. - -@example -* First Slide - -[[Some-sort-of-cute-image.png]] - -** A subheading - - - A bullet point. - - Another bullet point. - -* Second Slide - -... and so on -@end example - -@cindex publishing styles, context-slides-pdf -@item context-slides-pdf -Publish a PDF document of ConTeXt slides. - -@end table - -@subheading Options provided - -@table @code - -@item muse-context-extension -Default file extension for publishing ConTeXt files. - -@item muse-context-pdf-extension -Default file extension for publishing ConTeXt files to PDF. - -@item muse-context-pdf-program -The program that is called to generate PDF content from ConTeXt content. - -@item muse-context-pdf-cruft -Extensions of files to remove after generating PDF output successfully. - -@item muse-context-header -Header used for publishing ConTeXt files. - -This may be text or a filename. - -@item muse-context-footer -Footer used for publishing ConTeXt files. - -This may be text or a filename. - -@item muse-context-markup-regexps -List of markup regexps for identifying regions in a Muse page. - -For more on the structure of this list, -@xref{muse-publish-markup-regexps}. - -@item muse-context-markup-functions -An alist of style types to custom functions for that kind of text. - -For more on the structure of this list, -@xref{muse-publish-markup-functions}. - -@item muse-context-markup-strings -Strings used for marking up text. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@item muse-context-slides-header -Header for publishing a presentation (slides) using ConTeXt. - -Any of the predefined modules, which are available in the -tex/context/base directory, can be used by writing a "module" directive -at the top of the Muse file; if no such directive is provided, module -pre-01 is used. Alternatively, you can use your own style ("mystyle", -in this example) by replacing "\usemodule[]" with "\input mystyle". - -This may be text or a filename. - -@item muse-context-slides-markup-strings -Strings used for marking up text in ConTeXt slides. - -@item muse-context-markup-specials-document -A table of characters which must be represented specially. -These are applied to the entire document, sans already-escaped -regions. - -@item muse-context-markup-specials-example -A table of characters which must be represented specially. -These are applied to @verb{|example>|} regions. - -With the default interpretation of @verb{||} regions, no -specials need to be escaped. - -@item muse-context-markup-specials-literal -A table of characters which must be represented specially. -This applies to =monospaced text= and @verb{||} regions. - -@item muse-context-markup-specials-url -A table of characters which must be represented specially. -These are applied to URLs. - -@item muse-context-markup-specials-image -A table of characters which must be represented specially. -These are applied to image filenames. - -@item muse-context-permit-contents-tag -If nil, ignore @verb{||} tags. Otherwise, insert table of -contents. - -Most of the time, it is best to have a table of contents on the -first page, with a new page immediately following. To make this -work with documents published in both HTML and ConTeXt, we need to -ignore the @verb{||} tag. - -If you don't agree with this, then set this option to non-nil, -and it will do what you expect. - -@end table - -@node DocBook, HTML, ConTeXt, Publishing Styles -@comment node-name, next, previous, up -@section Publishing in DocBook XML form - -This publishing style is used to generate DocBook XML files. - -@subheading Styles provided - -@table @code - -@cindex publishing styles, docbook -@item docbook -Publish a file in Docbook form. - -@end table - -@subheading Options provided - -This publishing style uses the same options for markup up special -characters as the ``xml'' publishing style. @xref{XML}, for details. - -@table @code - -@item muse-docbook-extension -Default file extension for publishing DocBook XML files. - -@item muse-docbook-header -Header used for publishing DocBook XML files. - -This may be text or a filename. - -@item muse-docbook-footer -Footer used for publishing DocBook XML files. - -This may be text or a filename. - -@item muse-docbook-markup-regexps -List of markup rules for publishing a Muse page to DocBook XML. - -@item muse-docbook-markup-functions -An alist of style types to custom functions for that kind of text. - -@item muse-docbook-markup-strings -Strings used for marking up text. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@item muse-docbook-encoding-default -The default Emacs buffer encoding to use in published files. -This will be used if no special characters are found. - -@item muse-docbook-charset-default -The default DocBook XML charset to use if no translation is -found in @code{muse-xml-encoding-map}. - -@end table - -@node HTML, Ikiwiki, DocBook, Publishing Styles -@comment node-name, next, previous, up -@section Publishing in HTML or XHTML form - -This publishing style is capable of producing HTML or XHTML documents. - -@subheading Styles provided - -@table @code - -@cindex publishing styles, html -@item html -Supports publishing to HTML 4.0 and HTML 4.01, Strict or Transitional. - -@item xhtml -Supports publishing to XHTML 1.0 and XHTML 1.1, Strict or Transitional. - -@end table - -@subheading Options provided - -If an HTML option does not have a corresponding XHTML option, it will -be used for both of these publishing styles. - -These publishing styles use the same options for markup up special -characters as the ``xml'' publishing style. @xref{XML}, for details. - -@table @code - -@item muse-html-extension -Default file extension for publishing HTML files. - -@item muse-xhtml-extension -Default file extension for publishing XHTML files. - -@item muse-html-style-sheet -Store your stylesheet definitions here. - -This is used in @code{muse-html-header}. You can put raw CSS in here or -a @verb{||} tag to an external stylesheet. This text may contain -@verb{||} markup tags. - -If you are publishing to XHTML, then customize the -@code{muse-xhtml-style-sheet} option instead. - -@item muse-xhtml-style-sheet -Store your stylesheet definitions here. - -This is used in @code{muse-xhtml-header}. You can put raw CSS in here -or a @verb{||} tag to an external stylesheet. This text may -contain @verb{||} markup tags. - -@item muse-html-header -Header used for publishing HTML files. - -This may be text or a filename. - -@item muse-html-footer -Footer used for publishing HTML files. - -This may be text or a filename. - -@item muse-xhtml-header -Header used for publishing XHTML files. - -This may be text or a filename. - -@item muse-xhtml-footer -Footer used for publishing XHTML files. - -This may be text or a filename. - -@item muse-html-anchor-on-word -When true, anchors surround the closest word. - -This allows you to select them in a browser (i.e. for pasting), but has -the side-effect of marking up headers in multiple colors if your header -style is different from your link style. - -@item muse-html-table-attributes -The attribute to be used with HTML @verb{|
    |} tags. - -If you want to make more-complicated tables in HTML, surround the HTML -with the @verb{|literal|} tag, so that it does not get escaped. - -@item muse-html-markup-regexps -List of markup rules for publishing a Muse page to HTML. - -@item muse-html-markup-functions -An alist of style types to custom functions for that kind of text. - -@item muse-html-markup-strings -Strings used for marking up text as HTML. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@item muse-xhtml-markup-strings -Strings used for marking up text as XHTML. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@item muse-html-markup-tags -A list of tag specifications, for specially marking up HTML. -@xref{muse-publish-markup-tags}, for more information. - -@item muse-html-meta-http-equiv -The http-equiv attribute used for the HTML @verb{||} tag. - -@item muse-html-meta-content-type -The content type used for the HTML @verb{||} tag. - -If you are striving for XHTML 1.1 compliance, you may want to change -this to ``application/xhtml+xml''. - -@item muse-html-meta-content-encoding -The charset to append to the HTML @verb{||} tag. - -If set to the symbol 'detect, use @code{muse-xml-encoding-map} to try -and determine the HTML charset from emacs's coding. If set to a string, -this string will be used to force a particular charset. - -@item muse-html-charset-default -The default HTML meta charset to use if no translation is found in -@code{muse-xml-encoding-map}. - -@item muse-html-encoding-default -The default Emacs buffer encoding to use in published files. -This will be used if no special characters are found. - -@end table - -@node Ikiwiki, Journal, HTML, Publishing Styles -@comment node-name, next, previous, up -@section Integrating with ikiwiki - -Note: Support for Ikiwiki is not yet complete. Use at your own risk. - -Ikiwiki is a wiki compiler (@url{http://ikiwiki.info/}). Emacs Muse can -(not yet) be used as a source format for Ikiwiki pages with the plugin -@file{IkiWiki::Plugin::muse}. - -The @file{lisp/muse-ikiwiki.el} file provides publishing functions and -styles for Ikiwiki. The plugin for Ikiwiki to recognize Muse files is -provided by the @file{contrib/ikiwiki/IkiWiki/Plugin/muse.pm} file. Two -sample init files are available in the @file{examples/ikiwiki} -directory. Configure your @file{ikiwiki.setup} file so that the -@code{muse_init} variable has the location of your Muse init file. - -If you are using CGI, The directory @file{contrib/ikiwiki/IkiWiki} must -be copied to the same directory as the CGI script that Ikiwiki -generates. When publishing your wiki, the @var{PERL5LIB} environment -variable must contain the path to the @file{contrib/ikiwiki/IkiWiki} -directory. - -@subheading Styles provided - -@table @code - -@cindex publishing styles, ikiwiki -@item ikiwiki -Supports publishing XHTML output that Ikiwiki can understand. - -@end table - -@subheading Options provided - -@table @code - -@item muse-ikiwiki-header -Header used for publishing Ikiwiki output files. - -This may be text or a filename. - -@item muse-ikiwiki-footer -Footer used for publishing Ikiwiki output files. - -This may be text or a filename. - -@end table - -@subheading Other relevant options - -@table @code - -@item muse-colors-evaluate-lisp-tags -Specify whether to evaluate the contents of @verb{||} tags at -display time. If nil, don't evaluate them. If non-nil, evaluate -them. - -The actual contents of the buffer are not changed, only the -displayed text. - -@item muse-html-src-allowed-modes -Modes that we allow the @verb{||} tag to colorize. If @code{t}, -permit the @verb{||} tag to colorize any mode. - -If a list of mode names, such as @code{'("html" "latex")}, and the lang -argument to @verb{||} is not in the list, then use fundamental mode -instead. - -@item muse-publish-enable-dangerous-tags -If non-nil, publish tags like @verb{||} and @verb{||} -that can call external programs or expose sensitive information. -Otherwise, ignore tags like this. - -This is useful to set to @code{nil} when the file to publish is coming -from an untrusted source. - -@end table - -@node Journal, LaTeX, Ikiwiki, Publishing Styles -@comment node-name, next, previous, up -@section Keeping a journal or blog -@cindex journal -@cindex blog, journal style - -The module facilitates the keeping and publication of a journal. When -publishing to HTML, it assumes the form of a web log, or blog. - -The input format for each entry is as follows. - -@example -* 20040317: Title of entry - -text for the entry. - - -"You know who you are. It comes down to a simple gut check: You -either love what you do or you don't. Period." -- P. Bronson - -@end example - -The "qotd", or Quote of the Day, is entirely optional. When generated -to HTML, this entry is rendered as the following. - -@example -
    -
    -

    Quote of the Day:

    -

    "You know who you are. It comes down to a simple gut - check: You either love what you do or you don't. Period." - -- P. Bronson

    -
    -
    -
    - -
    -

    Title of entry

    -
    -
    -
    -

    Text for the entry.

    -
    -
    -
    -@end example - -The plurality of "div" tags makes it possible to display the entries in -any form you wish, using a CSS style. - -Also, an .RDF file can be generated from your journal by publishing it -with the "rdf" style. It uses the first two sentences of the first -paragraph of each entry as its "description", and auto-generates tags -for linking to the various entries. - -@subheading muse-project-alist considerations - -If you wish to publish an RDF or RSS feed, it is important to include -the @option{:base-url} attribute in your @code{muse-project-alist} entry -for your Journal projects. An example follows. - -@example -(setq muse-project-alist - '(("Journal" ("~/Journal/" - :default "journal") - (:base "journal-rss" - :base-url "http://example.org/journal/" - :path "~/public_html/journal")))) -@end example - -@subheading Styles provided - -@table @code - -@cindex publishing styles, journal-html -@item journal-html -Publish journal entries as an HTML document. - -@cindex publishing styles, journal-xhtml -@item journal-xhtml -Publish journal entries as an XHTML document. - -@cindex publishing styles, journal-latex -@item journal-latex -Publish journal entries as a LaTeX document. - -@cindex publishing styles, journal-pdf -@item journal-pdf -Publish journal entries as a PDF document. - -@cindex publishing styles, journal-book-latex -@item journal-book-latex -Publish journal entries as a LaTeX book. - -@cindex publishing styles, journal-book-pdf -@item journal-book-pdf -Publish journal entries as a PDF book. - -@cindex publishing styles, journal-rdf -@cindex publishing styles, RSS 1.0 -@item journal-rdf -Publish journal entries as an RDF file (RSS 1.0). - -@cindex publishing styles, journal-rss -@cindex publishing styles, RSS 2.0 -@item journal-rss -Publish journal entries as an RSS file (RSS 2.0). - -@cindex publishing styles, journal-rss-entry -@item journal-rss-entry -Used internally by @code{journal-rss} and @code{journal-rdf} for -publishing individual entries. - -@end table - -@subheading Options provided - -@table @code - -@item muse-journal-heading-regexp -A regexp that matches a journal heading. - -Paren group 1 is the ISO date, group 2 is the optional category, and -group 3 is the optional heading for the entry. - -@item muse-journal-date-format -Date format to use for journal entries. - -@item muse-journal-html-heading-regexp -A regexp that matches a journal heading from an HTML document. - -Paren group 1 is the ISO date, group 2 is the optional category, and -group 3 is the optional heading for the entry. - -@item muse-journal-html-entry-template -Template used to publish individual journal entries as HTML. - -This may be text or a filename. - -@item muse-journal-latex-section -Template used to publish a LaTeX section. - -@item muse-journal-latex-subsection -Template used to publish a LaTeX subsection. - -@item muse-journal-markup-tags -A list of tag specifications, for specially marking up Journal entries. - -@xref{muse-publish-markup-tags}, for more information. - -This is used by @code{journal-latex} and its related styles, as well as -the @code{journal-rss-entry} style, which both @code{journal-rdf} and -@code{journal-rss} use. - -@item muse-journal-rdf-extension -Default file extension for publishing RDF (RSS 1.0) files. - -@item muse-journal-rdf-base-url -The base URL of the website referenced by the RDF file. - -@item muse-journal-rdf-header -Header used for publishing RDF (RSS 1.0) files. - -This may be text or a filename. - -@item muse-journal-rdf-footer -Footer used for publishing RDF (RSS 1.0) files. - -This may be text or a filename. - -@item muse-journal-rdf-date-format -Date format to use for RDF entries. - -@item muse-journal-rdf-entry-template -Template used to publish individual journal entries as RDF. - -This may be text or a filename. - -@item muse-journal-rdf-summarize-entries -If non-nil, include only summaries in the RDF file, not the full data. - -The default is nil, because this annoys some subscribers. - -@item muse-journal-rss-heading-regexp -A regexp that matches a journal heading from an HTML document. - -Paren group 1 is the ISO date, group 2 is the optional category, -and group 3 is the optional heading for the entry. - -@item muse-journal-rss-extension -Default file extension for publishing RSS 2.0 files. - -@item muse-journal-rss-base-url -The base URL of the website referenced by the RSS file. - -@item muse-journal-rss-header -Header used for publishing RSS 2.0 files. - -This may be text or a filename. - -@item muse-journal-rss-footer -Footer used for publishing RSS 2.0 files. - -This may be text or a filename. - -@item muse-journal-rss-date-format -Date format to use for RSS 2.0 entries. - -@item muse-journal-rss-entry-template -Template used to publish individual journal entries as RSS 2.0. - -This may be text or a filename. - -@item muse-journal-rss-enclosure-types-alist -File types that are accepted as RSS enclosures. - -This is an alist that maps file extension to content type. - -Useful for podcasting. - -@item muse-journal-rss-summarize-entries -If non-nil, include only summaries in the RSS file, not the full data. - -The default is nil, because this annoys some subscribers. - -@item muse-journal-rss-markup-regexps -List of markup rules for publishing a Muse journal page to RSS. - -For more information on the structure of this list, -@xref{muse-publish-markup-regexps}. - -@item muse-journal-rss-markup-functions -An alist of style types to custom functions for that kind of text. - -For more on the structure of this list, -@xref{muse-publish-markup-functions}. - -@end table - -@node LaTeX, Poem, Journal, Publishing Styles -@comment node-name, next, previous, up -@section Publishing LaTeX documents - -This publishing style is capable of producing LaTeX or PDF documents. - -If you wish to publish PDF documents, you will need to have a good LaTeX -installation. For Debian and Ubuntu, this can be accomplished by -installing the ``tetex-bin'' and ``tetex-extra'' packages. TeX fonts -are also a must. - -If your LaTeX installation has the file @file{grffile.sty}, which may be -found in the @file{texlive-latex-recommended} package for Debian and -Ubuntu, then consider using it by adding the following to your header -file. This allows spaces in filenames to work. - -@example -\usepackage@{grffile@} -@end example - -@subheading Styles provided - -@table @code - -@cindex publishing styles, latex -@item latex -Publish a LaTeX document. - -@cindex publishing styles, pdf -@item pdf -Publish a PDF document, using an external LaTeX document conversion -tool. - -@cindex publishing styles, latexcjk -@item latexcjk -Publish a LaTeX document with CJK (Chinese) encodings. - -@cindex publishing styles, pdfcjk -@item pdfcjk -Publish a PDF document with CJK (Chinese) encodings, using an external -LaTeX document conversion tool. - -@cindex publishing styles, slides -@item slides -Publish a LaTeX document that uses the Beamer extension. This is -suitable for producing slides. - -Here is an example of a slide. - -@example - -Everything between the slide tags composes this slide. - -[[Some-sort-of-cute-image.png]] - - - A bullet point. - - Another bullet point. - -@end example - -@cindex publishing styles, slides-pdf -@item slides-pdf -Publish a PDF document of slides, using the Beamer extension. - -@cindex publishing styles, lecture-notes -@item lecture-notes -Publish a LaTeX document that uses the Beamer extension. This is -suitable for producing lecture notes. - -This can also use the @verb{||} tag. - -@cindex publishing styles, lecture-notes-pdf -@item lecture-notes-pdf -Publish a PDF document of lecture notes, using the Beamer extension. - -@end table - -@subheading Options provided - -@table @code - -@item muse-latex-extension -Default file extension for publishing LaTeX files. - -@item muse-latex-pdf-extension -Default file extension for publishing LaTeX files to PDF. - -@item muse-latex-pdf-browser -The program to use when browsing a published PDF file. - -This should be a format string. - -@item muse-latex-pdf-program -The program that is called to generate PDF content from LaTeX content. - -@item muse-latex-pdf-cruft -Extensions of files to remove after generating PDF output successfully. - -@item muse-latex-header -Header used for publishing LaTeX files. - -This may be text or a filename. - -@item muse-latex-footer -Footer used for publishing LaTeX files. - -This may be text or a filename. - -@item muse-latexcjk-header -Header used for publishing LaTeX files (CJK). - -This may be text or a filename. - -@item muse-latexcjk-footer -Footer used for publishing LaTeX files (CJK). - -This may be text or a filename. - -@item muse-latex-slides-header -Header for publishing of slides using LaTeX. - -This may be text or a filename. - -You must have the Beamer extension for LaTeX installed for this to work. - -@item muse-latex-lecture-notes-header -Header publishing of lecture notes using LaTeX. - -This may be text or a filename. - -You must have the Beamer extension for LaTeX installed for this to work. - -@item muse-latex-markup-regexps -List of markup regexps for identifying regions in a Muse page. - -For more on the structure of this list, -@xref{muse-publish-markup-regexps}. - -@item muse-latex-markup-functions -An alist of style types to custom functions for that kind of text. - -For more on the structure of this list, -@xref{muse-publish-markup-functions}. - -@item muse-latex-markup-strings -Strings used for marking up text. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@item muse-latex-slides-markup-tags -A list of tag specifications, for specially marking up LaTeX slides. - -@item muse-latexcjk-encoding-map -An alist mapping emacs coding systems to appropriate CJK codings. -Use the base name of the coding system (ie, without the -unix). - -@item muse-latexcjk-encoding-default -The default Emacs buffer encoding to use in published files. - -This will be used if no special characters are found. - -@item muse-latex-markup-specials-document -A table of characters which must be represented specially. -These are applied to the entire document, sans already-escaped -regions. - -@item muse-latex-markup-specials-example -A table of characters which must be represented specially. -These are applied to @verb{|example>|} regions. - -With the default interpretation of @verb{||} regions, no -specials need to be escaped. - -@item muse-latex-markup-specials-literal -A table of characters which must be represented specially. -This applies to =monospaced text= and @verb{||} regions. - -@item muse-latex-markup-specials-url -A table of characters which must be represented specially. -These are applied to URLs. - -@item muse-latex-markup-specials-image -A table of characters which must be represented specially. -These are applied to image filenames. - -@item muse-latex-permit-contents-tag -If nil, ignore @verb{||} tags. Otherwise, insert table of -contents. - -Most of the time, it is best to have a table of contents on the -first page, with a new page immediately following. To make this -work with documents published in both HTML and LaTeX, we need to -ignore the @verb{||} tag. - -If you don't agree with this, then set this option to non-nil, -and it will do what you expect. - -@end table - -@node Poem, Texinfo, LaTeX, Publishing Styles -@comment node-name, next, previous, up -@section Publish a poem to LaTeX or PDF - -The @code{muse-poem} module makes it easy to attractively publish and -reference poems in the following format, using the "memoir" module for -LaTeX publishing. It will also markup poems for every other output -style, though none are nearly as pretty. - -@example -Title - - -Body of poem - - -Annotations, history, notes, etc. -@end example - -Once a poem is written in this format, just publish it to PDF using the -@code{poem-pdf} style. To make an inlined reference to a poem that -you've written -- for example, from a blog page -- there is a "poem" tag -defined by this module. - -@example - -@end example - -Let's assume the template above was called @file{name.of.poem.page}; -then the above tag would result in this inclusion. - -@example -** Title - -> Body of poem -@end example - -John Wiegley uses this module for publishing all of the poems on his -website, which are at -@uref{http://www.newartisans.com/johnw/poems.html}. - -@subheading Styles provided - -@table @code - -@cindex publishing styles, poem-latex -@item poem-latex -Publish a poem in LaTeX form. - -@cindex publishing styles, poem-pdf -@item poem-pdf -Publish a poem to a PDF document. - -@cindex publishing styles, chapbook-latex -@item chapbook-latex -Publish a book of poems in LaTeX form. - -@cindex publishing styles, chapbook-pdf -@item chapbook-pdf -Publish a book of poems to a PDF document. - -@end table - -@subheading Options provided - -@table @code - -@item muse-poem-latex-header -Header used for publishing LaTeX poems. - -This may be text or a filename. - -@item muse-poem-latex-footer -Footer used for publishing LaTeX files. - -This may be text or a filename. - -@item muse-poem-markup-strings -Strings used for marking up poems. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@item muse-chapbook-latex-header -Header used for publishing a book of poems in LaTeX form. - -This may be text or a filename. - -@item muse-chapbook-latex-footer -Footer used for publishing a book of poems in LaTeX form. - -This may be text or a filename. - -@item muse-poem-chapbook-strings -Strings used for marking up books of poems. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@end table - -@node Texinfo, XML, Poem, Publishing Styles -@comment node-name, next, previous, up -@section Publish entries to Texinfo format or PDF - -Rules for publishing a Muse file as a Texinfo article. - -@subheading Styles provided - -@table @code - -@cindex publishing styles, texi -@item texi -Publish a file in Texinfo form. - -@cindex publishing styles, texi -@item info -Generate an Info file from a Muse file. - -@cindex publishing styles, info-pdf -@item info-pdf -Publish a file in PDF form. - -@end table - -@subheading Options provided - -@table @code - -@item muse-texinfo-process-natively -If non-nil, use the Emacs `texinfmt' module to make Info files. - -@item muse-texinfo-extension -Default file extension for publishing Texinfo files. - -@item muse-texinfo-info-extension -Default file extension for publishing Info files. - -@item muse-texinfo-pdf-extension -Default file extension for publishing PDF files. - -@item muse-texinfo-header -Text to prepend to a Muse page being published as Texinfo. - -This may be text or a filename. -It may contain @verb{||} markup tags. - -@item muse-texinfo-footer -Text to append to a Muse page being published as Texinfo. - -This may be text or a filename. -It may contain @verb{||} markup tags. - -@item muse-texinfo-markup-regexps -List of markup rules for publishing a Muse page to Texinfo. - -For more on the structure of this list, -@xref{muse-publish-markup-regexps}. - -@item muse-texinfo-markup-functions -An alist of style types to custom functions for that kind of text. - -For more on the structure of this list, -@xref{muse-publish-markup-functions}. - -@item muse-texinfo-markup-strings -Strings used for marking up text. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@item muse-texinfo-markup-specials -A table of characters which must be represented specially. - -@item muse-texinfo-markup-specials -A table of characters which must be represented specially. -These are applied to URLs. - -@end table - -@node XML, , Texinfo, Publishing Styles -@comment node-name, next, previous, up -@section Publish entries to XML - -Muse is capable of publishing XML documents, with the help of the -@file{muse-xml.el} module. - -A RelaxNG schema is available as part of the Muse distribution in the -@file{etc/muse.rnc} file. - -@subheading Styles provided - -@table @code - -@cindex publishing styles, xml -@item xml -Publish a file in XML form. - -@end table - -@subheading Options provided - -@table @code - -@cindex muse-xml-encoding-map -@item muse-xml-encoding-map -An alist mapping Emacs coding systems to appropriate XML charsets. -Use the base name of the coding system (i.e. without the -unix). - -@item muse-xml-markup-specials -A table of characters which must be represented specially in all -XML-like markup formats. - -@item muse-xml-markup-specials-url-extra -A table of characters which must be represented specially in all -XML-like markup formats. - -These are extra characters that are escaped within URLs. - -@item muse-xml-extension -Default file extension used for publishing XML files. - -@item muse-xml-header -Header used for publishing XML files. - -This may be text or a filename. - -@item muse-xml-footer -Footer used for publishing XML files. - -This may be text or a filename. - -@item muse-xml-markup-regexps -List of markup rules for publishing a Muse page to XML. - -For more on the structure of this list, -@xref{muse-publish-markup-regexps}. - -@item muse-xml-markup-functions -An alist of style types to custom functions for that kind of text. - -For more on the structure of this list, -@xref{muse-publish-markup-functions}. - -@item muse-xml-markup-strings -Strings used for marking up text. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@item muse-xml-encoding-default -The default Emacs buffer encoding to use in published files. - -This will be used if no special characters are found. - -@item muse-xml-charset-default -The default XML charset to use if no translation is found in -@code{muse-xml-encoding-map}. - -@end table - - -@node Extending Muse, Miscellaneous, Publishing Styles, Top -@comment node-name, next, previous, up -@chapter Making your own publishing styles - -@menu -* Markup Functions:: Specifying functions to mark up text. -* Markup Regexps:: Markup rules for publishing. -* Markup Strings:: Strings specific to a publishing style. -* Markup Tags:: Tag specifications for special markup. -* Style Elements:: Parameters used for defining styles. -* Deriving Styles:: Deriving a new style from an existing - one. -@end menu - -@node Markup Functions, Markup Regexps, , Extending Muse -@comment node-name, next, previous, up -@section Specifying functions to mark up text -@cindex publishing, markup functions - -@anchor{muse-publish-markup-functions} -@code{muse-publish-markup-functions} - -An alist of style types to custom functions for that kind of text. - -This is used by publishing styles to attempt to minimize the amount of -custom regexps that each has to define. @file{muse-publish} provides -rules for the most common types of markup. - -Each member of the list is of the following form. - -@example -(SYMBOL FUNCTION) -@end example - -@itemize @bullet -@item SYMBOL -Describes the type of text to associate with this rule. -@code{muse-publish-markup-regexps} maps regexps to these symbols. - -@item FUNCTION -Function to use to mark up this kind of rule if no suitable function is -found through the @option{:functions} tag of the current style. -@end itemize - -@node Markup Regexps, Markup Strings, Markup Functions, Extending Muse -@comment node-name, next, previous, up -@section Markup rules for publishing -@cindex publishing, markup regexps -@cindex publishing, rules - -@anchor{muse-publish-markup-regexps} -@code{muse-publish-markup-regexps} - -List of markup rules for publishing a page with Muse. - -The rules given in this variable are invoked first, followed by whatever -rules are specified by the current style. - -Each member of the list is either a function, or a list of the following -form. - -@example -(REGEXP/SYMBOL TEXT-BEGIN-GROUP REPLACEMENT-TEXT/FUNCTION/SYMBOL) -@end example - -@itemize @bullet -@item REGEXP -A regular expression, or symbol whose value is a regular expression, -which is searched for using `re-search-forward'. - -@item TEXT-BEGIN-GROUP -The matching group within that regexp which denotes the beginning of the -actual text to be marked up. - -@item REPLACEMENT-TEXT -A string that will be passed to `replace-match'. - -If it is not a string, but a function, it will be called to determine -what the replacement text should be (it must return a string). If it is -a symbol, the value of that symbol should be a string. -@end itemize - -The replacements are done in order, one rule at a time. Writing -the regular expressions can be a tricky business. Note that case -is never ignored. `case-fold-search' is always bound to nil -while processing the markup rules. - -@subheading Publishing order - -This is the order that the publishing rules are consulted, by default. -This may be changed by customizing @code{muse-publish-markup-regexps}. - -@table @code - -@item trailing and leading whitespace -Remove trailing and leading whitespace from a file. - -@item directive -@samp{#directive} - -This is only recognized at the beginning of a file. - -@item comment -@samp{; a commented line} - -@item tag -@samp{} - -@item comment -@samp{; comment} - -@item explicit links -Prevent emphasis characters in explicit links from being marked up. - -Don't actually publish them here, just add a special no-emphasis text -property. - -@item word -Whitespace-delimited word, possibly with emphasis characters - -This function is responsible for marking up emphasis and escaping some -specials. - -@item heading -@samp{** Heading} - -Outline-mode style headings. - -@item enddots -@samp{....} - -These are ellipses with a dot at end. - -@item dots -@samp{...} - -Ellipses. - -@item rule -@samp{----} - -Horizontal rule or section separator. - -@item no-break-space -@samp{~~} - -Prevent lines from being split before or after these characters. - -@item line-break -@samp{
    } - -Break a line at point. - -@item fn-sep -@samp{Footnotes:} - -Beginning of footnotes section. - -@item footnote -@samp{[1]} - -Footnote definition or reference. If at beginning of line, it is a -definition. - -@item list -@itemize @bullet -@item -@samp{ 1. } - -@item -@samp{ - } - -@item -@samp{term :: } -@end itemize - -Numbered list, item list, or term definition list. - -@item table-el - -@file{table.el} style tables - -@item table -@samp{table | cells} - -Muse tables or orgtbl-mode style tables. - -@item quote -spaces before beginning of text - -Blockquotes. - -@item emdash -@samp{--} - -2-wide dash - -@item verse -@samp{> verse text} - -@item anchor -@samp{#anchor} - -@item link -@samp{[[explicit][links]]} - -@item url -@samp{http://example.com/} - -@item email -@samp{bare-email@@example.com} - -@end table - -@node Markup Strings, Markup Tags, Markup Regexps, Extending Muse -@comment node-name, next, previous, up -@section Strings specific to a publishing style -@cindex publishing, markup strings - -@dfn{Markup strings} are strings used for marking up text for a -particular style. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@subheading Available markup strings - -@table @code - -@item image-with-desc -An image and a description. - -Argument 1: image without extension. Argument 2: image extension. -Argument 3: description. - -@item image -An inlined image. - -Argument 1: image without extension. Argument 2: image extension. - -@item image-link -An image with a link around it. - -Argument 1: link. Argument 2: image without extension. -Argument 3: image extension. - -@item anchor-ref -A reference to an anchor on the current page. - -Argument 1: anchor name. Argument 2: description if one exists, or the -original link otherwise. - -@item url -A URL without a description. - -Argument 1: URL. - -@item link -A link to a Muse page with a description. - -Argument 1: link. Argument 2: description if one exists, or the -original link otherwise. - -@item link-and-anchor -A link to a Muse page with an anchor, and a description. - -Argument 1: link. Argument 2: anchor name. -Argument 3: description if one exists, or the original link otherwise. -Argument 4: link without an extension. - -@item email-addr -A link to an email address. - -Argument 1: email address. Argument 2: email address. - -@item anchor -An anchor. - -Argument 1: name of anchor. - -@item emdash -A 2-length dash. - -Argument 1: Initial whitespace. Argument 2: Terminating whitespace. - -@item comment-begin -Beginning of a comment. - -@item comment-end -End of a comment. - -@item rule -A horizontal line or space. - -@item no-break-space -A space that separates two words which are not to be separated. - -@item footnote -Beginning of footnote. - -@item footnote-end -End of footnote. - -@item footnotemark -Mark a reference for the current footnote. - -Argument 1: number of this footnote. - -@item footnotemark-end -End of a reference for the current footnote. - -@item footnotetext -Indicate the text of the current footnote. - -Argument 1: number of this footnote. - -@item footnotetext-end -End of a footnote text line. - -@item fn-sep -Text used to replace ``Footnotes:'' line. - -@item dots -3 dots. - -@item enddots -4 dots. - -@item part -Beginning of a part indicator line. This is used by book publishing. - -@item part-end -End of a part indicator line. This is used by book publishing. - -@item chapter -Beginning of a chapter indicator line. This is used by book publishing. - -@item chapter-end -End of a chapter indicator line. This is used by book publishing. - -@item section -Beginning of level 1 section indicator line. - -Argument 1: level of section; always 1. - -@item section-end -End of level 1 section indicator line. - -Argument 1: level of section; always 1. - -@item subsection -Beginning of level 2 section indicator line. - -Argument 1: level of section; always 2. - -@item subsection-end -End of level 2 section indicator line. - -Argument 1: level of section; always 2. - -@item subsubsection -Beginning of level 3 section indicator line. - -Argument 1: level of section; always 3. - -@item subsubsection-end -End of level 3 section indicator line. - -Argument 1: level of section; always 3. - -@item section-other -Beginning of section indicator line, where level is greater than 3. - -Argument 1: level of section. - -@item section-other-end -End of section indicator line, where level is greater than 3. - -Argument 1: level of section. - -@item begin-underline -Beginning of underlined text. - -@item end-underline -End of underlined text. - -@item begin-literal -Beginning of verbatim text. This includes @verb{||} tags and -=teletype text=. - -@item end-literal -End of verbatim text. This includes @verb{||} tags and =teletype -text=. - -@item begin-emph -Beginning of the first level of emphasized text. - -@item end-emph -End of the first level of emphasized text. - -@item begin-more-emph -Beginning of the second level of emphasized text. - -@item end-more-emph -End of the second level of emphasized text. - -@item begin-most-emph -Beginning of the third (and final) level of emphasized text. - -@item end-most-emph -End of the third (and final) level of emphasized text. - -@item begin-verse -Beginning of verse text. - -@item verse-space -String used to each space that is further indented than the beginning of -the verse. - -@item begin-verse-line -Beginning of a line of verse. - -@item empty-verse-line -End of a line of verse. - -@item begin-last-stanza-line -Beginning of the last line of a verse stanza. - -@item end-last-stanza-line -End of the last line of a verse stanza. - -@item end-verse -End of verse text. - -@item begin-example -Beginning of an example region. To make use of this, an -@samp{} tag is needed. - -@item end-example -End of an example region. To make use of this, an @samp{} tag -is needed. - -@item begin-center -Begin a centered line. - -@item end-center -End a centered line. - -@item begin-quote -Begin a quoted region. - -@item end-quote -End a quoted region. - -@item begin-quote-item -Begin a quote paragraph. - -@item end-quote-item -End a quote paragraph. - -@item begin-uli -Begin an unordered list. - -@item end-uli -End an unordered list. - -@item begin-uli-item -Begin an unordered list item. - -@item end-uli-item -End an unordered list item. - -@item begin-oli -Begin an ordered list. - -@item end-oli -End an ordered list. - -@item begin-oli-item -Begin an ordered list item. - -@item end-oli-item -End an ordered list item. - -@item begin-dl -Begin a definition list. - -@item end-dl -End a definition list. - -@item begin-dl-item -Begin a definition list item. - -@item end-dl-item -End a definition list item. - -@item begin-ddt -Begin a definition list term. - -@item end-ddt -End a definition list term. - -@item begin-dde -Begin a definition list entry. - -@item end-dde -End a definition list entry. - -@item begin-table -Begin a table. - -@item end-table -End a table. - -@item begin-table-group -Begin a table grouping. - -@item end-table-group -End a table grouping. - -@item begin-table-row -Begin a table row. - -@item end-table-row -End a table row. - -@item begin-table-entry -Begin a table entry. - -@item end-table-entry -End a table entry. - -@end table - -@node Markup Tags, Style Elements, Markup Strings, Extending Muse -@comment node-name, next, previous, up -@section Tag specifications for special markup -@cindex publishing, markup tags - -@anchor{muse-publish-markup-tags} -@code{muse-publish-markup-tags} - -A list of tag specifications, for specially marking up text. - -XML-style tags are the best way to add custom markup to Muse. This is -easily accomplished by customizing this list of markup tags. - -For each entry, the name of the tag is given, whether it expects a -closing tag and/or an optional set of attributes, whether it is -nestable, and a function that performs whatever action is desired within -the delimited region. - -The tags themselves are deleted during publishing, before the function -is called. The function is called with three arguments, the beginning -and end of the region surrounded by the tags. If properties are -allowed, they are passed as a third argument in the form of an alist. -The `end' argument to the function is always a marker. - -Point is always at the beginning of the region within the tags, when the -function is called. Wherever point is when the function finishes is -where tag markup will resume. - -These tag rules are processed once at the beginning of markup, and once -at the end, to catch any tags which may have been inserted in-between. - -@node Style Elements, Deriving Styles, Markup Tags, Extending Muse -@comment node-name, next, previous, up -@section Parameters used for defining styles -@cindex publishing, style elements - -Style elements are tags that define a style. Use either -@code{muse-define-style} or @code{muse-derive-style} -(@pxref{Deriving Styles}) to create a new style. - -@defun muse-define-style name &rest elements -@end defun - -@subheading Usable elements - -@table @option - -@item :suffix -File extension to use for publishing files with this style. - -@item :link-suffix -File extension to use for publishing links to Muse files with this -style. - -@item :osuffix -File extension to use for publishing second-stage files with this style. - -For example, PDF publishing generates a LaTeX file first, then a PDF -from that LaTeX file. - -@item :regexps -List of markup rules for publishing a page with Muse. -@xref{muse-publish-markup-regexps}. - -@item :functions -An alist of style types to custom functions for that kind of text. -@xref{muse-publish-markup-functions}. - -@item :strings -Strings used for marking up text with this style. - -These cover the most basic kinds of markup, the handling of which -differs little between the various styles. - -@item :tags -A list of tag specifications, used for handling extra tags. -@xref{muse-publish-markup-tags}. - -@item :specials -A table of characters which must be represented specially. - -@item :before -A function that is to be executed on the newly-created publishing buffer -(or the current region) before any publishing occurs. - -This is used to set extra parameters that direct the publishing process. - -@item :before-end -A function that is to be executed on the publishing buffer (or the -current region) immediately after applying all of the markup regexps. - -This is used to fix the order of table elements (header, footer, body) -in XML-ish styles. - -@item :after -A function that is to be executed on the publishing buffer after -:before-end, and immediately after inserting the header and footer. - -This is used for generating the table of contents as well as setting the -file coding system. - -@item :final -A function that is to be executed after saving the published file, but -while still in its buffer. - -This is used for generating second-stage documents like PDF files from -just-published LaTeX files. - -The function must accept three arguments: the name of the muse source -file, the name of the just-published file, and the name of the -second-stage target file. The name of the second-stage target file is -the same as that of the just-published file if no second-stage -publishing is required. - -@item :header -Header used for publishing files of this style. - -This may be a variable, text, or a filename. It is inserted at the -beginning of a file, after evaluating the publishing markup. - -@item :footer -Footer used for publishing files of this style. - -This may be a variable, text, or a filename. It is inserted at the end -of a file, after evaluating the publishing markup. - -@item :style-sheet -Style sheet used for publishing files of this style. - -This may be a variable or text. It is used in the header of HTML and -XHTML based publishing styles. - -@item :browser -The function used to browse the published result of files of this style. - -@end table - -@node Deriving Styles, , Style Elements, Extending Muse -@comment node-name, next, previous, up -@section Deriving a new style from an existing one -@cindex publishing styles, deriving - -To create a new style from an existing one, use @code{muse-derive-style} -as follows. This is a good way to fix something you don't like about a -particular publishing style, or to personalize it. - -@defun muse-derive-style new-name base-name &rest elements -@end defun - -The derived name is a string defining the new style, such as "my-html". -The base name must identify an existing style, such as "html" -- if you -have loaded @file{muse-html}. The style parameters are the same as -those used to create a style, except that they override whatever -definitions exist in the base style. However, some definitions only -partially override. The following parameters support partial -overriding. - -@xref{Style Elements}, for a complete list of all parameters. - -@table @option - -@item :functions -If a markup function is not found in the derived style's function list, -the base style's function list will be queried. - -@item :regexps -All regexps in the current style and the base style(s) will be used. - -@item :strings -If a markup string is not found in the derived style's string list, the -base style's string list will be queried. - -@end table - -@node Miscellaneous, Getting Help and Reporting Bugs, Extending Muse, Top -@comment node-name, next, previous, up -@chapter Miscellaneous add-ons, like a minor mode - -@menu -* Muse List Edit Minor Mode:: Edit lists easily in other major modes. -@end menu - -@node Muse List Edit Minor Mode, , , Miscellaneous -@comment node-name, next, previous, up -@section Edit lists easily in other major modes -@cindex muse-list-edit-minor-mode - -@code{muse-list-edit-minor-mode} is meant to be used with other major -modes, such as Message (for composing email) and debian-changelog-mode -(for editing debian/changelog files). - -It implements practically perfect support for editing and filling lists. -It can even handle nested lists. In addition to Muse-specific list -items ("-", numbers, definition lists, footnotes), it can also handle -items that begin with "*" or "+". Filling list items behaves in the -same way that it does in Muse, regardless of whether filladapt is also -enabled, which is the primary reason to use this tool. - -@subheading Installation - -To use it, add ``(require 'muse-mode)'' to your Emacs customization file -and add the function @code{turn-on-muse-list-edit-minor-mode} to any -mode hooks where you wish to enable this minor mode. - -@subheading Keybindings - -@code{muse-list-edit-minor-mode} uses the following keybindings. - -@table @kbd - -@item M-RET (`muse-l-e-m-m-insert-list-item') -Insert a new list item at point, using the indentation level of the -current list item. - -@item C-< (`muse-l-e-m-m-decrease-list-item-indent') -Decrease indentation of the current list item. - -@item C-> (`muse-l-e-m-m-increase-list-item-indent') -Increase indentation of the current list item. - -@end table - -@subheading Functions - -@defun muse-list-edit-minor-mode -This is a global minor mode for editing files with lists. -It is meant to be used with other major modes, and not with Muse mode. - -Interactively, with no prefix argument, toggle the mode. -With universal prefix @var{arg} turn mode on. -With zero or negative @var{arg} turn mode off. - -This minor mode provides the Muse keybindings for editing lists, -and support for filling lists properly. - -It recognizes not only Muse-style lists, which use the "-" -character or numbers, but also lists that use asterisks or plus -signs. This should make the minor mode generally useful. - -Definition lists and footnotes are also recognized. - -Note that list items may omit leading spaces, for compatibility -with modes that set @code{left-margin}, such as -@code{debian-changelog-mode}. -@end defun - -@defun turn-on-muse-list-edit-minor-mode -Unconditionally turn on Muse list edit minor mode. -@end defun - -@defun turn-off-muse-list-edit-minor-mode -Unconditionally turn off Muse list edit minor mode. -@end defun - -@node Getting Help and Reporting Bugs, History, Miscellaneous, Top -@comment node-name, next, previous, up -@chapter Getting Help and Reporting Bugs -@cindex help, getting -@cindex bugs, reporting - -After you have read this guide, if you still have questions about -Muse, or if you have bugs to report, there are several places you can -go. - -@itemize @bullet - -@item -@uref{http://www.emacswiki.org/cgi-bin/wiki/EmacsMuse} is the -emacswiki.org page, and anyone may add tips, hints, or bug descriptions -to it. - -@item -@uref{http://mwolson.org/projects/EmacsMuse.html} is the web page -that Michael Olson (the current maintainer) made for Muse. - -@item -Muse has several different mailing lists. - -@table @samp - -@item muse-el-announce -Low-traffic list for Muse-related announcements. - -You can join this mailing list (@email{muse-el-announce@@gna.org}) -using the subscription form at -@url{http://mail.gna.org/listinfo/muse-el-announce/}. This -mailing list is also available via Gmane (@url{http://gmane.org/}). The -group is called @samp{gmane.emacs.muse.announce}. - -@item muse-el-discuss -Discussion, bugfixes, suggestions, tips, and the like for Muse. -This mailing list also includes the content of muse-el-announce. - -You can join this mailing list (@email{muse-el-discuss@@gna.org}) -using the subscription form at -@url{http://mail.gna.org/listinfo/muse-el-discuss/}. This mailing -list is also available via Gmane with the identifier -@samp{gmane.emacs.muse.general}. - -@item muse-el-logs -Log messages for commits made to Muse. - -You can join this mailing list (@email{muse-el-logs@@gna.org}) using -the subscription form at -@url{http://mail.gna.org/listinfo/muse-el-logs/}. This mailing list -is also available via Gmane with the identifier -@samp{gmane.emacs.muse.scm}. - -@item muse-el-commits -Generated bug reports for Emacs Muse. If you use our bug-tracker at -@url{https://gna.org/bugs/?group=muse-el}, the bug reports will be -sent to this list automatically. - -You can join this mailing list (@email{muse-el-commits@@gna.org}) using -the subscription form at -@url{http://mail.gna.org/listinfo/muse-el-commits/}. This mailing list -is also available via Gmane with the identifier -@samp{gmane.emacs.muse.cvs}. - -@item muse-el-internationalization -Discussion of translation of the Muse website and documentation into -many languages. - -You can join this mailing list -(@email{muse-el-internationalization@@gna.org}) using the subscription -form at @url{http://mail.gna.org/listinfo/internationalization/}. This -mailing list is also available via Gmane with the identifier -@samp{gmane.emacs.muse.internationalization}. - -@end table - -@item -You can visit the IRC Freenode channel @samp{#emacs}. Many of the -contributors are frequently around and willing to answer your -questions. The @samp{#muse} channel is also available for -Muse-specific help, and its current maintainer hangs out there. - -@item -The maintainer of Emacs Muse, Michael Olson, may be contacted at -@email{mwolson@@gnu.org}. He can be rather slow at answering email, so -it is often better to use the muse-el-discuss mailing list. - -@end itemize - -@node History, Contributors, Getting Help and Reporting Bugs, Top -@comment node-name, next, previous, up -@chapter History of This Document -@cindex history, of Muse - -@itemize -@item 2004 -John Wiegley started Muse upon realizing that EmacsWiki had some serious -limitations. Around February 2004, he started making "emacs-wiki version -3.00 APLHA", which eventually became known as Muse. - -Most of those who frequent the emacs-wiki mailing list continued to use -emacs-wiki, mainly because Planner hasn't been ported over to it. - -As of 2004-12-01, Michael Olson became the maintainer of Muse, as per -John Wiegley's request. - -@item 2005 -Michael Olson overhauled this document and added many new sections in -preparation for the first release of Muse (3.01). - -@end itemize - -@node Contributors, GNU Free Documentation License, History, Top -@comment node-name, next, previous, up -@chapter Contributors to This Documentation -@cindex contributors - -The first draft of this document was taken from the emacs-wiki texinfo -manual. Michael Olson adapted it for Muse and added most of its -content. - -John Sullivan did a majority of the work on the emacs-wiki texinfo -manual. - -While Sacha Chua maintained emacs-wiki, she worked quite a bit on the -emacs-wiki texinfo manual. - - -@node GNU Free Documentation License, Concept Index, Contributors, Top -@appendix GNU Free Documentation License -@include doclicense.texi - - -@node Concept Index, , GNU Free Documentation License, Top -@comment node-name, next, previous, up -@unnumbered Index - -@printindex cp - -@bye diff --git a/elpa/org-jira-20160821.1939/jiralib.el b/elpa/org-jira-20160821.1939/jiralib.el deleted file mode 100644 index 6e5d09a..0000000 --- a/elpa/org-jira-20160821.1939/jiralib.el +++ /dev/null @@ -1,639 +0,0 @@ -;;; jiralib.el -- Provide connectivity to JIRA SOAP service - -;; Copyright (C) 2011 Bao Haojun -;; original Copyright (C) 2009 Alex Harsanyi - -;; Also, used some code from jira.el, which use xml-rpc instead of soap. -;; Thus Copyright (C) for jira.el related code: -;; Brian Zwahr -;; Dave Benjamin - -;; Authors: -;; Bao Haojun -;; Alex Harsanyi - -;; 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 . - -;; Author: Alexandru Harsanyi (AlexHarsanyi@gmail.com) -;; Created: December, 2009 -;; Keywords: soap, web-services, jira -;; Homepage: http://code.google.com/p/emacs-soap-client - -;;; Commentary: -;; This file provides a programatic interface to JIRA. It provides access to -;; JIRA from other programs, but no user level functionality. - -;; Jira References: -;; -;; http://confluence.atlassian.com/display/JIRA/Creating+a+SOAP+Client -;; -;; JavaDoc for the Jira SOAP service -;; http://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/com/atlassian/jira/rpc/soap/JiraSoapService.html - -(eval-when-compile (require 'cl)) -(require 'soap-client) -(require 'url-parse) - -;;; Code: -(defgroup jiralib nil - "Jiralib customization group." - :group 'applications) - -(defgroup jiralib-faces nil - "Faces for displaying Jiralib information." - :group 'jiralib) - -(defcustom jiralib-host "" - "User customizable host name of the Jiralib server. - -This will be used with USERNAME to compute password from -.authinfo file. Will be calculated from jiralib-url if not set." - :group 'jiralib - :type 'string - :initialize 'custom-initialize-set) - -(defface jiralib-issue-info-face - '((t (:foreground "black" :background "yellow4"))) - "Base face for issue information." - :group 'jiralib-faces) - -(defface jiralib-issue-info-header-face - '((t (:bold t :inherit 'jiralib-issue-info-face))) - "Base face for issue headers." - :group 'jiralib-faces) - -(defface jiralib-issue-summary-face - '((t (:bold t))) - "Base face for issue summary." - :group 'jiralib-faces) - -(defface jiralib-comment-face - '((t (:background "gray23"))) - "Base face for comments." - :group 'jiralib-faces) - -(defface jiralib-comment-header-face - '((t (:bold t))) - "Base face for comment headers." - :group 'jiralib-faces) - -(defface jiralib-link-issue-face - '((t (:underline t))) - "Face for linked issues." - :group 'jiralib-faces) - -(defface jiralib-link-project-face - '((t (:underline t))) - "Face for linked projects" - :group 'jiralib-faces) - -(defface jiralib-link-filter-face - '((t (:underline t))) - "Face for linked filters" - :group 'jiralib-faces) - -(defvar jiralib-mode-hook nil) - -(defvar jiralib-mode-map nil) - -(defcustom jiralib-wsdl-descriptor-url - "" - "The location for the WSDL descriptor for the JIRA service. -This is specific to your local JIRA installation. The URL is -tipically: - - http://YOUR_INSTALLATION/rpc/soap/jirasoapservice-v2?wsdl - -The default value works if JIRA is located at a hostname named -'jira'." - :type 'string - :group 'jiralib) - -(defcustom jiralib-url - "http://localhost:18888/" - "The address of the jira host." - :type 'string - :group 'jiralib) - -(defvar jiralib-token nil - "JIRA token used for authentication.") - -(defvar jiralib-user-login-name nil - "The name of the user logged into JIRA. -This is maintained by `jiralib-login'.") - -(defvar jiralib-wsdl nil) - -(defun jiralib-load-wsdl () - "Load the JIRA WSDL descriptor." - (setq jiralib-wsdl (soap-load-wsdl-from-url (if (string-equal jiralib-wsdl-descriptor-url "") - (concat jiralib-url "/rpc/soap/jirasoapservice-v2?wsdl") - jiralib-wsdl-descriptor-url)))) - -(defun jiralib-login (username password) - "Login into JIRA as user USERNAME with PASSWORD. - -After a succesful login, store the authentication token in -`jiralib-token'." - ;; NOTE that we cannot rely on `jiralib-call' because `jiralib-call' relies on - ;; us ;-) - (interactive - (if (> 24 emacs-major-version) - (let ((user (read-string "Username for Jira server login? ")) - (password (read-passwd "Password for Jira server login? "))) - (list user password)) - (let ((found (nth 0 (auth-source-search :max 1 - :host (if (string= jiralib-host "") - (url-host (url-generic-parse-url jiralib-url)) - jiralib-host) - :port (url-port (url-generic-parse-url jiralib-url)) - :require '(:user :secret) - :create t))) - user secret) - (when found - (setq user (plist-get found :user) - secret - (let ((sec (plist-get found :secret))) - (if (functionp sec) - (funcall sec) - sec))) - (list user secret))))) - (unless jiralib-wsdl - (jiralib-load-wsdl)) - (setq jiralib-token - (car (soap-invoke jiralib-wsdl "jirasoapservice-v2" "login" username password))) - (setq jiralib-user-login-name username) - - ;; At this poing, soap-invoke didn't raise an error, so the login - ;; credentials are OK. use them to log into the web interface as - ;; well, as this will be used to link issues (an operation which is - ;; not exposed to the SOAP interface. - ;; - ;; Note that we don't validate the response at all -- not sure how we - ;; would do it... - - (let ((url (concat jiralib-url "/secure/Dashboard.jspa?" - (format "&os_username=%s&os_password=%s&os_cookie=true" - username password)))) - (let ((url-request-method "POST") - (url-package-name "Emacs jiralib.el") - (url-package-version "1.0") - (url-mime-charset-string "utf-8;q=1, iso-8859-1;q=0.5") - (url-request-data "abc") - (url-request-coding-system 'utf-8) - (url-http-attempt-keepalives t)) - (let ((buffer (url-retrieve-synchronously url))) - ;; This is just a basic check that the page was retrieved - ;; correctly. No error does not indicate a succesfull login, - ;; we would have to parse the HTML page to find that out... - (with-current-buffer buffer - (declare (special url-http-response-status)) - (if (> url-http-response-status 299) - (error "Error logging into JIRA Web interface %s" - url-http-response-status))) - (kill-buffer buffer))))) - -(defun jiralib-call (method &rest params) - "Invoke the JIRA METHOD with supplied PARAMS. - -This function should be used for all JIRA interface calls, as the -method ensures the user is logged in and invokes `soap-invoke' -with the correct service name and authentication token. - -All JIRA inteface methods take an authentication token as the -first argument. The authentication token is supplied by this -function, so PARAMS should omit this parameter. For example, the -\"getIssue\" method takes two parameters: auth and key, however, -when invoking it through `jiralib-call', the call shoulbe be: - - (jiralib-call \"getIssue\" KEY)" - (car (apply 'jiralib--call-it method params))) - -(defun jiralib--call-it (method &rest params) - "Invoke the JIRA METHOD with supplied PARAMS. - -Internal use, returns a list of responses, of which only the -first is normally used." - (when (symbolp method) - (setq method (symbol-name method))) - (unless jiralib-token - (call-interactively 'jiralib-login)) - (condition-case data - (apply 'soap-invoke jiralib-wsdl "jirasoapservice-v2" - method jiralib-token params) - (soap-error - ;; If we are here, we had a token, but it expired. Re-login and try - ;; again. - (setq jiralib-token nil) - (call-interactively 'jiralib-login) - (apply 'soap-invoke jiralib-wsdl "jirasoapservice-v2" - method jiralib-token params)))) - - -;;;; Some utility functions - -(defun jiralib-make-list (data field) - "Map all assoc elements in DATA to the value of FIELD in that element." - (loop for element in data - collect (cdr (assoc field element)))) -(defun jiralib-make-assoc-list (data key-field value-field) - "Create an association list from a SOAP structure array. - -DATA is a list of association lists (a SOAP array-of type) -KEY-FIELD is the field to use as the key in the returned alist -VALUE-FIELD is the field to use as the value in the returned alist" - (loop for element in data - collect (cons (cdr (assoc key-field element)) - (cdr (assoc value-field element))))) - -(defun jiralib-make-remote-field-values (fields) - "Transform the (KEY . VALUE) list FIELDS into a RemoteFieldValue structure. - -Each (KEY . VALUE) pair is transformed into - ((id . KEY) (values . (VALUE))) - -This method exists because Several JIRA methods require a -RemoteFieldValue list, but it is easier to work with ALISTS in -emacs-lisp" - (let ((remote-field-values)) - - ;; we accept an ALIST of field-name field-values parameter, but we need to - ;; construct a structure that encodes as a RemoteFieldValue which is what - ;; updateIssue wants - (dolist (field fields) - (let ((name (car field)) - (value (cdr field))) - (when (symbolp name) - (setq name (symbol-name name))) - ;; Value must be an "array" (for which soap-client accepts lists) even - ;; if it is just one value - (unless (vectorp value) - (setq value (vector value))) - (push `((id . ,name) (values . ,value)) - remote-field-values))) - - (apply 'vector (nreverse remote-field-values)))) - -;;;; Wrappers around JIRA methods - -(defun jiralib-update-issue (key fields) - "Update the issue with id KEY with the values in FIELDS." - (jiralib-call "updateIssue" key (jiralib-make-remote-field-values fields))) - - -(defvar jiralib-status-codes-cache nil) - -(defun jiralib-get-statuses () - "Return an assoc list mapping a status code to its name. -NOTE: Status codes are stored as strings, not numbers. - -This function will only ask JIRA for the list of codes once, then -will cache it." - (unless jiralib-status-codes-cache - (setq jiralib-status-codes-cache - (jiralib-make-assoc-list (jiralib-call "getStatuses") 'id 'name))) - jiralib-status-codes-cache) - -(defvar jiralib-issue-types-cache nil) - -(defun jiralib-get-issue-types () - "Return an assoc list mapping an issue type code to its name. -NOTE: Issue type codes are stored as strings, not numbers. - -This function will only ask JIRA for the list of codes once, than -will cache it." - (unless jiralib-issue-types-cache - (setq jiralib-issue-types-cache - (jiralib-make-assoc-list (jiralib-call "getIssueTypes") 'id 'name))) - jiralib-issue-types-cache) - -(defvar jiralib-priority-codes-cache nil) - -(defun jiralib-get-priorities () - "Return an assoc list mapping a priority code to its name. -NOTE: Priority codes are stored as strings, not numbers. - -This function will only ask JIRA for the list of codes once, than -will cache it." - (unless jiralib-priority-codes-cache - (setq jiralib-priority-codes-cache - (jiralib-make-assoc-list (jiralib-call "getPriorities") 'id 'name))) - jiralib-priority-codes-cache) - -(defvar jiralib-resolution-code-cache nil) - -(defun jiralib-get-resolutions () - "Return an assoc list mapping a resolution code to its name. -NOTE: Resolution codes are stored as strings, not numbers. - -This function will only ask JIRA for the list of codes once, than -will cache it." - (unless jiralib-resolution-code-cache - (setq jiralib-resolution-code-cache - (jiralib-make-assoc-list (jiralib-call "getResolutions") 'id 'name))) - jiralib-resolution-code-cache) - -(defvar jiralib-issue-regexp nil) - -;; NOTE: it is not such a good ideea to use this, as it needs a JIRA -;; connection to construct the regexp (the user might be prompted for a JIRA -;; username and password). -;; -;; The best use of this function is to generate the regexp once-off and -;; persist it somewhere. - -(defun jiralib-get-issue-regexp () - "Return a regexp that will match an issue id. - -The regexp is constructed from the project keys in the JIRA -database. An issue is assumed to be in the format KEY-NUMBER, -where KEY is a project key and NUMBER is the issue number." - (unless jiralib-issue-regexp - (let ((projects (mapcar (lambda (e) (downcase (cdr (assoc 'key e)))) - (jiralib-call "getProjectsNoSchemes")))) - (setq jiralib-issue-regexp (concat "\\<" (regexp-opt projects) "-[0-9]+\\>")))) - jiralib-issue-regexp) - -(defun jiralib-do-jql-search (jql &optional limit) - "Run a JQL query and return the list of issues that matched. -LIMIT is the maximum number of queries to return. Note that JIRA -has an internal limit of how many queries to return, as such, it -might not be possible to find *ALL* the issues that match a -query." - (unless (or limit (numberp limit)) - (setq limit 100)) - (jiralib-call "getIssuesFromJqlSearch" jql limit)) - -(defun jiralib-get-available-actions (issue-key) - "Return the available workflow actions for ISSUE-KEY. -This runs the getAvailableActions SOAP method." - (jiralib-make-assoc-list - (jiralib-call "getAvailableActions" issue-key) - 'id 'name)) - -(defun jiralib-get-fields-for-action (issue-key action-id) - "Return the required fields to change ISSUE-KEY to ACTION-ID." - (jiralib-make-assoc-list - (jiralib-call "getFieldsForAction" issue-key action-id) - 'id 'name)) - -(defun jiralib-progress-workflow-action (issue-key action-id params) - "Progress issue with ISSUE-KEY to action ACTION-ID, and provide the needed PARAMS." - (jiralib-call "progressWorkflowAction" issue-key action-id (jiralib-make-remote-field-values params))) - -(defun jiralib-add-worklog-and-autoadjust-remaining-estimate (issue-key start-date time-spent comment) - "Log time spent on ISSUE-KEY to its worklog. -The time worked begins at START-DATE and has a TIME-SPENT -duration. JIRA will automatically update the remaining estimate -by subtracting TIME-SPENT from it. - -START-DATE should be in the format 2010-02-05T14:30:00Z - -TIME-SPENT can be in one of the following formats: 10m, 120m -hours; 10h, 120h days; 10d, 120d weeks. - -COMMENT will be added to this worklog." - (jiralib-call "addWorklogAndAutoAdjustRemainingEstimate" - issue-key - `((startDate . ,start-date) - (timeSpent . ,time-spent) - (comment . ,comment)))) - -(defun jiralib-link-issue (issue-key link-type other-issue-key) - "Link ISSUE-KEY with a link of type LINK-TYPE to OTHER-ISSUE-KEY. -LINK-TYPE is a string representing the type of the link, e.g -\"requires\", \"depends on\", etc. I believe each JIRA -installation can define its own link types." - - ;; IMPLEMENTATION NOTES: The linking jira issues functionality is - ;; not exposed through the SOAP api, we must use the web interface - ;; to do the linking. Unfortunately, we cannot parse the result, so - ;; we don't know that the linking was succesfull or not. To reduce - ;; the risk, we use the SOAP api to retrieve the issues for - ;; ISSUE-KEY and OTHER-ISSUE-KEY. This will ensure that we are - ;; logged in (see also jiralib-login) and that both issues exist. We - ;; don't validate the LINK-TYPE, not sure how to do it. - - (let ((issue (jiralib-get-issue issue-key)) - (other-issue (jiralib-get-issue other-issue-key))) - (let ((url (concat jiralib-url - "/secure/LinkExistingIssue.jspa?" - (format "linkDesc=%s&linkKey=%s&id=%s&Link=Link" - link-type other-issue-key (cdr (assq 'id issue)))))) - (let ((url-request-method "POST") - (url-package-name "Emacs scratch.el") - (url-package-version "1.0") - (url-mime-charset-string "utf-8;q=1, iso-8859-1;q=0.5") - (url-request-data "abc") - (url-request-coding-system 'utf-8) - (url-http-attempt-keepalives t) - ;; see http://confluence.atlassian.com/display/JIRA/Form+Token+Handling - (url-request-extra-headers '(("X-Atlassian-Token" . "no-check")))) - - (let ((buffer (url-retrieve-synchronously url))) - ;; This is just a basic check that the page was retrieved - ;; correctly. No error does not indicate a success as we - ;; have to parse the HTML page to find that out... - (with-current-buffer buffer - (declare (special url-http-response-status)) - (if (> url-http-response-status 299) - (error "Error linking issue through JIRA Web interface %s" - url-http-response-status))) - (kill-buffer buffer)))))) - - -;;;; Issue field accessors - -(defun jiralib-issue-key (issue) - "Return the key of ISSUE." - (cdr (assoc 'key issue))) - -(defun jiralib-issue-owner (issue) - "Return the owner of ISSUE." - (cdr (assq 'assignee issue))) - -(defun jiralib-issue-status (issue) - "Return the status of ISSUE as a status string (not as a number!)." - (let ((status-code (cdr (assq 'status issue)))) - (cdr (assoc status-code (jiralib-get-statuses))))) - -(defun jiralib-custom-field-value (custom-field issue) - "Return the value of CUSTOM-FIELD for ISSUE. -Return nil if the field is not found" - (catch 'found - (dolist (field (cdr (assq 'customFieldValues issue))) - (when (equal (cdr (assq 'customfieldId field)) custom-field) - (throw 'found (cadr (assq 'values field))))))) - -(defvar jiralib-current-issue nil - "This holds the currently selected issue.") - -(defvar jiralib-projects-list nil - "This holds a list of projects and their details.") - -(defvar jiralib-types nil - "This holds a list of issues types.") - -(defvar jiralib-priorities nil - "This holds a list of priorities.") - -(defvar jiralib-user-fullnames nil - "This holds a list of user fullnames.") - -(defun jiralib-get-project-name (key) - "Return the name of the JIRA project with id KEY." - (let ((projects jiralib-projects-list) - (name nil)) - (dolist (project projects) - (if (equal (cdr (assoc 'key project)) key) - (setf name (cdr (assoc 'name project))))) - name)) - -(defun jiralib-get-type-name (id) - "Return the name of the issue type with ID." - (let ((types jiralib-types) - (name nil)) - (dolist (type types) - (if (equal (cdr (assoc 'id type)) id) - (setf name (cdr (assoc 'name type))))) - name)) - -(defun jiralib-get-user-fullname (username) - "Return the full name (display name) of the user with USERNAME." - (if (assoc username jiralib-user-fullnames) - (cdr (assoc username jiralib-user-fullnames)) - (progn - (let ((user (jiralib-get-user username))) - (setf jiralib-user-fullnames (append jiralib-user-fullnames (list (cons username (cdr (assoc 'fullname user)))))) - (cdr (assoc 'fullname user)))))) - - -(defun jiralib-get-filter (filter-id) - "Return a filter given its FILTER-ID." - (cl-flet ((id-match (filter) - (equal filter-id (cdr (assoc 'id filter))))) - (cl-find-if 'id-match (jiralib-get-saved-filters)))) - -(defun jiralib-get-filter-alist () - "Return an association list mapping filter names to IDs." - (mapcar (lambda (filter) - (cons (cdr (assoc 'name filter)) - (cdr (assoc 'id filter)))) - (jiralib-get-saved-filters))) - -(defun jiralib-add-comment (issue-key comment) - "Add to issue with ISSUE-KEY the given COMMENT." - (jiralib-call "addComment" issue-key `((body . ,comment)))) - -(defun jiralib-edit-comment (comment-id comment) - "Edit comment with COMMENT-ID to reflect the new COMMENT." - (jiralib-call "editComment" `((id . ,comment-id) - (body . ,comment)))) - -(defun jiralib-create-issue (issue) - "Create a new ISSUE in JIRALIB. - -ISSUE is a Hashtable object." - (jiralib-call "createIssue" issue)) - -(defun jiralib-create-subtask (subtask parent-issue-id) - "Create SUBTASK for issue with PARENT-ISSUE-ID. - -SUBTASK is a Hashtable object." - (jiralib-call "createIssueWithParent" subtask parent-issue-id)) - - -(defvar jiralib-subtask-types-cache nil) - -(defun jiralib-get-subtask-types () - "Return an assoc list mapping an issue type code to its name. -NOTE: Issue type codes are stored as strings, not numbers. - -This function will only ask JIRA for the list of codes once, than -will cache it." - (unless jiralib-subtask-types-cache - (setq jiralib-subtask-types-cache - (jiralib-make-assoc-list (jiralib-call "getSubTaskIssueTypes") 'id 'name))) - jiralib-subtask-types-cache) - - -(defun jiralib-get-comments (issue-key) - "Return all comments associated with issue ISSUE-KEY." - (jiralib-call "getComments" issue-key)) - -(defun jiralib-get-worklogs (issue-key) - "Return all worklogs associated with issue ISSUE-KEY." - (jiralib-call "getWorklogs" issue-key)) - -(defun jiralib-update-worklog (worklog) - "Update the WORKLOG, updating the ETA for the related issue." - (jiralib-call "updateWorklogAndAutoAdjustRemainingEstimate" worklog)) - -(defun jiralib-get-components (project-key) - "Return all components available in the project PROJECT-KEY." - (jiralib-make-assoc-list (jiralib-call "getComponents" project-key) 'id 'name)) - -(defun jiralib-get-issue (issue-key) - "Get the issue with key ISSUE-KEY." - (jiralib-call "getIssue" issue-key)) - -(defun jiralib-get-issues-from-filter (filter-id) - "Get the issues from applying saved filter FILTER-ID." - (jiralib-call "getIssuesFromFilter" filter-id)) - -(defun jiralib-get-issues-from-text-search (search-terms) - "Find issues using free text search SEARCH-TERMS." - (jiralib-call "getIssuesFromTextSearch" search-terms)) - -(defun jiralib-get-issues-from-text-search-with-project - (project-keys search-terms max-num-results) - "Find issues in projects PROJECT-KEYS, using free text search SEARCH-TERMS. - -Return no more than MAX-NUM-RESULTS." - (jiralib-call "getIssuesFromTextSearchWithProject" - (apply 'vector project-keys) search-terms max-num-results)) - -;; Modified by Brian Zwahr to use getProjectsNoSchemes instead of getProjects -(defun jiralib-get-projects () - "Return a list of projects available to the user." - (if jiralib-projects-list - jiralib-projects-list - (setq jiralib-projects-list (jiralib-call "getProjectsNoSchemes")))) - -(defun jiralib-get-saved-filters () - "Get all saved filters available for the currently logged in user." - (jiralib-make-assoc-list (jiralib-call "getSavedFilters") 'id 'name)) - -(defun jiralib-get-server-info () - "Return the Server information such as baseUrl, version, edition, buildDate, buildNumber." - (jiralib-call "getServerInfo")) - -(defun jiralib-get-sub-task-issue-types () - "Return all visible subtask issue types in the system." - (jiralib-call "getSubTaskIssueTypes")) - -(defun jiralib-get-user (username) - "Return a user's information given their USERNAME." - (jiralib-call "getUser" username)) - -(defun jiralib-get-versions (project-key) - "Return all versions available in project PROJECT-KEY." - (jiralib-call "getVersions" project-key)) - -(defun jiralib-strip-cr (string) - "Remove carriage returns from STRING." - (when string (replace-regexp-in-string "\r" "" string))) - -(provide 'jiralib) -;;; jiralib.el ends here diff --git a/elpa/org-jira-20160821.1939/org-jira-autoloads.el b/elpa/org-jira-20160821.1939/org-jira-autoloads.el deleted file mode 100644 index 0807194..0000000 --- a/elpa/org-jira-20160821.1939/org-jira-autoloads.el +++ /dev/null @@ -1,128 +0,0 @@ -;;; org-jira-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "org-jira" "org-jira.el" (22499 31105 318000 -;;;;;; 0)) -;;; Generated autoloads from org-jira.el - -(autoload 'org-jira-mode "org-jira" "\ -Toggle org-jira mode. -With no argument, the mode is toggled on/off. -Non-nil argument turns mode on. -Nil argument turns mode off. - -Commands: -\\{org-jira-entry-mode-map} - -Entry to this mode calls the value of `org-jira-mode-hook'. - -\(fn &optional ARG)" t nil) - -(autoload 'org-jira-get-projects "org-jira" "\ -Get list of projects. - -\(fn)" t nil) - -(autoload 'org-jira-get-issues-headonly "org-jira" "\ -Get list of ISSUES, head only. - -The default behavior is to return issues assigned to you and unresolved. - -With a prefix argument, allow you to customize the jql. See -`org-jira-get-issue-list'. - -\(fn ISSUES)" t nil) - -(autoload 'org-jira-get-issue "org-jira" "\ -Get a JIRA issue, allowing you to enter the issue-id first. - -\(fn)" t nil) - -(autoload 'org-jira-get-issues "org-jira" "\ -Get list of ISSUES into an org buffer. - -Default is get unfinished issues assigned to you, but you can -customize jql with a prefix argument. -See`org-jira-get-issue-list' - -\(fn ISSUES)" t nil) - -(autoload 'org-jira-update-comment "org-jira" "\ -Update a comment for the current issue. - -\(fn)" t nil) - -(autoload 'org-jira-copy-current-issue-key "org-jira" "\ -Copy the current issue's key into clipboard. - -\(fn)" t nil) - -(autoload 'org-jira-update-issue "org-jira" "\ -Update an issue. - -\(fn)" t nil) - -(autoload 'org-jira-todo-to-jira "org-jira" "\ -Convert an ordinary todo item to a jira ticket. - -\(fn)" t nil) - -(autoload 'org-jira-get-subtasks "org-jira" "\ -Get subtasks for the current issue. - -\(fn)" t nil) - -(autoload 'org-jira-create-issue "org-jira" "\ -Create an issue in PROJECT, of type TYPE, with given SUMMARY and DESCRIPTION. - -\(fn PROJECT TYPE SUMMARY DESCRIPTION)" t nil) - -(autoload 'org-jira-create-subtask "org-jira" "\ -Create a subtask issue for PROJECT, of TYPE, with SUMMARY and DESCRIPTION. - -\(fn PROJECT TYPE SUMMARY DESCRIPTION)" t nil) - -(autoload 'org-jira-refresh-issue "org-jira" "\ -Refresh issue from jira to org. - -\(fn)" t nil) - -(autoload 'org-jira-progress-issue "org-jira" "\ -Progress issue workflow. - -\(fn)" t nil) - -(autoload 'org-jira-browse-issue "org-jira" "\ -Open the current issue in external browser. - -\(fn)" t nil) - -(autoload 'org-jira-get-issues-from-filter "org-jira" "\ -Get issues from the server-side stored filter named FILTER. - -Provide this command in case some users are not able to use -client side jql (maybe because of JIRA server version?). - -\(fn FILTER)" t nil) - -(autoload 'org-jira-get-issues-from-filter-headonly "org-jira" "\ -Get issues *head only* from saved filter named FILTER. -See `org-jira-get-issues-from-filter'. - -\(fn FILTER)" t nil) - -;;;*** - -;;;### (autoloads nil nil ("jiralib.el" "org-jira-pkg.el") (22499 -;;;;;; 31105 327035 785000)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; org-jira-autoloads.el ends here diff --git a/elpa/org-jira-20160821.1939/org-jira-pkg.el b/elpa/org-jira-20160821.1939/org-jira-pkg.el deleted file mode 100644 index 9f4db96..0000000 --- a/elpa/org-jira-20160821.1939/org-jira-pkg.el +++ /dev/null @@ -1,4 +0,0 @@ -(define-package "org-jira" "20160821.1939" "Syncing between Jira and Org-mode." 'nil :url "https://github.com/baohaojun/org-jira") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/org-jira-20160821.1939/org-jira.el b/elpa/org-jira-20160821.1939/org-jira.el deleted file mode 100644 index 5f2b83f..0000000 --- a/elpa/org-jira-20160821.1939/org-jira.el +++ /dev/null @@ -1,1024 +0,0 @@ -;;; org-jira.el --- Syncing between Jira and Org-mode. - -;; Author: Bao Haojun -;; Maintainer: Bao Haojun -;; Version: 0.1 -;; Homepage: https://github.com/baohaojun/org-jira - -;; This file is not part of GNU Emacs. - -;; 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 . - -;; 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 -;; 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, write to the Free Software -;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -;; 02110-1301, USA. - -;;; Commentary: -;; -;; This provides an extension to org-mode for syncing issues with JIRA -;; issue servers. -;; -;;; Code: - -(eval-when-compile (load-library "cl-extra")) -(require 'org) -(require 'jiralib) -(require 'cl-lib) -(require 'cl) - -(defgroup org-jira nil - "Customisation group for org-jira." - :tag "Org JIRA" - :group 'org) - -(defvar org-jira-working-dir "~/.org-jira" - "Folder under which to store org-jira working files.") - -(defcustom org-jira-default-jql - "assignee = currentUser() and resolution = unresolved ORDER BY - priority DESC, created ASC" - "Default jql for querying your Jira tickets." - :group 'org-jira - :type 'string) - -(defcustom org-jira-done-states - '("Closed" "Resolved" "Done") - "Jira states that should be considered as DONE for `org-mode'." - :group 'org-jira - :type '(repeat (string :tag "Jira state name:"))) - -(defvar jira-users (list (cons "Full Name" "username")) - "Jira has not api for discovering all users, so we should provide it somewhere else.") - -(defcustom org-jira-serv-alist nil - "Association list to set information for each jira server. -Each element of the alist is a jira server name. The CAR of each -element is a string, uniquely identifying the server. The CDR of -each element is a well-formed property list with an even number -of elements, alternating keys and values, specifying parameters -for the server. - - (:property value :property value ... ) - -When a property is given a value in org-jira-serv-alist, its -setting overrides the value of the corresponding user -variable (if any) during syncing. - -Most properties are optional, but some should always be set: - - :url soap url of the jira server. - :username username to be used. - :host hostname of the jira server (TODO: compute it from ~url~). - -All the other properties are optional. They override the global -variables. - - :password password to be used, will be prompted if missing." - :group 'org-jira - :type '(alist :value-type plist)) - -(defcustom org-jira-use-status-as-todo nil - "Use the JIRA status as the TODO tag value." - :group 'org-jira) - -(defvar org-jira-serv nil - "Parameters of the currently selected blog.") - -(defvar org-jira-serv-name nil - "Name of the blog, to pick from `org-jira-serv-alist'.") - -(defvar org-jira-projects-list nil - "List of jira projects.") - -(defvar org-jira-current-project nil - "Currently selected (i.e., active project).") - -(defvar org-jira-issues-list nil - "List of jira issues under the current project.") - -(defvar org-jira-server-rpc-url nil - "Jira server soap URL.") - -(defvar org-jira-server-userid nil - "Jira server user id.") - -(defvar org-jira-proj-id nil - "Jira project ID.") - -(defvar org-jira-logged-in nil - "Flag whether user is logged-in or not.") - -(defvar org-jira-buffer-name "*org-jira-%s*" - "Name of the jira buffer.") - -(defvar org-jira-buffer-kill-prompt t - "Ask before killing buffer.") -(make-variable-buffer-local 'org-jira-buffer-kill-prompt) - -(defconst org-jira-version "0.1" - "Current version of org-jira.el.") - -(defvar org-jira-mode-hook nil - "Hook to run upon entry into mode.") - -(defvar org-jira-issue-id-history '() - "Prompt history for issue id.") - -(defmacro ensure-on-issue (&rest body) - "Make sure we are on an issue heading, before executing BODY." - - `(save-excursion - (while (org-up-heading-safe)) ; go to the top heading - (let ((org-jira-id (org-jira-id))) - (unless (and org-jira-id (string-match (jiralib-get-issue-regexp) (downcase org-jira-id))) - (error "Not on a issue region!"))) - ,@body)) - -(defmacro ensure-on-issue-id (issue-id &rest body) - "Make sure we are on an issue heading with id ISSUE-ID, before executing BODY." - (declare (indent 1)) - `(save-excursion - (save-restriction - (widen) - (show-all) - (goto-char (point-min)) - (let (p) - (setq p (org-find-entry-with-id ,issue-id)) - (unless p - (error "Issue %s not found!" ,issue-id)) - (goto-char p) - (org-narrow-to-subtree) - ,@body)))) - -(defmacro ensure-on-todo (&rest body) - "Make sure we are on an todo heading, before executing BODY." - `(save-excursion - (save-restriction - (let ((continue t) - (on-todo nil)) - (while continue - (when (org-get-todo-state) - (setq continue nil on-todo t)) - (unless (and continue (org-up-heading-safe)) - (setq continue nil))) - (if (not on-todo) - (error "TODO not found") - (org-narrow-to-subtree) - ,@body))))) - -(defmacro ensure-on-comment (&rest body) - "Make sure we are on a comment heading, before executing BODY." - `(save-excursion - (org-back-to-heading) - (forward-thing 'whitespace) - (unless (looking-at "Comment:") - (error "Not on a comment region!")) - (save-restriction - (org-narrow-to-subtree) - ,@body))) - -(defmacro ensure-on-worklog (&rest body) - "Make sure we are on a worklog heading, before executing BODY." - `(save-excursion - (org-back-to-heading) - (forward-thing 'whitespace) - (unless (looking-at "Worklog:") - (error "Not on a worklog region!")) - (save-restriction - (org-narrow-to-subtree) - ,@body))) - -(defun org-jira-kill-buffer-hook () - "Prompt before killing buffer." - (if (and org-jira-buffer-kill-prompt - (not (buffer-file-name))) - (if (y-or-n-p "Save Jira? ") - (progn - (save-buffer) - (org-jira-save-details (org-jira-parse-entry) nil - (y-or-n-p "Published? ")))))) - -(defvar org-jira-entry-mode-map - (let ((org-jira-map (make-sparse-keymap))) - (define-key org-jira-map (kbd "C-c pg") 'org-jira-get-projects) - (define-key org-jira-map (kbd "C-c ib") 'org-jira-browse-issue) - (define-key org-jira-map (kbd "C-c ig") 'org-jira-get-issues) - (define-key org-jira-map (kbd "C-c ih") 'org-jira-get-issues-headonly) - (define-key org-jira-map (kbd "C-c if") 'org-jira-get-issues-from-filter-headonly) - (define-key org-jira-map (kbd "C-c iF") 'org-jira-get-issues-from-filter) - (define-key org-jira-map (kbd "C-c iu") 'org-jira-update-issue) - (define-key org-jira-map (kbd "C-c iw") 'org-jira-progress-issue) - (define-key org-jira-map (kbd "C-c ir") 'org-jira-refresh-issue) - (define-key org-jira-map (kbd "C-c ic") 'org-jira-create-issue) - (define-key org-jira-map (kbd "C-c ik") 'org-jira-copy-current-issue-key) - (define-key org-jira-map (kbd "C-c sc") 'org-jira-create-subtask) - (define-key org-jira-map (kbd "C-c sg") 'org-jira-get-subtasks) - (define-key org-jira-map (kbd "C-c cu") 'org-jira-update-comment) - (define-key org-jira-map (kbd "C-c wu") 'org-jira-update-worklog) - (define-key org-jira-map (kbd "C-c tj") 'org-jira-todo-to-jira) - org-jira-map)) - - -;;;###autoload -(define-minor-mode org-jira-mode - "Toggle org-jira mode. -With no argument, the mode is toggled on/off. -Non-nil argument turns mode on. -Nil argument turns mode off. - -Commands: -\\{org-jira-entry-mode-map} - -Entry to this mode calls the value of `org-jira-mode-hook'." - - :init-value nil - :lighter " jira" - :group 'org-jira - :keymap org-jira-entry-mode-map - - (if org-jira-mode - (run-mode-hooks 'org-jira-mode-hook))) - -;;;###autoload -(defun org-jira-get-projects () - "Get list of projects." - (interactive) - (let ((projects-file (expand-file-name "projects-list.org" org-jira-working-dir))) - (or (find-buffer-visiting projects-file) - (find-file projects-file)) - (org-jira-mode t) - (save-excursion - (let* ((oj-projs (jiralib-get-projects))) - (mapc (lambda (proj) - (let* ((proj-key (cdr (assoc 'key proj))) - (proj-headline (format "Project: [[file:%s.org][%s]]" proj-key proj-key))) - (save-restriction - (widen) - (goto-char (point-min)) - (show-all) - (setq p (org-find-exact-headline-in-buffer proj-headline)) - (if (and p (>= p (point-min)) - (<= p (point-max))) - (progn - (goto-char p) - (org-narrow-to-subtree) - (end-of-line)) - (goto-char (point-max)) - (unless (looking-at "^") - (insert "\n")) - (insert "* ") - (insert proj-headline) - (org-narrow-to-subtree)) - (org-entry-put (point) "name" (cdr (assoc 'name proj))) - (org-entry-put (point) "key" (cdr (assoc 'key proj))) - (org-entry-put (point) "lead" (cdr (assoc 'lead proj))) - (org-entry-put (point) "ID" (cdr (assoc 'id proj))) - (org-entry-put (point) "url" (cdr (assoc 'url proj)))))) - oj-projs))))) - -(defun org-jira-get-issue-components (issue) - "Return the components the ISSUE belongs to." - (mapconcat (lambda (comp) - (cdr (assoc 'name comp))) - (cdr (assoc 'components issue)) ", ")) - -(defun org-jira-transform-time-format (jira-time-str) - "Convert JIRA-TIME-STR to format \"%Y-%m-%d %T\". - -Example: \"2012-01-09T08:59:15.000Z\" becomes \"2012-01-09 -16:59:15\", with the current timezone being +0800." - (condition-case () - (format-time-string "%Y-%m-%d %T" - (apply - 'encode-time - (parse-time-string (replace-regexp-in-string "T\\|\\.000" " " jira-time-str)))) - (error jira-time-str))) - -(defun org-jira--fix-encode-time-args (arg) - "Fix ARG for 3 nil values at the head." - (loop - for n from 0 to 2 by 1 do - (when (not (nth n arg)) - (setcar (nthcdr n arg) 0))) - arg) - -(defun org-jira-time-format-to-jira (org-time-str) - "Convert ORG-TIME-STR back to jira time format." - (condition-case () - (format-time-string "%Y-%m-%dT%T.000Z" - (apply 'encode-time - (org-jira--fix-encode-time-args (parse-time-string org-time-str))) t) - (error org-time-str))) - -(defun org-jira-get-comment-val (key comment) - "Return the value associated with KEY of COMMENT." - (org-jira-get-issue-val key comment)) - -(defun org-jira-get-worklog-val (key WORKLOG) - "Return the value associated with KEY of WORKLOG." - (org-jira-get-comment-val key WORKLOG)) - -(defun org-jira-get-issue-val (key issue) - "Return the value associated with key KEY of issue ISSUE." - (let ((tmp (or (cdr (assoc key issue)) ""))) - (cond ((eq key 'components) - (org-jira-get-issue-components issue)) - ((member key '(created updated startDate)) - (org-jira-transform-time-format tmp)) - ((eq key 'status) - (cdr (assoc tmp (jiralib-get-statuses)))) - ((eq key 'resolution) - (cdr (assoc tmp (jiralib-get-resolutions)))) - ((eq key 'type) - (cdr (assoc tmp (jiralib-get-issue-types)))) - ((eq key 'priority) - (cdr (assoc tmp (jiralib-get-priorities)))) - ((eq key 'description) - (org-jira-strip-string tmp)) - (t - tmp)))) - -(defvar org-jira-jql-history nil) -(defun org-jira-get-issue-list () - "Get list of issues, using jql (jira query language). - -Default is unresolved issues assigned to current login user; with -a prefix argument you are given the chance to enter your own -jql." - (let ((jql org-jira-default-jql)) - (when current-prefix-arg - (setq jql (read-string "Jql: " - (if org-jira-jql-history - (car org-jira-jql-history) - "assignee = currentUser() and resolution = unresolved") - 'org-jira-jql-history - "assignee = currentUser() and resolution = unresolved"))) - (list (jiralib-do-jql-search jql)))) - -(defun org-jira-get-issue-by-id (id) - "Get an issue by its ID." - (interactive (list (read-string "Issue ID: " "IMINAN-" 'org-jira-issue-id-history))) - (push id org-jira-issue-id-history) - (let ((jql (format "id = %s" id))) - (jiralib-do-jql-search jql))) - -;;;###autoload -(defun org-jira-get-issues-headonly (issues) - "Get list of ISSUES, head only. - -The default behavior is to return issues assigned to you and unresolved. - -With a prefix argument, allow you to customize the jql. See -`org-jira-get-issue-list'." - - (interactive - (org-jira-get-issue-list)) - - (let* ((issues-file (expand-file-name "issues-headonly.org" org-jira-working-dir)) - (issues-headonly-buffer (or (find-buffer-visiting issues-file) - (find-file issues-file)))) - (with-current-buffer issues-headonly-buffer - (widen) - (delete-region (point-min) (point-max)) - - (mapc (lambda (issue) - (let ((issue-id (org-jira-get-issue-val 'key issue)) - (issue-summary (org-jira-get-issue-val 'summary issue))) - (insert (format "- [jira:%s] %s\n" issue-id issue-summary)))) - issues)) - (switch-to-buffer issues-headonly-buffer))) - -;;;###autoload -(defun org-jira-get-issue () - "Get a JIRA issue, allowing you to enter the issue-id first." - (interactive) - (org-jira-get-issues (call-interactively 'org-jira-get-issue-by-id))) - -;;;###autoload -(defun org-jira-get-issues (issues) - "Get list of ISSUES into an org buffer. - -Default is get unfinished issues assigned to you, but you can -customize jql with a prefix argument. -See`org-jira-get-issue-list'" - - (interactive - (org-jira-get-issue-list)) - (let (project-buffer) - (mapc (lambda (issue) - (let* ((proj-key (cdr (assoc 'project issue))) - (issue-id (cdr (assoc 'key issue))) - (issue-summary (cdr (assoc 'summary issue))) - (issue-headline issue-summary)) - (let ((project-file (expand-file-name (concat proj-key ".org") org-jira-working-dir))) - (setq project-buffer (or (find-buffer-visiting project-file) - (find-file project-file))) - (with-current-buffer project-buffer - (org-jira-mode t) - (widen) - (show-all) - (goto-char (point-min)) - (setq p (org-find-entry-with-id issue-id)) - (save-restriction - (if (and p (>= p (point-min)) - (<= p (point-max))) - (progn - (goto-char p) - (forward-thing 'whitespace) - (kill-line)) - (goto-char (point-max)) - (unless (looking-at "^") - (insert "\n")) - (insert "* ")) - (let ((status (org-jira-get-issue-val 'status issue))) - (insert (concat (cond (org-jira-use-status-as-todo - (upcase (replace-regexp-in-string " " "-" status))) - ((member status org-jira-done-states) "DONE") - ("TODO")) " " - issue-headline))) - (save-excursion - (unless (search-forward "\n" (point-max) 1) - (insert "\n"))) - (org-narrow-to-subtree) - (org-change-tag-in-region - (point-min) - (save-excursion - (forward-line 1) - (point)) - (replace-regexp-in-string "-" "_" issue-id) - nil) - - (mapc (lambda (entry) - (let ((val (org-jira-get-issue-val entry issue))) - (when (and val (not (string= val ""))) - (org-entry-put (point) (symbol-name entry) val)))) - '(assignee reporter type priority resolution status components created updated)) - (org-entry-put (point) "ID" (cdr (assoc 'key issue))) - - (mapc (lambda (heading-entry) - (ensure-on-issue-id - issue-id - (let* ((entry-heading (concat (symbol-name heading-entry) (format ": [[%s][%s]]" (concat jiralib-url "/browse/" issue-id) issue-id)))) - (setq p (org-find-exact-headline-in-buffer entry-heading)) - (if (and p (>= p (point-min)) - (<= p (point-max))) - (progn - (goto-char p) - (org-narrow-to-subtree) - (goto-char (point-min)) - (forward-line 1) - (delete-region (point) (point-max))) - (if (org-goto-first-child) - (org-insert-heading) - (goto-char (point-max)) - (org-insert-subheading t)) - (insert entry-heading "\n")) - - (insert (replace-regexp-in-string "^" " " (org-jira-get-issue-val heading-entry issue)))))) - '(description)) - (org-jira-update-comments-for-current-issue) - (org-jira-update-worklogs-for-current-issue) - ))))) - issues) - (switch-to-buffer project-buffer))) - -;;;###autoload -(defun org-jira-update-comment () - "Update a comment for the current issue." - (interactive) - (let* ((issue-id (org-jira-get-from-org 'issue 'key)) - (comment-id (org-jira-get-from-org 'comment 'id)) - (comment (replace-regexp-in-string "^ " "" (org-jira-get-comment-body comment-id)))) - (if comment-id - (jiralib-edit-comment comment-id comment) - (jiralib-add-comment issue-id comment) - (org-jira-delete-current-comment) - (org-jira-update-comments-for-current-issue)))) - -(defun org-jira-update-worklog () - "Update a worklog for the current issue." - (interactive) - (let* ((issue-id (org-jira-get-from-org 'issue 'key)) - (worklog-id (org-jira-get-from-org 'worklog 'id)) - (timeSpent (org-jira-get-from-org 'worklog 'timeSpent)) - (timeSpent (if timeSpent - timeSpent - (read-string "Input the time you spent (such as 3w 1d 2h): "))) - (timeSpent (replace-regexp-in-string " \\(\\sw\\)\\sw*\\(,\\|$\\)" "\\1" timeSpent)) - (startDate (org-jira-get-from-org 'worklog 'startDate)) - (startDate (if startDate - startDate - (org-read-date nil nil nil "Inputh when did you start"))) - (startDate (org-jira-time-format-to-jira startDate)) - (comment (replace-regexp-in-string "^ " "" (org-jira-get-worklog-comment worklog-id))) - (worklog `((comment . ,comment) - (timeSpent . ,timeSpent) - (timeSpentInSeconds . 10) - (startDate . ,startDate))) - (worklog (if worklog-id - (cons `(id . ,(replace-regexp-in-string "^worklog-" "" worklog-id)) worklog) - worklog))) - (if worklog-id - (jiralib-update-worklog worklog) - (jiralib-add-worklog-and-autoadjust-remaining-estimate issue-id startDate timeSpent comment)) - (org-jira-delete-current-worklog) - (org-jira-update-worklogs-for-current-issue))) - -(defun org-jira-delete-current-comment () - "Delete the current comment." - (ensure-on-comment - (delete-region (point-min) (point-max)))) - -(defun org-jira-delete-current-worklog () - "Delete the current worklog." - (ensure-on-worklog - (delete-region (point-min) (point-max)))) - -;;;###autoload -(defun org-jira-copy-current-issue-key () - "Copy the current issue's key into clipboard." - (interactive) - (let ((issue-id (org-jira-get-from-org 'issue 'key))) - (with-temp-buffer - (insert issue-id) - (kill-region (point-min) (point-max))))) - -(defun org-jira-update-comments-for-current-issue () - "Update the comments for the current issue." - (let* ((issue-id (org-jira-get-from-org 'issue 'key)) - (comments (jiralib-get-comments issue-id))) - (mapc (lambda (comment) - (ensure-on-issue-id issue-id - (let* ((comment-id (cdr (assoc 'id comment))) - (comment-author (or (car (rassoc - (cdr (assoc 'author comment)) - jira-users)) - (cdr (assoc 'author comment)))) - (comment-headline (format "Comment: %s" comment-author))) - (setq p (org-find-entry-with-id comment-id)) - (when (and p (>= p (point-min)) - (<= p (point-max))) - (goto-char p) - (org-narrow-to-subtree) - (delete-region (point-min) (point-max))) - (goto-char (point-max)) - (unless (looking-at "^") - (insert "\n")) - (insert "** ") - (insert comment-headline "\n") - (org-narrow-to-subtree) - (org-entry-put (point) "ID" comment-id) - (let ((created (org-jira-get-comment-val 'created comment)) - (updated (org-jira-get-comment-val 'updated comment))) - (org-entry-put (point) "created" created) - (unless (string= created updated) - (org-entry-put (point) "updated" updated))) - (goto-char (point-max)) - (insert (replace-regexp-in-string "^" " " (or (cdr (assoc 'body comment)) "")))))) - (cl-mapcan (lambda (comment) (if (string= (cdr (assoc 'author comment)) - "admin") - nil - (list comment))) - comments)))) - -(defun org-jira-update-worklogs-for-current-issue () - "Update the worklogs for the current issue." - (let* ((issue-id (org-jira-get-from-org 'issue 'key)) - (worklogs (jiralib-get-worklogs issue-id))) - (mapc (lambda (worklog) - (ensure-on-issue-id issue-id - (let* ((worklog-id (concat "worklog-" (cdr (assoc 'id worklog)))) - (worklog-author (or (car (rassoc - (cdr (assoc 'author worklog)) - jira-users)) - (cdr (assoc 'author worklog)))) - (worklog-headline (format "Worklog: %s" worklog-author))) - (setq p (org-find-entry-with-id worklog-id)) - (when (and p (>= p (point-min)) - (<= p (point-max))) - (goto-char p) - (org-narrow-to-subtree) - (delete-region (point-min) (point-max))) - (goto-char (point-max)) - (unless (looking-at "^") - (insert "\n")) - (insert "** ") - (insert worklog-headline "\n") - (org-narrow-to-subtree) - (org-entry-put (point) "ID" worklog-id) - (let ((created (org-jira-get-worklog-val 'created worklog)) - (updated (org-jira-get-worklog-val 'updated worklog))) - (org-entry-put (point) "created" created) - (unless (string= created updated) - (org-entry-put (point) "updated" updated))) - (org-entry-put (point) "startDate" (org-jira-get-worklog-val 'startDate worklog)) - (org-entry-put (point) "timeSpent" (org-jira-get-worklog-val 'timeSpent worklog)) - (goto-char (point-max)) - (insert (replace-regexp-in-string "^" " " (or (cdr (assoc 'comment worklog)) "")))))) - worklogs))) - - -;;;###autoload -(defun org-jira-update-issue () - "Update an issue." - (interactive) - (let ((issue-id (org-jira-parse-issue-id))) - (if issue-id - (org-jira-update-issue-details issue-id) - (error "Not on an issue")))) - -;;;###autoload -(defun org-jira-todo-to-jira () - "Convert an ordinary todo item to a jira ticket." - (interactive) - (ensure-on-todo - (when (org-jira-parse-issue-id) - (error "Already on jira ticket")) - (save-excursion (org-jira-create-issue - (org-jira-read-project) - (org-jira-read-issue-type) - (org-get-heading t t) - (org-get-entry))) - (delete-region (point-min) (point-max)))) - -;;;###autoload -(defun org-jira-get-subtasks () - "Get subtasks for the current issue." - (interactive) - (ensure-on-issue - (org-jira-get-issues-headonly (jiralib-do-jql-search (format "parent = %s" (org-jira-parse-issue-id)))))) - -(defvar org-jira-project-read-history nil) -(defvar org-jira-priority-read-history nil) -(defvar org-jira-type-read-history nil) - -(defun org-jira-read-project () - "Read project name." - (completing-read - "Project: " - (jiralib-make-list (jiralib-get-projects) 'key) - nil - t - (car org-jira-project-read-history) - 'org-jira-project-read-history)) - -(defun org-jira-read-priority () - "Read priority name." - (completing-read - "Priority: " - (mapcar 'cdr (jiralib-get-priorities)) - nil - t - (car org-jira-priority-read-history) - 'org-jira-priority-read-history)) - -(defun org-jira-read-issue-type () - "Read issue type name." - (completing-read - "Type: " - (mapcar 'cdr (jiralib-get-issue-types)) - nil - t - (car org-jira-type-read-history) - 'org-jira-type-read-history)) - -(defun org-jira-read-subtask-type () - "Read issue type name." - (completing-read - "Type: " - (mapcar 'cdr (jiralib-get-subtask-types)) - nil - t - (car org-jira-type-read-history) - 'org-jira-type-read-history)) - -(defun org-jira-get-issue-struct (project type summary description) - "Create an issue struct for PROJECT, of TYPE, with SUMMARY and DESCRIPTION." - (if (or (equal project "") - (equal type "") - (equal summary "")) - (error "Must provide all information!")) - (let* ((project-components (jiralib-get-components project)) - (user (completing-read "Assignee: " (mapcar 'car jira-users))) - (priority (car (rassoc (org-jira-read-priority) (jiralib-get-priorities)))) - (ticket-struct (list (cons 'project project) - (cons 'type (car (rassoc type (if (and (boundp 'parent-id) parent-id) - (jiralib-get-subtask-types) - (jiralib-get-issue-types))))) - (cons 'summary (format "%s%s" summary - (if (and (boundp 'parent-id) parent-id) - (format " (subtask of [jira:%s])" parent-id) - ""))) - (cons 'description description) - (cons 'priority priority) - (cons 'assignee (cdr (assoc user jira-users)))))) - ticket-struct)) -;;;###autoload -(defun org-jira-create-issue (project type summary description) - "Create an issue in PROJECT, of type TYPE, with given SUMMARY and DESCRIPTION." - (interactive (list (org-jira-read-project) - (org-jira-read-issue-type) - (read-string "Summary: ") - (read-string "Description: "))) - (if (or (equal project "") - (equal type "") - (equal summary "")) - (error "Must provide all information!")) - (let* ((parent-id nil) - (ticket-struct (org-jira-get-issue-struct project type summary description))) - (org-jira-get-issues (list (jiralib-create-issue ticket-struct))))) - -;;;###autoload -(defun org-jira-create-subtask (project type summary description) - "Create a subtask issue for PROJECT, of TYPE, with SUMMARY and DESCRIPTION." - (interactive (ensure-on-issue (list (org-jira-read-project) - (org-jira-read-subtask-type) - (read-string "Summary: ") - (read-string "Description: ")))) - (if (or (equal project "") - (equal type "") - (equal summary "")) - (error "Must provide all information!")) - (let* ((parent-id (org-jira-parse-issue-id)) - (ticket-struct (org-jira-get-issue-struct project type summary description))) - (org-jira-get-issues (list (jiralib-create-subtask ticket-struct parent-id))))) - -(defun org-jira-strip-string (str) - "Remove the beginning and ending white space for a string STR." - (replace-regexp-in-string "\\`\n+\\|\n+\\'" "" str)) - -(defun org-jira-get-issue-val-from-org (key) - "Return the requested value by KEY from the current issue." - (ensure-on-issue - (cond ((eq key 'description) - (org-goto-first-child) - (forward-thing 'whitespace) - (if (looking-at "description: ") - (org-jira-strip-string (org-get-entry)) - (error "Can not find description field for this issue"))) - ((eq key 'summary) - (ensure-on-issue - (org-get-heading t t))) - (t - (when (symbolp key) - (setq key (symbol-name key))) - (when (string= key "key") - (setq key "ID")) - (or (org-entry-get (point) key) - ""))))) - -(defvar org-jira-actions-history nil) -(defun org-jira-read-action (actions) - "Read issue workflow progress ACTIONS." - (let ((action (completing-read - "Action: " - (mapcar 'cdr actions) - nil - t - (car org-jira-actions-history) - 'org-jira-actions-history))) - (car (rassoc action actions)))) - -(defvar org-jira-fields-history nil) -(defun org-jira-read-field (fields) - "Read (custom) FIELDS for workflow progress." - (let ((field-desc (completing-read - "More fields to set: " - (cons "Thanks, no more fields are *required*." (mapcar 'cdr fields)) - nil - t - nil - 'org-jira-fields-history)) - field-name) - (setq field-name (car (rassoc field-desc fields))) - (if field-name - (intern field-name) - field-name))) - - -(defvar org-jira-resolution-history nil) -(defun org-jira-read-resolution () - "Read issue workflow progress resolution." - (let ((resolution (completing-read - "Resolution: " - (mapcar 'cdr (jiralib-get-resolutions)) - nil - t - (car org-jira-resolution-history) - 'org-jira-resolution-history))) - (car (rassoc resolution (jiralib-get-resolutions))))) - -;;;###autoload -(defun org-jira-refresh-issue () - "Refresh issue from jira to org." - (interactive) - (ensure-on-issue - (let* ((issue-id (org-jira-id))) - (org-jira-get-issues (list (jiralib-get-issue issue-id)))))) - -(defvar org-jira-fields-values-history nil) -;;;###autoload -(defun org-jira-progress-issue () - "Progress issue workflow." - (interactive) - (ensure-on-issue - (let* ((issue-id (org-jira-id)) - (actions (jiralib-get-available-actions issue-id)) - (action (org-jira-read-action actions)) - (fields (jiralib-get-fields-for-action issue-id action)) - (field-key) - (custom-fields-collector nil) - (custom-fields (progn - ; delete those elements in fields, which have - ; already been set in custom-fields-collector - - (while fields - (setq fields (cl-remove-if (lambda (strstr) - (cl-member-if (lambda (symstr) - (string= (car strstr) (symbol-name (car symstr)))) - custom-fields-collector)) - fields)) - (setq field-key (org-jira-read-field fields)) - (if (not field-key) - (setq fields nil) - (setq custom-fields-collector - (cons - (cons field-key - (if (eq field-key 'resolution) - (org-jira-read-resolution) - (completing-read - (format "Please enter %s's value: " - (cdr (assoc (symbol-name field-key) fields))) - org-jira-fields-values-history - nil - nil - nil - 'org-jira-fields-values-history))) - custom-fields-collector)))) - custom-fields-collector)) - (issue (jiralib-progress-workflow-action issue-id action custom-fields))) - (org-jira-get-issues (list issue))))) - - -(defun org-jira-update-issue-details (issue-id) - "Update the details of issue ISSUE-ID." - (ensure-on-issue-id - issue-id - (let* ((org-issue-components (org-jira-get-issue-val-from-org 'components)) - (org-issue-description (replace-regexp-in-string "^ " "" (org-jira-get-issue-val-from-org 'description))) - (org-issue-resolution (org-jira-get-issue-val-from-org 'resolution)) - (org-issue-priority (org-jira-get-issue-val-from-org 'priority)) - (org-issue-type (org-jira-get-issue-val-from-org 'type)) - (org-issue-assignee (org-jira-get-issue-val-from-org 'assignee)) - (org-issue-status (org-jira-get-issue-val-from-org 'status)) - (issue (jiralib-get-issue issue-id)) - (project (org-jira-get-issue-val 'project issue)) - (project-components (jiralib-get-components project))) - - (jiralib-update-issue issue-id ; (jiralib-update-issue "FB-1" '((components . ["10001" "10000"]))) - (list (cons - 'components - (apply 'vector - (cl-mapcan - (lambda (item) - (let ((comp-id (car (rassoc item project-components)))) - (if comp-id - (list comp-id) - nil))) - (split-string org-issue-components ",\\s *")))) - (cons 'priority (car (rassoc org-issue-priority (jiralib-get-priorities)))) - (cons 'description org-issue-description) - (cons 'assignee org-issue-assignee) - (cons 'summary (org-jira-get-issue-val-from-org 'summary)))) - (org-jira-get-issues (list (jiralib-get-issue issue-id)))))) - - -(defun org-jira-parse-issue-id () - "Get issue id from org text." - (save-excursion - (let ((continue t) - issue-id) - (while continue - (when (string-match (jiralib-get-issue-regexp) - (or (setq issue-id (org-entry-get (point) "ID")) - "")) - (setq continue nil)) - (unless (and continue (org-up-heading-safe)) - (setq continue nil))) - issue-id))) - -(defun org-jira-get-from-org (type entry) - "Get an org property from the current item. - -TYPE is the type to of the current item, and can be 'issue, or 'comment. - -ENTRY will vary, and is the name of the property to return. If -it is a symbol, it will be converted to string." - (when (symbolp entry) - (setq entry (symbol-name entry))) - (cond - ((eq type 'issue) - (org-jira-get-issue-val-from-org entry)) - ((eq type 'comment) - (org-jira-get-comment-val-from-org entry)) - ((eq type 'worklog) - (org-jira-get-worklog-val-from-org entry)) - (t (error "Unknown type %s" type)))) - -(defun org-jira-get-comment-val-from-org (entry) - "Get the JIRA issue field value ENTRY of the current comment item." - (ensure-on-comment - (when (symbolp entry) - (setq entry (symbol-name entry))) - (when (string= entry "id") - (setq entry "ID")) - (org-entry-get (point) entry))) - -(defun org-jira-get-worklog-val-from-org (entry) - "Get the JIRA issue field value ENTRY of the current worklog item." - (ensure-on-worklog - (when (symbolp entry) - (setq entry (symbol-name entry))) - (when (string= entry "id") - (setq entry "ID")) - (org-entry-get (point) entry))) - -(defun org-jira-get-comment-body (&optional comment-id) - "Get the comment body of the comment with id COMMENT-ID." - (ensure-on-comment - (goto-char (point-min)) - ;; so that search for :END: won't fail - (org-entry-put (point) "ID" comment-id) - (search-forward ":END:") - (forward-line) - (org-jira-strip-string (buffer-substring-no-properties (point) (point-max))))) - -(defun org-jira-get-worklog-comment (&optional worklog-id) - "Get the worklog comment of the worklog with id WORKLOG-ID." - (ensure-on-worklog - (goto-char (point-min)) - ;; so that search for :END: won't fail - (org-entry-put (point) "ID" worklog-id) - (search-forward ":END:") - (forward-line) - (org-jira-strip-string (buffer-substring-no-properties (point) (point-max))))) - -(defun org-jira-id () - "Get the ID entry for the current heading." - (org-entry-get (point) "ID")) - -;;;###autoload -(defun org-jira-browse-issue () - "Open the current issue in external browser." - (interactive) - (ensure-on-issue - (browse-url (concat jiralib-url "/browse/" (org-jira-id))))) - -;;;###autoload -(defun org-jira-get-issues-from-filter (filter) - "Get issues from the server-side stored filter named FILTER. - -Provide this command in case some users are not able to use -client side jql (maybe because of JIRA server version?)." - (interactive - (list (completing-read "Filter: " (mapcar 'cdr (jiralib-get-saved-filters))))) - (org-jira-get-issues (jiralib-get-issues-from-filter (car (rassoc filter (jiralib-get-saved-filters)))))) - -;;;###autoload -(defun org-jira-get-issues-from-filter-headonly (filter) - "Get issues *head only* from saved filter named FILTER. -See `org-jira-get-issues-from-filter'." - (interactive - (list (completing-read "Filter: " (mapcar 'cdr (jiralib-get-saved-filters))))) - (org-jira-get-issues-headonly (jiralib-get-issues-from-filter (car (rassoc filter (jiralib-get-saved-filters)))))) - -(org-add-link-type "jira" 'org-jira-open) - -(defun org-jira-open (path) - "Open a Jira Link from PATH." - (org-jira-get-issues (list (jiralib-get-issue path)))) - -(provide 'org-jira) -;;; org-jira.el ends here diff --git a/elpa/pcache-20160724.1929/pcache-autoloads.el b/elpa/pcache-20160724.1929/pcache-autoloads.el deleted file mode 100644 index 42444f9..0000000 --- a/elpa/pcache-20160724.1929/pcache-autoloads.el +++ /dev/null @@ -1,15 +0,0 @@ -;;; pcache-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path)))) - -;;;### (autoloads nil nil ("pcache.el") (22454 5302 309786 624000)) - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; pcache-autoloads.el ends here diff --git a/elpa/pcache-20160724.1929/pcache-pkg.el b/elpa/pcache-20160724.1929/pcache-pkg.el deleted file mode 100644 index 83962f4..0000000 --- a/elpa/pcache-20160724.1929/pcache-pkg.el +++ /dev/null @@ -1,2 +0,0 @@ -;;; -*- no-byte-compile: t -*- -(define-package "pcache" "20160724.1929" "persistent caching for Emacs." '((eieio "1.3"))) diff --git a/elpa/pcache-20160724.1929/pcache.el b/elpa/pcache-20160724.1929/pcache.el deleted file mode 100644 index 6643a6c..0000000 --- a/elpa/pcache-20160724.1929/pcache.el +++ /dev/null @@ -1,246 +0,0 @@ -;;; pcache.el --- persistent caching for Emacs. - -;; Copyright (C) 2011 Yann Hodique - -;; Author: Yann Hodique -;; Keywords: -;; Package-Version: 20160724.1929 -;; Version: 0.4.1 -;; Package-Requires: ((eieio "1.3")) - -;; This file is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. - -;; This file is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. - -;;; Commentary: - -;; pcache provides a persistent way of caching data, in a hashtable-like -;; structure. It relies on `eieio-persistent' in the backend, so that any -;; object that can be serialized by EIEIO can be stored with pcache. - -;; pcache handles objects called "repositories" (`pcache-repository') and -;; "entries" (`pcache-entry'). Each repository is identified by a unique name, -;; that defines an entry in `pcache-directory'. Subdirectories are allowed, by -;; the use of a directory separator in the repository name. - -;; Example: -;; (let ((repo (pcache-repository "plop"))) -;; (pcache-put repo 'foo 42) ; store value 42 with key 'foo -;; (pcache-get repo 'foo) ; => 42 -;; ) - -;; Keys can be pretty much any Lisp object, and are compared for equality using -;; `eql' - -;; Optionally, cache entries can expire: -;; (let ((repo (pcache-repository "plop"))) -;; (pcache-put repo 'foo 42 1) ; store value 42 with key 'foo for 1 second -;; (sleep-for 1) -;; (pcache-get repo 'foo) ; => nil -;; ) - -;;; Code: - -(eval-when-compile - (require 'cl)) - -(require 'eieio) -(require 'eieio-base) - -(defvar pcache-directory - (let ((dir (concat user-emacs-directory "var/pcache/"))) - (make-directory dir t) - dir)) - -(defvar *pcache-repositories* (make-hash-table :test 'equal)) - -(defconst pcache-default-save-delay 300) - -(defconst pcache-internal-version-constant "0.4") - -(defconst pcache-version-constant - (format "%s/%s" emacs-version pcache-internal-version-constant)) - -(defclass pcache-repository (eieio-persistent eieio-named) - ((version :initarg :version :initform nil) - (version-constant :allocation :class) - (entries :initarg :entries :initform (make-hash-table)) - (entry-cls :initarg :entry-cls :initform pcache-entry) - (timestamp :initarg :timestamp :initform (float-time (current-time))) - (save-delay :initarg :save-delay))) - -(oset-default 'pcache-repository :save-delay pcache-default-save-delay) -(oset-default 'pcache-repository version-constant pcache-version-constant) - -(defvar *pcache-repository-name* nil) - -(defmethod constructor :static ((cache pcache-repository) &rest args) - (let* ((newname (or (and (stringp (car args)) (car args)) - (plist-get args :object-name) - *pcache-repository-name* - (symbol-name cache))) - (e (gethash newname *pcache-repositories*)) - (path (concat pcache-directory newname))) - (setq args (append args (list :object-name newname))) - (or e - (and (not (boundp 'pcache-avoid-recursion)) - (file-exists-p path) - (condition-case nil - (let* ((pcache-avoid-recursion t) - (*pcache-repository-name* newname) - (obj (eieio-persistent-read path 'pcache-repository t))) - (and (or (pcache-validate-repo obj) - (error "wrong version")) - (puthash newname obj *pcache-repositories*) - obj)) - (error nil))) - (let ((obj (call-next-method)) - (dir (file-name-directory path))) - (unless (file-exists-p dir) - (make-directory dir t)) - (oset obj :file path) - (oset obj :version (oref-default obj version-constant)) - (puthash newname obj *pcache-repositories*) - obj)))) - -(defun pcache-validate-repo (cache) - (and - (equal (oref cache :version) - (oref-default (object-class cache) version-constant)) - (hash-table-p (oref cache :entries)) - (every - (lambda (entry) - (and (object-of-class-p entry (oref cache :entry-cls)) - (or (null (oref entry :value-cls)) - (object-of-class-p - (oref entry :value) (oref entry :value-cls))))) - (hash-table-values (oref cache :entries))))) - -(defclass pcache-entry () - ((timestamp :initarg :timestamp - :initform (float-time (current-time))) - (ttl :initarg :ttl :initform nil) - (value :initarg :value :initform nil) - (value-cls :initarg :value-cls :initform nil))) - -(defmethod pcache-entry-valid-p ((entry pcache-entry)) - (let ((ttl (oref entry :ttl))) - (or (null ttl) - (let ((time (float-time (current-time)))) - (< time (+ ttl (oref entry :timestamp))))))) - -(defmethod pcache-get ((cache pcache-repository) key &optional default) - (let* ((table (oref cache :entries)) - (entry (gethash key table))) - (if entry - (if (pcache-entry-valid-p entry) - (oref entry :value) - (remhash key table) - default) - default))) - -(defmethod pcache-has ((cache pcache-repository) key) - (let* ((default (make-symbol ":nil")) - (table (oref cache :entries)) - (entry (gethash key table default))) - (if (eq entry default) nil - (if (pcache-entry-valid-p entry) - t nil)))) - -(defmethod pcache-put ((cache pcache-repository) key value &optional ttl) - (let ((table (oref cache :entries)) - (entry (or (and (eieio-object-p value) - (object-of-class-p value 'pcache-entry) - value) - (make-instance - (oref cache :entry-cls) - :value value - :value-cls (and (object-p value) (object-class value)))))) - (when ttl - (oset entry :ttl ttl)) - (prog1 - (puthash key entry table) - (pcache-save cache)))) - -(defmethod pcache-invalidate ((cache pcache-repository) key) - (let ((table (oref cache :entries))) - (remhash key table) - (pcache-save cache))) - -(defmethod pcache-clear ((cache pcache-repository)) - (let* ((entries (oref cache :entries)) - (test (hash-table-test entries)) - (resize (hash-table-rehash-size entries)) - (threshold (hash-table-rehash-threshold entries)) - (weakness (hash-table-weakness entries))) - (oset cache :entries (make-hash-table :test test :rehash-size resize - :rehash-threshold threshold - :weakness weakness))) - (pcache-save cache)) - -(defmethod pcache-purge-invalid ((cache pcache-repository)) - (let ((table (oref cache :entries))) - (maphash #'(lambda (k e) - (unless (pcache-entry-valid-p e) - (remhash k table))) - table) - (pcache-save cache))) - -(defmethod pcache-save ((cache pcache-repository) &optional force) - (let ((timestamp (oref cache :timestamp)) - (delay (oref cache :save-delay)) - (time (float-time (current-time)))) - (when (or force (> time (+ timestamp delay))) - (oset cache :timestamp time) - ;; make sure version is saved to file - (oset cache :version (oref-default (object-class cache) version-constant)) - (eieio-persistent-save cache)))) - -(defmethod pcache-map ((cache pcache-repository) func) - (let ((table (oref cache :entries))) - (maphash func table))) - -(defun pcache-kill-emacs-hook () - (maphash #'(lambda (k v) - (condition-case nil - (pcache-purge-invalid v) - (error nil)) - (condition-case nil - (pcache-save v t) - (error nil))) - *pcache-repositories*)) - -(defun pcache-destroy-repository (name) - (remhash name *pcache-repositories*) - (let ((fname (concat pcache-directory name))) - (when (file-exists-p fname) - (delete-file fname)))) - -(add-hook 'kill-emacs-hook 'pcache-kill-emacs-hook) - -;; in case we reload in place, clean all repositories with invalid version -(let (to-clean) - (maphash #'(lambda (k v) - (condition-case nil - (unless (eql (oref v :version) - pcache-version-constant) - (signal 'error nil)) - (error - (setq to-clean (cons k to-clean))))) - *pcache-repositories*) - (dolist (k to-clean) - (remhash k *pcache-repositories*))) - -(provide 'pcache) -;;; pcache.el ends here diff --git a/elpa/queue-0.1.1/queue-autoloads.el b/elpa/queue-0.1.1/queue-autoloads.el deleted file mode 100644 index 299c2da..0000000 --- a/elpa/queue-0.1.1/queue-autoloads.el +++ /dev/null @@ -1,19 +0,0 @@ -;;; queue-autoloads.el --- automatically extracted autoloads -;; -;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) - -;;;### (autoloads nil "queue" "queue.el" (22500 1794 888069 675000)) -;;; Generated autoloads from queue.el - -(defalias 'make-queue 'queue-create "\ -Create an empty queue data structure.") - -;;;*** - -;; Local Variables: -;; version-control: never -;; no-byte-compile: t -;; no-update-autoloads: t -;; End: -;;; queue-autoloads.el ends here diff --git a/elpa/queue-0.1.1/queue-pkg.el b/elpa/queue-0.1.1/queue-pkg.el deleted file mode 100644 index adeecde..0000000 --- a/elpa/queue-0.1.1/queue-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "queue" "0.1.1" "Queue data structure" 'nil :url "http://www.dr-qubit.org/emacs.php" :keywords '("extensions" "data structures" "queue")) diff --git a/elpa/queue-0.1.1/queue.el b/elpa/queue-0.1.1/queue.el deleted file mode 100644 index aab8c1d..0000000 --- a/elpa/queue-0.1.1/queue.el +++ /dev/null @@ -1,173 +0,0 @@ -;;; queue.el --- Queue data structure -*- lexical-binding: t; -*- - -;; Copyright (C) 1991-1995, 2008-2009, 2012 Free Software Foundation, Inc - -;; Author: Inge Wallin -;; Toby Cubitt -;; Maintainer: Toby Cubitt -;; Version: 0.1.1 -;; Keywords: extensions, data structures, queue -;; URL: http://www.dr-qubit.org/emacs.php -;; Repository: http://www.dr-qubit.org/git/predictive.git - -;; This file is part of 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 . - - -;;; Commentary: -;; -;; These queues can be used both as a first-in last-out (FILO) and as a -;; first-in first-out (FIFO) stack, i.e. elements can be added to the front or -;; back of the queue, and can be removed from the front. (This type of data -;; structure is sometimes called an "output-restricted deque".) -;; -;; You create a queue using `make-queue', add an element to the end of the -;; queue using `queue-enqueue', and push an element onto the front of the -;; queue using `queue-prepend'. To remove the first element from a queue, use -;; `queue-dequeue'. A number of other queue convenience functions are also -;; provided, all starting with the prefix `queue-'. Functions with prefix -;; `queue--' are for internal use only, and should never be used outside this -;; package. - - -;;; Code: - -(eval-when-compile (require 'cl)) - - -(defstruct (queue - ;; A tagged list is the pre-defstruct representation. - ;; (:type list) - :named - (:constructor nil) - (:constructor queue-create ()) - (:copier nil)) - head tail) - - -;;;###autoload -(defalias 'make-queue 'queue-create - "Create an empty queue data structure.") - - -(defun queue-enqueue (queue element) - "Append an ELEMENT to the end of the QUEUE." - (if (queue-head queue) - (setcdr (queue-tail queue) - (setf (queue-tail queue) (cons element nil))) - (setf (queue-head queue) - (setf (queue-tail queue) (cons element nil))))) - -(defalias 'queue-append 'queue-enqueue) - - -(defun queue-prepend (queue element) - "Prepend an ELEMENT to the front of the QUEUE." - (if (queue-head queue) - (push element (queue-head queue)) - (setf (queue-head queue) - (setf (queue-tail queue) (cons element nil))))) - - -(defun queue-dequeue (queue) - "Remove the first element of QUEUE and return it. -Returns nil if the queue is empty." - (unless (cdr (queue-head queue)) (setf (queue-tail queue) nil)) - (pop (queue-head queue))) - - -(defun queue-empty (queue) - "Return t if QUEUE is empty, otherwise return nil." - (null (queue-head queue))) - - -(defun queue-first (queue) - "Return the first element of QUEUE or nil if it is empty, -without removing it from the QUEUE." - (car (queue-head queue))) - - -(defun queue-nth (queue n) - "Return the nth element of a queue, without removing it. -If the length of the queue is less than N, return nil. The first -element in the queue has index 0." - (nth n (queue-head queue))) - - -(defun queue-last (queue) - "Return the last element of QUEUE, without removing it. -Returns nil if the QUEUE is empty." - (car (queue-tail queue))) - - -(defun queue-all (queue) - "Return a list of all elements of QUEUE or nil if it is empty. -The oldest element in the queue is the first in the list." - (queue-head queue)) - - -(defun queue-copy (queue) - "Return a copy of QUEUE. -The new queue contains the elements of QUEUE in the same -order. The elements themselves are *not* copied." - (let ((q (queue-create)) - (list (queue-head queue))) - (when (queue-head queue) - (setf (queue-head q) (cons (car (queue-head queue)) nil) - (queue-tail q) (queue-head q)) - (while (setq list (cdr list)) - (setf (queue-tail q) - (setcdr (queue-tail q) (cons (car list) nil))))) - q)) - - -(defun queue-length (queue) - "Return the number of elements in QUEUE." - (length (queue-head queue))) - - -(defun queue-clear (queue) - "Remove all elements from QUEUE." - (setf (queue-head queue) nil - (queue-tail queue) nil)) - -;;;; ChangeLog: - -;; 2014-05-15 Toby S. Cubitt -;; -;; queue.el: fix buggy queue-first and queue-empty definitions. -;; -;; 2012-04-30 Toby S. Cubitt -;; -;; Minor fixes to commentaries, package headers, and whitespace -;; -;; * queue.el: fix description of data structure in Commentary; add -;; Maintainer -;; header. -;; -;; * queue.el, heap.el, tNFA.el, trie.el, dict-tree.el: trivial whitespace -;; fixes. -;; -;; 2012-04-29 Toby S. Cubitt -;; -;; Add queue.el -;; - - - -(provide 'queue) - - -;;; queue.el ends here diff --git a/init.el b/init.el index 6bf54ff..bc5bda9 100644 --- a/init.el +++ b/init.el @@ -52,35 +52,28 @@ (ace-window ag avy - buffer-move coffee-mode command-log-mode company-c-headers company-quickhelp company-shell - django-manage django-mode drag-stuff electric-case electric-spacing emamux - erlang - fiplr flycheck flycheck-pkg-config focus ggtags - gh git-gutter git-messenger git-timemachine gitconfig gitconfig-mode - github-notifier gitignore-mode gnome-calendar gnugo - go-mode gobgen google goto-last-change @@ -91,38 +84,30 @@ helm-flyspell helm-google helm-gtags - helm-make helm-projectile helm-spotify helm-swoop helm-unicode - ht hyde id-manager identica-mode jinja2-mode js2-mode json-mode - logito magit-gerrit magithub mark markdown-mode - marshal mc-extras multiple-cursors - muse ng2-mode nyan-mode nyan-prompt org-bullets org-jekyll - org-jira org-projectile origami - pcache projectile-direnv - queue sass-mode smart-mode-line-powerline-theme smartparens @@ -318,17 +303,6 @@ :bind (([f9] . smartparens-strict-mode))) -(use-package fiplr - :init - (setq-default fiplr-ignored-globs - (quote - ((directories - (".git" ".svn" ".hg" ".bzr")) - (files - (".#*" "*.so" "*~"))))) - :config - (fiplr-clear-cache)) - (use-package smart-mode-line :init (setq-default sml/theme 'powerline)