id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
sequencelengths
1
47
7,243
package.lisp
blitz_stumpwm/package.lisp
;; package.lisp -- ;; Copyright (C) 2003-2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA (defpackage :stumpwm (:use :cl) (:shadow #:yes-or-no-p #:y-or-n-p)) (defpackage :stumpwm-user (:use :cl :stumpwm))
931
Common Lisp
.lisp
22
40.818182
71
0.742541
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
8532260a4079a2a9a47da9bb35910b073b9eeca57c06ffad456a63a5342d115a
7,243
[ -1 ]
7,244
version.lisp.in
blitz_stumpwm/version.lisp.in
;; Copyright (C) 2006-2008 Martin Bishop, Ivy Foster ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; 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 file contains version information. ;; ;; Code: (in-package :stumpwm) (export '(*version* version)) (defparameter *version* #.(concatenate 'string (if (probe-path ".git") (string-trim '(#\Newline) (run-shell-command "git describe" t)) "@PACKAGE_VERSION@") " Compiled On " (format-expand *time-format-string-alist* *time-format-string-default*))) (defcommand version () () "Print version information and compilation date." (message *version*)) ;; End of file
1,406
Common Lisp
.lisp
35
35.657143
84
0.687454
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
76a0c48926cea60f0886bcda014a990f5c7497a4326b4bcb1b626e6bbe7d70e4
7,244
[ -1 ]
7,245
primitives.lisp
blitz_stumpwm/primitives.lisp
;; Copyright (C) 2003-2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; 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 file contains primitive data structures and functions used ;; throughout stumpwm. ;; ;; Code: (in-package :stumpwm) (export '(*suppress-abort-messages* *suppress-frame-indicator* *timeout-wait* *timeout-frame-indicator-wait* *frame-indicator-text* *frame-indicator-timer* *message-window-timer* *urgent-window-hook* *new-window-hook* *destroy-window-hook* *focus-window-hook* *place-window-hook* *start-hook* *internal-loop-hook* *focus-frame-hook* *new-frame-hook* *message-hook* *top-level-error-hook* *focus-group-hook* *key-press-hook* *root-click-hook* *mode-line-click-hook* *display* *shell-program* *maxsize-border-width* *transient-border-width* *normal-border-width* *text-color* *window-events* *window-parent-events* *message-window-padding* *message-window-gravity* *editor-bindings* *input-window-gravity* *normal-gravity* *maxsize-gravity* *transient-gravity* *top-level-error-action* *window-name-source* *frame-number-map* *all-modifiers* *modifiers* *screen-list* *initializing* *processing-existing-windows* *executing-stumpwm-command* *debug-level* *debug-expose-events* *debug-stream* *window-formatters* *window-format* *group-formatters* *group-format* *list-hidden-groups* *x-selection* *last-command* *max-last-message-size* *record-last-msg-override* *suppress-echo-timeout* *run-or-raise-all-groups* *run-or-raise-all-screens* *deny-map-request* *deny-raise-request* *suppress-deny-messages* *honor-window-moves* *resize-hides-windows* *min-frame-width* *min-frame-height* *new-frame-action* *new-window-preferred-frame* *startup-message* *default-package* *window-placement-rules* *mouse-focus-policy* *root-click-focuses-frame* *banish-pointer-to* *xwin-to-window* *resize-map* *default-group-name* *window-border-style* *data-dir* add-hook clear-window-placement-rules data-dir-file dformat define-frame-preference redirect-all-output remove-hook run-hook run-hook-with-args split-string with-restarts-menu with-data-file move-to-head)) ;;; Message Timer (defvar *suppress-abort-messages* nil "Suppress abort message when non-nil.") (defvar *timeout-wait* 5 "Specifies, in seconds, how long a message will appear for. This must be an integer.") (defvar *timeout-frame-indicator-wait* 1 "The amount of time a frame indicator timeout takes.") (defvar *frame-indicator-timer* nil "Keep track of the timer that hides the frame indicator.") (defvar *frame-indicator-text* " Current Frame " "What appears in the frame indicator window?") (defvar *suppress-frame-indicator* nil "Set this to T if you never want to see the frame indicator.") (defvar *message-window-timer* nil "Keep track of the timer that hides the message window.") ;;; Hooks (defvar *urgent-window-hook* '() "A hook called whenever a window sets the property indicating that it demands the user's attention") (defvar *map-window-hook* '() "A hook called whenever a window is mapped.") (defvar *unmap-window-hook* '() "A hook called whenever a window is withdrawn.") (defvar *new-window-hook* '() "A hook called whenever a window is added to the window list. This includes a genuinely new window as well as bringing a withdrawn window back into the window list.") (defvar *destroy-window-hook* '() "A hook called whenever a window is destroyed or withdrawn.") (defvar *focus-window-hook* '() "A hook called when a window is given focus. It is called with 2 arguments: the current window and the last window (could be nil).") (defvar *place-window-hook* '() "A hook called whenever a window is placed by rule. Arguments are window group and frame") (defvar *start-hook* '() "A hook called when stumpwm starts.") (defvar *internal-loop-hook* '() "A hook called inside stumpwm's inner loop.") (defvar *focus-frame-hook* '() "A hook called when a frame is given focus. The hook functions are called with 2 arguments: the current frame and the last frame.") (defvar *new-frame-hook* '() "A hook called when a new frame is created. the hook is called with the frame as an argument.") (defvar *message-hook* '() "A hook called whenever stumpwm displays a message. The hook function is passed any number of arguments. Each argument is a line of text.") (defvar *top-level-error-hook* '() "Called when a top level error occurs. Note that this hook is run before the error is dealt with according to *top-level-error-action*.") (defvar *focus-group-hook* '() "A hook called whenever stumpwm switches groups. It is called with 2 arguments: the current group and the last group.") (defvar *key-press-hook* '() "A hook called whenever a key under *top-map* is pressed. It is called with 3 argument: the key, the (possibly incomplete) key sequence it is a part of, and command value bound to the key.") (defvar *root-click-hook* '() "A hook called whenever there is a mouse click on the root window. Called with 4 arguments, the screen containing the root window, the button clicked, and the x and y of the pointer.") (defvar *mode-line-click-hook* '() "Called whenever the mode-line is clicked. It is called with 4 arguments, the mode-line, the button clicked, and the x and y of the pointer.") ;; Data types and globals used by stumpwm (defvar *display* nil "The display for the X server") (defvar *shell-program* "/bin/sh" "The shell program used by @code{run-shell-command}.") (defvar *maxsize-border-width* 1 "The width in pixels given to the borders of windows with maxsize or ratio hints.") (defvar *transient-border-width* 1 "The width in pixels given to the borders of transient or pop-up windows.") (defvar *normal-border-width* 1 "The width in pixels given to the borders of regular windows.") (defvar *text-color* "white" "The color of message text.") (defparameter +netwm-supported+ '(:_NET_SUPPORTING_WM_CHECK :_NET_NUMBER_OF_DESKTOPS :_NET_DESKTOP_GEOMETRY :_NET_DESKTOP_VIEWPORT :_NET_CURRENT_DESKTOP :_NET_WM_WINDOW_TYPE :_NET_WM_STATE :_NET_WM_STATE_MODAL :_NET_WM_ALLOWED_ACTIONS :_NET_WM_STATE_FULLSCREEN :_NET_WM_STATE_HIDDEN :_NET_WM_STATE_DEMANDS_ATTENTION :_NET_WM_FULL_WINDOW_PLACEMENT :_NET_CLOSE_WINDOW :_NET_CLIENT_LIST :_NET_CLIENT_LIST_STACKING :_NET_ACTIVE_WINDOW :_KDE_NET_SYSTEM_TRAY_WINDOW_FOR) "Supported NETWM properties. Window types are in +WINDOW-TYPES+.") (defparameter +netwm-allowed-actions+ '(:_NET_WM_ACTION_CHANGE_DESKTOP :_NET_WM_ACTION_FULLSCREEN :_NET_WM_ACTION_CLOSE) "Allowed NETWM actions for managed windows") (defparameter +netwm-window-types+ '( ;; (:_NET_WM_WINDOW_TYPE_DESKTOP . :desktop) (:_NET_WM_WINDOW_TYPE_DOCK . :dock) ;; (:_NET_WM_WINDOW_TYPE_TOOLBAR . :toolbar) ;; (:_NET_WM_WINDOW_TYPE_MENU . :menu) ;; (:_NET_WM_WINDOW_TYPE_UTILITY . :utility) ;; (:_NET_WM_WINDOW_TYPE_SPLASH . :splash) (:_NET_WM_WINDOW_TYPE_DIALOG . :dialog) (:_NET_WM_WINDOW_TYPE_NORMAL . :normal)) "Alist mapping NETWM window types to keywords. Include only those we are ready to support.") ;; Window states (defconstant +withdrawn-state+ 0) (defconstant +normal-state+ 1) (defconstant +iconic-state+ 3) (defvar *window-events* '(:structure-notify :property-change :colormap-change :focus-change :enter-window) "The events to listen for on managed windows.") (defvar *window-parent-events* '(:substructure-notify :substructure-redirect) "The events to listen for on managed windows' parents.") ;; Message window variables (defvar *message-window-padding* 5 "The number of pixels that pad the text in the message window.") (defvar *message-window-gravity* :top-right "This variable controls where the message window appears. The follow are valid values. @table @asis @item :top-left @item :top-right @item :bottom-left @item :bottom-right @item :center @end table") ;; line editor (defvar *editor-bindings* nil "A list of key-bindings for line editing.") (defvar *input-window-gravity* :top-right "This variable controls where the input window appears. The follow are valid values. @table @asis @item :top-left @item :top-right @item :bottom-left @item :bottom-right @item :center @end table") ;; default values. use the set-* functions to these attributes (defparameter +default-foreground-color+ "White") (defparameter +default-background-color+ "Black") (defparameter +default-window-background-color+ "Black") (defparameter +default-border-color+ "White") (defparameter +default-font-name+ "9x15bold") (defparameter +default-focus-color+ "White") (defparameter +default-unfocus-color+ "Black") (defparameter +default-frame-outline-width+ 2) ;; Don't set these variables directly, use set-<var name> instead (defvar *normal-gravity* :center) (defvar *maxsize-gravity* :center) (defvar *transient-gravity* :center) (defvar *top-level-error-action* :abort "If an error is encountered at the top level, in STUMPWM-INTERNAL-LOOP, then this variable decides what action shall be taken. By default it will print a message to the screen and to *standard-output*. Valid values are :message, :break, :abort. :break will break to the debugger. This can be problematic because if the user hit's a mapped key the ENTIRE keyboard will be frozen and you will have to login remotely to regain control. :abort quits stumpmwm.") (defvar *window-name-source* :title "This variable controls what is used for the window's name. The default is @code{:title}. @table @code @item :title Use the window's title given to it by its owner. @item :class Use the window's resource class. @item :resource-name Use the window's resource name. @end table") (defstruct frame (number nil :type integer) x y width height window) (defstruct (head (:include frame)) ;; point back to the screen this head belongs to screen ;; a bar along the top or bottom that displays anything you want. mode-line) (defclass screen () ((id :initform nil :accessor screen-id) (host :initform nil :accessor screen-host) (number :initform nil :accessor screen-number) (heads :initform nil :accessor screen-heads :documentation "heads of screen") (groups :initform nil :accessor screen-groups :documentation "the list of groups available on this screen") (current-group :initform nil :accessor screen-current-group) ;; various colors (as returned by alloc-color) (border-color :initform nil :accessor screen-border-color) (fg-color :initform nil :accessor screen-fg-color) (bg-color :initform nil :accessor screen-bg-color) (win-bg-color :initform nil :accessor screen-win-bg-color) (focus-color :initform nil :accessor screen-focus-color) (unfocus-color :initform nil :accessor screen-unfocus-color) (msg-border-width :initform nil :accessor screen-msg-border-width) (frame-outline-width :initform nil :accessor screen-frame-outline-width) (font :initform nil :accessor screen-font) (mapped-windows :initform nil :accessor screen-mapped-windows :documentation "A list of all mapped windows. These are the raw xlib:window's. window structures are stored in groups.") (withdrawn-windows :initform nil :accessor screen-withdrawn-windows :documentation "A list of withdrawn windows. These are of type stumpwm::window and when they're mapped again they'll be put back in the group they were in when they were unmapped unless that group doesn't exist, in which case they go into the current group.") (urgent-windows :initform nil :accessor screen-urgent-windows :documentation "a list of windows for which (window-urgent-p) currently true.") (input-window :initform nil :accessor screen-input-window) (key-window :initform nil :accessor screen-key-window :documentation "the window that accepts further keypresses after a toplevel key has been pressed.") (focus-window :initform nil :accessor screen-focus-window :documentation "The window that gets focus when no window has focus") ;; (frame-window :initform nil :accessor screen-frame-window) (frame-outline-gc :initform nil :accessor screen-frame-outline-gc) ;; color contexts (message-cc :initform nil :accessor screen-message-cc) (mode-line-cc :initform nil :accessor screen-mode-line-cc) ;; color maps (color-map-normal :initform nil :accessor screen-color-map-normal) (color-map-bright :initform nil :accessor screen-color-map-bright) (ignore-msg-expose :initform nil :accessor screen-ignore-msg-expose :documentation "used to ignore the first expose even when mapping the message window.") ;; the window that has focus (focus :initform nil :accessor screen-focus) (current-msg :initform nil :accessor screen-current-msg) (current-msg-highlights :initform nil :accessor screen-current-msg-highlights) (last-msg :initform nil :accessor screen-last-msg) (last-msg-highlights :initform nil :accessor screen-last-msg-highlights))) (defstruct ccontext win px gc default-fg default-bright default-bg) (defun screen-message-window (screen) (ccontext-win (screen-message-cc screen))) (defun screen-message-pixmap (screen) (ccontext-px (screen-message-cc screen))) (defun screen-message-gc (screen) (ccontext-gc (screen-message-cc screen))) (defmethod print-object ((object frame) stream) (format stream "#S(frame ~d ~a ~d ~d ~d ~d)" (frame-number object) (frame-window object) (frame-x object) (frame-y object) (frame-width object) (frame-height object))) (defvar *frame-number-map* "0123456789abcdefghijklmnopqrstuvxwyz" "Set this to a string to remap the frame numbers to more convenient keys. For instance, \"hutenosa\" would map frame 0 to 7 to be selectable by hitting the appropriate homerow key on a dvorak keyboard. Currently, only single char keys are supported. By default, the frame labels are the 36 (lower-case) alphanumeric characters, starting with numbers 0-9.") (defun get-frame-number-translation (frame) "Given a frame return its number translation using *frame-number-map* as a char." (let ((num (frame-number frame))) (or (and (< num (length *frame-number-map*)) (char *frame-number-map* num)) ;; translate the frame number to a char. FIXME: it loops after 9 (char (prin1-to-string num) 0)))) (defstruct modifiers (meta nil) (alt nil) (hyper nil) (super nil) (altgr nil) (numlock nil)) (defvar *all-modifiers* nil "A list of all keycodes that are considered modifiers") (defvar *modifiers* nil "A mapping from modifier type to x11 modifier.") (defmethod print-object ((object screen) stream) (format stream "#S<screen ~s>" (screen-number object))) (defvar *screen-list* '() "The list of screens managed by stumpwm.") (defvar *initializing* nil "True when starting stumpwm. Use this variable in your rc file to run code that should only be executed once, when stumpwm starts up and loads the rc file.") (defvar *processing-existing-windows* nil "True when processing pre-existing windows at startup.") (defvar *executing-stumpwm-command* nil "True when executing external commands.") (defvar *interactivep* nil "True when a defcommand is executed from colon or a keybinding") ;;; The restarts menu macro (defmacro with-restarts-menu (&body body) "Execute BODY. If an error occurs allow the user to pick a restart from a menu of possible restarts. If a restart is not chosen, resignal the error." (let ((c (gensym))) `(handler-bind ((warning #'muffle-warning) ((or serious-condition error) (lambda (,c) (restarts-menu ,c) (signal ,c)))) ,@body))) ;;; Hook functionality (defun run-hook-with-args (hook &rest args) "Call each function in HOOK and pass args to it." (handler-case (with-simple-restart (abort-hooks "Abort running the remaining hooks.") (with-restarts-menu (dolist (fn hook) (with-simple-restart (continue-hooks "Continue running the remaining hooks.") (apply fn args))))) (t (c) (message "^B^1*Error on hook ^b~S^B!~% ^n~A" hook c) (values nil c)))) (defun run-hook (hook) "Call each function in HOOK." (run-hook-with-args hook)) (defmacro add-hook (hook fn) "Add @var{function} to the hook @var{hook-variable}. For example, to display a message whenever you switch frames: @example \(defun my-rad-fn (to-frame from-frame) (stumpwm:message \"Mustard!\")) \(stumpmwm:add-hook stumpwm:*focus-frame-hook* 'my-rad-fn) @end example" `(setf ,hook (adjoin ,fn ,hook))) (defmacro remove-hook (hook fn) "Remove the specified function from the hook." `(setf ,hook (remove ,fn ,hook))) ;; Misc. utility functions (defun conc1 (list arg) "Append arg to the end of list" (nconc list (list arg))) (defun sort1 (list sort-fn &rest keys &key &allow-other-keys) "Return a sorted copy of list." (let ((copy (copy-list list))) (apply 'sort copy sort-fn keys))) (defun mapcar-hash (fn hash) "Just like maphash except it accumulates the result in a list." (let ((accum nil)) (labels ((mapfn (key val) (push (funcall fn key val) accum))) (maphash #'mapfn hash)) accum)) (defun find-free-number (l &optional (min 0) dir) "Return a number that is not in the list l. If dir is :negative then look for a free number in the negative direction. anything else means positive direction." (let* ((dirfn (if (eq dir :negative) '> '<)) ;; sort it and crop numbers below/above min depending on dir (nums (sort (remove-if (lambda (n) (funcall dirfn n min)) l) dirfn)) (max (car (last nums))) (inc (if (eq dir :negative) -1 1)) (new-num (loop for n = min then (+ n inc) for i in nums when (/= n i) do (return n)))) (dformat 3 "Free number: ~S~%" nums) (if new-num new-num ;; there was no space between the numbers, so use the max+inc (if max (+ inc max) min)))) (defun remove-plist (plist &rest keys) "Remove the keys from the plist. Useful for re-using the &REST arg after removing some options." (do (copy rest) ((null (setq rest (nth-value 2 (get-properties plist keys)))) (nreconc copy plist)) (do () ((eq plist rest)) (push (pop plist) copy) (push (pop plist) copy)) (setq plist (cddr plist)))) (defun screen-display-string (screen &optional (assign t)) (format nil (if assign "DISPLAY=~a:~d.~d" "~a:~d.~d") (screen-host screen) (xlib:display-display *display*) (screen-id screen))) (defun split-seq (seq separators &key test default-value) "split a sequence into sub sequences given the list of seperators." (let ((seps separators)) (labels ((sep (c) (find c seps :test test))) (or (loop for i = (position-if (complement #'sep) seq) then (position-if (complement #'sep) seq :start j) as j = (position-if #'sep seq :start (or i 0)) while i collect (subseq seq i j) while j) ;; the empty seq causes the above to return NIL, so help ;; it out a little. default-value)))) (defun split-string (string &optional (separators " ")) "Splits STRING into substrings where there are matches for SEPARATORS. Each match for SEPARATORS is a splitting point. The substrings between the splitting points are made into a list which is returned. ***If SEPARATORS is absent, it defaults to \"[ \f\t\n\r\v]+\". If there is match for SEPARATORS at the beginning of STRING, we do not include a null substring for that. Likewise, if there is a match at the end of STRING, we don't include a null substring for that. Modifies the match data; use `save-match-data' if necessary." (split-seq string separators :test #'char= :default-value '(""))) (defun insert-before (list item nth) "Insert ITEM before the NTH element of LIST." (declare (type (integer 0 *) nth)) (let* ((nth (min nth (length list))) (pre (subseq list 0 nth)) (post (subseq list nth))) (nconc pre (list item) post))) (defvar *debug-level* 0 "Set this variable to a number > 0 to turn on debugging. The greater the number the more debugging output.") (defvar *debug-expose-events* nil "Set this variable for a visual indication of expose events on internal StumpWM windows.") (defvar *debug-stream* *error-output* "This is the stream debugging output is sent to. It defaults to *error-output*. It may be more convenient for you to pipe debugging output directly to a file.") (defun dformat (level fmt &rest args) (when (>= *debug-level* level) (multiple-value-bind (sec m h) (decode-universal-time (get-universal-time)) (format *debug-stream* "~2,'0d:~2,'0d:~2,'0d " h m sec)) ;; strip out non base-char chars quick-n-dirty like (write-string (map 'string (lambda (ch) (if (typep ch 'standard-char) ch #\?)) (apply 'format nil fmt args)) *debug-stream*))) (defvar *redirect-stream* nil "This variable Keeps track of the stream all output is sent to when `redirect-all-output' is called so if it changes we can close it before reopening.") (defun redirect-all-output (file) "Elect to redirect all output to the specified file. For instance, if you want everything to go to ~/stumpwm.d/debug-output.txt you would do: @example (redirect-all-output (data-dir-file \"debug-output\" \"txt\")) @end example " (when (typep *redirect-stream* 'file-stream) (close *redirect-stream*)) (setf *redirect-stream* (open file :direction :output :if-exists :append :if-does-not-exist :create) *error-output* *redirect-stream* *standard-output* *redirect-stream* *trace-output* *redirect-stream* *debug-stream* *redirect-stream*)) ;;; ;;; formatting routines (defun format-expand (fmt-alist fmt &rest args) (let* ((chars (coerce fmt 'list)) (output "") (cur chars)) ;; FIXME: this is horribly inneficient (loop (cond ((null cur) (return-from format-expand output)) ;; if % is the last char in the string then it's a literal. ((and (char= (car cur) #\%) (cdr cur)) (setf cur (cdr cur)) (let* ((tmp (loop while (and cur (char<= #\0 (car cur) #\9)) collect (pop cur))) (len (and tmp (parse-integer (coerce tmp 'string)))) ;; So that eg "%25^t" will trim from the left (from-left-p (when (char= #\^ (car cur)) (pop cur)))) (if (null cur) (format t "%~a~@[~a~]" len from-left-p) (let* ((fmt (cadr (assoc (car cur) fmt-alist :test 'char=))) (str (cond (fmt ;; it can return any type, not jut as string. (format nil "~a" (apply fmt args))) ((char= (car cur) #\%) (string #\%)) (t (concatenate 'string (string #\%) (string (car cur))))))) ;; crop string if needed (setf output (concatenate 'string output (cond ((null len) str) ((not from-left-p) ; Default behavior (subseq str 0 (min len (length str)))) ;; New behavior -- trim from the left (t (subseq str (max 0 (- (length str) len))))))) (setf cur (cdr cur)))))) (t (setf output (concatenate 'string output (string (car cur))) cur (cdr cur))))))) (defvar *window-formatters* '((#\n window-number) (#\s fmt-window-status) (#\t window-name) (#\c window-class) (#\i window-res) (#\r window-role) (#\m fmt-window-marked) (#\h window-height) (#\w window-width) (#\g gravity-for-window)) "an alist containing format character format function pairs for formatting window lists.") (defvar *window-format* "%m%n%s%50t" "This variable decides how the window list is formatted. It is a string with the following formatting options: @table @asis @item %n Substitute the window number. @item %s Substitute the window's status. * means current window, + means last window, and - means any other window. @item %t Substitute the window's name. @item %c Substitute the window's class. @item %i Substitute the window's resource ID. @item %m Draw a # if the window is marked. @end table Note, a prefix number can be used to crop the argument to a specified size. For instance, @samp{%20t} crops the window's title to 20 characters.") (defvar *window-info-format* "%wx%h %n (%t)" "The format used in the info command. @xref{*window-format*} for formatting details.") (defvar *group-formatters* '((#\n group-number) (#\s fmt-group-status) (#\t group-name)) "An alist of characters and formatter functions. The character can be used as a format character in @var{*group-format*}. When the character is encountered in the string, the corresponding function is called with a group as an argument. The functions return value is inserted into the string. If the return value isn't a string it is converted to one using @code{prin1-to-string}.") (defvar *group-format* "%n%s%t" "The format string that decides what information will show up in the group listing. The following format options are available: @table @asis @item %n The group's number. @item %s The group's status. Similar to a window's status. @item %t The group's name. @end table") (defvar *list-hidden-groups* nil "Controls whether hidden groups are displayed by 'groups' and 'vgroups' commands") (defun font-height (font) (+ (xlib:font-descent font) (xlib:font-ascent font))) (defvar *x-selection* nil "This holds stumpwm's current selection. It is generally set when killing text in the input bar.") (defvar *last-command* nil "Set to the last interactive command run.") (defvar *max-last-message-size* 20 "how many previous messages to keep.") (defvar *record-last-msg-override* nil "assign this to T and messages won't be recorded. It is recommended this is assigned using LET.") (defvar *suppress-echo-timeout* nil "Assign this T and messages will not time out. It is recommended this is assigned using LET.") (defvar *ignore-echo-timeout* nil "Assign this T and the message time out won't be touched. It is recommended this is assigned using LET.") (defvar *run-or-raise-all-groups* t "When this is @code{T} the @code{run-or-raise} function searches all groups for a running instance. Set it to NIL to search only the current group.") (defvar *run-or-raise-all-screens* nil "When this is @code{T} the @code{run-or-raise} function searches all screens for a running instance. Set it to @code{NIL} to search only the current screen. If @var{*run-or-raise-all-groups*} is @code{NIL} this variable has no effect.") (defvar *deny-map-request* nil "A list of window properties that stumpwm should deny matching windows' requests to become mapped for the first time.") (defvar *deny-raise-request* nil "Exactly the same as @var{*deny-map-request*} but for raise requests. Note that no denial message is displayed if the window is already visible.") (defvar *suppress-deny-messages* nil "For complete focus on the task at hand, set this to @code{T} and no raise/map denial messages will be seen.") (defvar *honor-window-moves* t "Allow windows to move between frames.") (defvar *resize-hides-windows* nil "Set to T to hide windows during interactive resize") (defun deny-request-p (window deny-list) (or (eq deny-list t) (and (listp deny-list) (find-if (lambda (props) (apply 'window-matches-properties-p window props)) deny-list) t))) (defun list-splice-replace (item list &rest replacements) "splice REPLACEMENTS into LIST where ITEM is, removing ITEM. Return the new list." (let ((p (position item list))) (if p (nconc (subseq list 0 p) replacements (subseq list (1+ p))) list))) (defvar *min-frame-width* 50 "The minimum width a frame can be. A frame will not shrink below this width. Splitting will not affect frames if the new frame widths are less than this value.") (defvar *min-frame-height* 50 "The minimum height a frame can be. A frame will not shrink below this height. Splitting will not affect frames if the new frame heights are less than this value.") (defvar *new-frame-action* :last-window "When a new frame is created, this variable controls what is put in the new frame. Valid values are @table @code @item :empty The frame is left empty @item :last-window The last focused window that is not currently visible is placed in the frame. This is the default. @end table") (defvar *new-window-preferred-frame* '(:focused) "This variable controls what frame a new window appears in. It is a list of preferences. The first preference that is satisfied is used. Valid list elements are as follows: @table @code @item :focused Choose the focused frame. @item :last Choose the last focused frame. @item :empty Choose any empty frame. @item :unfocused Choose any unfocused frame. @end table Alternatively, it can be set to a function that takes one argument, the new window, and returns the preferred frame or a list of the above preferences.") (defun backtrace-string () "Similar to print-backtrace, but return the backtrace as a string." (with-output-to-string (*standard-output*) (print-backtrace))) (defvar *startup-message* "^2*Welcome to The ^BStump^b ^BW^bindow ^BM^banager! Press ^5*~a ?^2* for help." "This is the message StumpWM displays when it starts. Set it to NIL to suppress.") (defvar *default-package* (find-package '#:stumpwm-user) "This is the package eval reads and executes in. You might want to set this to @code{:stumpwm} if you find yourself using a lot of internal stumpwm symbols. Setting this variable anywhere but in your rc file will have no effect.") (defun concat (&rest strings) (apply 'concatenate 'string strings)) (defvar *window-placement-rules* '() "List of rules governing window placement. Use define-frame-preference to add rules") (defmacro define-frame-preference (target-group &rest frame-rules) "Create a rule that matches windows and automatically places them in a specified group and frame. Each frame rule is a lambda list: @example \(frame-number raise lock &key create restore dump-name class instance type role title) @end example @table @var @item frame-number The frame number to send matching windows to @item raise When non-nil, raise and focus the window in its frame @item lock When this is nil, this rule will only match when the current group matches @var{target-group}. When non-nil, this rule matches regardless of the group and the window is sent to @var{target-group}. If @var{lock} and @var{raise} are both non-nil, then stumpwm will jump to the specified group and focus the matched window. @item create When non-NIL the group is created and eventually restored when the value of create is a group dump filename in *DATA-DIR*. Defaults to NIL. @item restore When non-NIL the group is restored even if it already exists. This arg should be set to the dump filename to use for forced restore. Defaults to NIL @item class The window's class must match @var{class}. @item instance The window's instance/resource name must match @var{instance}. @item type The window's type must match @var{type}. @item role The window's role must match @var{role}. @item title The window's title must match @var{title}. @end table" (let ((x (gensym "X"))) `(dolist (,x ',frame-rules) ;; verify the correct structure (destructuring-bind (frame-number raise lock &rest keys &key create restore class instance type role title) ,x (declare (ignore create restore class instance type role title)) (push (list* ,target-group frame-number raise lock keys) *window-placement-rules*))))) (defun clear-window-placement-rules () "Clear all window placement rules." (setf *window-placement-rules* nil)) (defvar *mouse-focus-policy* :ignore "The mouse focus policy decides how the mouse affects input focus. Possible values are :ignore, :sloppy, and :click. :ignore means stumpwm ignores the mouse. :sloppy means input focus follows the mouse; the window that the mouse is in gets the focus. :click means input focus is transfered to the window you click on.") (defvar *root-click-focuses-frame* t "Set to NIL if you don't want clicking the root window to focus the frame containing the pointer when *mouse-focus-policy* is :click.") (defvar *banish-pointer-to* :head "Where to put the pointer when no argument is given to (banish-pointer) or the banish command. May be one of :screen :head :frame or :window") (defvar *xwin-to-window* (make-hash-table) "Hash table for looking up windows quickly.") (defvar *resize-map* nil "The keymap used for resizing a window") (defvar *default-group-name* "Default" "The name of the default group.") (defmacro with-focus (xwin &body body) "Set the focus to xwin, do body, then restore focus" `(progn (grab-keyboard ,xwin) (unwind-protect (progn ,@body) (ungrab-keyboard)))) (defvar *last-unhandled-error* nil "If an unrecoverable error occurs, this variable will contain the condition and the backtrace.") (defvar *show-command-backtrace* nil "When this is T a backtrace is displayed with errors that occurred within an interactive call to a command.") (defvar *window-border-style* :thick "This controls the appearance of the border around windows. valid values are: @table @var @item :thick All space within the frame not used by the window is dedicated to the border. @item :thin Only the border width as controlled by *maxsize-border-width* *normal-border-width* and *transient-border-width* is used as the border. The rest is filled with the unfocus color. @item :tight The same as :thin but the border surrounds the window and the wasted space within the frame is not obscured, revealing the background. @item :none Like :tight but no border is ever visible. @end table After changing this variable you may need to call sync-all-frame-windows to see the change.") (defvar *data-dir* (make-pathname :directory (append (pathname-directory (user-homedir-pathname)) (list ".stumpwm.d"))) "The directory used by stumpwm to store data between sessions.") (defun data-dir-file (name &optional type) "Return a pathname inside stumpwm's data dir with the specified name and type" (ensure-directories-exist *data-dir*) (make-pathname :name name :type type :defaults *data-dir*)) (defmacro with-data-file ((s file &rest keys &key (if-exists :supersede) &allow-other-keys) &body body) "Open a file in StumpWM's data directory. keyword arguments are sent directly to OPEN. Note that IF-EXISTS defaults to :supersede, instead of :error." (declare (ignorable if-exists)) `(progn (ensure-directories-exist *data-dir*) (with-open-file (,s ,(merge-pathnames *data-dir* file) ,@keys) ,@body))) (defmacro move-to-head (list elt) "Move the specified element in in LIST to the head of the list." `(progn (setf ,list (remove ,elt ,list)) (push ,elt ,list))) (define-condition stumpwm-error (error) () (:documentation "Any stumpwm specific error should inherit this.")) (defun intern1 (thing &optional (package *package*) (rt *readtable*)) "A DWIM intern." (intern (ecase (readtable-case rt) (:upcase (string-upcase thing)) (:downcase (string-downcase thing)) ;; Prooobably this is what they want? It could make sense to ;; upcase them as well. (:preserve thing) (:invert (string-downcase thing))) package))
38,659
Common Lisp
.lisp
916
36.555677
132
0.682093
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b332113441283cffc844a1244db433f6c3aa9d4e7ccc6c299dfc9951c7f95813
7,245
[ -1 ]
7,246
stumpwm.lisp
blitz_stumpwm/stumpwm.lisp
;; Copyright (C) 2003-2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; 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: (in-package :stumpwm) (export '(cancel-timer run-with-timer stumpwm timer-p)) ;;; Main (defun load-rc-file (&optional (catch-errors t)) "Load the user's .stumpwmrc file or the system wide one if that doesn't exist. Returns a values list: whether the file loaded (t if no rc files exist), the error if it didn't, and the rc file that was loaded. When CATCH-ERRORS is nil, errors are left to be handled further up. " (let* ((user-rc (probe-file (merge-pathnames (user-homedir-pathname) #p".stumpwmrc"))) (etc-rc (probe-file #p"/etc/stumpwmrc")) (rc (or user-rc etc-rc))) (if rc ;; TODO: Should we compile the file before we load it? (if catch-errors (handler-case (load rc) (error (c) (values nil (format nil "~a" c) rc)) (:no-error (&rest args) (declare (ignore args)) (values t nil rc))) (progn (load rc) (values t nil rc))) (values t nil nil)))) (defun error-handler (display error-key &rest key-vals &key asynchronous &allow-other-keys) "Handle X errors" (cond ;; ignore asynchronous window errors ((and asynchronous (find error-key '(xlib:window-error xlib:drawable-error xlib:match-error))) (dformat 4 "Ignoring error: ~s~%" error-key)) ((eq error-key 'xlib:access-error) (write-line "Another window manager is running.") (throw :top-level :quit)) ;; all other asynchronous errors are printed. (asynchronous (message "Caught Asynchronous X Error: ~s ~s" error-key key-vals)) (t (apply 'error error-key :display display :error-key error-key key-vals)))) ;;; Timers (defvar *timer-list* nil "List of active timers.") (defstruct timer time repeat function args) (defun run-with-timer (secs repeat function &rest args) "Perform an action after a delay of SECS seconds. Repeat the action every REPEAT seconds, if repeat is non-nil. SECS and REPEAT may be reals. The action is to call FUNCTION with arguments ARGS." (check-type secs (real 0 *)) (check-type repeat (or null (real 0 *))) (check-type function (or function symbol)) (let ((timer (make-timer :repeat repeat :function function :args args))) (schedule-timer timer secs) (setf *timer-list* (sort-timers (cons timer *timer-list*))) timer)) (defun cancel-timer (timer) "Remove TIMER from the list of active timers." (check-type timer timer) (setf *timer-list* (remove timer *timer-list*))) (defun schedule-timer (timer when) (setf (timer-time timer) (+ (get-internal-real-time) (* when internal-time-units-per-second)))) (defun sort-timers (timers) "Return a new list of timers sorted by time to time out." (sort (copy-list timers) (lambda (a b) (< (timer-time a) (timer-time b))))) (defun run-expired-timers (timers) "Return a new list of valid timers and run the timer functions of those expired." (let ((now (get-internal-real-time))) (sort-timers (loop for i in timers with keepers = nil do (if (< (timer-time i) now) (progn (apply (timer-function i) (timer-args i)) (when (timer-repeat i) (schedule-timer i (timer-repeat i)) (push i keepers))) (push i keepers)) finally (return keepers))))) (defun get-next-timeout (timers) "Return the number of seconds until the next timeout or nil if there are no timers." (when timers (max (/ (- (timer-time (car timers)) (get-internal-real-time)) internal-time-units-per-second) 0))) (defun perform-top-level-error-action (c) (ecase *top-level-error-action* (:message (let ((s (format nil "~&Caught '~a' at the top level. Please report this." c))) (write-line s) (print-backtrace) (message "^1*^B~a" s))) (:break (invoke-debugger c)) (:abort (throw :top-level (list c (backtrace-string)))))) (defun stumpwm-internal-loop () "The internal loop that waits for events and handles them." (loop (run-hook *internal-loop-hook*) (handler-bind ((xlib:lookup-error (lambda (c) (if (lookup-error-recoverable-p) (recover-from-lookup-error) (error c)))) (warning #'muffle-warning) ((or serious-condition error) (lambda (c) (run-hook *top-level-error-hook*) (perform-top-level-error-action c))) (t (lambda (c) ;; some other wacko condition was raised so first try ;; what we can to keep going. (cond ((find-restart 'muffle-warning) (muffle-warning)) ((find-restart 'continue) (continue))) ;; and if that fails treat it like a top level error. (perform-top-level-error-action c)))) ;; Note: process-event appears to hang for an unknown ;; reason. This is why it is passed a timeout in hopes that ;; this will keep it from hanging. (let ((timeout (get-next-timeout *timer-list*))) (dformat 10 "timeout: ~a~%" timeout) (if timeout (let* ((nevents (xlib:event-listen *display* (ceiling timeout)))) (setf *timer-list* (run-expired-timers *timer-list*)) (when nevents (xlib:process-event *display* :handler #'handle-event))) ;; Otherwise, simply wait for an event (xlib:process-event *display* :handler #'handle-event)) ;; flush any pending output. You'd think process-event would, but ;; it seems not. (xlib:display-finish-output *display*) ;;(dformat 10 "toplevel focus: ~a~%" (multiple-value-list (xlib:input-focus *display*))) )))) (defun parse-display-string (display) "Parse an X11 DISPLAY string and return the host and display from it." (ppcre:register-groups-bind (protocol host ('parse-integer display screen)) ("^(?:(.*?)/)?(.*?)?:(\\d+)(?:\\.(\\d+))?" display :sharedp t) (values ;; clx doesn't like (vector character *) (coerce (or host "") '(simple-array character (*))) display screen (cond (protocol (intern1 protocol :keyword)) ((or (string= host "") (string-equal host "unix")) :local) (t :internet))))) (defun stumpwm-internal (display-str) (multiple-value-bind (host display screen protocol) (parse-display-string display-str) (declare (ignore screen)) (setf *display* (xlib:open-display host :display display :protocol protocol) (xlib:display-error-handler *display*) 'error-handler) (with-simple-restart (quit-stumpwm "Quit Stumpwm") ;; In the event of an error, we always need to close the display (unwind-protect (progn (let ((*initializing* t)) ;; we need to do this first because init-screen grabs keys (update-modifier-map) ;; Initialize all the screens (setf *screen-list* (loop for i in (xlib:display-roots *display*) for n from 0 collect (init-screen i n host))) (xlib:display-finish-output *display*) ;; Load rc file (let ((*package* (find-package *default-package*))) (multiple-value-bind (success err rc) (load-rc-file) (if success (and *startup-message* (message *startup-message* (print-key *escape-key*))) (message "^B^1*Error loading ^b~A^B: ^n~A" rc err)))) (when *last-unhandled-error* (message-no-timeout "^B^1*StumpWM Crashed With An Unhandled Error!~%Copy the error to the clipboard with the 'copy-unhandled-error' command.~%^b~a^B^n~%~%~a" (first *last-unhandled-error*) (second *last-unhandled-error*))) (mapc 'process-existing-windows *screen-list*) ;; We need to setup each screen with its current window. Go ;; through them in reverse so the first screen's frame ends up ;; with focus. (dolist (s (reverse *screen-list*)) ;; map the current group's windows (mapc 'unhide-window (reverse (group-windows (screen-current-group s)))) ;; update groups (dolist (g (reverse (screen-groups s))) ;; raise the current window and frame. (dformat 3 "Group windows: ~S~%" (group-windows g)) (let ((window (first (group-windows g)))) (if window (focus-frame g (window-frame window)) (focus-frame g (tile-group-current-frame g))))) ;; switch to the (old) current group. (let ((netwm-id (first (xlib:get-property (screen-root s) :_NET_CURRENT_DESKTOP)))) (when (and netwm-id (< netwm-id (length (screen-groups s)))) (switch-to-group (elt (sort-groups s) netwm-id)))) (redraw-current-message (current-screen)))) ;; Let's manage. (let ((*package* (find-package *default-package*))) (run-hook *start-hook*) (stumpwm-internal-loop))) (xlib:close-display *display*)))) ;; what should the top level loop do? :quit) ;; Usage: (stumpwm) (defun stumpwm (&optional (display-str (or (getenv "DISPLAY") ":0"))) "Start the stump window manager." (loop (let ((ret (catch :top-level (stumpwm-internal display-str)))) (setf *last-unhandled-error* nil) (cond ((and (consp ret) (typep (first ret) 'condition)) (format t "~&Caught '~a' at the top level. Please report this.~%~a" (first ret) (second ret)) (setf *last-unhandled-error* ret)) ;; we need to jump out of the event loop in order to hup ;; the process because otherwise we get errors. ((eq ret :hup-process) (apply 'execv (first (argv)) (argv))) ((eq ret :restart)) (t ;; the number is the unix return code (return-from stumpwm 0))))))
11,492
Common Lisp
.lisp
249
35.947791
174
0.584722
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
f163e7d440c5ab1afad04b359e09854f76fa44e8e8f81a83b5995123e704cefa
7,246
[ -1 ]
7,247
tile-window.lisp
blitz_stumpwm/tile-window.lisp
;;; a dumping spot for window stuff that has tiling stuff in it (in-package :stumpwm) (defclass tile-window (window) ((frame :initarg :frame :accessor window-frame))) (defmethod update-decoration ((window tile-window)) ;; give it a colored border but only if there are more than 1 frames. (let* ((group (window-group window)) (screen (group-screen group))) (let ((c (if (and (> (length (group-frames group)) 1) (eq (group-current-window group) window)) (screen-focus-color screen) (screen-unfocus-color screen)))) (setf (xlib:window-border (window-parent window)) c ;; windows that dont fill the entire screen have a transparent background. (xlib:window-background (window-parent window)) (if (eq (window-type window) :normal) (if (eq *window-border-style* :thick) c (screen-win-bg-color screen)) :none)) ;; get the background updated (xlib:clear-area (window-parent window))))) (defmethod window-sync ((window tile-window) hint) (case hint ((:normal-hints :type) (maximize-window window)))) (defmethod window-visible-p ((window tile-window)) ;; In this case, visible means the window is the top window in the ;; frame. This is not entirely true when it doesn't take up the ;; entire frame and there's a window below it. (eq window (frame-window (window-frame window)))) (defmethod window-head ((window tile-window)) (frame-head (window-group window) (window-frame window))) (defmethod (setf window-fullscreen) :after (val (window tile-window)) (if val (maximize-window window) (progn (setf (xlib:drawable-border-width (window-parent window)) (default-border-width-for-type window)) (maximize-window window)))) ;;;; (defun really-raise-window (window) (frame-raise-window (window-group window) (window-frame window) window)) (defun raise-modals-of (window) (mapc 'really-raise-window (modals-of window))) (defun raise-modals-of-gang (window) (mapc 'really-raise-window (only-modals (window-gang window)))) (defun raise-transients-of-gang (window) (mapc 'really-raise-window (only-transients (window-gang window)))) ;;; (defun geometry-hints (win) "Return hints for max width and height and increment hints. These hints have been modified to always be defined and never be greater than the root window's width and height." (let* ((f (window-frame win)) (x (frame-x f)) (y (frame-display-y (window-group win) f)) (border (xlib:drawable-border-width (window-parent win))) (fwidth (- (frame-width f) (* 2 border))) (fheight (- (frame-display-height (window-group win) f) (* 2 border))) (width fwidth) (height fheight) (hints (window-normal-hints win)) (hints-min-width (and hints (xlib:wm-size-hints-min-width hints))) (hints-min-height (and hints (xlib:wm-size-hints-min-height hints))) (hints-max-width (and hints (xlib:wm-size-hints-max-width hints))) (hints-max-height (and hints (xlib:wm-size-hints-max-height hints))) (hints-width (and hints (xlib:wm-size-hints-base-width hints))) (hints-height (and hints (xlib:wm-size-hints-base-height hints))) (hints-inc-x (and hints (xlib:wm-size-hints-width-inc hints))) (hints-inc-y (and hints (xlib:wm-size-hints-height-inc hints))) (hints-min-aspect (and hints (xlib:wm-size-hints-min-aspect hints))) (hints-max-aspect (and hints (xlib:wm-size-hints-max-aspect hints))) (border (case *window-border-style* (:none 0) (t (default-border-width-for-type win)))) center) ;; (dformat 4 "hints: ~s~%" hints) ;; determine what the width and height should be (cond ;; handle specially fullscreen windows. ((window-fullscreen win) (let ((head (frame-head (window-group win) f))) (setf x (frame-x head) y (frame-y head) width (frame-width head) height (frame-height head) (xlib:window-priority (window-parent win)) :above)) (return-from geometry-hints (values x y 0 0 width height 0 t))) ;; Adjust the defaults if the window is a transient_for window. ((find (window-type win) '(:transient :dialog)) (setf center t width (min (max (or hints-width 0) (or hints-min-width 0) (window-width win)) width) height (min (max (or hints-height 0) (or hints-min-height 0) (window-height win)) height))) ;; aspect hints are handled similar to max size hints ((and hints-min-aspect hints-max-aspect) (let ((ratio (/ width height))) (cond ((< ratio hints-min-aspect) (setf height (ceiling width hints-min-aspect))) ((> ratio hints-max-aspect) (setf width (ceiling (* height hints-max-aspect))))) (setf center t))) ;; Update our defaults if the window has the maxsize hints ((or hints-max-width hints-max-height) (when (and hints-max-width (< hints-max-width width)) (setf width hints-max-width)) (when (and hints-max-height (< hints-max-height height)) (setf height hints-max-height)) (setf center t)) (t ;; if they have inc hints then start with the size and adjust ;; based on those increments until the window fits in the frame (when (and hints-inc-x (plusp hints-inc-x)) (let ((w (or hints-width (window-width win)))) (setf width (+ w (* hints-inc-x (+ (floor (- fwidth w) hints-inc-x))))))) (when (and hints-inc-y (plusp hints-inc-y)) (let ((h (or hints-height (window-height win)))) (setf height (+ h (* hints-inc-y (+ (floor (- fheight h -1) hints-inc-y))))))))) ;; adjust for gravity (multiple-value-bind (wx wy) (get-gravity-coords (gravity-for-window win) width height 0 0 fwidth fheight) (when (or center (find *window-border-style* '(:tight :none))) (setf x (+ wx (frame-x f)) y (+ wy (frame-display-y (window-group win) f)) wx 0 wy 0)) ;; Now return our findings (values x y wx wy width height border center)))) (defun maximize-window (win) "Maximize the window." (multiple-value-bind (x y wx wy width height border stick) (geometry-hints win) (dformat 4 "maximize window ~a x: ~d y: ~d width: ~d height: ~d border: ~d stick: ~s~%" win x y width height border stick) ;; This is the only place a window's geometry should change (set-window-geometry win :x wx :y wy :width width :height height :border-width 0) (xlib:with-state ((window-parent win)) ;; FIXME: updating the border doesn't need to be run everytime ;; the window is maximized, but only when the border style or ;; window type changes. The overhead is probably minimal, ;; though. (setf (xlib:drawable-x (window-parent win)) x (xlib:drawable-y (window-parent win)) y (xlib:drawable-border-width (window-parent win)) border) ;; the parent window should stick to the size of the window ;; unless it isn't being maximized to fill the frame. (if (or stick (find *window-border-style* '(:tight :none))) (setf (xlib:drawable-width (window-parent win)) (window-width win) (xlib:drawable-height (window-parent win)) (window-height win)) (let ((frame (window-frame win))) (setf (xlib:drawable-width (window-parent win)) (- (frame-width frame) (* 2 (xlib:drawable-border-width (window-parent win)))) (xlib:drawable-height (window-parent win)) (- (frame-display-height (window-group win) frame) (* 2 (xlib:drawable-border-width (window-parent win))))))) ;; update the "extents" (xlib:change-property (window-xwin win) :_NET_FRAME_EXTENTS (list wx wy (- (xlib:drawable-width (window-parent win)) width wx) (- (xlib:drawable-height (window-parent win)) height wy)) :cardinal 32)))) ;;; (defun focus-next-window (group) (focus-forward group (sort-windows group))) (defun focus-prev-window (group) (focus-forward group (reverse (sort-windows group)))) (defcommand (next tile-group) () () "Go to the next window in the window list." (let ((group (current-group))) (if (group-current-window group) (focus-next-window group) (other-window group)))) (defcommand (prev tile-group) () () "Go to the previous window in the window list." (let ((group (current-group))) (if (group-current-window group) (focus-prev-window group) (other-window group)))) (defun pull-window (win &optional (to-frame (tile-group-current-frame (window-group win)))) (let ((f (window-frame win)) (group (window-group win))) (unless (eq (frame-window to-frame) win) (xwin-hide win) (setf (window-frame win) to-frame) (maximize-window win) (when (eq (window-group win) (current-group)) (xwin-unhide (window-xwin win) (window-parent win))) ;; We have to restore the focus after hiding. (when (eq win (screen-focus (window-screen win))) (screen-set-focus (window-screen win) win)) (frame-raise-window group to-frame win) ;; if win was focused in its old frame then give the old ;; frame the frame's last focused window. (when (eq (frame-window f) win) ;; the current value is no longer valid. (setf (frame-window f) nil) (frame-raise-window group f (first (frame-windows group f)) nil))))) ;; In the future, this window will raise the window into the current ;; frame. (defun focus-forward (group window-list &optional pull-p (predicate (constantly t))) "Set the focus to the next item in window-list from the focused window. If PULL-P is T then pull the window into the current frame." ;; The window with focus is the "current" window, so find it in the ;; list and give that window focus (let* ((w (group-current-window group)) (wins (remove-if-not predicate (cdr (member w window-list)))) (nw (if (null wins) ;; If the last window in the list is focused, then ;; focus the first one. (car (remove-if-not predicate window-list)) ;; Otherwise, focus the next one in the list. (first wins)))) ;; there's still the case when the window is the only one in the ;; list, so make sure its not the same as the current window. (if (and nw (not (eq w nw))) (if pull-p (pull-window nw) (frame-raise-window group (window-frame nw) nw)) (message "No other window.")))) (defcommand (pull-window-by-number tile-group) (n &optional (group (current-group))) ((:window-number "Pull: ")) "Pull window N from another frame into the current frame and focus it." (let ((win (find n (group-windows group) :key 'window-number :test '=))) (when win (pull-window win)))) (defcommand-alias pull pull-window-by-number) (defun other-hidden-window (group) "Return the last window that was accessed and that is hidden." (let ((wins (remove-if (lambda (w) (eq (frame-window (window-frame w)) w)) (group-windows group)))) (first wins))) (defun pull-other-hidden-window (group) "pull the last accessed hidden window from any frame into the current frame and raise it." (let ((win (other-hidden-window group))) (if win (pull-window win) (echo-string (group-screen group) "No other window.")))) (defun other-window-in-frame (group) (let* ((f (tile-group-current-frame group)) (wins (frame-windows group f)) (win (if (frame-window f) (second wins) (first wins)))) (if win (frame-raise-window group (window-frame win) win) (echo-string (group-screen group) "No other window.")))) (defcommand (pull-hidden-next tile-group) () () "Pull the next hidden window into the current frame." (let ((group (current-group))) (focus-forward group (sort-windows group) t (lambda (w) (not (eq (frame-window (window-frame w)) w)))))) (defcommand (pull-hidden-previous tile-group) () () "Pull the next hidden window into the current frame." (let ((group (current-group))) (focus-forward group (nreverse (sort-windows group)) t (lambda (w) (not (eq (frame-window (window-frame w)) w)))))) (defcommand (pull-hidden-other tile-group) () () "Pull the last focused, hidden window into the current frame." (let ((group (current-group))) (pull-other-hidden-window group))) (defun exchange-windows (win1 win2) "Exchange the windows in their respective frames." (let ((f1 (window-frame win1)) (f2 (window-frame win2))) (unless (eq f1 f2) (pull-window win1 f2) (pull-window win2 f1) (focus-frame (window-group win1) f2)))) (defcommand (exchange-direction tile-group) (dir &optional (win (current-window))) ((:direction "Direction: ")) "Exchange the current window (by default) with the top window of the frame in specified direction. @table @asis @item up @item down @item left @item right @end table" (if win (let* ((frame-set (group-frames (window-group win))) (neighbour (neighbour dir (window-frame win) frame-set))) (if (and neighbour (frame-window neighbour)) (exchange-windows win (frame-window neighbour)) (message "No window in direction ~A!" dir))) (message "No window in current frame!"))) (defcommand (echo-frame-windows tile-group) (&optional (fmt *window-format*)) (:rest) "Display a list of all the windows in the current frame." (echo-windows fmt (current-group) (frame-windows (current-group) (tile-group-current-frame (current-group))))) (defcommand-alias frame-windows echo-frame-windows) (defcommand (fullscreen tile-group) () () "Toggle the fullscreen mode of the current widnow. Use this for clients with broken (non-NETWM) fullscreen implemenations, such as any program using SDL." (update-fullscreen (current-window) 2)) (defcommand (gravity tile-group) (gravity) ((:gravity "Gravity: ")) "Set a window's gravity within its frame. Gravity controls where the window will appear in a frame if it is smaller that the frame. Possible values are: @table @var @item center @item top @item right @item bottom @item left @item top-right @item top-left @item bottom-right @item bottom-left @end table" (when (current-window) (setf (window-gravity (current-window)) gravity) (maximize-window (current-window)))) (defcommand (pull-marked tile-group) () () "Pull all marked windows into the current frame and clear the marks." (let ((group (current-group))) (dolist (i (marked-windows group)) (pull-window i)) (clear-window-marks group))) ;;; window placement commands (defun make-rule-for-window (window &optional lock title) "Guess at a placement rule for WINDOW and add it to the current set." (let* ((group (window-group window)) (group-name (group-name group)) (frame-number (frame-number (window-frame window))) (role (window-role window))) (push (list group-name frame-number t lock :class (window-class window) :instance (window-res window) :title (and title (window-name window)) :role (and (not (equal role "")) role)) *window-placement-rules*))) (defcommand (remember tile-group) (lock title) ((:y-or-n "Lock to group? ") (:y-or-n "Use title? ")) "Make a generic placement rule for the current window. Might be too specific/not specific enough!" (make-rule-for-window (current-window) (first lock) (first title))) (defcommand (forget tile-group) () () "Forget the window placement rule that matches the current window." (let* ((window (current-window)) (match (rule-matching-window window))) (if match (progn (setf *window-placement-rules* (delete match *window-placement-rules*)) (message "Rule forgotten")) (message "No matching rule")))) (defcommand (dump-window-placement-rules tile-group) (file) ((:rest "Filename: ")) "Dump *window-placement-rules* to FILE." (dump-to-file *window-placement-rules* file)) (defcommand-alias dump-rules dump-window-placement-rules) (defcommand (restore-window-placement-rules tile-group) (file) ((:rest "Filename: ")) "Restore *window-placement-rules* from FILE." (setf *window-placement-rules* (read-dump-from-file file))) (defcommand-alias restore-rules restore-window-placement-rules) (defcommand (redisplay tile-group) () () "Refresh current window by a pair of resizes, also make it occupy entire frame." (let ((window (current-window))) (with-slots (width height frame) window (set-window-geometry window :width (- width (window-width-inc window)) :height (- height (window-height-inc window))) ;; make sure the first one goes through before sending the second (xlib:display-finish-output *display*) (set-window-geometry window :width (+ width (* (window-width-inc window) (floor (- (frame-width frame) width) (window-width-inc window)))) :height (+ height (* (window-height-inc window) (floor (- (frame-height frame) height) (window-height-inc window))))) (maximize-window window)))) (defcommand frame-windowlist (&optional (fmt *window-format*)) (:rest) "Allow the user to select a window from the list of windows in the current frame and focus the selected window. The optional argument @var{fmt} can be specified to override the default window formatting." (let* ((group (current-group)) (frame (tile-group-current-frame group))) (if (null (frame-windows group frame)) (message "No Managed Windows") (let ((window (select-window-from-menu (frame-sort-windows group frame) fmt))) (if window (group-focus-window group window) (throw 'error :abort))))))
19,393
Common Lisp
.lisp
398
39.479899
126
0.614747
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
33be10a424a0739d1e84f1592f8fc4e54417634aa1506ead309ebb5f58a6d5f2
7,247
[ -1 ]
7,248
keytrans.lisp
blitz_stumpwm/keytrans.lisp
;; Copyright (C) 2006-2008 Matthew Kennedy ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;; Commentary: ;; ;; Translate between stumpwm key names and keysym names. ;; ;; Code: (in-package #:stumpwm) (defvar *stumpwm-name->keysym-name-translations* (make-hash-table :test #'equal) "Hashtable mapping from stumpwm key names to keysym names.") (defun define-keysym-name (stumpwm-name keysym-name) "Define a mapping from a STUMPWM-NAME to KEYSYM-NAME. This function is used to translate Emacs-like names to keysym names." (setf (gethash stumpwm-name *stumpwm-name->keysym-name-translations*) keysym-name)) (defun stumpwm-name->keysym-name (stumpwm-name) (multiple-value-bind (value present-p) (gethash stumpwm-name *stumpwm-name->keysym-name-translations*) (declare (ignore present-p)) value)) (defun keysym-name->stumpwm-name (keysym-name) (maphash (lambda (k v) (when (equal v keysym-name) (return-from keysym-name->stumpwm-name k))) *stumpwm-name->keysym-name-translations*)) (defun stumpwm-name->keysym (stumpwm-name) "Return the keysym corresponding to STUMPWM-NAME. If no mapping for STUMPWM-NAME exists, then fallback by calling KEYSYM-NAME->KEYSYM." (let ((keysym-name (stumpwm-name->keysym-name stumpwm-name))) (keysym-name->keysym (or keysym-name stumpwm-name)))) (defun keysym->stumpwm-name (keysym) "Return the stumpwm key name corresponding to KEYSYM. If no mapping for the stumpwm key name exists, then fall back by calling KEYSYM->KEYSYM-NAME." (let ((keysym-name (keysym->keysym-name keysym))) (or (keysym-name->stumpwm-name keysym-name) keysym-name))) (define-keysym-name "RET" "Return") (define-keysym-name "ESC" "Escape") (define-keysym-name "TAB" "Tab") (define-keysym-name "DEL" "BackSpace") (define-keysym-name "SPC" "space") (define-keysym-name "!" "exclam") (define-keysym-name "\"" "quotedbl") (define-keysym-name "$" "dollar") (define-keysym-name "%" "percent") (define-keysym-name "&" "ampersand") (define-keysym-name "'" "quoteright") ;deprecated (define-keysym-name "'" "apostrophe") (define-keysym-name "`" "quoteleft") ;deprecated (define-keysym-name "`" "grave") (define-keysym-name "&" "ampersand") (define-keysym-name "(" "parenleft") (define-keysym-name ")" "parenright") (define-keysym-name "*" "asterisk") (define-keysym-name "+" "plus") (define-keysym-name "," "comma") (define-keysym-name "-" "minus") (define-keysym-name "." "period") (define-keysym-name "/" "slash") (define-keysym-name ":" "colon") (define-keysym-name ";" "semicolon") (define-keysym-name "<" "less") (define-keysym-name "=" "equal") (define-keysym-name ">" "greater") (define-keysym-name "?" "question") (define-keysym-name "@" "at") (define-keysym-name "[" "bracketleft") (define-keysym-name "\\" "backslash") (define-keysym-name "]" "bracketright") (define-keysym-name "^" "asciicircum") (define-keysym-name "_" "underscore") (define-keysym-name "#" "numbersign") (define-keysym-name "{" "braceleft") (define-keysym-name "|" "bar") (define-keysym-name "}" "braceright") (define-keysym-name "~" "asciitilde")
3,828
Common Lisp
.lisp
93
39.021505
80
0.719656
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
896df4cfdd09258b70ab426be180f490063306e642d3643be9a7062ab5de6a22
7,248
[ -1 ]
7,249
menu.lisp
blitz_stumpwm/menu.lisp
;; Copyright (C) 2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;; Commentary: ;; ;; Implementation of an interactive menu. ;; ;; Code: ;;; interactive menu (in-package #:stumpwm) (export '()) (defvar *menu-map* nil "The keymap used by the interactive menu.") (when (null *menu-map*) (setf *menu-map* (let ((m (make-sparse-keymap))) (define-key m (kbd "C-p") 'menu-up) (define-key m (kbd "Up") 'menu-up) (define-key m (kbd "k") 'menu-up) (define-key m (kbd "C-n") 'menu-down) (define-key m (kbd "Down") 'menu-down) (define-key m (kbd "j") 'menu-down) (define-key m (kbd "C-g") 'menu-abort) (define-key m (kbd "ESC") 'menu-abort) (define-key m (kbd "RET") 'menu-finish) m))) (defvar *current-menu-input* nil) (defstruct menu-state table prompt selected) (defun bound-check-menu (menu) (setf (menu-state-selected menu) (cond ((< (menu-state-selected menu) 0) (1- (length (menu-state-table menu)))) ((>= (menu-state-selected menu) (length (menu-state-table menu))) 0) (t (menu-state-selected menu))))) (defun menu-up (menu) (setf *current-menu-input* "") (decf (menu-state-selected menu)) (bound-check-menu menu)) (defun menu-down (menu) (setf *current-menu-input* "") (incf (menu-state-selected menu)) (bound-check-menu menu)) (defun menu-finish (menu) (throw :menu-quit (nth (menu-state-selected menu) (menu-state-table menu)))) (defun menu-abort (menu) (declare (ignore menu)) (throw :menu-quit nil)) (defun get-input-char (key) "If @var{key} is a character suitable for menu completion (e.g. not backspace or F9), return it otherwise return nil" (let ((char (xlib:keysym->character *display* (key-keysym key)))) (if (or (key-mods-p key) (null char) (not (characterp char))) nil char))) (defun menu-element-name (element) (if (listp element) (first element) element)) (defun check-menu-complete (menu key-seq) "If the use entered a key not mapped in @var{*menu-map}, check if he's trying to type an entry's name. Match is case insensitive as long as the user types lower-case characters." (let ((input-char (get-input-char key-seq))) (when input-char (setf *current-menu-input* (concatenate 'string *current-menu-input* (string input-char))) (do* ((cur-pos 0 (1+ cur-pos)) (rest-elem (menu-state-table menu) (cdr rest-elem)) (cur-elem (car rest-elem) (car rest-elem)) (cur-elem-name (menu-element-name cur-elem) (menu-element-name cur-elem)) (current-input-length (length *current-menu-input*)) (match-regex (ppcre:create-scanner *current-menu-input* :case-insensitive-mode (string= (string-downcase *current-menu-input*) *current-menu-input*)))) ((not cur-elem)) (when (and (>= (length cur-elem-name) current-input-length) (ppcre:scan match-regex cur-elem-name)) (setf (menu-state-selected menu) cur-pos) (return)))))) (defun select-from-menu (screen table &optional prompt (initial-selection 0)) "Prompt the user to select from a menu on SCREEN. TABLE can be a list of values or an alist. If it's an alist, the CAR of each element is displayed in the menu. What is displayed as menu items must be strings. Returns the selected element in TABLE or nil if aborted. See *menu-map* for menu bindings." (check-type screen screen) (check-type table list) (check-type prompt (or null string)) (check-type initial-selection integer) (let* ((menu (make-menu-state :table table :prompt prompt :selected initial-selection)) (menu-options (mapcar #'menu-element-name table)) (menu-text (if prompt (cons prompt menu-options) menu-options)) (*record-last-msg-override* t) (*suppress-echo-timeout* t) (*current-menu-input* "")) (bound-check-menu menu) (catch :menu-quit (unwind-protect (with-focus (screen-key-window screen) (loop (echo-string-list screen menu-text (+ (menu-state-selected menu) (if prompt 1 0))) (multiple-value-bind (action key-seq) (read-from-keymap (list *menu-map*)) (if action (funcall action menu) (check-menu-complete menu (first key-seq)))))) (unmap-all-message-windows)))))
5,303
Common Lisp
.lisp
133
33.62406
90
0.641095
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
076be47094c7fe6817c49beca3760e6d7d782840f145e1af7b791ff55242ce56
7,249
[ -1 ]
7,250
iresize.lisp
blitz_stumpwm/iresize.lisp
;; Copyright (C) 2003-2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;; Commentary: ;; ;;; A resize minor mode. Something a bit better should probably be ;;; written. But it's an interesting way of doing it. ;; ;; Code: (in-package #:stumpwm) (export '(*resize-increment* iresize abort-iresize exit-iresize)) (defvar *resize-backup* nil) (defvar *resize-increment* 10 "Number of pixels to increment by when interactively resizing frames.") (defun set-resize-increment (val) (setf *resize-increment* val) (update-resize-map)) (defun update-resize-map () (let ((m (or *resize-map* (setf *resize-map* (make-sparse-keymap))))) (let ((i *resize-increment*)) (labels ((dk (m k c) (define-key m k (format nil c i)))) (dk m (kbd "Up") "resize 0 -~D") (dk m (kbd "C-p") "resize 0 -~D") (dk m (kbd "p") "resize 0 -~D") (dk m (kbd "k") "resize 0 -~D") (dk m (kbd "Down") "resize 0 ~D") (dk m (kbd "C-n") "resize 0 ~D") (dk m (kbd "n") "resize 0 ~D") (dk m (kbd "j") "resize 0 ~D") (dk m (kbd "Left") "resize -~D 0") (dk m (kbd "C-b") "resize -~D 0") (dk m (kbd "b") "resize -~D 0") (dk m (kbd "h") "resize -~D 0") (dk m (kbd "Right") "resize ~D 0") (dk m (kbd "C-f") "resize ~D 0") (dk m (kbd "f") "resize ~D 0") (dk m (kbd "l") "resize ~D 0") (define-key m (kbd "RET") "exit-iresize") (define-key m (kbd "C-g") "abort-iresize") (define-key m (kbd "ESC") "abort-iresize"))))) (update-resize-map) (defcommand (iresize tile-group) () () "Start the interactive resize mode. A new keymap specific to resizing the current frame is loaded. Hit @key{C-g}, @key{RET}, or @key{ESC} to exit." (let ((frame (tile-group-current-frame (current-group)))) (if (atom (tile-group-frame-head (current-group) (frame-head (current-group) frame))) (message "There's only 1 frame!") (progn (when *resize-hides-windows* (dolist (f (head-frames (current-group) (current-head))) (clear-frame f (current-group)))) (message "Resize Frame") (push-top-map *resize-map*) (draw-frame-outlines (current-group) (current-head))) ;; (setf *resize-backup* (copy-frame-tree (current-group))) ))) (defun resize-unhide () (clear-frame-outlines (current-group)) (when *resize-hides-windows* (let ((group (current-group)) (head (current-head))) (dolist (f (head-frames group head)) (sync-frame-windows group f)) (dolist (w (reverse (head-windows group head))) (setf (frame-window (window-frame w)) w) (raise-window w)) (when (current-window) (focus-window (current-window)))))) (defcommand (abort-iresize tile-group) () () "Exit from the interactive resize mode." (resize-unhide) (message "Abort resize") ;; TODO: actually revert the frames (pop-top-map)) (defcommand (exit-iresize tile-group) () () "Exit from the interactive resize mode." (resize-unhide) (message "Resize Complete") (pop-top-map))
3,893
Common Lisp
.lisp
97
34.742268
89
0.623975
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
2089bee2a49bdc09b1676ce03af16e5913b388d22c1f26581612ff7139b741e0
7,250
[ -1 ]
7,251
bindings.lisp
blitz_stumpwm/bindings.lisp
;; Copyright (C) 2003-2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;; Commentary: ;; ;; define standard key bindings ;; ;; Code: (in-package #:stumpwm) (export '(*groups-map* *help-map* *root-map* set-prefix-key)) (defvar *escape-key* (kbd "C-t") "The escape key. Any keymap that wants to hang off the escape key should use this specific key struct instead of creating their own C-t.") (defvar *escape-fake-key* (kbd "t") "The binding that sends the fake escape key to the current window.") (defvar *root-map* nil "This is the keymap by default bound to @kbd{C-t}. It is known as the @dfn{prefix map}.") (defvar *groups-map* nil "The keymap that group related key bindings sit on. It is bound to @kbd{C-t g} by default.") (defvar *help-map* nil "Help related bindings hang from this keymap") (defvar *group-top-maps* '((tile-group *tile-group-top-map*) (float-group *float-group-top-map*) (group *group-top-map*)) "An alist of the top level maps for each group type. For a given group, all maps whose type matches the given group are active. So for a tile-group, both the group map and tile-group map are active. Order is important. Each map is seached in the order they appear in the list (inactive maps being skipped). In general the order should go from most specific groups to most general groups.") (defvar *group-top-map* nil) (defvar *group-root-map* nil) (defvar *tile-group-top-map* nil) (defvar *tile-group-root-map* nil) (defvar *float-group-top-map* nil) (defvar *float-group-root-map* nil) ;; Do it this way so its easier to wipe the map and get a clean one. (defmacro fill-keymap (map &rest bindings) `(unless ,map (setf ,map (let ((m (make-sparse-keymap))) ,@(loop for i = bindings then (cddr i) while i collect `(define-key m ,(first i) ,(second i))) m)))) (fill-keymap *top-map* *escape-key* '*root-map*) (fill-keymap *root-map* (kbd "c") "exec xterm" (kbd "C-c") "exec xterm" (kbd "e") "emacs" (kbd "C-e") "emacs" (kbd "b") "banish" (kbd "C-b") "banish" (kbd "a") "time" (kbd "C-a") "time" (kbd "!") "exec" (kbd "C-g") "abort" *escape-fake-key* "send-escape" (kbd ";") "colon" (kbd ":") "eval" (kbd "v") "version" (kbd "m") "lastmsg" (kbd "C-m") "lastmsg" (kbd "G") "vgroups" (kbd "g") '*groups-map* (kbd "F1") "gselect 1" (kbd "F2") "gselect 2" (kbd "F3") "gselect 3" (kbd "F4") "gselect 4" (kbd "F5") "gselect 5" (kbd "F6") "gselect 6" (kbd "F7") "gselect 7" (kbd "F8") "gselect 8" (kbd "F9") "gselect 9" (kbd "F10") "gselect 10" (kbd "h") '*help-map*) (fill-keymap *group-top-map* *escape-key* '*group-root-map*) (fill-keymap *group-root-map* (kbd "C-u") "next-urgent" (kbd "w") "windows" (kbd "C-w") "windows" (kbd "k") "delete" (kbd "C-k") "delete" (kbd "K") "kill" (kbd "'") "select" (kbd "\"") "windowlist" (kbd "0") "select-window-by-number 0" (kbd "1") "select-window-by-number 1" (kbd "2") "select-window-by-number 2" (kbd "3") "select-window-by-number 3" (kbd "4") "select-window-by-number 4" (kbd "5") "select-window-by-number 5" (kbd "6") "select-window-by-number 6" (kbd "7") "select-window-by-number 7" (kbd "8") "select-window-by-number 8" (kbd "9") "select-window-by-number 9" (kbd "C-N") "number" (kbd "#") "mark" (kbd "F11") "fullscreen" (kbd "A") "title" (kbd "i") "info") (fill-keymap *tile-group-top-map* *escape-key* '*tile-group-root-map*) (fill-keymap *tile-group-root-map* (kbd "n") "pull-hidden-next" (kbd "C-n") "pull-hidden-next" (kbd "M-n") "next" (kbd "C-M-n") "next-in-frame" (kbd "SPC") "pull-hidden-next" (kbd "C-SPC") "pull-hidden-next" (kbd "p") "pull-hidden-previous" (kbd "C-p") "pull-hidden-previous" (kbd "M-p") "prev" (kbd "C-M-p") "prev-in-frame" (kbd "W") "place-existing-windows" *escape-key* "pull-hidden-other" (kbd "M-t") "other-in-frame" (kbd "C-0") "pull 0" (kbd "C-1") "pull 1" (kbd "C-2") "pull 2" (kbd "C-3") "pull 3" (kbd "C-4") "pull 4" (kbd "C-5") "pull 5" (kbd "C-6") "pull 6" (kbd "C-7") "pull 7" (kbd "C-8") "pull 8" (kbd "C-9") "pull 9" (kbd "R") "remove" (kbd "s") "vsplit" (kbd "S") "hsplit" (kbd "r") "iresize" (kbd "o") "fnext" (kbd "TAB") "fnext" (kbd "M-TAB") "fother" (kbd "f") "fselect" (kbd "F") "curframe" (kbd "-") "fclear" (kbd "Q") "only" (kbd "Up") "move-focus up" (kbd "Down") "move-focus down" (kbd "Left") "move-focus left" (kbd "Right") "move-focus right" (kbd "M-Up") "move-window up" (kbd "M-Down") "move-window down" (kbd "M-Left") "move-window left" (kbd "M-Right") "move-window right" (kbd "+") "balance-frames" (kbd "l") "redisplay" (kbd "C-l") "redisplay") (fill-keymap *float-group-top-map*) (fill-keymap *float-group-root-map*) (fill-keymap *groups-map* (kbd "g") "groups" (kbd "c") "gnew" (kbd "n") "gnext" (kbd "C-n") "gnext" (kbd "SPC") "gnext" (kbd "C-SPC") "gnext" (kbd "N") "gnext-with-window" (kbd "p") "gprev" (kbd "C-p") "gprev" (kbd "P") "gprev-with-window" (kbd "o") "gother" (kbd "'") "gselect" (kbd "\"") "grouplist" (kbd "m") "gmove" (kbd "M") "gmove-marked" (kbd "k") "gkill" (kbd "A") "grename" (kbd "r") "grename" (kbd "1") "gselect 1" (kbd "2") "gselect 2" (kbd "3") "gselect 3" (kbd "4") "gselect 4" (kbd "5") "gselect 5" (kbd "6") "gselect 6" (kbd "7") "gselect 7" (kbd "8") "gselect 8" (kbd "9") "gselect 9" (kbd "0") "gselect 10") (fill-keymap *help-map* (kbd "v") "describe-variable" (kbd "f") "describe-function" (kbd "k") "describe-key" (kbd "c") "describe-command" (kbd "w") "where-is") (defcommand command-mode () () "Command mode allows you to type ratpoison commands without needing the @key{C-t} prefix. Keys not bound in StumpWM will still get sent to the current window. To exit command mode, type @key{C-g}." (message "Press C-g to exit command-mode.") (push-top-map *root-map*)) (defcommand set-prefix-key (key) ((:key "Key: ")) "Change the stumpwm prefix key to KEY. @example \(stumpwm:set-prefix-key (stumpwm:kbd \"C-M-H-s-z\")) @end example This will change the prefix key to @key{Control} + @key{Meta} + @key{Hyper} + @key{Super} + the @key{z} key. By most standards, a terrible prefix key but it makes a great example." (check-type key key) (copy-key-into key *escape-key*) ;; if the escape key has no modifiers then disable the fake key by ;; giving it keysym -1, an impossible value. Otherwise you have 2 ;; identical bindings and the one that appears first in the list ;; will be matched. (copy-key-into (make-key :keysym (if (key-mods-p *escape-key*) (key-keysym key) -1)) *escape-fake-key*) (sync-keys)) (defcommand-alias escape set-prefix-key) (defcommand bind (key command) ((:string "Key Chord: ") (:rest "Command: ")) "Hang a key binding off the escape key." (define-key *root-map* (kbd key) command)) (defcommand send-escape () () "Send the escape key to the current window." (send-meta-key (current-screen) *escape-key*))
8,375
Common Lisp
.lisp
238
31.563025
94
0.600198
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
df1529bdfc7c1f8d34b033e7e0130f164fd34cba0e8f881c20f304abde995d17
7,251
[ -1 ]
7,252
module.lisp.in
blitz_stumpwm/module.lisp.in
;; Copyright (C) 2008 Julian Stecklina, Shawn Betts, Ivy Foster ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;; Commentary: ;; ;; Use `set-contrib-dir' to set the location stumpwm searches for modules. ;; Code: (in-package #:stumpwm) (export '(load-module list-modules *contrib-dir* set-contrib-dir find-module)) (defun module-string-as-directory (dir) (unless (string= "/" (subseq dir (1- (length dir)))) (setf dir (concat dir "/"))) (pathname dir)) (defvar *contrib-dir* (module-string-as-directory "@CONTRIB_DIR@") "The location of the contrib modules on your system.") (defcommand set-contrib-dir (dir) ((:string "Directory: ")) "Sets the location of the contrib modules" (setf *contrib-dir* (module-string-as-directory dir))) (define-stumpwm-type :module (input prompt) (or (argument-pop-rest input) (completing-read (current-screen) prompt (list-modules) :require-match t))) (defun list-modules () "Return a list of the available modules." (mapcar 'pathname-name (directory (make-pathname :defaults *contrib-dir* :name :wild :type "lisp")))) (defun find-module (name) (probe-file (make-pathname :defaults *contrib-dir* :name name :type "lisp"))) (defcommand load-module (name) ((:module "Load Module: ")) "Loads the contributed module with the given NAME." ;; FIXME: This should use ASDF in the future. And maybe there should ;; be an extra stumpwm-contrib repository. (when name (let ((module (find-module name))) (when module (load module))))) ;; End of file
2,352
Common Lisp
.lisp
57
37.052632
81
0.694298
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
a4d7d303e085d4df121910406b2589bc81e24330fec723e96174c57eda03a734
7,252
[ -1 ]
7,253
head.lisp
blitz_stumpwm/head.lisp
;; Copyright (C) 2003-2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;; Commentary: ;; ;; Head functionality ;; ;; Code: (in-package #:stumpwm) (export '(current-head)) (defun head-by-number (screen n) (find n (screen-heads screen) :key 'head-number)) (defun parse-xinerama-head (line) (ppcre:register-groups-bind (('parse-integer number width height x y)) ("^ +head #([0-9]+): ([0-9]+)x([0-9]+) @ ([0-9]+),([0-9]+)" line :sharedp t) (handler-case (make-head :number number :x x :y y :width width :height height) (parse-error () nil)))) (defun make-screen-heads (screen root) "or use xdpyinfo to query the xinerama extension, if it's enabled." (or (and (xlib:query-extension *display* "XINERAMA") (with-current-screen screen ;; Ignore 'clone' heads. (loop for i = 0 then (1+ i) for h in (delete-duplicates (loop for i in (split-string (run-shell-command "xdpyinfo -ext XINERAMA" t)) for head = (parse-xinerama-head i) when head collect head) :test #'frames-overlap-p) do (setf (head-number h) i) collect h))) (list (make-head :number 0 :x 0 :y 0 :width (xlib:drawable-width root) :height (xlib:drawable-height root) :window nil)))) (defun copy-heads (screen) "Return a copy of screen's heads." (mapcar 'copy-frame (screen-heads screen))) ;; Determining a frame's head based on position probably won't ;; work with overlapping heads. Would it be better to walk ;; up the frame tree? (defun frame-head (group frame) (dolist (head (screen-heads (group-screen group))) (when (and (>= (frame-x frame) (frame-x head)) (>= (frame-y frame) (frame-y head)) (<= (+ (frame-x frame) (frame-width frame)) (+ (frame-x head) (frame-width head))) (<= (+ (frame-y frame) (frame-height frame)) (+ (frame-y head) (frame-height head)))) (return head)))) (defun group-heads (group) (screen-heads (group-screen group))) (defun tile-group-frame-head (group head) (elt (tile-group-frame-tree group) (position head (group-heads group)))) (defun (setf tile-group-frame-head) (frame group head) (setf (elt (tile-group-frame-tree group) (position head (group-heads group))) frame)) (defun current-head (&optional (group (current-group))) (group-current-head group)) (defun head-windows (group head) "Returns a list of windows on HEAD of GROUP" (remove-if-not (lambda (w) (eq head (window-head w))) (group-windows group))) (defun frame-is-head (group frame) (< (frame-number frame) (length (group-heads group)))) (defun add-head (screen head) (dformat 1 "Adding head #~D~%" (head-number head)) (setf (screen-heads screen) (sort (push head (screen-heads screen)) #'< :key 'head-number)) (dolist (group (screen-groups screen)) (let ((new-frame-num (find-free-frame-number group))) (setf (tile-group-frame-tree group) (insert-before (tile-group-frame-tree group) (copy-frame head) (head-number head))) ;; Try to put something in the new frame and give it an unused number (let ((frame (tile-group-frame-head group head))) (setf (frame-number frame) new-frame-num) (choose-new-frame-window frame group) (when (frame-window frame) (unhide-window (frame-window frame))))))) (defun remove-head (screen head) (dformat 1 "Removing head #~D~%" (head-number head)) (when (head-mode-line head) (toggle-mode-line screen head)) (dolist (group (screen-groups screen)) ;; Hide its windows. (let ((windows (head-windows group head))) ;; Remove it from the frame tree. (setf (tile-group-frame-tree group) (delete (tile-group-frame-head group head) (tile-group-frame-tree group))) ;; Just set current frame to whatever. (let ((frame (first (group-frames group)))) (setf (tile-group-current-frame group) frame (tile-group-last-frame group) nil) (dolist (window windows) (hide-window window) (setf (window-frame window) frame)))) ;; Try to do something with the orphaned windows (populate-frames group)) ;; Remove it from SCREEN's head list. (setf (screen-heads screen) (delete head (screen-heads screen)))) (defun scale-head (screen oh nh) "Scales head OH to match the dimensions of NH." (dolist (group (screen-groups screen)) (resize-tree (tile-group-frame-head group oh) (head-width nh) (head-height nh) (head-x nh) (head-y nh))) (setf (head-x oh) (head-x nh) (head-y oh) (head-y nh) (head-width oh) (head-width nh) (head-height oh) (head-height nh))) (defun scale-screen (screen heads) "Scale all frames of all groups of SCREEN to match the dimensions of HEADS." (when (< (length heads) (length (screen-heads screen))) ;; Some heads were removed (or cloned), try to guess which. (dolist (oh (screen-heads screen)) (dolist (nh heads) (when (and (= (head-x nh) (head-x oh)) (= (head-y nh) (head-y oh))) ;; Same screen position; probably the same head. (setf (head-number nh) (head-number oh))))) ;; Actually remove the missing heads. (dolist (head (set-difference (screen-heads screen) heads :key 'head-number)) (remove-head screen head))) (loop for nh in heads as oh = (find (head-number nh) (screen-heads screen) :key 'head-number) do (if oh (scale-head screen oh nh) (add-head screen nh))))
6,790
Common Lisp
.lisp
151
36.503311
116
0.606922
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
c2bf135343c9cc86d95e96102b6f50c7cee38d35ffc23a1b3c41de564961b843
7,253
[ -1 ]
7,254
screen.lisp
blitz_stumpwm/screen.lisp
;; Copyright (C) 2003-2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;; Commentary: ;; ;; Screen functionality ;; ;; Code: (in-package #:stumpwm) (export '(current-screen current-window screen-current-window set-fg-color set-bg-color set-border-color set-win-bg-color set-focus-color set-unfocus-color set-msg-border-width set-frame-outline-width set-font)) ;; Screen helper functions (defun translate-id (src src-start src-end font dst dst-start) "A simple replacement for xlib:translate-default. just the identity with a range check." (let ((min (xlib:font-min-char font)) (max (xlib:font-max-char font))) (decf src-end) (if (stringp src) ; clx does this test so i guess it's needed (loop for i from src-start to src-end for j from dst-start as c = (char-code (char src i)) if (<= min c max) do (setf (aref dst j) c) ;; replace unknown characters with question marks else do (setf (aref dst j) (char-code #\?)) finally (return i)) (loop for i from src-start to src-end for j from dst-start as c = (elt src i) as n = (if (characterp c) (char-code c) c) if (and (integerp n) (<= min n max)) do (setf (aref dst j) n) ;; ditto else do (setf (aref dst j) (char-code #\?)) finally (return i))))) (defun screen-x (screen) (declare (ignore screen)) 0) (defun screen-y (screen) (declare (ignore screen)) 0) (defun screen-height (screen) (let ((root (screen-root screen))) (xlib:drawable-height root))) (defun screen-true-height (screen) "Return the height of the screen regardless of the modeline" (let ((root (screen-root screen))) (xlib:drawable-height root))) (defun screen-width (screen) (let ((root (screen-root screen))) (xlib:drawable-width root))) (defun find-screen (root) "Return the screen containing the root window." (find-if (lambda (s) (xlib:window-equal (screen-root s) root)) *screen-list*)) (defun screen-windows (screen) (mapcan (lambda (g) (copy-list (group-windows g))) (screen-groups screen))) (defun netwm-update-client-list-stacking (screen) (unless *initializing* (xlib:change-property (screen-root screen) :_NET_CLIENT_LIST_STACKING ;; Order is bottom to top. (reverse (mapcar 'window-xwin (all-windows))) :window 32 :transform #'xlib:drawable-id :mode :replace))) (defun netwm-update-client-list (screen) (xlib:change-property (screen-root screen) :_NET_CLIENT_LIST (screen-mapped-windows screen) :window 32 :transform #'xlib:drawable-id :mode :replace) (netwm-update-client-list-stacking screen)) (defun screen-add-mapped-window (screen xwin) (push xwin (screen-mapped-windows screen)) (netwm-update-client-list screen)) (defun screen-remove-mapped-window (screen xwin) (unregister-window xwin) (setf (screen-mapped-windows screen) (remove xwin (screen-mapped-windows screen))) (netwm-update-client-list screen)) (defun sort-screens () "Return the list of screen sorted by ID." (sort1 *screen-list* '< :key 'screen-id)) (defun next-screen (&optional (list (sort-screens))) (let ((matches (member (current-screen) list))) (if (null (cdr matches)) ;; If the last one in the list is current, then ;; use the first one. (car list) ;; Otherwise, use the next one in the list. (cadr matches)))) (defun move-screen-to-head (screen) (move-to-head *screen-list* screen)) (defun switch-to-screen (screen) (when (and screen (not (eq screen (current-screen)))) (if (screen-focus screen) (xlib:set-input-focus *display* (window-xwin (screen-focus screen)) :POINTER-ROOT) (xlib:set-input-focus *display* (screen-focus-window screen) :POINTER-ROOT)) (move-screen-to-head screen))) (defun screen-set-focus (screen window) (when (eq (window-group window) (screen-current-group screen)) ;;(format t "FOCUS TO: ~a ~a~%" window (window-xwin window)) ;;(format t "FOCUS BEFORE: ~a~%" (multiple-value-list (xlib:input-focus *display*))) ;;(format t "FOCUS RET: ~a~%" (xlib:set-input-focus *display* (window-xwin window) :POINTER-ROOT)) (xlib:set-input-focus *display* (window-xwin window) :POINTER-ROOT) ;;(xlib:display-finish-output *display*) ;;(format t "FOCUS IS: ~a~%" (multiple-value-list (xlib:input-focus *display*))) (xlib:change-property (screen-root screen) :_NET_ACTIVE_WINDOW (list (window-xwin window)) :window 32 :transform #'xlib:drawable-id :mode :replace) (setf (screen-focus screen) window) (move-screen-to-head screen))) (defun screen-current-window (screen) "Return the current window on the specified screen" (group-current-window (screen-current-group screen))) (defun current-window () "Return the current window on the current screen" (screen-current-window (current-screen))) (defun register-window (window) (setf (gethash (xlib:window-id (window-xwin window)) *xwin-to-window*) window)) (defun unregister-window (xwin) (remhash (xlib:window-id xwin) *xwin-to-window*)) (defun window-by-id (id) (gethash id *xwin-to-window*)) (defun find-window (xwin) (window-by-id (xlib:window-id xwin))) (defun find-window-by-parent (xwin &optional (windows (all-windows))) (dformat 3 "find-window-by-parent!~%") (find xwin windows :key 'window-parent :test 'xlib:window-equal)) (defun screen-root (screen) (xlib:screen-root (screen-number screen))) (defun update-colors-for-screen (screen) (let ((fg (screen-fg-color screen)) (bg (screen-bg-color screen))) (setf (xlib:gcontext-foreground (screen-message-gc screen)) fg (xlib:gcontext-background (screen-message-gc screen)) bg (xlib:gcontext-foreground (screen-frame-outline-gc screen)) fg (xlib:gcontext-background (screen-frame-outline-gc screen)) bg (ccontext-default-fg (screen-message-cc screen)) fg (ccontext-default-bg (screen-message-cc screen)) bg)) (dolist (i (list (screen-message-window screen) (screen-input-window screen) (screen-frame-window screen))) (setf (xlib:window-border i) (screen-border-color screen) (xlib:window-background i) (screen-bg-color screen))) ;; update the backgrounds of all the managed windows (dolist (g (screen-groups screen)) (dolist (w (group-windows g)) (unless (eq w (group-current-window g)) (setf (xlib:window-background (window-parent w)) (screen-win-bg-color screen)) (xlib:clear-area (window-parent w))))) (dolist (i (screen-withdrawn-windows screen)) (setf (xlib:window-background (window-parent i)) (screen-win-bg-color screen)) (xlib:clear-area (window-parent i))) (update-screen-color-context screen)) (defun update-colors-all-screens () "After setting the fg, bg, or border colors. call this to sync any existing windows." (mapc 'update-colors-for-screen *screen-list*)) (defun update-border-for-screen (screen) (setf (xlib:drawable-border-width (screen-input-window screen)) (screen-msg-border-width screen) (xlib:drawable-border-width (screen-message-window screen)) (screen-msg-border-width screen))) (defun update-border-all-screens () "After setting the border width call this to sync any existing windows." (mapc 'update-border-for-screen *screen-list*)) (defun internal-window-p (screen win) "Return t if win is a window used by stumpwm" (or (xlib:window-equal (screen-message-window screen) win) (xlib:window-equal (screen-input-window screen) win) (xlib:window-equal (screen-focus-window screen) win) (xlib:window-equal (screen-key-window screen) win))) (defun color-exists-p (color) (handler-case (loop for i in *screen-list* always (xlib:lookup-color (xlib:screen-default-colormap (screen-number i)) color)) (xlib:name-error () nil))) (defun font-exists-p (font-name) ;; if we can list the font then it exists (plusp (length (xlib:list-font-names *display* font-name :max-fonts 1)))) (defmacro set-any-color (val color) `(progn (dolist (s *screen-list*) (setf (,val s) (alloc-color s ,color))) (update-colors-all-screens))) ;; FIXME: I don't like any of this. Isn't there a way to define ;; a setf method to call (update-colors-all-screens) when the user ;; does eg. (setf *foreground-color* "green") instead of having ;; these redundant set-foo functions? (defun set-fg-color (color) "Set the foreground color for the message bar and input bar. @var{color} can be any color recognized by X." (setf *text-color* color) (set-any-color screen-fg-color color)) (defun set-bg-color (color) "Set the background color for the message bar and input bar. @var{color} can be any color recognized by X." (set-any-color screen-bg-color color)) (defun set-border-color (color) "Set the border color for the message bar and input bar. @var{color} can be any color recognized by X." (set-any-color screen-border-color color)) (defun set-win-bg-color (color) "Set the background color of the window. The background color will only be visible for windows with size increment hints such as @samp{emacs} and @samp{xterm}." (set-any-color screen-win-bg-color color)) (defun set-focus-color (color) "Set the border color for focused windows. This is only used when there is more than one frame." (set-any-color screen-focus-color color)) (defun set-unfocus-color (color) "Set the border color for windows without focus. This is only used when there is more than one frame." (set-any-color screen-unfocus-color color)) (defun set-msg-border-width (width) "Set the border width for the message bar and input bar." (check-type width (integer 0)) (dolist (i *screen-list*) (setf (screen-msg-border-width i) width)) (update-border-all-screens) t) (defun set-frame-outline-width (width) (check-type width (integer 0)) (dolist (i *screen-list*) (setf (screen-frame-outline-width i) (if (oddp width) (1+ width) width) (xlib:gcontext-line-width (screen-frame-outline-gc i)) (screen-frame-outline-width i))) (update-border-all-screens) t) (defun set-font (font) "Set the font for the message bar and input bar." (when (font-exists-p font) (dolist (i *screen-list*) (let ((fobj (xlib:open-font *display* (first (xlib:list-font-names *display* font :max-fonts 1))))) (xlib:close-font (screen-font i)) (setf (screen-font i) fobj (xlib:gcontext-font (screen-message-gc i)) fobj) ;; update the modelines too (dolist (h (screen-heads i)) (when (and (head-mode-line h) (eq (mode-line-mode (head-mode-line h)) :stump)) (setf (xlib:gcontext-font (mode-line-gc (head-mode-line h))) fobj) (resize-mode-line (head-mode-line h)) (sync-mode-line (head-mode-line h)))))) t)) (defmacro with-current-screen (screen &body body) "A macro to help us out with early set up." `(let ((*screen-list* (list ,screen))) ,@body)) (defun current-screen () "Return the current screen." (car *screen-list*)) (defun netwm-set-properties (screen focus-window) "Set NETWM properties on the root window of the specified screen. FOCUS-WINDOW is an extra window used for _NET_SUPPORTING_WM_CHECK." (let* ((screen-number (screen-number screen)) (root (xlib:screen-root screen-number))) ;; _NET_SUPPORTED (xlib:change-property root :_NET_SUPPORTED (mapcar (lambda (a) (xlib:intern-atom *display* a)) (append +netwm-supported+ (mapcar #'car +netwm-window-types+))) :atom 32) ;; _NET_SUPPORTING_WM_CHECK (xlib:change-property root :_NET_SUPPORTING_WM_CHECK (list focus-window) :window 32 :transform #'xlib:drawable-id) (xlib:change-property focus-window :_NET_SUPPORTING_WM_CHECK (list focus-window) :window 32 :transform #'xlib:drawable-id) (xlib:change-property focus-window :_NET_WM_NAME "stumpwm" :string 8 :transform #'xlib:char->card8) ;; _NET_CLIENT_LIST (xlib:change-property root :_NET_CLIENT_LIST () :window 32 :transform #'xlib:drawable-id) ;; _NET_DESKTOP_GEOMETRY (xlib:change-property root :_NET_DESKTOP_GEOMETRY (list (xlib:screen-width screen-number) (xlib:screen-height screen-number)) :cardinal 32) ;; _NET_DESKTOP_VIEWPORT (xlib:change-property root :_NET_DESKTOP_VIEWPORT (list 0 0) :cardinal 32) (netwm-set-group-properties screen))) (defun init-screen (screen-number id host) "Given a screen number, returns a screen structure with initialized members" ;; Listen for the window manager events on the root window (dformat 1 "Initializing screen: ~a ~a~%" host id) (setf (xlib:window-event-mask (xlib:screen-root screen-number)) '(:substructure-redirect :substructure-notify :property-change :structure-notify :button-press :exposure)) (xlib:display-finish-output *display*) ;; Initialize the screen structure (labels ((ac (color) (xlib:alloc-color (xlib:screen-default-colormap screen-number) color))) (let* ((screen (make-instance 'screen)) (fg (ac +default-foreground-color+)) (bg (ac +default-background-color+)) (border (ac +default-border-color+)) (focus (ac +default-focus-color+)) (unfocus (ac +default-unfocus-color+)) (win-bg (ac +default-window-background-color+)) (input-window (xlib:create-window :parent (xlib:screen-root screen-number) :x 0 :y 0 :width 20 :height 20 :background bg :border border :border-width 1 :colormap (xlib:screen-default-colormap screen-number) :event-mask '(:key-press :key-release))) (focus-window (xlib:create-window :parent (xlib:screen-root screen-number) :x 0 :y 0 :width 1 :height 1)) (key-window (xlib:create-window :parent (xlib:screen-root screen-number) :x 0 :y 0 :width 1 :height 1 :event-mask '(:key-press :key-release))) (message-window (xlib:create-window :parent (xlib:screen-root screen-number) :x 0 :y 0 :width 1 :height 1 :background bg :bit-gravity :north-east :border border :border-width 1 :colormap (xlib:screen-default-colormap screen-number) :event-mask '(:exposure))) (frame-window (xlib:create-window :parent (xlib:screen-root screen-number) :x 0 :y 0 :width 20 :height 20 :background bg :border border :border-width 1 :colormap (xlib:screen-default-colormap screen-number) :event-mask '(:exposure))) (font (xlib:open-font *display* (if (font-exists-p +default-font-name+) +default-font-name+ "*"))) (group (make-instance 'tile-group :screen screen :number 1 :name *default-group-name*))) ;; Create our screen structure ;; The focus window is mapped at all times (xlib:map-window focus-window) (xlib:map-window key-window) (setf (screen-number screen) screen-number (screen-id screen) id (screen-host screen) host (screen-groups screen) (list group) (screen-current-group screen) group (screen-font screen) font (screen-fg-color screen) fg (screen-bg-color screen) bg (screen-win-bg-color screen) win-bg (screen-border-color screen) border (screen-focus-color screen) focus (screen-unfocus-color screen) unfocus (screen-msg-border-width screen) 1 (screen-frame-outline-width screen) +default-frame-outline-width+ (screen-input-window screen) input-window (screen-focus-window screen) focus-window (screen-key-window screen) key-window (screen-frame-window screen) frame-window (screen-ignore-msg-expose screen) 0 (screen-message-cc screen) (make-ccontext :win message-window :gc (xlib:create-gcontext :drawable message-window :font font :foreground fg :background bg)) (screen-frame-outline-gc screen) (xlib:create-gcontext :drawable (screen-root screen) :font font :foreground fg :background fg :line-style :double-dash :line-width +default-frame-outline-width+)) (setf (screen-heads screen) (make-screen-heads screen (xlib:screen-root screen-number)) (tile-group-frame-tree group) (copy-heads screen) (tile-group-current-frame group) (first (tile-group-frame-tree group))) (netwm-set-properties screen focus-window) (update-colors-for-screen screen) (update-color-map screen) (xwin-grab-keys focus-window screen) screen))) ;;; Screen commands (defcommand snext () () "Go to the next screen." (switch-to-screen (next-screen)) (group-wake-up (current-group))) (defcommand sprev () () "Go to the previous screen." (switch-to-screen (next-screen (reverse (sort-screens)))) (group-wake-up (current-group))) (defcommand sother () () "Go to the last screen." (switch-to-screen (cadr *screen-list*)) (group-wake-up (current-group)))
20,744
Common Lisp
.lisp
430
36.655814
110
0.589531
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
2b722ecf926980c79a09a2b877ab423ccc2d84006c79bfdca582cd4c7fbfd511
7,254
[ -1 ]
7,255
time.lisp
blitz_stumpwm/time.lisp
;; Copyright (C) 2003-2008 Ivy Foster ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; 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 file contains code relating to the display of time. ;; ;; When setting `*time-format-string-default*' to look like you want, the ;; options are exactly the same as those in the output of date --help (with date ;; 6.12), with the exception of a few unimplemented functions (see the comments ;; in *time-format-string-alist*, below). `*time-modeline-string*' is also ;; customizable; it defaults to the same value as *time-format-string-default*. ;; ;; TODO: ;; ;; - Implement all options from date. ;; - Simplify code (fewer helper functions somehow?) ;; Code: (in-package :stumpwm) (export '(*time-format-string-default* *time-modeline-string* echo-date time)) (defvar *time-format-string-default* "%a %b %e %k:%M:%S" "The default value for `echo-date', (e.g, Thu Mar 3 23:05:25 2005).") (defvar *time-modeline-string* "%a %b %e %k:%M:%S" "The default time value to pass to the modeline.") (defvar *time-month-names* #("January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December")) (defvar *time-day-names* #("Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday")) ;; `date --help` with date_6.12 (defvar *time-format-string-alist* '((#\a time-dow-shortname) (#\A time-dow-name) (#\b time-month-shortname) (#\B time-month-name) (#\c time-date-and-time) (#\C time-century) (#\d time-day-of-month) (#\D time-date) (#\e time-day-of-month-zero) (#\F time-date-full) ;; (#\g) last two digits of year of ISO week number (see %G) ;; (#\G) year of ISO week number (see %V); normally useful only with %V (#\h time-month-shortname) (#\H time-hour) (#\I time-hour-12hr-zero) ;; (#\j) day of year (001..366) (#\k time-hour) (#\l time-hour-12hr) (#\m time-month) (#\M time-minute) (#\n time-newline) ;; (#\N) nanoseconds (000000000..999999999) (#\p time-am-pm) (#\P time-am-pm-caps) (#\r time-12hr-time) (#\R time-24hr-and-minute) (#\s time-unix-era) (#\S time-second) (#\t time-tab) (#\T time-24hr-time) (#\u time-day-of-week) ;; (#\U) week number of year, with Sunday as first day of week (00..53) ;; (#\V) ISO week number, with Monday as first day of week (01..53) (#\w time-day-of-week-sun-start) ;; (#\W) week number of year, with Monday as first day of week (00..53) ;; (#\x) locale's date representation (e.g., 12/31/99) ;; (#\X) locale's time representation (e.g., 23:13:48) (#\y time-year-short) (#\Y time-year) (#\z time-tz) ;; (#\:z) +hh:mm numeric timezone (e.g., -04:00) ;; (#\::z) +hh:mm:ss numeric time zone (e.g., -04:00:00) ;; (#\:::z) numeric time zone with : to necessary precision (e.g., -04, +05:30) ;; %Z alphabetic time zone abbreviation (e.g., EDT) )) (defcommand echo-date () () "Display the date and time." (message "~a" (format-expand *time-format-string-alist* *time-format-string-default*))) (defcommand-alias time echo-date) ;;; ------------------------------------------------------------------ ;;; Helper functions ;;; ------------------------------------------------------------------ (defun time-plist (&optional time) (multiple-value-bind (sec min hour dom mon year dow dstp tz) (or time (get-decoded-time)) (list :second sec :minute min :hour hour :dom dom :month mon :year year :dow dow :dlsavings-p dstp :tz tz))) (defun time-second () (format nil "~2,'0D" (getf (time-plist) :second))) (defun time-minute () (format nil "~2,'0D" (getf (time-plist) :minute))) (defun time-hour () (format nil "~2,D" (getf (time-plist) :hour))) (defun time-hour-zero () (format nil "~2,'0D" (getf (time-plist) :hour))) (defun time-hour-12hr () (let ((hour (rem (getf (time-plist) :hour) 12))) (format nil "~2,D" (if (zerop hour) 12 hour)))) (defun time-hour-12hr-zero () (let ((hour (rem (getf (time-plist) :hour) 12))) (format nil "~2,'0D" (if (zerop hour) 12 hour)))) (defun time-day-of-month-zero () (format nil "~2,'0D" (getf (time-plist) :dom))) (defun time-day-of-month () (format nil "~2,' D" (getf (time-plist) :dom))) (defun time-month () (format nil "~2,'0D" (getf (time-plist) :month))) (defun time-month-name () (aref *time-month-names* (1- (getf (time-plist) :month)))) (defun time-month-shortname () (subseq (time-month-name) 0 3)) (defun time-year () (write-to-string (getf (time-plist) :year))) (defun time-century () (subseq (time-year) 0 2)) (defun time-year-short () (subseq (time-year) 2)) (defun time-day-of-week () (write-to-string (1+ (getf (time-plist) :dow)))) (defun time-day-of-week-sun-start () (let ((dow (getf (time-plist) :dow))) (write-to-string (if (= dow 6) 0 (1+ dow))))) (defun time-dow-name () (aref *time-day-names* (getf (time-plist) :dow))) (defun time-dow-shortname () (subseq (time-dow-name) 0 3)) (defun time-newline () (format nil "~a" #\newline)) (defun time-tab () (format nil "~T")) (defun time-am-pm () (if (>= (getf (time-plist) :hour) 12) "pm" "am")) (defun time-am-pm-caps () (if (>= (getf (time-plist) :hour) 12) "PM" "AM")) (defun time-tz () (let ((tz (getf (time-plist) :tz)) (dlsave (if (getf (time-plist) :dlsavings-p) 1 0))) (multiple-value-bind (hour-local decimal-local) (truncate (+ (* (float tz) -1) (if dlsave 1 0))) (format nil "~A~2,'0D~2,'0D" (if (> hour-local 0) '+ '-) (abs hour-local) (truncate (if (/= decimal-local 0) (* 60 decimal-local) 0)))))) (defun time-unix-era () (format nil "~D" (- (get-universal-time) (encode-universal-time 0 0 0 1 1 1970 0)))) (defun time-date-and-time () (format-expand *time-format-string-alist* "%a %h %d %H:%M:%S %Y")) (defun time-date () (format-expand *time-format-string-alist* "%m/%d/%y")) (defun time-date-full () (format-expand *time-format-string-alist* "%Y-%m-%d")) (defun time-12hr-time () (format-expand *time-format-string-alist* "%I:%M:%S %P")) (defun time-24hr-and-minute () (format-expand *time-format-string-alist* "%H:%M")) (defun time-24hr-time () (format-expand *time-format-string-alist* "%H:%M:%S")) ;;; End of file
7,089
Common Lisp
.lisp
184
35.179348
84
0.622631
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
6825510499132718f81309197e2dbd76f876e6794aade4b584ba92f998b8e2f7
7,255
[ -1 ]
7,256
window-placement.lisp
blitz_stumpwm/window-placement.lisp
;;; Window placement routines (in-package :stumpwm) (defun xwin-to-window (xwin) "Build a window for XWIN" (make-instance 'window :xwin xwin :width (xlib:drawable-width xwin) :height (xlib:drawable-height xwin) :x (xlib:drawable-x xwin) :y (xlib:drawable-y xwin) :title (xwin-name xwin) :class (xwin-class xwin) :res (xwin-res-name xwin) :role (xwin-role xwin) :type (xwin-type xwin) :normal-hints (get-normalized-normal-hints xwin) :state +iconic-state+ :plist (make-hash-table) :unmap-ignores 0)) (defvar *rule-scanners-cache* (make-hash-table :test 'equal) "A cache for the ppcre scanners") (defun get-or-create-rule-scanner (regex) (or (gethash regex *rule-scanners-cache*) (setf (gethash regex *rule-scanners-cache*) (ppcre:create-scanner regex)))) (defun string-match (string pat) (ppcre:scan (get-or-create-rule-scanner pat) string)) (defun window-matches-properties-p (window &key class instance type role title) "Returns T if window matches all the given properties" (and (if class (string-match (window-class window) class) t) (if instance (string-match (window-res window) instance) t) (if type (string-match (window-type window) type) t) (if role (string-match (window-role window) role) t) (if title (string-match (window-title window) title) t) t)) (defun window-matches-rule-p (w rule) "Returns T if window matches rule" (destructuring-bind (group-name frame raise lock &key create restore class instance type role title) rule (declare (ignore frame raise create restore)) (if (or lock (equal group-name (group-name (or (when (slot-boundp w 'group) (window-group w)) (current-group))))) (window-matches-properties-p w :class class :instance instance :type type :role role :title title)))) (defun rule-matching-window (window) (dolist (rule *window-placement-rules*) (when (window-matches-rule-p window rule) (return rule)))) (defun get-window-placement (screen window) "Returns the ideal group and frame that WINDOW should belong to and whether the window should be raised." (let ((match (rule-matching-window window))) (if match (destructuring-bind (group-name frame raise lock &key create restore class instance type role title) match (declare (ignore lock class instance type role title)) (let ((group (find-group screen group-name))) (cond (group (when (and restore (stringp restore)) (let ((restore-file (data-dir-file restore))) (if (probe-file restore-file) (restore-group group (read-dump-from-file restore-file)) (message "^B^1*Can't restore group \"^b~a^B\" with \"^b~a^B\"." group-name restore-file)))) (values group (frame-by-number group frame) raise)) (create (let ((new-group (add-group (current-screen) group-name)) (restore-file (if (stringp create) (data-dir-file create) (data-dir-file group-name)))) (if (and new-group (probe-file restore-file)) (restore-group new-group (read-dump-from-file restore-file)) (when (stringp create) (message "^B^1*Can't restore group \"^b~a^B\" with \"^b~a^B\"." group-name restore-file))) (values new-group (frame-by-number new-group frame) raise))) (t (message "^B^1*Error placing window, group \"^b~a^B\" does not exist." group-name) (values))))) (values)))) (defun sync-window-placement () "Re-arrange existing windows according to placement rules" (dolist (screen *screen-list*) (dolist (window (screen-windows screen)) (multiple-value-bind (to-group frame raise) (with-current-screen screen (get-window-placement screen window)) (declare (ignore raise)) (when to-group (unless (eq (window-group window) to-group) (move-window-to-group window to-group)) (unless (eq (window-frame window) frame) (pull-window window frame))))))) (defun assign-window (window group &optional (where :tail)) "Assign the window to the specified group and perform the necessary housekeeping." (setf (window-group window) group (window-number window) (find-free-window-number group)) (if (eq where :head) (push window (group-windows group)) (setf (group-windows group) (append (group-windows group) (list window)))) (setf (xwin-state (window-xwin window)) +iconic-state+) (netwm-set-group window)) (defun place-window (screen window) "Pick a group WINDOW and return the group-specific placement hints, if any." (let* ((netwm-group (netwm-group window screen)) (placement (multiple-value-list (get-window-placement screen window))) (placement-group (first placement)) (group (or (when *processing-existing-windows* netwm-group) placement-group netwm-group (screen-current-group screen)))) (assign-window window group (if *processing-existing-windows* :head :tail)) ;; if we're using the placement group, then return the extra data. (when (eq group placement-group) (list :frame (second placement) :raise (third placement))))) (defun pick-preferred-frame (window) (let* ((group (window-group window)) (frames (group-frames group)) (default (tile-group-current-frame group)) (preferred-frame (or *new-window-preferred-frame* default))) (when (or (functionp *new-window-preferred-frame*) (and (symbolp *new-window-preferred-frame*) (fboundp *new-window-preferred-frame*))) (setq preferred-frame (handler-case (funcall *new-window-preferred-frame* window) (t (c) (message "^1*^BError while calling ^b^3**new-window-preferred-frame*^1*^B: ^n~a" c) default)))) (cond ;; If we already have a frame use it. ((frame-p preferred-frame) preferred-frame) ;; If `preferred-frame' is a list of keyword use it to determine the ;; frame. The sanity check doesn't cover not recognized keywords. We ;; simply fall back to the default then. ((and (listp preferred-frame) (every #'keywordp preferred-frame)) (loop for i in preferred-frame thereis (case i (:last ;; last-frame can be stale (and (> (length frames) 1) (tile-group-last-frame group))) (:unfocused (find-if (lambda (f) (not (eq f (tile-group-current-frame group)))) frames)) (:empty (find-if (lambda (f) (null (frame-window f))) frames)) (:choice ;; Transient windows sometimes specify a location ;; relative to the TRANSIENT_FOR window. Just ignore ;; these hints. (unless (find (window-type window) '(:transient :dialog)) (let ((hints (window-normal-hints window))) (when (and hints (xlib:wm-size-hints-user-specified-position-p hints)) (find-frame group (window-x window) (window-y window)))))) (t ; :focused or not recognized keyword default)))) ;; Not well formed `*new-window-preferred-frame*'. Message an error and ;; return the default. (t (message "^1*^BInvalid ^b^3**new-window-preferred-frame*^1*^B: ^n~a" preferred-frame) default))))
8,623
Common Lisp
.lisp
174
36.097701
105
0.560522
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
1c8d8f3e059b2929bffc974cab706d1edf0b7443253e17a8dee7a138ee2ba95a
7,256
[ -1 ]
7,257
input.lisp
blitz_stumpwm/input.lisp
;; Copyright (C) 2003-2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; 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 file handles input stuff ;; ;; Code: (in-package :stumpwm) (export '(*input-history-ignore-duplicates* *input-map* completing-read input-delete-region input-goto-char input-insert-char input-insert-string input-point input-substring input-validate-region read-one-char read-one-line)) (defstruct input-line string position history history-bk) (defvar *input-map* nil "This is the keymap containing all input editing key bindings.") (when (null *input-map*) (setf *input-map* (let ((map (make-sparse-keymap))) (define-key map (kbd "DEL") 'input-delete-backward-char) (define-key map (kbd "M-DEL") 'input-backward-kill-word) (define-key map (kbd "C-d") 'input-delete-forward-char) (define-key map (kbd "M-d") 'input-forward-kill-word) (define-key map (kbd "Delete") 'input-delete-forward-char) (define-key map (kbd "C-f") 'input-forward-char) (define-key map (kbd "Right") 'input-forward-char) (define-key map (kbd "M-f") 'input-forward-word) (define-key map (kbd "C-b") 'input-backward-char) (define-key map (kbd "Left") 'input-backward-char) (define-key map (kbd "M-b") 'input-backward-word) (define-key map (kbd "C-a") 'input-move-beginning-of-line) (define-key map (kbd "Home") 'input-move-beginning-of-line) (define-key map (kbd "C-e") 'input-move-end-of-line) (define-key map (kbd "End") 'input-move-end-of-line) (define-key map (kbd "C-k") 'input-kill-line) (define-key map (kbd "C-u") 'input-kill-to-beginning) (define-key map (kbd "C-p") 'input-history-back) (define-key map (kbd "Up") 'input-history-back) (define-key map (kbd "C-n") 'input-history-forward) (define-key map (kbd "Down") 'input-history-forward) (define-key map (kbd "RET") 'input-submit) (define-key map (kbd "C-g") 'input-abort) (define-key map (kbd "ESC") 'input-abort) (define-key map (kbd "C-y") 'input-yank-selection) (define-key map (kbd "TAB") 'input-complete-forward) (define-key map (kbd "ISO_Left_Tab") 'input-complete-backward) (define-key map t 'input-self-insert) map))) (defvar *input-history* nil "History for the input line.") (defvar *input-last-command* nil "The last input command.") (defvar *input-completions* nil "The list of completions") (defvar *input-current-completions* nil "The list of matching completions.") (defvar *input-current-completions-idx* nil "The current index in the current completions list.") (defvar *input-history-ignore-duplicates* nil "Do not add a command to the input history if it's already the first in the list.") ;;; keysym functions (defun is-modifier (keycode) "Return t if keycode is a modifier" (or (find keycode *all-modifiers* :test 'eql) ;; Treat No Symbol keys as modifiers (and therefore ignorable) (= (xlib:keycode->keysym *display* keycode 0) 0))) (defun keycode->character (code mods) (let ((idx (if (member :shift mods) 1 0))) (xlib:keysym->character *display* (xlib:keycode->keysym *display* code idx) 0))) ;;; line and key reading functions (defun setup-input-window (screen prompt input) "Set the input window up to read input" (let* ((height (+ (xlib:font-descent (screen-font screen)) (xlib:font-ascent (screen-font screen)))) (win (screen-input-window screen))) ;; Window dimensions (xlib:with-state (win) (setf (xlib:window-priority win) :above (xlib:drawable-height win) height)) (xlib:map-window win) ;; Draw the prompt (draw-input-bucket screen prompt input) ;; Ready to recieve input )) (defun shutdown-input-window (screen) (xlib:ungrab-keyboard *display*) (xlib:unmap-window (screen-input-window screen))) (defun input-handle-key-press-event (&rest event-slots &key event-key root code state &allow-other-keys) (declare (ignore event-slots root)) ;; FIXME: don't use a cons (list* event-key code state)) (defun input-handle-selection-event (&key window selection property &allow-other-keys) (declare (ignore selection)) (if property (xlib:get-property window property :type :string :result-type 'string :transform #'xlib:card8->char :delete-p t) "")) (defun read-key-handle-event (&rest event-slots &key display event-key &allow-other-keys) (declare (ignore display)) (case event-key ((or :key-release :key-press) (apply 'input-handle-key-press-event event-slots)) (t nil))) (defun read-key-or-selection-handle-event (&rest event-slots &key display event-key &allow-other-keys) (declare (ignore display)) (case event-key ((or :key-release :key-press) (apply 'input-handle-key-press-event event-slots)) (:selection-notify (apply 'input-handle-selection-event event-slots)) (t nil))) (defun read-key () "Return a dotted pair (code . state) key." (loop for ev = (xlib:process-event *display* :handler #'read-key-handle-event :timeout nil) do (when (and (consp ev) (eq (first ev) :key-press)) (return (cdr ev))))) (defun read-key-no-modifiers () "Like read-key but never returns a modifier key." (loop for k = (read-key) while (is-modifier (car k)) finally (return k))) (defun read-key-or-selection () (loop for ev = (xlib:process-event *display* :handler #'read-key-or-selection-handle-event :timeout nil) do (cond ((stringp ev) (return ev)) ((and (consp ev) (eq (first ev) :key-press)) (return (cdr ev)))))) (defun make-input-string (initial-input) (make-array (length initial-input) :element-type 'character :initial-contents initial-input :adjustable t :fill-pointer t)) (defun completing-read (screen prompt completions &key (initial-input "") require-match) "Read a line of input through stumpwm and return it with TAB completion. completions can be a list, an fbound symbol, or a function. if its an fbound symbol or a function then that function is passed the substring to complete on and is expected to return a list of matches. If require-match argument is non-nil then the input must match with an element of the completions." (check-type completions (or list function symbol)) (let ((*input-completions* completions) (*input-current-completions* nil) (*input-current-completions-idx* nil)) (let ((line (read-one-line screen prompt :initial-input initial-input :require-match require-match))) (when line (string-trim " " line))))) (defun read-one-line (screen prompt &key (initial-input "") require-match) "Read a line of input through stumpwm and return it. returns nil if the user aborted." (let ((*input-last-command* nil) (input (make-input-line :string (make-input-string initial-input) :position (length initial-input) :history -1))) (labels ((match-input () (let* ((in (string-trim " " (input-line-string input))) (compls (input-find-completions in *input-completions*))) (and (consp compls) (string= in (car compls))))) (key-loop () (loop for key = (read-key-or-selection) do (cond ((stringp key) ;; handle selection (input-insert-string input key) (draw-input-bucket screen prompt input)) ;; skip modifiers ((is-modifier (car key))) ((process-input screen prompt input (car key) (cdr key)) (if (or (not require-match) (match-input)) (return (input-line-string input)) (draw-input-bucket screen prompt input "[No match]" t))))))) (setup-input-window screen prompt input) (catch :abort (unwind-protect (with-focus (screen-input-window screen) (key-loop)) (shutdown-input-window screen)))))) (defun read-one-char (screen) "Read a single character from the user." (with-focus (screen-key-window screen) (let ((k (read-key-no-modifiers))) (keycode->character (car k) (xlib:make-state-keys (cdr k)))))) (defun draw-input-bucket (screen prompt input &optional (tail "") errorp) "Draw to the screen's input window the contents of input." (let* ((gcontext (screen-message-gc screen)) (win (screen-input-window screen)) (prompt-width (xlib:text-width (screen-font screen) prompt :translate #'translate-id)) (string (input-line-string input)) (string-width (xlib:text-width (screen-font screen) string :translate #'translate-id)) (space-width (xlib:text-width (screen-font screen) " " :translate #'translate-id)) (tail-width (xlib:text-width (screen-font screen) tail :translate #'translate-id)) (full-string-width (+ string-width space-width)) (pos (input-line-position input)) (width (+ prompt-width (max 100 (+ full-string-width space-width tail-width))))) (xlib:with-state (win) (xlib:clear-area win :x (+ *message-window-padding* prompt-width string-width)) (setf (xlib:drawable-width win) (+ width (* *message-window-padding* 2))) (setup-win-gravity screen win *input-window-gravity*)) (xlib:with-state (win) (xlib:draw-image-glyphs win gcontext *message-window-padding* (xlib:font-ascent (screen-font screen)) prompt :translate #'translate-id :size 16) (xlib:draw-image-glyphs win gcontext (+ *message-window-padding* prompt-width) (xlib:font-ascent (screen-font screen)) string :translate #'translate-id :size 16) (xlib:draw-image-glyphs win gcontext (+ *message-window-padding* prompt-width full-string-width space-width) (xlib:font-ascent (screen-font screen)) tail :translate #'translate-id :size 16) ;; draw a block cursor (invert-rect screen win (+ *message-window-padding* prompt-width (xlib:text-width (screen-font screen) (subseq string 0 pos) :translate #'translate-id)) 0 (xlib:text-width (screen-font screen) (if (>= pos (length string)) " " (string (char string pos))) :translate #'translate-id) (+ (xlib:font-descent (screen-font screen)) (xlib:font-ascent (screen-font screen)))) ;; draw the error (when errorp (invert-rect screen win 0 0 (xlib:drawable-width win) (xlib:drawable-height win)) (xlib:display-force-output *display*) (sleep 0.05) (invert-rect screen win 0 0 (xlib:drawable-width win) (xlib:drawable-height win)))))) (defun code-state->key (code state) (let* ((mods (xlib:make-state-keys state)) (shift-p (and (find :shift mods) t)) (altgr-p (and (intersection (modifiers-altgr *modifiers*) mods) t)) (base (if altgr-p 2 0)) (sym (xlib:keycode->keysym *display* code base)) (upsym (xlib:keycode->keysym *display* code (+ base 1)))) ;; If a keysym has a shift modifier, then use the uppercase keysym ;; and remove remove the shift modifier. (make-key :keysym (if (and shift-p (not (eql sym upsym))) upsym sym) :control (and (find :control mods) t) :shift (and shift-p (eql sym upsym)) :meta (and (intersection mods (modifiers-meta *modifiers*)) t) :alt (and (intersection mods (modifiers-alt *modifiers*)) t) :hyper (and (intersection mods (modifiers-hyper *modifiers*)) t) :super (and (intersection mods (modifiers-super *modifiers*)) t)))) ;;; input string utility functions (defun input-submit (input key) (declare (ignore input key)) :done) (defun input-abort (input key) (declare (ignore input key)) (throw :abort nil)) (defun input-goto-char (input point) "Move the cursor to the specified point in the string" (setf (input-line-position input) (min (max 0 point) (length (input-line-string input))))) (defun input-insert-string (input string) "Insert @var{string} into the input at the current position. @var{input} must be of type @var{input-line}. Input functions are passed this structure as their first argument." (check-type string string) (loop for c across string do (input-insert-char input c))) (defun input-point (input) "Return the position of the cursor." (check-type input input-line) (input-line-position input)) (defun input-validate-region (input start end) "Return a value pair of numbers where the first number is < the second and neither excedes the bounds of the input string." (values (max 0 (min start end)) (min (length (input-line-string input)) (max start end)))) (defun input-delete-region (input start end) "Delete the region between start and end in the input string" (check-type input input-line) (check-type start fixnum) (check-type end fixnum) (multiple-value-setq (start end) (input-validate-region input start end)) (replace (input-line-string input) (input-line-string input) :start2 end :start1 start) (decf (fill-pointer (input-line-string input)) (- end start)) (cond ((< (input-line-position input) start)) ((< (input-line-position input) end) (setf (input-line-position input) start)) (t (decf (input-line-position input) (- end start))))) (defun input-insert-char (input char) "Insert @var{char} into the input at the current position. @var{input} must be of type @var{input-line}. Input functions are passed this structure as their first argument." (vector-push-extend #\_ (input-line-string input)) (replace (input-line-string input) (input-line-string input) :start2 (input-line-position input) :start1 (1+ (input-line-position input))) (setf (char (input-line-string input) (input-line-position input)) char) (incf (input-line-position input))) (defun input-substring (input start end) "Return a the substring in INPUT bounded by START and END." (subseq (input-line-string input) start end)) ;;; "interactive" input functions (defun input-find-completions (str completions) (if (or (functionp completions) (and (symbolp completions) (fboundp completions))) (funcall completions str) (remove-if-not (lambda (elt) (when (listp elt) (setf elt (car elt))) (and (<= (length str) (length elt)) (string= str elt :end1 (length str) :end2 (length str)))) completions))) (defun input-complete (input direction) ;; reset the completion list if this is the first time they're ;; trying to complete. (unless (find *input-last-command* '(input-complete-forward input-complete-backward)) (setf *input-current-completions* (input-find-completions (input-substring input 0 (input-point input)) *input-completions*) *input-current-completions-idx* -1)) (if *input-current-completions* (progn ;; Insert the next completion (input-delete-region input 0 (input-point input)) (if (eq direction :forward) (progn (incf *input-current-completions-idx*) (when (>= *input-current-completions-idx* (length *input-current-completions*)) (setf *input-current-completions-idx* 0))) (progn (decf *input-current-completions-idx*) (when (< *input-current-completions-idx* 0) (setf *input-current-completions-idx* (1- (length *input-current-completions*)))))) (let ((elt (nth *input-current-completions-idx* *input-current-completions*))) (input-insert-string input (if (listp elt) (first elt) elt)) (input-insert-char input #\Space))) :error)) (defun input-complete-forward (input key) (declare (ignore key)) (input-complete input :forward)) (defun input-complete-backward (input key) (declare (ignore key)) (input-complete input :backward)) (defun input-delete-backward-char (input key) (declare (ignore key)) (let ((pos (input-line-position input))) (cond ((or (<= (length (input-line-string input)) 0) (<= pos 0)) :error) (t (replace (input-line-string input) (input-line-string input) :start2 pos :start1 (1- pos)) (decf (fill-pointer (input-line-string input))) (decf (input-line-position input)))))) (defun input-delete-forward-char (input key) (declare (ignore key)) (let ((pos (input-line-position input))) (cond ((>= pos (length (input-line-string input))) :error) (t (replace (input-line-string input) (input-line-string input) :start1 pos :start2 (1+ pos)) (decf (fill-pointer (input-line-string input))))))) (defun input-forward-kill-word (input key) (declare (ignore key)) (let* ((p1 (position-if 'alphanumericp (input-line-string input) :start (input-line-position input))) (p2 (and p1 (position-if-not 'alphanumericp (input-line-string input) :start p1)))) (input-delete-region input (input-point input) (or p2 (length (input-line-string input)))))) (defun input-backward-kill-word (input key) (declare (ignore key)) (let* ((p1 (position-if 'alphanumericp (input-line-string input) :end (input-line-position input) :from-end t)) (p2 (and p1 (position-if-not 'alphanumericp (input-line-string input) :end p1 :from-end t)))) (input-delete-region input (input-point input) (or (and p2 (1+ p2)) 0)))) (defun input-forward-word (input key) (declare (ignore key)) (let* ((p1 (position-if 'alphanumericp (input-line-string input) :start (input-line-position input))) (p2 (and p1 (position-if-not 'alphanumericp (input-line-string input) :start p1)))) (setf (input-line-position input) (or p2 (length (input-line-string input)))))) (defun input-backward-word (input key) (declare (ignore key)) (let* ((p1 (position-if 'alphanumericp (input-line-string input) :end (input-line-position input) :from-end t)) (p2 (and p1 (position-if-not 'alphanumericp (input-line-string input) :end p1 :from-end t)))) (setf (input-line-position input) (or (and p2 (1+ p2)) 0)))) (defun input-forward-char (input key) (declare (ignore key)) (incf (input-line-position input)) (when (> (input-line-position input) (length (input-line-string input))) (setf (input-line-position input) (length (input-line-string input))))) (defun input-backward-char (input key) (declare (ignore key)) (decf (input-line-position input)) (when (< (input-line-position input) 0) (setf (input-line-position input) 0))) (defun input-move-beginning-of-line (input key) (declare (ignore key)) (setf (input-line-position input) 0)) (defun input-move-end-of-line (input key) (declare (ignore key)) (setf (input-line-position input) (length (input-line-string input)))) (defun input-kill-line (input key) (declare (ignore key)) (unless (= (input-line-position input) (length (input-line-string input))) (set-x-selection (subseq (input-line-string input) (input-line-position input)))) (setf (fill-pointer (input-line-string input)) (input-line-position input))) (defun input-kill-to-beginning (input key) (declare (ignore key)) (unless (= (input-line-position input) 0) (set-x-selection (subseq (input-line-string input) 0 (input-line-position input)))) (replace (input-line-string input) (input-line-string input) :start2 (input-line-position input) :start1 0) (decf (fill-pointer (input-line-string input)) (input-line-position input)) (setf (input-line-position input) 0)) (defun input-history-back (input key) (declare (ignore key)) (when (= (input-line-history input) -1) (setf (input-line-history-bk input) (input-line-string input))) (incf (input-line-history input)) (if (>= (input-line-history input) (length *input-history*)) (progn (decf (input-line-history input)) :error) (setf (input-line-string input) (make-input-string (elt *input-history* (input-line-history input))) (input-line-position input) (length (input-line-string input))))) (defun input-history-forward (input key) (declare (ignore key)) (decf (input-line-history input)) (cond ((< (input-line-history input) -1) (incf (input-line-history input)) :error) ((= (input-line-history input) -1) (setf (input-line-string input) (input-line-history-bk input) (input-line-position input) (length (input-line-string input)))) (t (setf (input-line-string input) (make-input-string (elt *input-history* (input-line-history input))) (input-line-position input) (length (input-line-string input)))))) (defun input-self-insert (input key) (let ((char (xlib:keysym->character *display* (key-keysym key)))) (if (or (key-mods-p key) (null char) (not (characterp char))) :error (input-insert-char input char)))) (defun input-yank-selection (input key) (declare (ignore key)) ;; if we own the selection then just insert it. (if *x-selection* (input-insert-string input *x-selection*) (xlib:convert-selection :primary :string (screen-input-window (current-screen)) :stumpwm-selection))) ;;; Misc functions (defun process-input (screen prompt input code state) "Process the key (code and state), given the current input buffer. Returns a new modified input buffer." (labels ((process-key (code state) "Call the appropriate function based on the key pressed. Return 'done when the use has signalled the finish of his input (pressing Return), nil otherwise." (let* ((key (code-state->key code state)) (command (and key (lookup-key *input-map* key t)))) (if command (prog1 (funcall command input key) (setf *input-last-command* command)) :error)))) (case (process-key code state) (:done (unless (and *input-history-ignore-duplicates* (string= (input-line-string input) (first *input-history*))) (push (input-line-string input) *input-history*)) :done) (:abort (throw :abort t)) (:error ;; FIXME draw inverted text (draw-input-bucket screen prompt input "" t) nil) (t (draw-input-bucket screen prompt input) nil)))) (defun all-modifier-codes () (multiple-value-bind (shift-codes lock-codes control-codes mod1-codes mod2-codes mod3-codes mod4-codes mod5-codes) (xlib:modifier-mapping *display*) (append shift-codes lock-codes control-codes mod1-codes mod2-codes mod3-codes mod4-codes mod5-codes))) (defun get-modifier-map () (labels ((find-mod (mod codes) (find mod (mapcar (lambda (code) (keysym->keysym-name (xlib:keycode->keysym *display* code 0))) codes) :test 'string=))) (let ((modifiers (make-modifiers))) (multiple-value-bind (shift-codes lock-codes control-codes mod1-codes mod2-codes mod3-codes mod4-codes mod5-codes) (xlib:modifier-mapping *display*) (declare (ignore shift-codes lock-codes control-codes)) (loop for mod in '(:mod-1 :mod-2 :mod-3 :mod-4 :mod-5) for codes in (list mod1-codes mod2-codes mod3-codes mod4-codes mod5-codes) do (cond ((or (find-mod "Meta_L" codes) (find-mod "Meta_R" codes)) (push mod (modifiers-meta modifiers))) ((or (find-mod "Alt_L" codes) (find-mod "Alt_R" codes)) (push mod (modifiers-alt modifiers))) ((or (find-mod "Super_L" codes) (find-mod "Super_R" codes)) (push mod (modifiers-super modifiers))) ((or (find-mod "Hyper_L" codes) (find-mod "Hyper_R" codes)) (push mod (modifiers-hyper modifiers))) ((find-mod "Num_Lock" codes) (push mod (modifiers-numlock modifiers))) ((find-mod "ISO_Level3_Shift" codes) (push mod (modifiers-altgr modifiers))))) ;; If alt is defined but meta isn't set meta to alt and clear alt (when (and (modifiers-alt modifiers) (null (modifiers-meta modifiers))) (setf (modifiers-meta modifiers) (modifiers-alt modifiers) (modifiers-alt modifiers) nil)) modifiers)))) (defun update-modifier-map () (setf *modifiers* (get-modifier-map) *all-modifiers* (all-modifier-codes))) ;; (defun x11mod->stumpmod (screen state) ;; (let ((mod nil)) ;; (when (member state (modifiers-alt (screen-modifiers screen))) ;; (push :alt mod)) ;; (when (member state (modifiers-meta (screen-modifiers screen))) ;; (push :meta mod)) ;; (when (member state (modifiers-hyper (screen-modifiers screen))) ;; (push :hyper mod)) ;; (when (member state (modifiers-super (screen-modifiers screen))) ;; (push :super mod)) ;; (when (member state :control) ;; (push :control mod)) ;; mod)) (defun mod->string (state) "Convert a stump modifier list to a string" (let ((alist '((:alt . "A-") (:meta . "M-") (:hyper . "H-") (:super . "S-")))) (apply #'concatenate 'string (mapcar (lambda (x) (cdr (assoc x alist))) state)))) ;; (defun keycode->string (code state) ;; (concatenate 'string (mod->string state) ;; (string (keysym->character *display* ;; (xlib:keycode->keysym *display* code 0) ;; state)))) ;; (defun cook-keycode (code state) ;; (values (xlib:keycode->keysym *display* code 0) (x11mod->stumpmod state))) (defun y-or-n-p (message) "ask a \"y or n\" question on the current screen and return T if the user presses 'y'" (message "~a(y or n) " message) (char= (read-one-char (current-screen)) #\y)) (defun yes-or-no-p (message) "ask a \"yes or no\" question on the current screen and return T if the user presses 'yes'" (loop for line = (read-one-line (current-screen) (format nil "~a(yes or no) " message)) until (find line '("yes" "no") :test 'string-equal) do (message "Please answer yes or no") (sleep 1) finally (return (string-equal line "yes"))))
29,052
Common Lisp
.lisp
603
39.140962
128
0.613405
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
398c87f315654dbc9705719ff0e70f282e77601631459e8556a354371e6fb0ee
7,257
[ -1 ]
7,258
tile-group.lisp
blitz_stumpwm/tile-group.lisp
;; Copyright (C) 2003-2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;; Commentary: ;; ;; Frame functions ;; ;; Code: (in-package #:stumpwm) (export '(save-frame-excursion)) (defclass tile-group (group) ((frame-tree :accessor tile-group-frame-tree) (last-frame :initform nil :accessor tile-group-last-frame) (current-frame :accessor tile-group-current-frame))) (defmethod initialize-instance :after ((group tile-group) &key &allow-other-keys) (let* ((heads (copy-heads (group-screen group)))) (setf (tile-group-frame-tree group) heads (tile-group-current-frame group) (first heads)))) (defmethod group-wake-up ((group tile-group)) (focus-frame group (tile-group-current-frame group)) ;; doesn't get called by focus-frame (show-frame-indicator group)) (defmethod group-delete-window ((group tile-group) window) (let ((f (window-frame window))) ;; maybe pick a new window for the old frame (when (eq (frame-window f) window) (frame-raise-window group f (first (frame-windows group f)) nil)))) (defmethod group-add-window ((group tile-group) window &key frame raise &allow-other-keys) ;; This is important to get the frame slot (change-class window 'tile-window) ;; Try to put the window in the appropriate frame for the group. (setf (window-frame window) (or frame (when *processing-existing-windows* (find-frame group (xlib:drawable-x (window-parent window)) (xlib:drawable-y (window-parent window)))) (pick-preferred-frame window))) (when *processing-existing-windows* (setf (frame-window (window-frame window)) window)) (when (and frame raise) (setf (tile-group-current-frame group) frame (frame-window frame) nil)) (sync-frame-windows group (window-frame window)) ;; maybe show the window in its new frame (when (null (frame-window (window-frame window))) (really-raise-window window))) (defmethod group-current-window ((group tile-group)) (frame-window (tile-group-current-frame group))) (defmethod group-current-head ((group tile-group)) (frame-head group (tile-group-current-frame group))) (defmethod group-move-request ((group tile-group) window x y relative-to) (when *honor-window-moves* (dformat 3 "Window requested new position ~D,~D relative to ~S~%" x y relative-to) (let* ((pos (if (eq relative-to :parent) (list (+ (xlib:drawable-x (window-parent window)) x) (+ (xlib:drawable-y (window-parent window)) y)) (list x y))) (frame (apply #'find-frame group pos))) (when frame (pull-window window frame))))) (defmethod group-resize-request ((group tile-group) window width height) ;; it's important to grant the resize request first so that resize ;; increment hints use the proper base size to resize from. (set-window-geometry window :width width :height height) (maximize-window window)) (defmethod group-raise-request ((group tile-group) window stack-mode) (when (window-in-current-group-p window) (case stack-mode (:map (maybe-map-window window)) (:above (maybe-raise-window window))))) (defmethod group-lost-focus ((group tile-group)) ;; If this window had the focus, try to avoid losing it. (let ((frame (tile-group-current-frame group))) (setf (frame-window frame) (first (remove-if 'window-hidden-p (frame-windows group frame)))) (focus-frame group frame))) (defmethod group-indicate-focus ((group tile-group)) (show-frame-indicator group)) (defmethod group-focus-window ((group tile-group) win) (frame-raise-window group (window-frame win) win)) (defmethod group-button-press ((group tile-group) x y (where (eql :root))) (when (and (eq *mouse-focus-policy* :click) *root-click-focuses-frame*) (let* ((frame (find-frame group x y))) (when frame (focus-frame group frame) (update-all-mode-lines))))) (defmethod group-button-press ((group tile-group) x y (where window)) (declare (ignore x y)) (when (eq *mouse-focus-policy* :click) (focus-all where) (update-all-mode-lines))) (defmethod group-root-exposure ((group tile-group)) (show-frame-outline group nil)) (defmethod group-add-head ((group tile-group)) (sync-all-frame-windows group)) (defmethod group-sync-head ((group tile-group) head) (dolist (f (head-frames group head)) (sync-frame-windows group f))) ;;;;; (defun populate-frames (group) "Try to fill empty frames in GROUP with hidden windows" (dolist (f (group-frames group)) (unless (frame-window f) (choose-new-frame-window f group) (when (frame-window f) (maximize-window (frame-window f)) (unhide-window (frame-window f)))))) (defun frame-by-number (group n) (unless (eq n nil) (find n (group-frames group) :key 'frame-number :test '=))) (defun find-frame (group x y) "Return the frame of GROUP containing the pixel at X Y" (dolist (f (group-frames group)) (let* ((fy (frame-y f)) (fx (frame-x f)) (fwx (+ fx (frame-width f))) (fhy (+ fy (frame-height f)))) (when (and (>= y fy) (<= y fhy) (>= x fx) (<= x fwx) (return f)))))) (defun frame-set-x (frame v) (decf (frame-width frame) (- v (frame-x frame))) (setf (frame-x frame) v)) (defun frame-set-y (frame v) (decf (frame-height frame) (- v (frame-y frame))) (setf (frame-y frame) v)) (defun frame-set-r (frame v) (setf (frame-width frame) (- v (frame-x frame)))) (defun frame-set-b (frame v) (setf (frame-height frame) (- v (frame-y frame)))) (defun frame-r (frame) (+ (frame-x frame) (frame-width frame))) (defun frame-b (frame) (+ (frame-y frame) (frame-height frame))) (defun frame-display-y (group frame) "Return a Y for frame that doesn't overlap the mode-line." (let* ((head (frame-head group frame)) (ml (head-mode-line head)) (head-y (frame-y head)) (rel-frame-y (- (frame-y frame) head-y))) (if (and ml (not (eq (mode-line-mode ml) :hidden))) (case (mode-line-position ml) (:top (+ head-y (+ (mode-line-height ml) (round (* rel-frame-y (mode-line-factor ml)))))) (:bottom (+ head-y (round (* rel-frame-y (mode-line-factor ml)))))) (frame-y frame)))) (defun frame-display-height (group frame) "Return a HEIGHT for frame that doesn't overlap the mode-line." (let* ((head (frame-head group frame)) (ml (head-mode-line head))) (if (and ml (not (eq (mode-line-mode ml) :hidden))) (round (* (frame-height frame) (mode-line-factor ml))) (frame-height frame)))) (defun frame-intersect (f1 f2) "Return a new frame representing (only) the intersection of F1 and F2. WIDTH and HEIGHT will be <= 0 if there is no overlap" (let ((r (copy-frame f1))) (when (> (frame-x f2) (frame-x f1)) (frame-set-x r (frame-x f2))) (when (< (+ (frame-x f2) (frame-width f2)) (+ (frame-x f1) (frame-width f1))) (frame-set-r r (frame-r f2))) (when (> (frame-y f2) (frame-y f1)) (frame-set-y r (frame-y f2))) (when (< (+ (frame-y f2) (frame-height f2)) (+ (frame-y f1) (frame-height f1))) (frame-set-b r (frame-b f2))) (values r))) (defun frames-overlap-p (f1 f2) "Returns T if frames F1 and F2 overlap at all" (check-type f1 frame) (check-type f2 frame) (and (and (frame-p f1) (frame-p f2)) (let ((frame (frame-intersect f1 f2))) (values (and (plusp (frame-width frame)) (plusp (frame-height frame))))))) (defun frame-raise-window (g f w &optional (focus t)) "Raise the window w in frame f in group g. if FOCUS is T (default) then also focus the frame." (let ((oldw (frame-window f))) ;; nothing to do when W is nil (setf (frame-window f) w) (unless (and w (eq oldw w)) (if w (raise-window w) (mapc 'hide-window (frame-windows g f)))) ;; If raising a window in the current frame we must focus it or ;; the group and screen will get out of sync. (when (or focus (eq (tile-group-current-frame g) f)) (focus-frame g f)) (when (and w (not (window-modal-p w))) (raise-modals-of w)))) (defun focus-frame (group f) (let ((w (frame-window f)) (last (tile-group-current-frame group)) (show-indicator nil)) (setf (tile-group-current-frame group) f) ;; record the last frame to be used in the fother command. (unless (eq f last) (setf (tile-group-last-frame group) last) (run-hook-with-args *focus-frame-hook* f last) (setf show-indicator t)) (if w (focus-window w) (no-focus group (frame-window last))) (if show-indicator (show-frame-indicator group) (show-frame-outline group)))) (defun frame-windows (group f) (remove-if-not (lambda (w) (eq (window-frame w) f)) (group-windows group))) (defun frame-sort-windows (group f) (remove-if-not (lambda (w) (eq (window-frame w) f)) (sort-windows group))) (defun copy-frame-tree (tree) "Return a copy of the frame tree." (cond ((null tree) tree) ((typep tree 'frame) (copy-structure tree)) (t (mapcar #'copy-frame-tree tree)))) (defun group-frames (group) (tree-accum-fn (tile-group-frame-tree group) 'nconc 'list)) (defun head-frames (group head) (tree-accum-fn (tile-group-frame-head group head) 'nconc 'list)) (defun find-free-frame-number (group) (find-free-number (mapcar 'frame-number (group-frames group)))) (defun choose-new-frame-window (frame group) "Find out what window should go in a newly created frame." (let ((win (case *new-frame-action* (:last-window (other-hidden-window group)) (t nil)))) (setf (frame-window frame) win) (when win (setf (window-frame win) frame)))) (defun split-frame-h (group p ratio) "Return 2 new frames. The first one stealing P's number and window" (let* ((w (truncate (* (frame-width p) ratio))) (h (frame-height p)) (f1 (make-frame :number (frame-number p) :x (frame-x p) :y (frame-y p) :width w :height h :window (frame-window p))) (f2 (make-frame :number (find-free-frame-number group) :x (+ (frame-x p) w) :y (frame-y p) ;; gobble up the modulo :width (- (frame-width p) w) :height h :window nil))) (run-hook-with-args *new-frame-hook* f2) (values f1 f2))) (defun split-frame-v (group p ratio) "Return 2 new frames. The first one stealing P's number and window" (let* ((w (frame-width p)) (h (truncate (* (frame-height p) ratio))) (f1 (make-frame :number (frame-number p) :x (frame-x p) :y (frame-y p) :width w :height h :window (frame-window p))) (f2 (make-frame :number (find-free-frame-number group) :x (frame-x p) :y (+ (frame-y p) h) :width w ;; gobble up the modulo :height (- (frame-height p) h) :window nil))) (run-hook-with-args *new-frame-hook* f2) (values f1 f2))) (defun funcall-on-leaf (tree leaf fn) "Return a new tree with LEAF replaced with the result of calling FN on LEAF." (cond ((atom tree) (if (eq leaf tree) (funcall fn leaf) tree)) (t (mapcar (lambda (sib) (funcall-on-leaf sib leaf fn)) tree)))) (defun funcall-on-node (tree fn match) "Call fn on the node where match returns t." (if (funcall match tree) (funcall fn tree) (cond ((atom tree) tree) (t (mapcar (lambda (sib) (funcall-on-node sib fn match)) tree))))) (defun replace-frame-in-tree (tree f &rest frames) (funcall-on-leaf tree f (lambda (f) (declare (ignore f)) frames))) (defun sibling-internal (tree leaf fn) "helper for next-sibling and prev-sibling." (cond ((atom tree) nil) ((find leaf tree) (let* ((rest (cdr (member leaf (funcall fn tree)))) (pick (car (if (null rest) (funcall fn tree) rest)))) (unless (eq pick leaf) pick))) (t (find-if (lambda (x) (sibling-internal x leaf fn)) tree)))) (defun next-sibling (tree leaf) "Return the sibling of LEAF in TREE." (sibling-internal tree leaf 'identity)) (defun prev-sibling (tree leaf) (sibling-internal tree leaf 'reverse)) (defun closest-sibling (tree leaf) "Return the sibling to the right/below of leaf or left/above if leaf is the most right/below of its siblings." (let* ((parent (tree-parent tree leaf)) (lastp (= (position leaf parent) (1- (length parent))))) (if lastp (prev-sibling parent leaf) (next-sibling parent leaf)))) (defun migrate-frame-windows (group src dest) "Migrate all windows in SRC frame to DEST frame." (mapc (lambda (w) (when (eq (window-frame w) src) (setf (window-frame w) dest))) (group-windows group))) (defun tree-accum-fn (tree acc fn) "Run an accumulator function on fn applied to each leaf" (cond ((null tree) nil) ((atom tree) (funcall fn tree)) (t (apply acc (mapcar (lambda (x) (tree-accum-fn x acc fn)) tree))))) (defun tree-iterate (tree fn) "Call FN on every leaf in TREE" (cond ((null tree) nil) ((atom tree) (funcall fn tree)) (t (mapc (lambda (x) (tree-iterate x fn)) tree)))) (defun tree-x (tree) (tree-accum-fn tree 'min 'frame-x)) (defun tree-y (tree) (tree-accum-fn tree 'min 'frame-y)) (defun tree-width (tree) (cond ((atom tree) (frame-width tree)) ((tree-row-split tree) ;; in row splits, all children have the same width, so use the ;; first one. (tree-width (first tree))) (t ;; for column splits we add the width of each child (reduce '+ tree :key 'tree-width)))) (defun tree-height (tree) (cond ((atom tree) (frame-height tree)) ((tree-column-split tree) ;; in row splits, all children have the same width, so use the ;; first one. (tree-height (first tree))) (t ;; for column splits we add the width of each child (reduce '+ tree :key 'tree-height)))) (defun tree-parent (top node) "Return the list in TOP that contains NODE." (cond ((atom top) nil) ((find node top) top) (t (loop for i in top thereis (tree-parent i node))))) (defun tree-leaf (top) "Return a leaf of the tree. Use this when you need a leaf but you don't care which one." (tree-accum-fn top (lambda (&rest siblings) (car siblings)) #'identity)) (defun tree-row-split (tree) "Return t if the children of tree are stacked vertically" (loop for i in (cdr tree) with head = (car tree) always (= (tree-x head) (tree-x i)))) (defun tree-column-split (tree) "Return t if the children of tree are side-by-side" (loop for i in (cdr tree) with head = (car tree) always (= (tree-y head) (tree-y i)))) (defun tree-split-type (tree) "return :row or :column" (cond ((tree-column-split tree) :column) ((tree-row-split tree) :row) (t (error "tree-split-type unknown")))) (defun offset-tree (tree x y) "move the screen's frames around." (tree-iterate tree (lambda (frame) (incf (frame-x frame) x) (incf (frame-y frame) y)))) (defun offset-tree-dir (tree amount dir) (ecase dir (:left (offset-tree tree (- amount) 0)) (:right (offset-tree tree amount 0)) (:top (offset-tree tree 0 (- amount))) (:bottom (offset-tree tree 0 amount)))) (defun expand-tree (tree amount dir) "expand the frames in tree by AMOUNT in DIR direction. DIR can be :top :bottom :left :right" (labels ((expand-frame (f amount dir) (ecase dir (:left (decf (frame-x f) amount) (incf (frame-width f) amount)) (:right (incf (frame-width f) amount)) (:top (decf (frame-y f) amount) (incf (frame-height f) amount)) (:bottom (incf (frame-height f) amount))))) (cond ((null tree) nil) ((atom tree) (expand-frame tree amount dir)) ((or (and (find dir '(:left :right)) (tree-row-split tree)) (and (find dir '(:top :bottom)) (tree-column-split tree))) (dolist (i tree) (expand-tree i amount dir))) (t (let* ((children (if (find dir '(:left :top)) (reverse tree) tree)) (sz-fn (if (find dir '(:left :right)) 'tree-width 'tree-height)) (total (funcall sz-fn tree)) (amt-list (loop for i in children for old-sz = (funcall sz-fn i) collect (floor (* amount old-sz) total))) (remainder (- amount (apply '+ amt-list))) (ofs 0)) ;; spread the remainder out as evenly as possible (assert (< remainder (length amt-list))) (loop for i upfrom 0 while (> remainder 0) do (incf (nth i amt-list)) (decf remainder)) ;; resize proportionally (loop for i in children for amt in amt-list do (expand-tree i amt dir) (offset-tree-dir i ofs dir) (incf ofs amt))))))) (defun join-subtrees (tree leaf) "expand the children of tree to occupy the space of LEAF. Return tree with leaf removed." (let* ((others (remove leaf tree)) (newtree (if (= (length others) 1) (car others) others)) (split-type (tree-split-type tree)) (dir (if (eq split-type :column) :right :bottom)) (ofsdir (if (eq split-type :column) :left :top)) (amt (if (eq split-type :column) (tree-width leaf) (tree-height leaf))) (after (cdr (member leaf tree)))) ;; align all children after the leaf with the edge of the ;; frame before leaf. (offset-tree-dir after amt ofsdir) (expand-tree newtree amt dir) newtree)) (defun resize-tree (tree w h &optional (x (tree-x tree)) (y (tree-y tree))) "Scale TREE to width W and height H, ignoring aspect. If X and Y are provided, reposition the TREE as well." (let* ((tw (tree-width tree)) (th (tree-height tree)) (tx (tree-x tree)) (ty (tree-y tree)) (wf (/ w tw)) (hf (/ h th))) (tree-iterate tree (lambda (f) (setf (frame-height f) (round (* (frame-height f) hf)) (frame-y f) (+ (round (* (- (frame-y f) ty) hf)) y) (frame-width f) (round (* (frame-width f) wf)) (frame-x f) (+ (round (* (- (frame-x f) tx) wf)) x)))) (dformat 4 "resize-tree ~Dx~D -> ~Dx~D~%" tw th (tree-width tree) (tree-height tree)))) (defun remove-frame (tree leaf) "Return a new tree with LEAF and it's sibling merged into one." (cond ((atom tree) tree) ((find leaf tree) (join-subtrees tree leaf)) (t (mapcar (lambda (sib) (remove-frame sib leaf)) tree)))) (defun sync-frame-windows (group frame) "synchronize windows attached to FRAME." (mapc (lambda (w) (when (eq (window-frame w) frame) (dformat 3 "maximizing ~S~%" w) (maximize-window w))) (group-windows group))) (defun sync-all-frame-windows (group) "synchronize all frames in GROUP." (let ((tree (tile-group-frame-tree group))) (tree-iterate tree (lambda (f) (sync-frame-windows group f))))) (defun sync-head-frame-windows (group head) "synchronize all frames in GROUP and HEAD." (dolist (f (head-frames group head)) (sync-frame-windows group f))) (defun offset-frames (group x y) "move the screen's frames around." (let ((tree (tile-group-frame-tree group))) (tree-iterate tree (lambda (frame) (incf (frame-x frame) x) (incf (frame-y frame) y))))) (defun resize-frame (group frame amount dim) "Resize FRAME by AMOUNT in DIM dimension, DIM can be either :width or :height" (check-type group group) (check-type frame frame) (check-type amount integer) ;; (check-type dim (member :width :height)) (labels ((max-amount (parent node min dim-fn) (let ((right-sibling (cadr (member node parent))) (left-sibling (cadr (member node (reverse parent))))) (dformat 10 "max ~@{~a~^ ~}~%" parent node min dim-fn right-sibling left-sibling) (if parent (cond (right-sibling (max 0 (- (funcall dim-fn right-sibling) min))) (left-sibling (max 0 (- (funcall dim-fn left-sibling) min))) (t 0)) ;; no parent means the frame can't get any bigger. 0)))) (let* ((tree (tile-group-frame-tree group)) (parent (tree-parent tree frame)) (gparent (tree-parent tree parent)) (split-type (tree-split-type parent))) (dformat 10 "~s ~s parent: ~s ~s width: ~s h: ~s~%" dim amount split-type parent (tree-width parent) (tree-height parent)) ;; normalize amount (let* ((max (ecase dim (:width (if (>= (frame-width frame) (frame-width (frame-head group frame))) 0 (if (eq split-type :column) (max-amount parent frame *min-frame-width* 'tree-width) (max-amount gparent parent *min-frame-width* 'tree-width)))) (:height (if (>= (frame-height frame) (frame-height (frame-head group frame))) 0 (if (eq split-type :row) (max-amount parent frame *min-frame-height* 'tree-height) (max-amount gparent parent *min-frame-height* 'tree-height)))))) (min (ecase dim ;; Frames taking up the entire HEAD in one ;; dimension can't be resized in that dimension. (:width (if (and (eq split-type :row) (or (null gparent) (>= (frame-width frame) (frame-width (frame-head group frame))))) 0 (- *min-frame-width* (frame-width frame)))) (:height (if (and (eq split-type :column) (or (null gparent) (>= (frame-height frame) (frame-height (frame-head group frame))))) 0 (- *min-frame-height* (frame-height frame))))))) (setf amount (max (min amount max) min)) (dformat 10 "bounds ~d ~d ~d~%" amount max min)) ;; if FRAME is taking up the whole DIM or if AMOUNT = 0, do nothing (unless (zerop amount) (let* ((resize-parent (or (and (eq split-type :column) (eq dim :height)) (and (eq split-type :row) (eq dim :width)))) (to-resize (if resize-parent parent frame)) (to-resize-parent (if resize-parent gparent parent)) (lastp (= (position to-resize to-resize-parent) (1- (length to-resize-parent)))) (to-shrink (if lastp (prev-sibling to-resize-parent to-resize) (next-sibling to-resize-parent to-resize)))) (expand-tree to-resize amount (ecase dim (:width (if lastp :left :right)) (:height (if lastp :top :bottom)))) (expand-tree to-shrink (- amount) (ecase dim (:width (if lastp :right :left)) (:height (if lastp :bottom :top)))) (unless (and *resize-hides-windows* (eq *top-map* *resize-map*)) (tree-iterate to-resize (lambda (leaf) (sync-frame-windows group leaf))) (tree-iterate to-shrink (lambda (leaf) (sync-frame-windows group leaf))))))))) (defun balance-frames-internal (group tree) "Resize all the children of tree to be of equal width or height depending on the tree's split direction." (let* ((split-type (tree-split-type tree)) (fn (if (eq split-type :column) 'tree-width 'tree-height)) (side (if (eq split-type :column) :right :bottom)) (total (funcall fn tree)) size rem) (multiple-value-setq (size rem) (truncate total (length tree))) (loop for i in tree for j = rem then (1- j) for totalofs = 0 then (+ totalofs ofs) for ofs = (+ (- size (funcall fn i)) (if (plusp j) 1 0)) do (expand-tree i ofs side) (offset-tree-dir i totalofs side) (tree-iterate i (lambda (leaf) (sync-frame-windows group leaf)))))) (defun split-frame (group how &optional (ratio 1/2)) "Split the current frame into 2 frames. Return new frame number, if it succeeded. NIL otherwise." (check-type how (member :row :column)) (let* ((frame (tile-group-current-frame group)) (head (frame-head group frame))) ;; don't create frames smaller than the minimum size (when (or (and (eq how :row) (>= (frame-height frame) (* *min-frame-height* 2))) (and (eq how :column) (>= (frame-width frame) (* *min-frame-width* 2)))) (multiple-value-bind (f1 f2) (funcall (if (eq how :column) 'split-frame-h 'split-frame-v) group frame ratio) (setf (tile-group-frame-head group head) (if (atom (tile-group-frame-head group head)) (list f1 f2) (funcall-on-node (tile-group-frame-head group head) (lambda (tree) (if (eq (tree-split-type tree) how) (list-splice-replace frame tree f1 f2) (substitute (list f1 f2) frame tree))) (lambda (tree) (unless (atom tree) (find frame tree)))))) (migrate-frame-windows group frame f1) (choose-new-frame-window f2 group) (if (eq (tile-group-current-frame group) frame) (setf (tile-group-current-frame group) f1)) (setf (tile-group-last-frame group) f2) (sync-frame-windows group f1) (sync-frame-windows group f2) ;; we also need to show the new window in the other frame (when (frame-window f2) (unhide-window (frame-window f2))) (frame-number f2))))) (defun draw-frame-outline (group f tl br) "Draw an outline around FRAME." (let* ((screen (group-screen group)) (win (if (frame-window f) (window-xwin (frame-window f)) (screen-root screen))) (width (screen-frame-outline-width screen)) (gc (screen-frame-outline-gc screen)) (halfwidth (/ width 2))) (when (> width 0) (let ((x (frame-x f)) (y (frame-display-y group f)) (w (frame-width f)) (h (frame-display-height group f))) (when tl (xlib:draw-line win gc x (+ halfwidth y) w 0 t) (xlib:draw-line win gc (+ halfwidth x) y 0 h t)) (when br (xlib:draw-line win gc (+ x (- w halfwidth)) y 0 h t) (xlib:draw-line win gc x (+ y (- h halfwidth)) w 0 t)))))) (defun draw-frame-outlines (group &optional head) "Draw an outline around all frames in GROUP." (clear-frame-outlines group) (dolist (h (if head (list head) (group-heads group))) (draw-frame-outline group h nil t) (tree-iterate (tile-group-frame-head group h) (lambda (f) (draw-frame-outline group f t nil))))) (defun clear-frame-outlines (group) "Clear the outlines drawn with DRAW-FRAME-OUTLINES." (xlib:clear-area (screen-root (group-screen group)))) (defun draw-frame-numbers (group) "Draw the number of each frame in its corner. Return the list of windows used to draw the numbers in. The caller must destroy them." (let ((screen (group-screen group))) (mapcar (lambda (f) (let ((w (xlib:create-window :parent (screen-root screen) :x (frame-x f) :y (frame-display-y group f) :width 1 :height 1 :background (screen-fg-color screen) :border (screen-border-color screen) :border-width 1 :event-mask '()))) (xlib:map-window w) (setf (xlib:window-priority w) :above) (echo-in-window w (screen-font screen) (screen-fg-color screen) (screen-bg-color screen) (string (get-frame-number-translation f))) (xlib:display-finish-output *display*) (dformat 3 "mapped ~S~%" (frame-number f)) w)) (group-frames group)))) (defmacro save-frame-excursion (&body body) "Execute body and then restore the current frame." (let ((oframe (gensym "OFRAME")) (ogroup (gensym "OGROUP"))) `(let ((,oframe (tile-group-current-frame (current-group))) (,ogroup (current-group))) (unwind-protect (progn ,@body) (focus-frame ,ogroup ,oframe))))) ;;; Frame commands (defun split-frame-in-dir (group dir) (let ((f (tile-group-current-frame group))) (if (split-frame group dir) (progn (when (frame-window f) (update-decoration (frame-window f))) (show-frame-indicator group)) (message "Cannot split smaller than minimum size.")))) (defcommand (hsplit tile-group) () () "Split the current frame into 2 side-by-side frames." (split-frame-in-dir (current-group) :column)) (defcommand (vsplit tile-group) () () "Split the current frame into 2 frames, one on top of the other." (split-frame-in-dir (current-group) :row)) (defcommand (remove-split tile-group) (&optional (group (current-group)) (frame (tile-group-current-frame group))) () "Remove the specified frame in the specified group (defaults to current group, current frame). Windows in the frame are migrated to the frame taking up its space." (let* ((head (frame-head group frame)) (current (tile-group-current-frame group)) (tree (tile-group-frame-head group head)) (s (closest-sibling (list tree) frame)) ;; grab a leaf of the siblings. The siblings doesn't have to be ;; a frame. (l (tree-accum-fn s (lambda (&rest siblings) (car siblings)) #'identity))) ;; Only remove the current frame if it has a sibling (if (atom tree) (message "No more frames!") (when s (when (frame-is-head group frame) (setf (frame-number l) (frame-number frame))) ;; Move the windows from the removed frame to its sibling (migrate-frame-windows group frame l) ;; If the frame has no window, give it the current window of ;; the current frame. (unless (frame-window l) (setf (frame-window l) (frame-window frame))) ;; Unsplit (setf (tile-group-frame-head group head) (remove-frame tree frame)) ;; update the current frame and sync all windows (when (eq frame current) (setf (tile-group-current-frame group) l)) (tree-iterate tree (lambda (leaf) (sync-frame-windows group leaf))) (frame-raise-window group l (frame-window l) nil) (when (frame-window l) (update-decoration (frame-window l))) (when (eq frame current) (show-frame-indicator group)))))) (defcommand-alias remove remove-split) (defcommand (only tile-group) () () "Delete all the frames but the current one and grow it to take up the entire head." (let* ((screen (current-screen)) (group (screen-current-group screen)) (win (group-current-window group)) (head (current-head group)) (frame (copy-frame head))) (if (atom (tile-group-frame-head group head)) (message "There's only one frame.") (progn (mapc (lambda (w) ;; windows in other frames disappear (unless (eq (window-frame w) (tile-group-current-frame group)) (hide-window w)) (setf (window-frame w) frame)) (head-windows group head)) (setf (frame-window frame) win (tile-group-frame-head group head) frame (tile-group-current-frame group) frame) (focus-frame group frame) (if (frame-window frame) (update-decoration (frame-window frame)) (show-frame-indicator group)) (sync-frame-windows group (tile-group-current-frame group)))))) (defcommand (curframe tile-group) () () "Display a window indicating which frame is focused." (show-frame-indicator (current-group) t)) (defun focus-frame-next-sibling (group) (let* ((sib (next-sibling (tile-group-frame-tree group) (tile-group-current-frame group)))) (when sib (focus-frame group (tree-accum-fn sib (lambda (x y) (declare (ignore y)) x) 'identity)) (show-frame-indicator group)))) (defun focus-last-frame (group) ;; make sure the last frame still exists in the frame tree (when (and (tile-group-last-frame group) (find (tile-group-last-frame group) (group-frames group))) (focus-frame group (tile-group-last-frame group)))) (defun focus-frame-after (group frames) "Given a list of frames focus the next one in the list after the current frame." (let ((rest (cdr (member (tile-group-current-frame group) frames :test 'eq)))) (focus-frame group (if (null rest) (car frames) (car rest))))) (defun focus-next-frame (group) (focus-frame-after group (group-frames group))) (defun focus-prev-frame (group) (focus-frame-after group (nreverse (group-frames group)))) (defcommand (fnext tile-group) () () "Cycle through the frame tree to the next frame." (focus-next-frame (current-group))) (defcommand (sibling tile-group) () () "Jump to the frame's sibling. If a frame is split into two frames, these two frames are siblings." (focus-frame-next-sibling (current-group))) (defcommand (fother tile-group) () () "Jump to the last frame that had focus." (focus-last-frame (current-group))) (defun choose-frame-by-number (group) "show a number in the corner of each frame and wait for the user to select one. Returns the selected frame or nil if aborted." (let* ((wins (progn (draw-frame-outlines group) (draw-frame-numbers group))) (ch (read-one-char (group-screen group))) (num (read-from-string (string ch) nil nil))) (dformat 3 "read ~S ~S~%" ch num) (mapc #'xlib:destroy-window wins) (clear-frame-outlines group) (find ch (group-frames group) :test 'char= :key 'get-frame-number-translation))) (defcommand (fselect tile-group) (frame-number) ((:frame t)) "Display a number in the corner of each frame and let the user to select a frame by number. If @var{frame-number} is specified, just jump to that frame." (let ((group (current-group))) (focus-frame group frame-number))) (defcommand (resize tile-group) (width height) ((:number "+ Width: ") (:number "+ Height: ")) "Resize the current frame by @var{width} and @var{height} pixels" (let* ((group (current-group)) (f (tile-group-current-frame group))) (if (atom (tile-group-frame-tree group)) (message "No more frames!") (progn (clear-frame-outlines group) (resize-frame group f width :width) (resize-frame group f height :height) (draw-frame-outlines group (current-head)))))) (defun clear-frame (frame group) "Clear the given frame." (frame-raise-window group frame nil (eq (tile-group-current-frame group) frame))) (defcommand (fclear tile-group) () () "Clear the current frame." (clear-frame (tile-group-current-frame (current-group)) (current-group))) (defun get-edge (frame edge) "Returns the specified edge of FRAME. Valid values for EDGE are :TOP, :BOTTOM, :LEFT, and :RIGHT. An edge is a START, END, and OFFSET. For horizontal edges, START is the left coordinate, END is the right coordinate, and OFFSET is the Y coordinate. Similarly, for vertical lines, START is top, END is bottom, and OFFSET is X coordinate." (let* ((x1 (frame-x frame)) (y1 (frame-y frame)) (x2 (+ x1 (frame-width frame))) (y2 (+ y1 (frame-height frame)))) (ecase edge (:top (values x1 x2 y1)) (:bottom (values x1 x2 y2)) (:left (values y1 y2 x1)) (:right (values y1 y2 x2))))) (defun neighbour (direction frame frameset) "Returns the best neighbour of FRAME in FRAMESET on the DIRECTION edge. Valid directions are :UP, :DOWN, :LEFT, :RIGHT. eg: (NEIGHBOUR :UP F FS) finds the frame in FS that is the 'best' neighbour above F." (let ((src-edge (ecase direction (:up :top) (:down :bottom) (:left :left) (:right :right))) (opposite (ecase direction (:up :bottom) (:down :top) (:left :right) (:right :left))) (best-frame nil) (best-overlap 0)) (multiple-value-bind (src-s src-e src-offset) (get-edge frame src-edge) (dolist (f frameset) (multiple-value-bind (s e offset) (get-edge f opposite) (let ((overlap (- (min src-e e) (max src-s s)))) ;; Two edges are neighbours if they have the same offset and their starts and ends ;; overlap. We want to find the neighbour that overlaps the most. (when (and (= src-offset offset) (> overlap best-overlap)) (setf best-frame f) (setf best-overlap overlap)))))) best-frame)) (defun move-focus-and-or-window (dir &optional win-p) (declare (type (member :up :down :left :right) dir)) (let* ((group (current-group)) (new-frame (neighbour dir (tile-group-current-frame group) (group-frames group))) (window (current-window))) (when new-frame (if (and win-p window) (pull-window window new-frame) (focus-frame group new-frame))))) (defcommand (move-focus tile-group) (dir) ((:direction "Direction: ")) "Focus the frame adjacent to the current one in the specified direction. The following are valid directions: @table @asis @item up @item down @item left @item right @end table" (move-focus-and-or-window dir)) (defcommand (move-window tile-group) (dir) ((:direction "Direction: ")) "Just like move-focus except that the current is pulled along." (move-focus-and-or-window dir t)) (defcommand (next-in-frame tile-group) () () "Go to the next window in the current frame." (let ((group (current-group))) (if (group-current-window group) (focus-forward group (frame-sort-windows group (tile-group-current-frame group))) (other-window-in-frame group)))) (defcommand (prev-in-frame tile-group) () () "Go to the previous window in the current frame." (let ((group (current-group))) (if (group-current-window group) (focus-forward group (reverse (frame-sort-windows group (tile-group-current-frame group)))) (other-window-in-frame group)))) (defcommand (other-in-frame tile-group) () () "Go to the last accessed window in the current frame." (other-window-in-frame (current-group))) (defcommand (balance-frames tile-group) () () "Make frames the same height or width in the current frame's subtree." (let* ((group (current-group)) (tree (tree-parent (tile-group-frame-head group (current-head)) (tile-group-current-frame group)))) (if tree (balance-frames-internal (current-group) tree) (message "There's only one frame."))))
43,405
Common Lisp
.lisp
991
33.795156
128
0.573577
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
47def8b943fedbcc89a7c946cd4ef028dfcb1677ca58adce526e6226de95dd77
7,258
[ -1 ]
7,259
test-wm.lisp
blitz_stumpwm/test-wm.lisp
(defpackage :test-wm (:use :cl)) (in-package :test-wm) (defparameter *current-test-num* 0) (defparameter *tests* nil) (defmacro define-test ((dpy screen) &body body) (let ((name (intern (format nil "TEST-~d" *current-test-num*)))) `(progn (defun ,name (,dpy ,screen) (format t "Starting test ~d~%" ,*current-test-num*) ,@body (format t "Done.~%")) (push ',name *tests*) (incf *current-test-num*)))) (define-test (dpy screen) (let ((w (xlib:create-window :parent (xlib:screen-root screen) :x 10 :y 10 :width 100 :height 100 :border-width 1))) (xlib:map-window w) (xlib:display-finish-output dpy) (xlib:destroy-window w) (xlib:display-finish-output dpy))) (define-test (dpy screen) (let ((w (xlib:create-window :parent (xlib:screen-root screen) :x 10 :y 10 :width 100 :height 100 :border-width 1))) (xlib:map-window w) (xlib:display-finish-output dpy) (sleep 1) (setf (xlib:window-priority w) :above) ;; (setf (xlib:drawable-border-width w) 3) (xlib:display-finish-output dpy) (xlib:destroy-window w) (xlib:display-finish-output dpy))) (define-test (dpy screen) (let ((windows (loop for i from 0 to 100 collect (let ((w (xlib:create-window :parent (xlib:screen-root screen) :x 10 :y 10 :width 100 :height 100 :border-width 1))) (xlib:map-window w) (xlib:display-finish-output dpy) (setf (xlib:window-priority w) :above) w)))) (xlib:display-finish-output dpy) (loop for i in windows do (xlib:unmap-window i)) (xlib:display-finish-output dpy) (sleep 3) (loop for i in windows do (xlib:destroy-window i)))) ;; (define-test (dpy screen) ;; (let ((windows (loop for i from 0 to 100 ;; collect (let ((w (xlib:create-window :parent (xlib:screen-root screen) ;; :x 10 :y 10 :width 100 :height 100 :border-width 1))) ;; (xlib:map-window w) ;; (xlib:display-finish-output dpy) ;; (setf (xlib:window-priority w) :above) ;; w)))) ;; (xlib:display-finish-output dpy) ;; (loop for i in windows do ;; (xlib:unmap-window i)) ;; (xlib:display-finish-output dpy) ;; (sleep 3) ;; (loop for i in windows do ;; (xlib:destroy-window i)))) (define-test (dpy screen) (let ((w (xlib:create-window :parent (xlib:screen-root screen) :x 10 :y 10 :width 100 :height 100 :border-width 1))) (xlib:map-window w) (setf (xlib:window-priority w) :above) (xlib:display-finish-output dpy) (xlib:unmap-window w) (setf (xlib:drawable-x w) 5) (xlib:display-finish-output dpy))) (define-test (dpy screen) ;; create a window and set its role after being mapped (let ((w (xlib:create-window :parent (xlib:screen-root screen) :x 10 :y 10 :width 100 :height 100 :border-width 1))) (xlib:map-window w) (xlib:display-finish-output dpy) (sleep 1) (xlib:change-property w :WM_WINDOW_ROLE (map 'list 'char-code "rad dude") :string 8) (xlib:display-finish-output dpy) (sleep 10))) (defun break-display-xid-cache () (labels ((make-win (dpy) (xlib:create-window :parent (xlib:screen-root (first (xlib:display-roots dpy))) :x 0 :y 0 :width 50 :height 50)) (make-pixmap (window) (xlib:create-pixmap :width (random 100) :height (random 100) :depth 8 :drawable window)) (first-pass (dpy) ;; Open a fresh connection. Create a window and a pixmap. (let* ((dpy2 (xlib:open-default-display)) (window (make-win dpy2)) (pixmap (make-pixmap window))) ;; make the pixmap the window's icon pixmap hint. (setf (xlib:wm-hints window) (xlib:make-wm-hints :icon-pixmap pixmap)) (format t "Window ID: ~s pixmap ID: ~s~%" (xlib:window-id window) (xlib:pixmap-id pixmap)) (xlib:map-window window) (xlib:display-finish-output dpy2) (sleep 1) ;; On the old connection, list the root window children ;; and the icon pixmap hint to cache their XIDs. (loop for w in (xlib:query-tree (xlib:screen-root (first (xlib:display-roots dpy)))) for hints = (xlib:wm-hints w) when hints do (format t "top level window id: ~s | icon pixmap hint: ~s~%" (xlib:window-id w) (xlib:wm-hints-icon-pixmap hints))) (xlib:close-display dpy2))) (second-pass (dpy) ;; Open a fresh connection and create 2 windows. (let* ((dpy2 (xlib:open-default-display)) (window1 (make-win dpy2)) (window2 (make-win dpy2))) (format t "Window#1 ID: ~s Window#2 ID: ~s~%" (xlib:window-id window1) (xlib:window-id window2)) (xlib:display-finish-output dpy2) ;; On the old connection, list the root window children ;; and note the second window is erroneously a pixmap ;; due to too agressive caching in clx. (loop for w in (xlib:query-tree (xlib:screen-root (first (xlib:display-roots dpy)))) do (format t "window: ~s~%" w)) (xlib:close-display dpy2)))) (let ((dpy (xlib:open-default-display))) (first-pass dpy) (second-pass dpy) (xlib:close-display dpy)))) (defun test-wm-class (map-p) "Test the robustness of CLX's wm-class function. If MAP-P is T then map the window. Useful if you want to test the running window manager." (labels ((test-it (w &rest strings) (xlib:change-property w :WM_CLASS (apply #'concatenate '(vector xlib:card8) strings) :string 8) (print (multiple-value-list (xlib:get-wm-class w))) ;; give the wm a chance to try out the value (when map-p (sleep 1))) (convert (s) (map '(vector xlib:card8) #'xlib:char->card8 s))) (let* ((dpy (xlib:open-default-display)) (screen (first (xlib:display-roots dpy))) (root (xlib:screen-root screen)) (win (xlib:create-window :parent root :x 0 :y 0 :width 100 :height 100 :background (xlib:screen-white-pixel screen)))) (unwind-protect (when map-p (xlib:map-window win)) (progn (test-it win (convert "string 1") #(0) (convert "string 2") #(0)) (test-it win (convert "Manifold X") #(0) (convert "Powercoupling Y") #(0) (convert "Magistrate Z") #(0)) (test-it win #(0)) (test-it win) (test-it win #(0) (convert "checkity checkfoo")) (test-it win (convert "ohh bother") #(0) (convert "Magic Fudge")) (test-it win (convert "You Gellin?") #(0)) (test-it win (convert "Blinky The Cloon"))) (xlib:close-display dpy)) (values)))) (defun get-wm-hints () "simias reports that on sbcl the wm-hints property is all screwed up when he runs an x server on 32 or 64bit freebsd and runs any x client on a fedora 32bit, connecting through an ssh tunnel. clisp works fine. so run this function on clisp and sbcl and compare the numbers. This assumes you're running a reparenting wm." (let ((dpy (xlib:open-default-display))) (write-line "you gotta have some windows open for this to work.") (dolist (top (xlib:query-tree (xlib:screen-root (first (xlib:display-roots dpy))))) (dolist (w (xlib:query-tree top)) (format t "~s ~s: ~s~%" w (xlib:wm-name w) (xlib:get-property w :WM_HINTS :type :WM_HINTS :result-type 'vector)))) (xlib:close-display dpy))) (defun parse-display-string (display) "Parse an X11 DISPLAY string and return the host and display from it." (let* ((colon (position #\: display)) (host (subseq display 0 colon)) (rest (subseq display (1+ colon))) (dot (position #\. rest)) (num (parse-integer (subseq rest 0 dot)))) (values host num))) (defvar *dpy* nil) (defun test-wm (display-str) (multiple-value-bind (host display) (parse-display-string display-str) (setf *dpy* (xlib:open-display host :display display :protocol nil)) (let* ((dpy *dpy*) (screen (first (xlib:display-roots dpy)))) (unwind-protect (progn ;; (dolist (i *tests*) ;; (funcall i dpy screen)) (funcall (car *tests*) dpy screen) ) (xlib:close-display *dpy*)))))
9,733
Common Lisp
.lisp
209
34.598086
136
0.527871
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
d471a2baa56c9abdb7507167016db09c47d780e84fd661ee6686cdf19a11bd17
7,259
[ -1 ]
7,260
core.lisp
blitz_stumpwm/core.lisp
;; Copyright (C) 2003-2008 Shawn Betts ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; 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 file contains core functionality including functions on ;; windows, screens, and events. ;; ;; Code: (in-package :stumpwm) ;; Wow, is there an easier way to do this? (defmacro def-thing-attr-macro (thing hash-slot) (let ((attr (gensym "ATTR")) (obj (gensym "METAOBJ")) (val (gensym "METAVAL"))) `(defmacro ,(intern1 (format nil "DEF-~a-ATTR" thing)) (,attr) "Create a new attribute and corresponding get/set functions." (let ((,obj (gensym "OBJ")) (,val (gensym "VAL"))) `(progn (defun ,(intern1 (format nil ,(format nil "~a-~~a" thing) ,attr)) (,,obj) (gethash ,,attr (,(quote ,hash-slot) ,,obj))) (defun (setf ,(intern1 (format nil ,(format nil "~a-~~a" thing) ,attr))) (,,val ,,obj) (setf (gethash ,,attr (,(quote ,hash-slot) ,,obj))) ,,val)))))) ;;; keyboard helper functions (defun key-to-keycode+state (key) (let ((code (xlib:keysym->keycodes *display* (key-keysym key)))) (cond ((eq (xlib:keycode->keysym *display* code 0) (key-keysym key)) (values code (x11-mods key))) ((eq (xlib:keycode->keysym *display* code 1) (key-keysym key)) (values code (apply 'xlib:make-state-mask (cons :shift (xlib:make-state-keys (x11-mods key)))))) (t ;; just warn them and go ahead as scheduled (warn "Don't know how to encode ~s" key) (values code (x11-mods key)))))) (defun send-fake-key (win key) "Send a fake key press event to win." (multiple-value-bind (code state) (key-to-keycode+state key) (xlib:send-event (window-xwin win) :key-press (xlib:make-event-mask :key-press) :display *display* :root (screen-root (window-screen win)) ;; Apparently we need these in here, though they ;; make no sense for a key event. :x 0 :y 0 :root-x 0 :root-y 0 :window (window-xwin win) :event-window (window-xwin win) :code code :state state))) (defun send-fake-click (win button) "Send a fake click (button press + button release) to win." ;; I don't know why this doesn't work. Sadly CLX doesn't have the ;; XTest extension like xlib does. With it this would be 2 lines. (multiple-value-bind (x y) (xlib:query-pointer (window-xwin win)) (multiple-value-bind (rx ry) (xlib:query-pointer (screen-root (window-screen win))) (xlib:send-event (window-xwin win) :button-press (xlib:make-event-mask :button-press) :display *display* :root (screen-root (window-screen win)) :window (window-xwin win) :event-window (window-xwin win) :code button :state 0 :x x :y y :root-x rx :root-y ry :same-screen-p t) (xlib:send-event (window-xwin win) :button-release (xlib:make-event-mask :button-release) :display *display* :root (screen-root (window-screen win)) :window (window-xwin win) :event-window (window-xwin win) :code button :state #x100 :x x :y y :root-x rx :root-y ry :same-screen-p t)))) ;;; Pointer helper functions (defun grab-pointer (screen) "Grab the pointer and set the pointer shape." (let* ((white (xlib:make-color :red 1.0 :green 1.0 :blue 1.0)) (black (xlib:make-color :red 0.0 :green 0.0 :blue 0.0)) (cursor-font (xlib:open-font *display* "cursor")) (cursor (xlib:create-glyph-cursor :source-font cursor-font :source-char 64 :mask-font cursor-font :mask-char 65 :foreground black :background white))) (xlib:grab-pointer (screen-root screen) nil :owner-p nil :cursor cursor))) (defun ungrab-pointer () "Remove the grab on the cursor and restore the cursor shape." (xlib:ungrab-pointer *display*) (xlib:display-finish-output *display*)) (defun grab-keyboard (xwin) (let ((ret (xlib:grab-keyboard xwin :owner-p nil :sync-keyboard-p nil :sync-pointer-p nil))) (dformat 5 "vvv Grab keyboard: ~s~%" ret) ret)) (defun ungrab-keyboard () (let ((ret (xlib:ungrab-keyboard *display*))) (dformat 5 "^^^ Ungrab keyboard: ~s~%" ret) ret)) (defun warp-pointer (screen x y) "Move the pointer to the specified location." (let ((root (screen-root screen))) (xlib:warp-pointer root x y))) (defun warp-pointer-relative (dx dy) "Move the pointer by DX and DY relative to the current location." (xlib:warp-pointer-relative *display* dx dy))
5,816
Common Lisp
.lisp
117
39.34188
96
0.588836
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
609bfa9d732cad5f3b030ecff60e7f80b7494b79fccf56de1f136a05f90f68a5
7,260
[ -1 ]
7,261
sample-stumpwmrc.lisp
blitz_stumpwm/sample-stumpwmrc.lisp
;; -*-lisp-*- ;; ;; Here is a sample .stumpwmrc file (in-package :stumpwm) ;; change the prefix key to something else (set-prefix-key (kbd "C-z")) ;; prompt the user for an interactive command. The first arg is an ;; optional initial contents. (defcommand colon1 (&optional (initial "")) (:rest) (let ((cmd (read-one-line (current-screen) ": " :initial-input initial))) (when cmd (eval-command cmd t)))) ;; Read some doc (define-key *root-map* (kbd "d") "exec gv") ;; Browse somewhere (define-key *root-map* (kbd "b") "colon1 exec firefox http://www.") ;; Ssh somewhere (define-key *root-map* (kbd "C-s") "colon1 exec xterm -e ssh ") ;; Lock screen (define-key *root-map* (kbd "C-l") "exec xlock") ;; Web jump (works for Google and Imdb) (defmacro make-web-jump (name prefix) `(defcommand ,name (search) ((:rest ,(concatenate 'string name " search: "))) (substitute #\+ #\Space search) (run-shell-command (concatenate 'string ,prefix search)))) (make-web-jump "google" "firefox http://www.google.fr/search?q=") (make-web-jump "imdb" "firefox http://www.imdb.com/find?q=") ;; C-t M-s is a terrble binding, but you get the idea. (define-key *root-map* (kbd "M-s") "google") (define-key *root-map* (kbd "i") "imdb") ;; Message window font (set-font "-xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso8859-15") ;;; Define window placement policy... ;; Clear rules (clear-window-placement-rules) ;; Last rule to match takes precedence! ;; TIP: if the argument to :title or :role begins with an ellipsis, a substring ;; match is performed. ;; TIP: if the :create flag is set then a missing group will be created and ;; restored from *data-dir*/create file. ;; TIP: if the :restore flag is set then group dump is restored even for an ;; existing group using *data-dir*/restore file. (define-frame-preference "Default" ;; frame raise lock (lock AND raise == jumpto) (0 t nil :class "Konqueror" :role "...konqueror-mainwindow") (1 t nil :class "XTerm")) (define-frame-preference "Ardour" (0 t t :instance "ardour_editor" :type :normal) (0 t t :title "Ardour - Session Control") (0 nil nil :class "XTerm") (1 t nil :type :normal) (1 t t :instance "ardour_mixer") (2 t t :instance "jvmetro") (1 t t :instance "qjackctl") (3 t t :instance "qjackctl" :role "qjackctlMainForm")) (define-frame-preference "Shareland" (0 t nil :class "XTerm") (1 nil t :class "aMule")) (define-frame-preference "Emacs" (1 t t :restore "emacs-editing-dump" :title "...xdvi") (0 t t :create "emacs-dump" :class "Emacs"))
2,584
Common Lisp
.lisp
61
40.295082
79
0.681275
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0d3df0d03eb3d480f35095299faed1c2426fd10b217329c76faf615cd1f386dd
7,261
[ -1 ]
7,262
workarounds.lisp
blitz_stumpwm/workarounds.lisp
;;; workarounds for bugs in clx (in-package :xlib) ;;; SBCL workaround for a clx caching bug. This is taken from portable-clx's display.lisp. ;;; NOTE! The latest clx in Rhodes' repository has fixed this in a far ;;; better way by only caching XIDs created by the client. ;; Define functions to find the CLX data types given a display and resource-id ;; If the data type is being cached, look there first. #+sbcl (macrolet ((generate-lookup-functions (useless-name &body types) `(within-definition (,useless-name generate-lookup-functions) ,@(mapcar #'(lambda (type) `(defun ,(xintern 'lookup- type) (display id) (declare (type display display) (type resource-id id)) (declare (clx-values ,type)) ,(if (member type +clx-cached-types+) `(let ((,type (lookup-resource-id display id))) (cond ((null ,type) ;; Not found, create and save it. (setq ,type (,(xintern 'make- type) :display display :id id)) (save-id display id ,type)) ;; Found. Check the type ((type? ,type ',type) ,type) (t (restart-case (x-error 'lookup-error :id id :display display :type ',type :object ,type) (:one () :report "Invalidate this cache entry" (save-id display id (,(xintern 'make- type) :display display :id id))) (:all () :report "Invalidate all display cache" (clrhash (display-resource-id-map display)) (save-id display id (,(xintern 'make- type) :display display :id id))))))) ;; Not being cached. Create a new one each time. `(,(xintern 'make- type) :display display :id id)))) types)))) (generate-lookup-functions ignore drawable window pixmap gcontext cursor colormap font)) ;;; Both clisp and SBCL can't handle incompliant (and in clisp's case, ;;; even compliant) wm-class strings. See test-wm-class in test-wm.lisp. #+sbcl (defun get-wm-class (window) (declare (type window window)) (declare (clx-values (or null name-string) (or null class-string))) (let ((value (get-property window :WM_CLASS :type :STRING :result-type '(vector card8)))) (declare (type (or null (vector card8)) value)) (when value ;; Buggy clients may not comply with the format, so deal with ;; the unexpected. (let* ((first-zero (position 0 (the (vector card8) value))) (second-zero (and first-zero (position 0 (the (vector card8) value) :start (1+ first-zero)))) (name (subseq (the (vector card8) value) 0 first-zero)) (class (and first-zero (subseq (the (vector card8) value) (1+ first-zero) second-zero)))) (values (and (plusp (length name)) (map 'string #'card8->char name)) (and (plusp (length class)) (map 'string #'card8->char class))))))) #+clisp (defun get-wm-class (window) (let ((value (get-property window :WM_CLASS :type :STRING :result-type 'string :transform #'card8->char))) (when value ;; Buggy clients may not comply with the format, so deal with ;; the unexpected. (let* ((first-zero (position (load-time-value (card8->char 0)) (the string value))) (second-zero (and first-zero (position (load-time-value (card8->char 0)) (the string value) :start (1+ first-zero)))) (name (subseq (the string value) 0 first-zero)) (class (and first-zero (subseq (the string value) (1+ first-zero) second-zero)))) (values (and (plusp (length name)) name) (and (plusp (length class)) class)))))) #+clisp (when (fboundp '%gcontext-key->mask) (defmacro WITH-GCONTEXT ((gcontext &rest options) &body body) (let ((saved (gensym)) (gcon (gensym)) (g0 (gensym)) (g1 (gensym)) (comps 0) (setf-forms nil) dashes? clip-mask?) (do ((q options (cddr q))) ((null q)) (cond ((eq (car q) :dashes) (setf dashes? t)) ((eq (car q) :clip-mask) (setf clip-mask? t))) (setf comps (logior comps (%gcontext-key->mask (car q))) setf-forms (nconc setf-forms (list (list (find-symbol (ext:string-concat "GCONTEXT-" (symbol-name (car q))) :xlib) gcon) (cadr q))))) `(LET* ((,gcon ,gcontext) (,saved (%SAVE-GCONTEXT-COMPONENTS ,gcon ,comps)) ,@(if dashes? (list `(,g0 (GCONTEXT-DASHES ,gcon)))) ,@(if clip-mask? (list `(,g1 (GCONTEXT-CLIP-MASK ,gcon))))) (UNWIND-PROTECT (PROGN (SETF ,@setf-forms) ,@body) (PROGN (%RESTORE-GCONTEXT-COMPONENTS ,gcon ,saved) ,@(if dashes? (list `(SETF (GCONTEXT-DASHES ,gcon) ,g0))) ,@(if clip-mask? (list `(SETF (GCONTEXT-CLIP-MASK ,gcon) ,g1)))))))))
5,573
Common Lisp
.lisp
112
35.9375
119
0.522465
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
9765ae7388ef0f6d6b571c5a476e887ddc35140f8c8d3228316291c318b95c50
7,262
[ -1 ]
7,263
asdf.lisp
blitz_stumpwm/asdf.lisp
;;; This is asdf: Another System Definition Facility. $Revision: 1.109 $ ;;; ;;; Feedback, bug reports, and patches are all welcome: please mail to ;;; <[email protected]>. But note first that the canonical ;;; source for asdf is presently the cCLan CVS repository at ;;; <URL:http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cclan/asdf/> ;;; ;;; If you obtained this copy from anywhere else, and you experience ;;; trouble using it, or find bugs, you may want to check at the ;;; location above for a more recent version (and for documentation ;;; and test files, if your copy came without them) before reporting ;;; bugs. There are usually two "supported" revisions - the CVS HEAD ;;; is the latest development version, whereas the revision tagged ;;; RELEASE may be slightly older but is considered `stable' ;;; Copyright (c) 2001-2007 Daniel Barlow and contributors ;;; ;;; Permission is hereby granted, free of charge, to any person obtaining ;;; a copy of this software and associated documentation files (the ;;; "Software"), to deal in the Software without restriction, including ;;; without limitation the rights to use, copy, modify, merge, publish, ;;; distribute, sublicense, and/or sell copies of the Software, and to ;;; permit persons to whom the Software is furnished to do so, subject to ;;; the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE ;;; LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION ;;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION ;;; WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ;;; the problem with writing a defsystem replacement is bootstrapping: ;;; we can't use defsystem to compile it. Hence, all in one file (defpackage #:asdf (:export #:defsystem #:oos #:operate #:find-system #:run-shell-command #:system-definition-pathname #:find-component ; miscellaneous #:hyperdocumentation #:hyperdoc #:compile-op #:load-op #:load-source-op #:test-system-version #:test-op #:operation ; operations #:feature ; sort-of operation #:version ; metaphorically sort-of an operation #:input-files #:output-files #:perform ; operation methods #:operation-done-p #:explain #:component #:source-file #:c-source-file #:cl-source-file #:java-source-file #:static-file #:doc-file #:html-file #:text-file #:source-file-type #:module ; components #:system #:unix-dso #:module-components ; component accessors #:component-pathname #:component-relative-pathname #:component-name #:component-version #:component-parent #:component-property #:component-system #:component-depends-on #:system-description #:system-long-description #:system-author #:system-maintainer #:system-license #:system-licence #:system-source-file #:system-relative-pathname #:operation-on-warnings #:operation-on-failure ;#:*component-parent-pathname* #:*system-definition-search-functions* #:*central-registry* ; variables #:*compile-file-warnings-behaviour* #:*compile-file-failure-behaviour* #:*asdf-revision* #:operation-error #:compile-failed #:compile-warned #:compile-error #:error-component #:error-operation #:system-definition-error #:missing-component #:missing-dependency #:circular-dependency ; errors #:duplicate-names #:retry #:accept ; restarts #:preference-file-for-system/operation #:load-preferences ) (:use :cl)) #+nil (error "The author of this file habitually uses #+nil to comment out forms. But don't worry, it was unlikely to work in the New Implementation of Lisp anyway") (in-package #:asdf) (defvar *asdf-revision* (let* ((v "$Revision: 1.109 $") (colon (or (position #\: v) -1)) (dot (position #\. v))) (and v colon dot (list (parse-integer v :start (1+ colon) :junk-allowed t) (parse-integer v :start (1+ dot) :junk-allowed t))))) (defvar *compile-file-warnings-behaviour* :warn) (defvar *compile-file-failure-behaviour* #+sbcl :error #-sbcl :warn) (defvar *verbose-out* nil) (defparameter +asdf-methods+ '(perform explain output-files operation-done-p)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; utility stuff (defmacro aif (test then &optional else) `(let ((it ,test)) (if it ,then ,else))) (defun pathname-sans-name+type (pathname) "Returns a new pathname with same HOST, DEVICE, DIRECTORY as PATHNAME, and NIL NAME and TYPE components" (make-pathname :name nil :type nil :defaults pathname)) (define-modify-macro appendf (&rest args) append "Append onto list") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; classes, condiitons (define-condition system-definition-error (error) () ;; [this use of :report should be redundant, but unfortunately it's not. ;; cmucl's lisp::output-instance prefers the kernel:slot-class-print-function ;; over print-object; this is always conditions::%print-condition for ;; condition objects, which in turn does inheritance of :report options at ;; run-time. fortunately, inheritance means we only need this kludge here in ;; order to fix all conditions that build on it. -- rgr, 28-Jul-02.] #+cmu (:report print-object)) (define-condition formatted-system-definition-error (system-definition-error) ((format-control :initarg :format-control :reader format-control) (format-arguments :initarg :format-arguments :reader format-arguments)) (:report (lambda (c s) (apply #'format s (format-control c) (format-arguments c))))) (define-condition circular-dependency (system-definition-error) ((components :initarg :components :reader circular-dependency-components))) (define-condition duplicate-names (system-definition-error) ((name :initarg :name :reader duplicate-names-name))) (define-condition missing-component (system-definition-error) ((requires :initform "(unnamed)" :reader missing-requires :initarg :requires) (version :initform nil :reader missing-version :initarg :version) (parent :initform nil :reader missing-parent :initarg :parent))) (define-condition missing-dependency (missing-component) ((required-by :initarg :required-by :reader missing-required-by))) (define-condition operation-error (error) ((component :reader error-component :initarg :component) (operation :reader error-operation :initarg :operation)) (:report (lambda (c s) (format s "~@<erred while invoking ~A on ~A~@:>" (error-operation c) (error-component c))))) (define-condition compile-error (operation-error) ()) (define-condition compile-failed (compile-error) ()) (define-condition compile-warned (compile-error) ()) (defclass component () ((name :accessor component-name :initarg :name :documentation "Component name: designator for a string composed of portable pathname characters") (version :accessor component-version :initarg :version) (in-order-to :initform nil :initarg :in-order-to) ;;; XXX crap name (do-first :initform nil :initarg :do-first) ;; methods defined using the "inline" style inside a defsystem form: ;; need to store them somewhere so we can delete them when the system ;; is re-evaluated (inline-methods :accessor component-inline-methods :initform nil) (parent :initarg :parent :initform nil :reader component-parent) ;; no direct accessor for pathname, we do this as a method to allow ;; it to default in funky ways if not supplied (relative-pathname :initarg :pathname) (operation-times :initform (make-hash-table ) :accessor component-operation-times) ;; XXX we should provide some atomic interface for updating the ;; component properties (properties :accessor component-properties :initarg :properties :initform nil))) ;;;; methods: conditions (defmethod print-object ((c missing-dependency) s) (format s "~@<~A, required by ~A~@:>" (call-next-method c nil) (missing-required-by c))) (defun sysdef-error (format &rest arguments) (error 'formatted-system-definition-error :format-control format :format-arguments arguments)) ;;;; methods: components (defmethod print-object ((c missing-component) s) (format s "~@<component ~S not found~ ~@[ or does not match version ~A~]~ ~@[ in ~A~]~@:>" (missing-requires c) (missing-version c) (when (missing-parent c) (component-name (missing-parent c))))) (defgeneric component-system (component) (:documentation "Find the top-level system containing COMPONENT")) (defmethod component-system ((component component)) (aif (component-parent component) (component-system it) component)) (defmethod print-object ((c component) stream) (print-unreadable-object (c stream :type t :identity t) (ignore-errors (prin1 (component-name c) stream)))) (defclass module (component) ((components :initform nil :accessor module-components :initarg :components) ;; what to do if we can't satisfy a dependency of one of this module's ;; components. This allows a limited form of conditional processing (if-component-dep-fails :initform :fail :accessor module-if-component-dep-fails :initarg :if-component-dep-fails) (default-component-class :accessor module-default-component-class :initform 'cl-source-file :initarg :default-component-class))) (defgeneric component-pathname (component) (:documentation "Extracts the pathname applicable for a particular component.")) (defun component-parent-pathname (component) (aif (component-parent component) (component-pathname it) *default-pathname-defaults*)) (defgeneric component-relative-pathname (component) (:documentation "Extracts the relative pathname applicable for a particular component.")) (defmethod component-relative-pathname ((component module)) (or (slot-value component 'relative-pathname) (make-pathname :directory `(:relative ,(component-name component)) :host (pathname-host (component-parent-pathname component))))) (defmethod component-pathname ((component component)) (let ((*default-pathname-defaults* (component-parent-pathname component))) (merge-pathnames (component-relative-pathname component)))) (defgeneric component-property (component property)) (defmethod component-property ((c component) property) (cdr (assoc property (slot-value c 'properties) :test #'equal))) (defgeneric (setf component-property) (new-value component property)) (defmethod (setf component-property) (new-value (c component) property) (let ((a (assoc property (slot-value c 'properties) :test #'equal))) (if a (setf (cdr a) new-value) (setf (slot-value c 'properties) (acons property new-value (slot-value c 'properties)))))) (defclass system (module) ((description :accessor system-description :initarg :description) (long-description :accessor system-long-description :initarg :long-description) (author :accessor system-author :initarg :author) (maintainer :accessor system-maintainer :initarg :maintainer) (licence :accessor system-licence :initarg :licence :accessor system-license :initarg :license))) ;;; version-satisfies ;;; with apologies to christophe rhodes ... (defun split (string &optional max (ws '(#\Space #\Tab))) (flet ((is-ws (char) (find char ws))) (nreverse (let ((list nil) (start 0) (words 0) end) (loop (when (and max (>= words (1- max))) (return (cons (subseq string start) list))) (setf end (position-if #'is-ws string :start start)) (push (subseq string start end) list) (incf words) (unless end (return list)) (setf start (1+ end))))))) (defgeneric version-satisfies (component version)) (defmethod version-satisfies ((c component) version) (unless (and version (slot-boundp c 'version)) (return-from version-satisfies t)) (let ((x (mapcar #'parse-integer (split (component-version c) nil '(#\.)))) (y (mapcar #'parse-integer (split version nil '(#\.))))) (labels ((bigger (x y) (cond ((not y) t) ((not x) nil) ((> (car x) (car y)) t) ((= (car x) (car y)) (bigger (cdr x) (cdr y)))))) (and (= (car x) (car y)) (or (not (cdr y)) (bigger (cdr x) (cdr y))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; finding systems (defvar *defined-systems* (make-hash-table :test 'equal)) (defun coerce-name (name) (typecase name (component (component-name name)) (symbol (string-downcase (symbol-name name))) (string name) (t (sysdef-error "~@<invalid component designator ~A~@:>" name)))) ;;; for the sake of keeping things reasonably neat, we adopt a ;;; convention that functions in this list are prefixed SYSDEF- (defvar *system-definition-search-functions* '(sysdef-central-registry-search)) (defun system-definition-pathname (system) (some (lambda (x) (funcall x system)) *system-definition-search-functions*)) (defvar *central-registry* '(*default-pathname-defaults* #+nil "/home/dan/src/sourceforge/cclan/asdf/systems/" #+nil "telent:asdf;systems;")) (defun sysdef-central-registry-search (system) (let ((name (coerce-name system))) (block nil (dolist (dir *central-registry*) (let* ((defaults (eval dir)) (file (and defaults (make-pathname :defaults defaults :version :newest :name name :type "asd" :case :local)))) (if (and file (probe-file file)) (return file))))))) (defun make-temporary-package () (flet ((try (counter) (ignore-errors (make-package (format nil "ASDF~D" counter) :use '(:cl :asdf))))) (do* ((counter 0 (+ counter 1)) (package (try counter) (try counter))) (package package)))) (defun find-system (name &optional (error-p t)) (let* ((name (coerce-name name)) (in-memory (gethash name *defined-systems*)) (on-disk (system-definition-pathname name))) (when (and on-disk (or (not in-memory) (< (car in-memory) (file-write-date on-disk)))) (let ((package (make-temporary-package))) (unwind-protect (let ((*package* package)) (format *verbose-out* "~&~@<; ~@;loading system definition from ~A into ~A~@:>~%" ;; FIXME: This wants to be (ENOUGH-NAMESTRING ;; ON-DISK), but CMUCL barfs on that. on-disk *package*) (load on-disk)) (delete-package package)))) (let ((in-memory (gethash name *defined-systems*))) (if in-memory (progn (if on-disk (setf (car in-memory) (file-write-date on-disk))) (cdr in-memory)) (if error-p (error 'missing-component :requires name)))))) (defun register-system (name system) (format *verbose-out* "~&~@<; ~@;registering ~A as ~A~@:>~%" system name) (setf (gethash (coerce-name name) *defined-systems*) (cons (get-universal-time) system))) (defun system-registered-p (name) (gethash (coerce-name name) *defined-systems*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; finding components (defgeneric find-component (module name &optional version) (:documentation "Finds the component with name NAME present in the MODULE module; if MODULE is nil, then the component is assumed to be a system.")) (defmethod find-component ((module module) name &optional version) (if (slot-boundp module 'components) (let ((m (find name (module-components module) :test #'equal :key #'component-name))) (if (and m (version-satisfies m version)) m)))) ;;; a component with no parent is a system (defmethod find-component ((module (eql nil)) name &optional version) (let ((m (find-system name nil))) (if (and m (version-satisfies m version)) m))) ;;; component subclasses (defclass source-file (component) ()) (defclass cl-source-file (source-file) ()) (defclass c-source-file (source-file) ()) (defclass java-source-file (source-file) ()) (defclass static-file (source-file) ()) (defclass doc-file (static-file) ()) (defclass html-file (doc-file) ()) (defgeneric source-file-type (component system)) (defmethod source-file-type ((c cl-source-file) (s module)) "lisp") (defmethod source-file-type ((c c-source-file) (s module)) "c") (defmethod source-file-type ((c java-source-file) (s module)) "java") (defmethod source-file-type ((c html-file) (s module)) "html") (defmethod source-file-type ((c static-file) (s module)) nil) (defmethod component-relative-pathname ((component source-file)) (let ((relative-pathname (slot-value component 'relative-pathname))) (if relative-pathname (merge-pathnames relative-pathname (make-pathname :type (source-file-type component (component-system component)))) (let* ((*default-pathname-defaults* (component-parent-pathname component)) (name-type (make-pathname :name (component-name component) :type (source-file-type component (component-system component))))) name-type)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; operations ;;; one of these is instantiated whenever (operate ) is called (defclass operation () ((forced :initform nil :initarg :force :accessor operation-forced) (original-initargs :initform nil :initarg :original-initargs :accessor operation-original-initargs) (visited-nodes :initform nil :accessor operation-visited-nodes) (visiting-nodes :initform nil :accessor operation-visiting-nodes) (parent :initform nil :initarg :parent :accessor operation-parent))) (defmethod print-object ((o operation) stream) (print-unreadable-object (o stream :type t :identity t) (ignore-errors (prin1 (operation-original-initargs o) stream)))) (defmethod shared-initialize :after ((operation operation) slot-names &key force &allow-other-keys) (declare (ignore slot-names force)) ;; empty method to disable initarg validity checking ) (defgeneric perform (operation component)) (defgeneric operation-done-p (operation component)) (defgeneric explain (operation component)) (defgeneric output-files (operation component)) (defgeneric input-files (operation component)) (defun node-for (o c) (cons (class-name (class-of o)) c)) (defgeneric operation-ancestor (operation) (:documentation "Recursively chase the operation's parent pointer until we get to the head of the tree")) (defmethod operation-ancestor ((operation operation)) (aif (operation-parent operation) (operation-ancestor it) operation)) (defun make-sub-operation (c o dep-c dep-o) (let* ((args (copy-list (operation-original-initargs o))) (force-p (getf args :force))) ;; note explicit comparison with T: any other non-NIL force value ;; (e.g. :recursive) will pass through (cond ((and (null (component-parent c)) (null (component-parent dep-c)) (not (eql c dep-c))) (when (eql force-p t) (setf (getf args :force) nil)) (apply #'make-instance dep-o :parent o :original-initargs args args)) ((subtypep (type-of o) dep-o) o) (t (apply #'make-instance dep-o :parent o :original-initargs args args))))) (defgeneric visit-component (operation component data)) (defmethod visit-component ((o operation) (c component) data) (unless (component-visited-p o c) (push (cons (node-for o c) data) (operation-visited-nodes (operation-ancestor o))))) (defgeneric component-visited-p (operation component)) (defmethod component-visited-p ((o operation) (c component)) (assoc (node-for o c) (operation-visited-nodes (operation-ancestor o)) :test 'equal)) (defgeneric (setf visiting-component) (new-value operation component)) (defmethod (setf visiting-component) (new-value operation component) ;; MCL complains about unused lexical variables (declare (ignorable new-value operation component))) (defmethod (setf visiting-component) (new-value (o operation) (c component)) (let ((node (node-for o c)) (a (operation-ancestor o))) (if new-value (pushnew node (operation-visiting-nodes a) :test 'equal) (setf (operation-visiting-nodes a) (remove node (operation-visiting-nodes a) :test 'equal))))) (defgeneric component-visiting-p (operation component)) (defmethod component-visiting-p ((o operation) (c component)) (let ((node (cons o c))) (member node (operation-visiting-nodes (operation-ancestor o)) :test 'equal))) (defgeneric component-depends-on (operation component) (:documentation "Returns a list of dependencies needed by the component to perform the operation. A dependency has one of the following forms: (<operation> <component>*), where <operation> is a class designator and each <component> is a component designator, which means that the component depends on <operation> having been performed on each <component>; or (FEATURE <feature>), which means that the component depends on <feature>'s presence in *FEATURES*. Methods specialized on subclasses of existing component types should usually append the results of CALL-NEXT-METHOD to the list.")) (defmethod component-depends-on ((op-spec symbol) (c component)) (component-depends-on (make-instance op-spec) c)) (defmethod component-depends-on ((o operation) (c component)) (cdr (assoc (class-name (class-of o)) (slot-value c 'in-order-to)))) (defgeneric component-self-dependencies (operation component)) (defmethod component-self-dependencies ((o operation) (c component)) (let ((all-deps (component-depends-on o c))) (remove-if-not (lambda (x) (member (component-name c) (cdr x) :test #'string=)) all-deps))) (defmethod input-files ((operation operation) (c component)) (let ((parent (component-parent c)) (self-deps (component-self-dependencies operation c))) (if self-deps (mapcan (lambda (dep) (destructuring-bind (op name) dep (output-files (make-instance op) (find-component parent name)))) self-deps) ;; no previous operations needed? I guess we work with the ;; original source file, then (list (component-pathname c))))) (defmethod input-files ((operation operation) (c module)) nil) (defmethod operation-done-p ((o operation) (c component)) (flet ((fwd-or-return-t (file) ;; if FILE-WRITE-DATE returns NIL, it's possible that the ;; user or some other agent has deleted an input file. If ;; that's the case, well, that's not good, but as long as ;; the operation is otherwise considered to be done we ;; could continue and survive. (let ((date (file-write-date file))) (cond (date) (t (warn "~@<Missing FILE-WRITE-DATE for ~S: treating ~ operation ~S on component ~S as done.~@:>" file o c) (return-from operation-done-p t)))))) (let ((out-files (output-files o c)) (in-files (input-files o c))) (cond ((and (not in-files) (not out-files)) ;; arbitrary decision: an operation that uses nothing to ;; produce nothing probably isn't doing much t) ((not out-files) (let ((op-done (gethash (type-of o) (component-operation-times c)))) (and op-done (>= op-done (apply #'max (mapcar #'fwd-or-return-t in-files)))))) ((not in-files) nil) (t (and (every #'probe-file out-files) (> (apply #'min (mapcar #'file-write-date out-files)) (apply #'max (mapcar #'fwd-or-return-t in-files))))))))) ;;; So you look at this code and think "why isn't it a bunch of ;;; methods". And the answer is, because standard method combination ;;; runs :before methods most->least-specific, which is back to front ;;; for our purposes. And CLISP doesn't have non-standard method ;;; combinations, so let's keep it simple and aspire to portability (defgeneric traverse (operation component)) (defmethod traverse ((operation operation) (c component)) (let ((forced nil)) (labels ((do-one-dep (required-op required-c required-v) (let* ((dep-c (or (find-component (component-parent c) ;; XXX tacky. really we should build the ;; in-order-to slot with canonicalized ;; names instead of coercing this late (coerce-name required-c) required-v) (error 'missing-dependency :required-by c :version required-v :requires required-c))) (op (make-sub-operation c operation dep-c required-op))) (traverse op dep-c))) (do-dep (op dep) (cond ((eq op 'feature) (or (member (car dep) *features*) (error 'missing-dependency :required-by c :requires (car dep) :version nil))) (t (dolist (d dep) (cond ((consp d) (assert (string-equal (symbol-name (first d)) "VERSION")) (appendf forced (do-one-dep op (second d) (third d)))) (t (appendf forced (do-one-dep op d nil))))))))) (aif (component-visited-p operation c) (return-from traverse (if (cdr it) (list (cons 'pruned-op c)) nil))) ;; dependencies (if (component-visiting-p operation c) (error 'circular-dependency :components (list c))) (setf (visiting-component operation c) t) (loop for (required-op . deps) in (component-depends-on operation c) do (do-dep required-op deps)) ;; constituent bits (let ((module-ops (when (typep c 'module) (let ((at-least-one nil) (forced nil) (error nil)) (loop for kid in (module-components c) do (handler-case (appendf forced (traverse operation kid )) (missing-dependency (condition) (if (eq (module-if-component-dep-fails c) :fail) (error condition)) (setf error condition)) (:no-error (c) (declare (ignore c)) (setf at-least-one t)))) (when (and (eq (module-if-component-dep-fails c) :try-next) (not at-least-one)) (error error)) forced)))) ;; now the thing itself (when (or forced module-ops (not (operation-done-p operation c)) (let ((f (operation-forced (operation-ancestor operation)))) (and f (or (not (consp f)) (member (component-name (operation-ancestor operation)) (mapcar #'coerce-name f) :test #'string=))))) (let ((do-first (cdr (assoc (class-name (class-of operation)) (slot-value c 'do-first))))) (loop for (required-op . deps) in do-first do (do-dep required-op deps))) (setf forced (append (delete 'pruned-op forced :key #'car) (delete 'pruned-op module-ops :key #'car) (list (cons operation c)))))) (setf (visiting-component operation c) nil) (visit-component operation c (and forced t)) forced))) (defmethod perform ((operation operation) (c source-file)) (sysdef-error "~@<required method PERFORM not implemented ~ for operation ~A, component ~A~@:>" (class-of operation) (class-of c))) (defmethod perform ((operation operation) (c module)) nil) (defmethod explain ((operation operation) (component component)) (format *verbose-out* "~&;;; ~A on ~A~%" operation component)) ;;; compile-op (defclass compile-op (operation) ((proclamations :initarg :proclamations :accessor compile-op-proclamations :initform nil) (on-warnings :initarg :on-warnings :accessor operation-on-warnings :initform *compile-file-warnings-behaviour*) (on-failure :initarg :on-failure :accessor operation-on-failure :initform *compile-file-failure-behaviour*))) (defmethod perform :before ((operation compile-op) (c source-file)) (map nil #'ensure-directories-exist (output-files operation c))) (defmethod perform :after ((operation operation) (c component)) (setf (gethash (type-of operation) (component-operation-times c)) (get-universal-time)) (load-preferences c operation)) ;;; perform is required to check output-files to find out where to put ;;; its answers, in case it has been overridden for site policy (defmethod perform ((operation compile-op) (c cl-source-file)) #-:broken-fasl-loader (let ((source-file (component-pathname c)) (output-file (car (output-files operation c)))) (multiple-value-bind (output warnings-p failure-p) (compile-file source-file :output-file output-file) ;(declare (ignore output)) (when warnings-p (case (operation-on-warnings operation) (:warn (warn "~@<COMPILE-FILE warned while performing ~A on ~A.~@:>" operation c)) (:error (error 'compile-warned :component c :operation operation)) (:ignore nil))) (when failure-p (case (operation-on-failure operation) (:warn (warn "~@<COMPILE-FILE failed while performing ~A on ~A.~@:>" operation c)) (:error (error 'compile-failed :component c :operation operation)) (:ignore nil))) (unless output (error 'compile-error :component c :operation operation))))) (defmethod output-files ((operation compile-op) (c cl-source-file)) #-:broken-fasl-loader (list (compile-file-pathname (component-pathname c))) #+:broken-fasl-loader (list (component-pathname c))) (defmethod perform ((operation compile-op) (c static-file)) nil) (defmethod output-files ((operation compile-op) (c static-file)) nil) (defmethod input-files ((op compile-op) (c static-file)) nil) ;;; load-op (defclass basic-load-op (operation) ()) (defclass load-op (basic-load-op) ()) (defmethod perform ((o load-op) (c cl-source-file)) (mapcar #'load (input-files o c))) (defmethod perform ((operation load-op) (c static-file)) nil) (defmethod operation-done-p ((operation load-op) (c static-file)) t) (defmethod output-files ((o operation) (c component)) nil) (defmethod component-depends-on ((operation load-op) (c component)) (cons (list 'compile-op (component-name c)) (call-next-method))) ;;; load-source-op (defclass load-source-op (basic-load-op) ()) (defmethod perform ((o load-source-op) (c cl-source-file)) (let ((source (component-pathname c))) (setf (component-property c 'last-loaded-as-source) (and (load source) (get-universal-time))))) (defmethod perform ((operation load-source-op) (c static-file)) nil) (defmethod output-files ((operation load-source-op) (c component)) nil) ;;; FIXME: we simply copy load-op's dependencies. this is Just Not Right. (defmethod component-depends-on ((o load-source-op) (c component)) (let ((what-would-load-op-do (cdr (assoc 'load-op (slot-value c 'in-order-to))))) (mapcar (lambda (dep) (if (eq (car dep) 'load-op) (cons 'load-source-op (cdr dep)) dep)) what-would-load-op-do))) (defmethod operation-done-p ((o load-source-op) (c source-file)) (if (or (not (component-property c 'last-loaded-as-source)) (> (file-write-date (component-pathname c)) (component-property c 'last-loaded-as-source))) nil t)) (defclass test-op (operation) ()) (defmethod perform ((operation test-op) (c component)) nil) (defgeneric load-preferences (system operation) (:documentation "Called to load system preferences after <perform operation system>. Typical uses are to set parameters that don't exist until after the system has been loaded.")) (defgeneric preference-file-for-system/operation (system operation) (:documentation "Returns the pathname of the preference file for this system. Called by 'load-preferences to determine what file to load.")) (defmethod load-preferences ((s t) (operation t)) ;; do nothing (values)) (defmethod load-preferences ((s system) (operation basic-load-op)) (let* ((*package* (find-package :common-lisp)) (file (probe-file (preference-file-for-system/operation s operation)))) (when file (when *verbose-out* (format *verbose-out* "~&~@<; ~@;loading preferences for ~A/~(~A~) from ~A~@:>~%" (component-name s) (type-of operation) file)) (load file)))) (defmethod preference-file-for-system/operation ((system t) (operation t)) ;; cope with anything other than systems (preference-file-for-system/operation (find-system system t) operation)) (defmethod preference-file-for-system/operation ((s system) (operation t)) (let ((*default-pathname-defaults* (make-pathname :name nil :type nil :defaults *default-pathname-defaults*))) (merge-pathnames (make-pathname :name (component-name s) :type "lisp" :directory '(:relative ".asdf")) (truename (user-homedir-pathname))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; invoking operations (defun operate (operation-class system &rest args &key (verbose t) version &allow-other-keys) (let* ((op (apply #'make-instance operation-class :original-initargs args args)) (*verbose-out* (if verbose *standard-output* (make-broadcast-stream))) (system (if (typep system 'component) system (find-system system)))) (unless (version-satisfies system version) (error 'missing-component :requires system :version version)) (let ((steps (traverse op system))) (with-compilation-unit () (loop for (op . component) in steps do (loop (restart-case (progn (perform op component) (return)) (retry () :report (lambda (s) (format s "~@<Retry performing ~S on ~S.~@:>" op component))) (accept () :report (lambda (s) (format s "~@<Continue, treating ~S on ~S as ~ having been successful.~@:>" op component)) (setf (gethash (type-of op) (component-operation-times component)) (get-universal-time)) (return))))))))) (defun oos (&rest args) "Alias of OPERATE function" (apply #'operate args)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; syntax (defun remove-keyword (key arglist) (labels ((aux (key arglist) (cond ((null arglist) nil) ((eq key (car arglist)) (cddr arglist)) (t (cons (car arglist) (cons (cadr arglist) (remove-keyword key (cddr arglist)))))))) (aux key arglist))) (defmacro defsystem (name &body options) (destructuring-bind (&key pathname (class 'system) &allow-other-keys) options (let ((component-options (remove-keyword :class options))) `(progn ;; system must be registered before we parse the body, otherwise ;; we recur when trying to find an existing system of the same name ;; to reuse options (e.g. pathname) from (let ((s (system-registered-p ',name))) (cond ((and s (eq (type-of (cdr s)) ',class)) (setf (car s) (get-universal-time))) (s #+clisp (sysdef-error "Cannot redefine the existing system ~A with a different class" s) #-clisp (change-class (cdr s) ',class)) (t (register-system (quote ,name) (make-instance ',class :name ',name))))) (parse-component-form nil (apply #'list :module (coerce-name ',name) :pathname (or ,pathname (when *load-truename* (pathname-sans-name+type (resolve-symlinks *load-truename*))) *default-pathname-defaults*) ',component-options)))))) (defun class-for-type (parent type) (let* ((extra-symbols (list (find-symbol (symbol-name type) *package*) (find-symbol (symbol-name type) #.(package-name *package*)))) (class (dolist (symbol (if (keywordp type) extra-symbols (cons type extra-symbols))) (when (and symbol (find-class symbol nil) (subtypep symbol 'component)) (return (find-class symbol)))))) (or class (and (eq type :file) (or (module-default-component-class parent) (find-class 'cl-source-file))) (sysdef-error "~@<don't recognize component type ~A~@:>" type)))) (defun maybe-add-tree (tree op1 op2 c) "Add the node C at /OP1/OP2 in TREE, unless it's there already. Returns the new tree (which probably shares structure with the old one)" (let ((first-op-tree (assoc op1 tree))) (if first-op-tree (progn (aif (assoc op2 (cdr first-op-tree)) (if (find c (cdr it)) nil (setf (cdr it) (cons c (cdr it)))) (setf (cdr first-op-tree) (acons op2 (list c) (cdr first-op-tree)))) tree) (acons op1 (list (list op2 c)) tree)))) (defun union-of-dependencies (&rest deps) (let ((new-tree nil)) (dolist (dep deps) (dolist (op-tree dep) (dolist (op (cdr op-tree)) (dolist (c (cdr op)) (setf new-tree (maybe-add-tree new-tree (car op-tree) (car op) c)))))) new-tree)) (defun remove-keys (key-names args) (loop for ( name val ) on args by #'cddr unless (member (symbol-name name) key-names :key #'symbol-name :test 'equal) append (list name val))) (defvar *serial-depends-on*) (defun parse-component-form (parent options) (destructuring-bind (type name &rest rest &key ;; the following list of keywords is reproduced below in the ;; remove-keys form. important to keep them in sync components pathname default-component-class perform explain output-files operation-done-p weakly-depends-on depends-on serial in-order-to ;; list ends &allow-other-keys) options (declare (ignorable perform explain output-files operation-done-p)) (check-component-input type name weakly-depends-on depends-on components in-order-to) (when (and parent (find-component parent name) ;; ignore the same object when rereading the defsystem (not (typep (find-component parent name) (class-for-type parent type)))) (error 'duplicate-names :name name)) (let* ((other-args (remove-keys '(components pathname default-component-class perform explain output-files operation-done-p weakly-depends-on depends-on serial in-order-to) rest)) (ret (or (find-component parent name) (make-instance (class-for-type parent type))))) (when weakly-depends-on (setf depends-on (append depends-on (remove-if (complement #'find-system) weakly-depends-on)))) (when (boundp '*serial-depends-on*) (setf depends-on (concatenate 'list *serial-depends-on* depends-on))) (apply #'reinitialize-instance ret :name (coerce-name name) :pathname pathname :parent parent other-args) (when (typep ret 'module) (setf (module-default-component-class ret) (or default-component-class (and (typep parent 'module) (module-default-component-class parent)))) (let ((*serial-depends-on* nil)) (setf (module-components ret) (loop for c-form in components for c = (parse-component-form ret c-form) collect c if serial do (push (component-name c) *serial-depends-on*)))) ;; check for duplicate names (let ((name-hash (make-hash-table :test #'equal))) (loop for c in (module-components ret) do (if (gethash (component-name c) name-hash) (error 'duplicate-names :name (component-name c)) (setf (gethash (component-name c) name-hash) t))))) (setf (slot-value ret 'in-order-to) (union-of-dependencies in-order-to `((compile-op (compile-op ,@depends-on)) (load-op (load-op ,@depends-on)))) (slot-value ret 'do-first) `((compile-op (load-op ,@depends-on)))) (%remove-component-inline-methods ret rest) ret))) (defun %remove-component-inline-methods (ret rest) (loop for name in +asdf-methods+ do (map 'nil ;; this is inefficient as most of the stored ;; methods will not be for this particular gf n ;; But this is hardly performance-critical (lambda (m) (remove-method (symbol-function name) m)) (component-inline-methods ret))) ;; clear methods, then add the new ones (setf (component-inline-methods ret) nil) (loop for name in +asdf-methods+ for v = (getf rest (intern (symbol-name name) :keyword)) when v do (destructuring-bind (op qual (o c) &body body) v (pushnew (eval `(defmethod ,name ,qual ((,o ,op) (,c (eql ,ret))) ,@body)) (component-inline-methods ret))))) (defun check-component-input (type name weakly-depends-on depends-on components in-order-to) "A partial test of the values of a component." (when weakly-depends-on (warn "We got one! XXXXX")) (unless (listp depends-on) (sysdef-error-component ":depends-on must be a list." type name depends-on)) (unless (listp weakly-depends-on) (sysdef-error-component ":weakly-depends-on must be a list." type name weakly-depends-on)) (unless (listp components) (sysdef-error-component ":components must be NIL or a list of components." type name components)) (unless (and (listp in-order-to) (listp (car in-order-to))) (sysdef-error-component ":in-order-to must be NIL or a list of components." type name in-order-to))) (defun sysdef-error-component (msg type name value) (sysdef-error (concatenate 'string msg "~&The value specified for ~(~A~) ~A is ~W") type name value)) (defun resolve-symlinks (path) #-allegro (truename path) #+allegro (excl:pathname-resolve-symbolic-links path) ) ;;; optional extras ;;; run-shell-command functions for other lisp implementations will be ;;; gratefully accepted, if they do the same thing. If the docstring ;;; is ambiguous, send a bug report (defun run-shell-command (control-string &rest args) "Interpolate ARGS into CONTROL-STRING as if by FORMAT, and synchronously execute the result using a Bourne-compatible shell, with output to *VERBOSE-OUT*. Returns the shell's exit code." (let ((command (apply #'format nil control-string args))) (format *verbose-out* "; $ ~A~%" command) #+sbcl (sb-ext:process-exit-code (sb-ext:run-program #+win32 "sh" #-win32 "/bin/sh" (list "-c" command) #+win32 #+win32 :search t :input nil :output *verbose-out*)) #+(or cmu scl) (ext:process-exit-code (ext:run-program "/bin/sh" (list "-c" command) :input nil :output *verbose-out*)) #+allegro (excl:run-shell-command command :input nil :output *verbose-out*) #+lispworks (system:call-system-showing-output command :shell-type "/bin/sh" :output-stream *verbose-out*) #+clisp ;XXX not exactly *verbose-out*, I know (ext:run-shell-command command :output :terminal :wait t) #+openmcl (nth-value 1 (ccl:external-process-status (ccl:run-program "/bin/sh" (list "-c" command) :input nil :output *verbose-out* :wait t))) #+ecl ;; courtesy of Juan Jose Garcia Ripoll (si:system command) #-(or openmcl clisp lispworks allegro scl cmu sbcl ecl) (error "RUN-SHELL-PROGRAM not implemented for this Lisp") )) (defgeneric hyperdocumentation (package name doc-type)) (defmethod hyperdocumentation ((package symbol) name doc-type) (hyperdocumentation (find-package package) name doc-type)) (defun hyperdoc (name doc-type) (hyperdocumentation (symbol-package name) name doc-type)) (defun system-source-file (system-name) (let ((system (asdf:find-system system-name))) (make-pathname :type "asd" :name (asdf:component-name system) :defaults (asdf:component-relative-pathname system)))) (defun system-source-directory (system-name) (make-pathname :name nil :type nil :defaults (system-source-file system-name))) (defun system-relative-pathname (system pathname &key name type) (let ((directory (pathname-directory pathname))) (when (eq (car directory) :absolute) (setf (car directory) :relative)) (merge-pathnames (make-pathname :name (or name (pathname-name pathname)) :type (or type (pathname-type pathname)) :directory directory) (system-source-directory system)))) (pushnew :asdf *features*) #+sbcl (eval-when (:compile-toplevel :load-toplevel :execute) (when (sb-ext:posix-getenv "SBCL_BUILDING_CONTRIB") (pushnew :sbcl-hooks-require *features*))) #+(and sbcl sbcl-hooks-require) (progn (defun module-provide-asdf (name) (handler-bind ((style-warning #'muffle-warning)) (let* ((*verbose-out* (make-broadcast-stream)) (system (asdf:find-system name nil))) (when system (asdf:operate 'asdf:load-op name) t)))) (defun contrib-sysdef-search (system) (let ((home (sb-ext:posix-getenv "SBCL_HOME"))) (when home (let* ((name (coerce-name system)) (home (truename home)) (contrib (merge-pathnames (make-pathname :directory `(:relative ,name) :name name :type "asd" :case :local :version :newest) home))) (probe-file contrib))))) (pushnew '(let ((home (sb-ext:posix-getenv "SBCL_HOME"))) (when home (merge-pathnames "site-systems/" (truename home)))) *central-registry*) (pushnew '(merge-pathnames ".sbcl/systems/" (user-homedir-pathname)) *central-registry*) (pushnew 'module-provide-asdf sb-ext:*module-provider-functions*) (pushnew 'contrib-sysdef-search *system-definition-search-functions*)) (provide 'asdf)
46,843
Common Lisp
.lisp
1,086
37.044199
181
0.662063
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
5c6635cbc241721837399c1adf8b31f4c44fcd717637a49a21d7fe19325f7b1d
7,263
[ -1 ]
7,264
keysyms.lisp
blitz_stumpwm/keysyms.lisp
;; Copyright (C) 2006-2008 Matthew Kennedy ;; ;; This file is part of stumpwm. ;; ;; stumpwm 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. ;; stumpwm 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;; Commentary: ;; ;; Mapping a keysym to a name is a client side activity in X11. Some ;; of the code here was taken from the CMUCL Hemlocks code base. The ;; actual mappings were taken from Xorg's keysymdefs.h. ;; ;; Code: (in-package #:stumpwm) (defvar *keysym-name-translations* (make-hash-table)) (defvar *name-keysym-translations* (make-hash-table :test #'equal)) (defun define-keysym (keysym name) "Define a mapping from a keysym name to a keysym." (setf (gethash keysym *keysym-name-translations*) name (gethash name *name-keysym-translations*) keysym)) (defun keysym-name->keysym (name) "Return the keysym corresponding to NAME." (multiple-value-bind (value present-p) (gethash name *name-keysym-translations*) (declare (ignore present-p)) value)) (defun keysym->keysym-name (keysym) "Return the name corresponding to KEYSYM." (multiple-value-bind (value present-p) (gethash keysym *keysym-name-translations*) (declare (ignore present-p)) value)) (define-keysym #xffffff "VoidSymbol") ;Void symbol (define-keysym #xff08 "BackSpace") ;Back space, back char (define-keysym #xff09 "Tab") (define-keysym #xff0a "Linefeed") ;Linefeed, LF (define-keysym #xff0b "Clear") (define-keysym #xff0d "Return") ;Return, enter (define-keysym #xff13 "Pause") ;Pause, hold (define-keysym #xff14 "Scroll_Lock") (define-keysym #xff15 "Sys_Req") (define-keysym #xff1b "Escape") (define-keysym #xffff "Delete") ;Delete, rubout (define-keysym #xff20 "Multi_key") ;Multi-key character compose (define-keysym #xff37 "Codeinput") (define-keysym #xff3c "SingleCandidate") (define-keysym #xff3d "MultipleCandidate") (define-keysym #xff3e "PreviousCandidate") (define-keysym #xff21 "Kanji") ;Kanji, Kanji convert (define-keysym #xff22 "Muhenkan") ;Cancel Conversion (define-keysym #xff23 "Henkan_Mode") ;Start/Stop Conversion (define-keysym #xff23 "Henkan") ;Alias for Henkan_Mode (define-keysym #xff24 "Romaji") ;to Romaji (define-keysym #xff25 "Hiragana") ;to Hiragana (define-keysym #xff26 "Katakana") ;to Katakana (define-keysym #xff27 "Hiragana_Katakana") ;Hiragana/Katakana toggle (define-keysym #xff28 "Zenkaku") ;to Zenkaku (define-keysym #xff29 "Hankaku") ;to Hankaku (define-keysym #xff2a "Zenkaku_Hankaku") ;Zenkaku/Hankaku toggle (define-keysym #xff2b "Touroku") ;Add to Dictionary (define-keysym #xff2c "Massyo") ;Delete from Dictionary (define-keysym #xff2d "Kana_Lock") ;Kana Lock (define-keysym #xff2e "Kana_Shift") ;Kana Shift (define-keysym #xff2f "Eisu_Shift") ;Alphanumeric Shift (define-keysym #xff30 "Eisu_toggle") ;Alphanumeric toggle (define-keysym #xff37 "Kanji_Bangou") ;Codeinput (define-keysym #xff3d "Zen_Koho") ;Multiple/All Candidate(s) (define-keysym #xff3e "Mae_Koho") ;Previous Candidate (define-keysym #xff50 "Home") (define-keysym #xff51 "Left") ;Move left, left arrow (define-keysym #xff52 "Up") ;Move up, up arrow (define-keysym #xff53 "Right") ;Move right, right arrow (define-keysym #xff54 "Down") ;Move down, down arrow (define-keysym #xff55 "Prior") ;Prior, previous (define-keysym #xff55 "Page_Up") (define-keysym #xff56 "Next") ;Next (define-keysym #xff56 "Page_Down") (define-keysym #xff57 "End") ;EOL (define-keysym #xff58 "Begin") ;BOL (define-keysym #xff60 "Select") ;Select, mark (define-keysym #xff61 "Print") (define-keysym #xff62 "Execute") ;Execute, run, do (define-keysym #xff63 "Insert") ;Insert, insert here (define-keysym #xff65 "Undo") (define-keysym #xff66 "Redo") ;Redo, again (define-keysym #xff67 "Menu") (define-keysym #xff68 "Find") ;Find, search (define-keysym #xff69 "Cancel") ;Cancel, stop, abort, exit (define-keysym #xff6a "Help") ;Help (define-keysym #xff6b "Break") (define-keysym #xff7e "Mode_switch") ;Character set switch (define-keysym #xff7e "script_switch") ;Alias for mode_switch (define-keysym #xff7f "Num_Lock") (define-keysym #xff80 "KP_Space") ;Space (define-keysym #xff89 "KP_Tab") (define-keysym #xff8d "KP_Enter") ;Enter (define-keysym #xff91 "KP_F1") ;PF1, KP_A, ... (define-keysym #xff92 "KP_F2") (define-keysym #xff93 "KP_F3") (define-keysym #xff94 "KP_F4") (define-keysym #xff95 "KP_Home") (define-keysym #xff96 "KP_Left") (define-keysym #xff97 "KP_Up") (define-keysym #xff98 "KP_Right") (define-keysym #xff99 "KP_Down") (define-keysym #xff9a "KP_Prior") (define-keysym #xff9a "KP_Page_Up") (define-keysym #xff9b "KP_Next") (define-keysym #xff9b "KP_Page_Down") (define-keysym #xff9c "KP_End") (define-keysym #xff9d "KP_Begin") (define-keysym #xff9e "KP_Insert") (define-keysym #xff9f "KP_Delete") (define-keysym #xffbd "KP_Equal") ;Equals (define-keysym #xffaa "KP_Multiply") (define-keysym #xffab "KP_Add") (define-keysym #xffac "KP_Separator") ;Separator, often comma (define-keysym #xffad "KP_Subtract") (define-keysym #xffae "KP_Decimal") (define-keysym #xffaf "KP_Divide") (define-keysym #xffb0 "KP_0") (define-keysym #xffb1 "KP_1") (define-keysym #xffb2 "KP_2") (define-keysym #xffb3 "KP_3") (define-keysym #xffb4 "KP_4") (define-keysym #xffb5 "KP_5") (define-keysym #xffb6 "KP_6") (define-keysym #xffb7 "KP_7") (define-keysym #xffb8 "KP_8") (define-keysym #xffb9 "KP_9") (define-keysym #xffbe "F1") (define-keysym #xffbf "F2") (define-keysym #xffc0 "F3") (define-keysym #xffc1 "F4") (define-keysym #xffc2 "F5") (define-keysym #xffc3 "F6") (define-keysym #xffc4 "F7") (define-keysym #xffc5 "F8") (define-keysym #xffc6 "F9") (define-keysym #xffc7 "F10") (define-keysym #xffc8 "F11") (define-keysym #xffc9 "F12") (define-keysym #xffca "F13") (define-keysym #xffcb "F14") (define-keysym #xffcc "F15") (define-keysym #xffcd "F16") (define-keysym #xffce "F17") (define-keysym #xffcf "F18") (define-keysym #xffd0 "F19") (define-keysym #xffd1 "F20") (define-keysym #xffd2 "F21") (define-keysym #xffd3 "F22") (define-keysym #xffd4 "F23") (define-keysym #xffd5 "F24") (define-keysym #xffd6 "F25") (define-keysym #xffd7 "F26") (define-keysym #xffd8 "F27") (define-keysym #xffd9 "F28") (define-keysym #xffda "F29") (define-keysym #xffdb "F30") (define-keysym #xffdc "F31") (define-keysym #xffdd "F32") (define-keysym #xffde "F33") (define-keysym #xffdf "F34") (define-keysym #xffe0 "F35") (define-keysym #xffe1 "Shift_L") ;Left shift (define-keysym #xffe2 "Shift_R") ;Right shift (define-keysym #xffe3 "Control_L") ;Left control (define-keysym #xffe4 "Control_R") ;Right control (define-keysym #xffe5 "Caps_Lock") ;Caps lock (define-keysym #xffe6 "Shift_Lock") ;Shift lock (define-keysym #xffe7 "Meta_L") ;Left meta (define-keysym #xffe8 "Meta_R") ;Right meta (define-keysym #xffe9 "Alt_L") ;Left alt (define-keysym #xffea "Alt_R") ;Right alt (define-keysym #xffeb "Super_L") ;Left super (define-keysym #xffec "Super_R") ;Right super (define-keysym #xffed "Hyper_L") ;Left hyper (define-keysym #xffee "Hyper_R") ;Right hyper (define-keysym #xfe01 "ISO_Lock") (define-keysym #xfe02 "ISO_Level2_Latch") (define-keysym #xfe03 "ISO_Level3_Shift") (define-keysym #xfe04 "ISO_Level3_Latch") (define-keysym #xfe05 "ISO_Level3_Lock") (define-keysym #xff7e "ISO_Group_Shift") ;Alias for mode_switch (define-keysym #xfe06 "ISO_Group_Latch") (define-keysym #xfe07 "ISO_Group_Lock") (define-keysym #xfe08 "ISO_Next_Group") (define-keysym #xfe09 "ISO_Next_Group_Lock") (define-keysym #xfe0a "ISO_Prev_Group") (define-keysym #xfe0b "ISO_Prev_Group_Lock") (define-keysym #xfe0c "ISO_First_Group") (define-keysym #xfe0d "ISO_First_Group_Lock") (define-keysym #xfe0e "ISO_Last_Group") (define-keysym #xfe0f "ISO_Last_Group_Lock") (define-keysym #xfe20 "ISO_Left_Tab") (define-keysym #xfe21 "ISO_Move_Line_Up") (define-keysym #xfe22 "ISO_Move_Line_Down") (define-keysym #xfe23 "ISO_Partial_Line_Up") (define-keysym #xfe24 "ISO_Partial_Line_Down") (define-keysym #xfe25 "ISO_Partial_Space_Left") (define-keysym #xfe26 "ISO_Partial_Space_Right") (define-keysym #xfe27 "ISO_Set_Margin_Left") (define-keysym #xfe28 "ISO_Set_Margin_Right") (define-keysym #xfe29 "ISO_Release_Margin_Left") (define-keysym #xfe2a "ISO_Release_Margin_Right") (define-keysym #xfe2b "ISO_Release_Both_Margins") (define-keysym #xfe2c "ISO_Fast_Cursor_Left") (define-keysym #xfe2d "ISO_Fast_Cursor_Right") (define-keysym #xfe2e "ISO_Fast_Cursor_Up") (define-keysym #xfe2f "ISO_Fast_Cursor_Down") (define-keysym #xfe30 "ISO_Continuous_Underline") (define-keysym #xfe31 "ISO_Discontinuous_Underline") (define-keysym #xfe32 "ISO_Emphasize") (define-keysym #xfe33 "ISO_Center_Object") (define-keysym #xfe34 "ISO_Enter") (define-keysym #xfe50 "dead_grave") (define-keysym #xfe51 "dead_acute") (define-keysym #xfe52 "dead_circumflex") (define-keysym #xfe53 "dead_tilde") (define-keysym #xfe54 "dead_macron") (define-keysym #xfe55 "dead_breve") (define-keysym #xfe56 "dead_abovedot") (define-keysym #xfe57 "dead_diaeresis") (define-keysym #xfe58 "dead_abovering") (define-keysym #xfe59 "dead_doubleacute") (define-keysym #xfe5a "dead_caron") (define-keysym #xfe5b "dead_cedilla") (define-keysym #xfe5c "dead_ogonek") (define-keysym #xfe5d "dead_iota") (define-keysym #xfe5e "dead_voiced_sound") (define-keysym #xfe5f "dead_semivoiced_sound") (define-keysym #xfe60 "dead_belowdot") (define-keysym #xfe61 "dead_hook") (define-keysym #xfe62 "dead_horn") (define-keysym #xfed0 "First_Virtual_Screen") (define-keysym #xfed1 "Prev_Virtual_Screen") (define-keysym #xfed2 "Next_Virtual_Screen") (define-keysym #xfed4 "Last_Virtual_Screen") (define-keysym #xfed5 "Terminate_Server") (define-keysym #xfe70 "AccessX_Enable") (define-keysym #xfe71 "AccessX_Feedback_Enable") (define-keysym #xfe72 "RepeatKeys_Enable") (define-keysym #xfe73 "SlowKeys_Enable") (define-keysym #xfe74 "BounceKeys_Enable") (define-keysym #xfe75 "StickyKeys_Enable") (define-keysym #xfe76 "MouseKeys_Enable") (define-keysym #xfe77 "MouseKeys_Accel_Enable") (define-keysym #xfe78 "Overlay1_Enable") (define-keysym #xfe79 "Overlay2_Enable") (define-keysym #xfe7a "AudibleBell_Enable") (define-keysym #xfee0 "Pointer_Left") (define-keysym #xfee1 "Pointer_Right") (define-keysym #xfee2 "Pointer_Up") (define-keysym #xfee3 "Pointer_Down") (define-keysym #xfee4 "Pointer_UpLeft") (define-keysym #xfee5 "Pointer_UpRight") (define-keysym #xfee6 "Pointer_DownLeft") (define-keysym #xfee7 "Pointer_DownRight") (define-keysym #xfee8 "Pointer_Button_Dflt") (define-keysym #xfee9 "Pointer_Button1") (define-keysym #xfeea "Pointer_Button2") (define-keysym #xfeeb "Pointer_Button3") (define-keysym #xfeec "Pointer_Button4") (define-keysym #xfeed "Pointer_Button5") (define-keysym #xfeee "Pointer_DblClick_Dflt") (define-keysym #xfeef "Pointer_DblClick1") (define-keysym #xfef0 "Pointer_DblClick2") (define-keysym #xfef1 "Pointer_DblClick3") (define-keysym #xfef2 "Pointer_DblClick4") (define-keysym #xfef3 "Pointer_DblClick5") (define-keysym #xfef4 "Pointer_Drag_Dflt") (define-keysym #xfef5 "Pointer_Drag1") (define-keysym #xfef6 "Pointer_Drag2") (define-keysym #xfef7 "Pointer_Drag3") (define-keysym #xfef8 "Pointer_Drag4") (define-keysym #xfefd "Pointer_Drag5") (define-keysym #xfef9 "Pointer_EnableKeys") (define-keysym #xfefa "Pointer_Accelerate") (define-keysym #xfefb "Pointer_DfltBtnNext") (define-keysym #xfefc "Pointer_DfltBtnPrev") (define-keysym #xfd01 "3270_Duplicate") (define-keysym #xfd02 "3270_FieldMark") (define-keysym #xfd03 "3270_Right2") (define-keysym #xfd04 "3270_Left2") (define-keysym #xfd05 "3270_BackTab") (define-keysym #xfd06 "3270_EraseEOF") (define-keysym #xfd07 "3270_EraseInput") (define-keysym #xfd08 "3270_Reset") (define-keysym #xfd09 "3270_Quit") (define-keysym #xfd0a "3270_PA1") (define-keysym #xfd0b "3270_PA2") (define-keysym #xfd0c "3270_PA3") (define-keysym #xfd0d "3270_Test") (define-keysym #xfd0e "3270_Attn") (define-keysym #xfd0f "3270_CursorBlink") (define-keysym #xfd10 "3270_AltCursor") (define-keysym #xfd11 "3270_KeyClick") (define-keysym #xfd12 "3270_Jump") (define-keysym #xfd13 "3270_Ident") (define-keysym #xfd14 "3270_Rule") (define-keysym #xfd15 "3270_Copy") (define-keysym #xfd16 "3270_Play") (define-keysym #xfd17 "3270_Setup") (define-keysym #xfd18 "3270_Record") (define-keysym #xfd19 "3270_ChangeScreen") (define-keysym #xfd1a "3270_DeleteWord") (define-keysym #xfd1b "3270_ExSelect") (define-keysym #xfd1c "3270_CursorSelect") (define-keysym #xfd1d "3270_PrintScreen") (define-keysym #xfd1e "3270_Enter") (define-keysym #x0020 "space") ;U+0020 SPACE (define-keysym #x0021 "exclam") ;U+0021 EXCLAMATION MARK (define-keysym #x0022 "quotedbl") ;U+0022 QUOTATION MARK (define-keysym #x0023 "numbersign") ;U+0023 NUMBER SIGN (define-keysym #x0024 "dollar") ;U+0024 DOLLAR SIGN (define-keysym #x0025 "percent") ;U+0025 PERCENT SIGN (define-keysym #x0026 "ampersand") ;U+0026 AMPERSAND (define-keysym #x0027 "apostrophe") ;U+0027 APOSTROPHE (define-keysym #x0027 "quoteright") ;deprecated (define-keysym #x0028 "parenleft") ;U+0028 LEFT PARENTHESIS (define-keysym #x0029 "parenright") ;U+0029 RIGHT PARENTHESIS (define-keysym #x002a "asterisk") ;U+002A ASTERISK (define-keysym #x002b "plus") ;U+002B PLUS SIGN (define-keysym #x002c "comma") ;U+002C COMMA (define-keysym #x002d "minus") ;U+002D HYPHEN-MINUS (define-keysym #x002e "period") ;U+002E FULL STOP (define-keysym #x002f "slash") ;U+002F SOLIDUS (define-keysym #x0030 "0") ;U+0030 DIGIT ZERO (define-keysym #x0031 "1") ;U+0031 DIGIT ONE (define-keysym #x0032 "2") ;U+0032 DIGIT TWO (define-keysym #x0033 "3") ;U+0033 DIGIT THREE (define-keysym #x0034 "4") ;U+0034 DIGIT FOUR (define-keysym #x0035 "5") ;U+0035 DIGIT FIVE (define-keysym #x0036 "6") ;U+0036 DIGIT SIX (define-keysym #x0037 "7") ;U+0037 DIGIT SEVEN (define-keysym #x0038 "8") ;U+0038 DIGIT EIGHT (define-keysym #x0039 "9") ;U+0039 DIGIT NINE (define-keysym #x003a "colon") ;U+003A COLON (define-keysym #x003b "semicolon") ;U+003B SEMICOLON (define-keysym #x003c "less") ;U+003C LESS-THAN SIGN (define-keysym #x003d "equal") ;U+003D EQUALS SIGN (define-keysym #x003e "greater") ;U+003E GREATER-THAN SIGN (define-keysym #x003f "question") ;U+003F QUESTION MARK (define-keysym #x0040 "at") ;U+0040 COMMERCIAL AT (define-keysym #x0041 "A") ;U+0041 LATIN CAPITAL LETTER A (define-keysym #x0042 "B") ;U+0042 LATIN CAPITAL LETTER B (define-keysym #x0043 "C") ;U+0043 LATIN CAPITAL LETTER C (define-keysym #x0044 "D") ;U+0044 LATIN CAPITAL LETTER D (define-keysym #x0045 "E") ;U+0045 LATIN CAPITAL LETTER E (define-keysym #x0046 "F") ;U+0046 LATIN CAPITAL LETTER F (define-keysym #x0047 "G") ;U+0047 LATIN CAPITAL LETTER G (define-keysym #x0048 "H") ;U+0048 LATIN CAPITAL LETTER H (define-keysym #x0049 "I") ;U+0049 LATIN CAPITAL LETTER I (define-keysym #x004a "J") ;U+004A LATIN CAPITAL LETTER J (define-keysym #x004b "K") ;U+004B LATIN CAPITAL LETTER K (define-keysym #x004c "L") ;U+004C LATIN CAPITAL LETTER L (define-keysym #x004d "M") ;U+004D LATIN CAPITAL LETTER M (define-keysym #x004e "N") ;U+004E LATIN CAPITAL LETTER N (define-keysym #x004f "O") ;U+004F LATIN CAPITAL LETTER O (define-keysym #x0050 "P") ;U+0050 LATIN CAPITAL LETTER P (define-keysym #x0051 "Q") ;U+0051 LATIN CAPITAL LETTER Q (define-keysym #x0052 "R") ;U+0052 LATIN CAPITAL LETTER R (define-keysym #x0053 "S") ;U+0053 LATIN CAPITAL LETTER S (define-keysym #x0054 "T") ;U+0054 LATIN CAPITAL LETTER T (define-keysym #x0055 "U") ;U+0055 LATIN CAPITAL LETTER U (define-keysym #x0056 "V") ;U+0056 LATIN CAPITAL LETTER V (define-keysym #x0057 "W") ;U+0057 LATIN CAPITAL LETTER W (define-keysym #x0058 "X") ;U+0058 LATIN CAPITAL LETTER X (define-keysym #x0059 "Y") ;U+0059 LATIN CAPITAL LETTER Y (define-keysym #x005a "Z") ;U+005A LATIN CAPITAL LETTER Z (define-keysym #x005b "bracketleft") ;U+005B LEFT SQUARE BRACKET (define-keysym #x005c "backslash") ;U+005C REVERSE SOLIDUS (define-keysym #x005d "bracketright") ;U+005D RIGHT SQUARE BRACKET (define-keysym #x005e "asciicircum") ;U+005E CIRCUMFLEX ACCENT (define-keysym #x005f "underscore") ;U+005F LOW LINE (define-keysym #x0060 "grave") ;U+0060 GRAVE ACCENT (define-keysym #x0060 "quoteleft") ;deprecated (define-keysym #x0061 "a") ;U+0061 LATIN SMALL LETTER A (define-keysym #x0062 "b") ;U+0062 LATIN SMALL LETTER B (define-keysym #x0063 "c") ;U+0063 LATIN SMALL LETTER C (define-keysym #x0064 "d") ;U+0064 LATIN SMALL LETTER D (define-keysym #x0065 "e") ;U+0065 LATIN SMALL LETTER E (define-keysym #x0066 "f") ;U+0066 LATIN SMALL LETTER F (define-keysym #x0067 "g") ;U+0067 LATIN SMALL LETTER G (define-keysym #x0068 "h") ;U+0068 LATIN SMALL LETTER H (define-keysym #x0069 "i") ;U+0069 LATIN SMALL LETTER I (define-keysym #x006a "j") ;U+006A LATIN SMALL LETTER J (define-keysym #x006b "k") ;U+006B LATIN SMALL LETTER K (define-keysym #x006c "l") ;U+006C LATIN SMALL LETTER L (define-keysym #x006d "m") ;U+006D LATIN SMALL LETTER M (define-keysym #x006e "n") ;U+006E LATIN SMALL LETTER N (define-keysym #x006f "o") ;U+006F LATIN SMALL LETTER O (define-keysym #x0070 "p") ;U+0070 LATIN SMALL LETTER P (define-keysym #x0071 "q") ;U+0071 LATIN SMALL LETTER Q (define-keysym #x0072 "r") ;U+0072 LATIN SMALL LETTER R (define-keysym #x0073 "s") ;U+0073 LATIN SMALL LETTER S (define-keysym #x0074 "t") ;U+0074 LATIN SMALL LETTER T (define-keysym #x0075 "u") ;U+0075 LATIN SMALL LETTER U (define-keysym #x0076 "v") ;U+0076 LATIN SMALL LETTER V (define-keysym #x0077 "w") ;U+0077 LATIN SMALL LETTER W (define-keysym #x0078 "x") ;U+0078 LATIN SMALL LETTER X (define-keysym #x0079 "y") ;U+0079 LATIN SMALL LETTER Y (define-keysym #x007a "z") ;U+007A LATIN SMALL LETTER Z (define-keysym #x007b "braceleft") ;U+007B LEFT CURLY BRACKET (define-keysym #x007c "bar") ;U+007C VERTICAL LINE (define-keysym #x007d "braceright") ;U+007D RIGHT CURLY BRACKET (define-keysym #x007e "asciitilde") ;U+007E TILDE (define-keysym #x00a0 "nobreakspace") ;U+00A0 NO-BREAK SPACE (define-keysym #x00a1 "exclamdown") ;U+00A1 INVERTED EXCLAMATION MARK (define-keysym #x00a2 "cent") ;U+00A2 CENT SIGN (define-keysym #x00a3 "sterling") ;U+00A3 POUND SIGN (define-keysym #x00a4 "currency") ;U+00A4 CURRENCY SIGN (define-keysym #x00a5 "yen") ;U+00A5 YEN SIGN (define-keysym #x00a6 "brokenbar") ;U+00A6 BROKEN BAR (define-keysym #x00a7 "section") ;U+00A7 SECTION SIGN (define-keysym #x00a8 "diaeresis") ;U+00A8 DIAERESIS (define-keysym #x00a9 "copyright") ;U+00A9 COPYRIGHT SIGN (define-keysym #x00aa "ordfeminine") ;U+00AA FEMININE ORDINAL INDICATOR (define-keysym #x00ab "guillemotleft") ;U+00AB LEFT-POINTING DOUBLE ANGLE QUOTATION MARK (define-keysym #x00ac "notsign") ;U+00AC NOT SIGN (define-keysym #x00ad "hyphen") ;U+00AD SOFT HYPHEN (define-keysym #x00ae "registered") ;U+00AE REGISTERED SIGN (define-keysym #x00af "macron") ;U+00AF MACRON (define-keysym #x00b0 "degree") ;U+00B0 DEGREE SIGN (define-keysym #x00b1 "plusminus") ;U+00B1 PLUS-MINUS SIGN (define-keysym #x00b2 "twosuperior") ;U+00B2 SUPERSCRIPT TWO (define-keysym #x00b3 "threesuperior") ;U+00B3 SUPERSCRIPT THREE (define-keysym #x00b4 "acute") ;U+00B4 ACUTE ACCENT (define-keysym #x00b5 "mu") ;U+00B5 MICRO SIGN (define-keysym #x00b6 "paragraph") ;U+00B6 PILCROW SIGN (define-keysym #x00b7 "periodcentered") ;U+00B7 MIDDLE DOT (define-keysym #x00b8 "cedilla") ;U+00B8 CEDILLA (define-keysym #x00b9 "onesuperior") ;U+00B9 SUPERSCRIPT ONE (define-keysym #x00ba "masculine") ;U+00BA MASCULINE ORDINAL INDICATOR (define-keysym #x00bb "guillemotright") ;U+00BB RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (define-keysym #x00bc "onequarter") ;U+00BC VULGAR FRACTION ONE QUARTER (define-keysym #x00bd "onehalf") ;U+00BD VULGAR FRACTION ONE HALF (define-keysym #x00be "threequarters") ;U+00BE VULGAR FRACTION THREE QUARTERS (define-keysym #x00bf "questiondown") ;U+00BF INVERTED QUESTION MARK (define-keysym #x00c0 "Agrave") ;U+00C0 LATIN CAPITAL LETTER A WITH GRAVE (define-keysym #x00c1 "Aacute") ;U+00C1 LATIN CAPITAL LETTER A WITH ACUTE (define-keysym #x00c2 "Acircumflex") ;U+00C2 LATIN CAPITAL LETTER A WITH CIRCUMFLEX (define-keysym #x00c3 "Atilde") ;U+00C3 LATIN CAPITAL LETTER A WITH TILDE (define-keysym #x00c4 "Adiaeresis") ;U+00C4 LATIN CAPITAL LETTER A WITH DIAERESIS (define-keysym #x00c5 "Aring") ;U+00C5 LATIN CAPITAL LETTER A WITH RING ABOVE (define-keysym #x00c6 "AE") ;U+00C6 LATIN CAPITAL LETTER AE (define-keysym #x00c7 "Ccedilla") ;U+00C7 LATIN CAPITAL LETTER C WITH CEDILLA (define-keysym #x00c8 "Egrave") ;U+00C8 LATIN CAPITAL LETTER E WITH GRAVE (define-keysym #x00c9 "Eacute") ;U+00C9 LATIN CAPITAL LETTER E WITH ACUTE (define-keysym #x00ca "Ecircumflex") ;U+00CA LATIN CAPITAL LETTER E WITH CIRCUMFLEX (define-keysym #x00cb "Ediaeresis") ;U+00CB LATIN CAPITAL LETTER E WITH DIAERESIS (define-keysym #x00cc "Igrave") ;U+00CC LATIN CAPITAL LETTER I WITH GRAVE (define-keysym #x00cd "Iacute") ;U+00CD LATIN CAPITAL LETTER I WITH ACUTE (define-keysym #x00ce "Icircumflex") ;U+00CE LATIN CAPITAL LETTER I WITH CIRCUMFLEX (define-keysym #x00cf "Idiaeresis") ;U+00CF LATIN CAPITAL LETTER I WITH DIAERESIS (define-keysym #x00d0 "ETH") ;U+00D0 LATIN CAPITAL LETTER ETH (define-keysym #x00d0 "Eth") ;deprecated (define-keysym #x00d1 "Ntilde") ;U+00D1 LATIN CAPITAL LETTER N WITH TILDE (define-keysym #x00d2 "Ograve") ;U+00D2 LATIN CAPITAL LETTER O WITH GRAVE (define-keysym #x00d3 "Oacute") ;U+00D3 LATIN CAPITAL LETTER O WITH ACUTE (define-keysym #x00d4 "Ocircumflex") ;U+00D4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX (define-keysym #x00d5 "Otilde") ;U+00D5 LATIN CAPITAL LETTER O WITH TILDE (define-keysym #x00d6 "Odiaeresis") ;U+00D6 LATIN CAPITAL LETTER O WITH DIAERESIS (define-keysym #x00d7 "multiply") ;U+00D7 MULTIPLICATION SIGN (define-keysym #x00d8 "Oslash") ;U+00D8 LATIN CAPITAL LETTER O WITH STROKE (define-keysym #x00d8 "Ooblique") ;U+00D8 LATIN CAPITAL LETTER O WITH STROKE (define-keysym #x00d9 "Ugrave") ;U+00D9 LATIN CAPITAL LETTER U WITH GRAVE (define-keysym #x00da "Uacute") ;U+00DA LATIN CAPITAL LETTER U WITH ACUTE (define-keysym #x00db "Ucircumflex") ;U+00DB LATIN CAPITAL LETTER U WITH CIRCUMFLEX (define-keysym #x00dc "Udiaeresis") ;U+00DC LATIN CAPITAL LETTER U WITH DIAERESIS (define-keysym #x00dd "Yacute") ;U+00DD LATIN CAPITAL LETTER Y WITH ACUTE (define-keysym #x00de "THORN") ;U+00DE LATIN CAPITAL LETTER THORN (define-keysym #x00de "Thorn") ;deprecated (define-keysym #x00df "ssharp") ;U+00DF LATIN SMALL LETTER SHARP S (define-keysym #x00e0 "agrave") ;U+00E0 LATIN SMALL LETTER A WITH GRAVE (define-keysym #x00e1 "aacute") ;U+00E1 LATIN SMALL LETTER A WITH ACUTE (define-keysym #x00e2 "acircumflex") ;U+00E2 LATIN SMALL LETTER A WITH CIRCUMFLEX (define-keysym #x00e3 "atilde") ;U+00E3 LATIN SMALL LETTER A WITH TILDE (define-keysym #x00e4 "adiaeresis") ;U+00E4 LATIN SMALL LETTER A WITH DIAERESIS (define-keysym #x00e5 "aring") ;U+00E5 LATIN SMALL LETTER A WITH RING ABOVE (define-keysym #x00e6 "ae") ;U+00E6 LATIN SMALL LETTER AE (define-keysym #x00e7 "ccedilla") ;U+00E7 LATIN SMALL LETTER C WITH CEDILLA (define-keysym #x00e8 "egrave") ;U+00E8 LATIN SMALL LETTER E WITH GRAVE (define-keysym #x00e9 "eacute") ;U+00E9 LATIN SMALL LETTER E WITH ACUTE (define-keysym #x00ea "ecircumflex") ;U+00EA LATIN SMALL LETTER E WITH CIRCUMFLEX (define-keysym #x00eb "ediaeresis") ;U+00EB LATIN SMALL LETTER E WITH DIAERESIS (define-keysym #x00ec "igrave") ;U+00EC LATIN SMALL LETTER I WITH GRAVE (define-keysym #x00ed "iacute") ;U+00ED LATIN SMALL LETTER I WITH ACUTE (define-keysym #x00ee "icircumflex") ;U+00EE LATIN SMALL LETTER I WITH CIRCUMFLEX (define-keysym #x00ef "idiaeresis") ;U+00EF LATIN SMALL LETTER I WITH DIAERESIS (define-keysym #x00f0 "eth") ;U+00F0 LATIN SMALL LETTER ETH (define-keysym #x00f1 "ntilde") ;U+00F1 LATIN SMALL LETTER N WITH TILDE (define-keysym #x00f2 "ograve") ;U+00F2 LATIN SMALL LETTER O WITH GRAVE (define-keysym #x00f3 "oacute") ;U+00F3 LATIN SMALL LETTER O WITH ACUTE (define-keysym #x00f4 "ocircumflex") ;U+00F4 LATIN SMALL LETTER O WITH CIRCUMFLEX (define-keysym #x00f5 "otilde") ;U+00F5 LATIN SMALL LETTER O WITH TILDE (define-keysym #x00f6 "odiaeresis") ;U+00F6 LATIN SMALL LETTER O WITH DIAERESIS (define-keysym #x00f7 "division") ;U+00F7 DIVISION SIGN (define-keysym #x00f8 "oslash") ;U+00F8 LATIN SMALL LETTER O WITH STROKE (define-keysym #x00f8 "ooblique") ;U+00F8 LATIN SMALL LETTER O WITH STROKE (define-keysym #x00f9 "ugrave") ;U+00F9 LATIN SMALL LETTER U WITH GRAVE (define-keysym #x00fa "uacute") ;U+00FA LATIN SMALL LETTER U WITH ACUTE (define-keysym #x00fb "ucircumflex") ;U+00FB LATIN SMALL LETTER U WITH CIRCUMFLEX (define-keysym #x00fc "udiaeresis") ;U+00FC LATIN SMALL LETTER U WITH DIAERESIS (define-keysym #x00fd "yacute") ;U+00FD LATIN SMALL LETTER Y WITH ACUTE (define-keysym #x00fe "thorn") ;U+00FE LATIN SMALL LETTER THORN (define-keysym #x00ff "ydiaeresis") ;U+00FF LATIN SMALL LETTER Y WITH DIAERESIS (define-keysym #x01a1 "Aogonek") ;U+0104 LATIN CAPITAL LETTER A WITH OGONEK (define-keysym #x01a2 "breve") ;U+02D8 BREVE (define-keysym #x01a3 "Lstroke") ;U+0141 LATIN CAPITAL LETTER L WITH STROKE (define-keysym #x01a5 "Lcaron") ;U+013D LATIN CAPITAL LETTER L WITH CARON (define-keysym #x01a6 "Sacute") ;U+015A LATIN CAPITAL LETTER S WITH ACUTE (define-keysym #x01a9 "Scaron") ;U+0160 LATIN CAPITAL LETTER S WITH CARON (define-keysym #x01aa "Scedilla") ;U+015E LATIN CAPITAL LETTER S WITH CEDILLA (define-keysym #x01ab "Tcaron") ;U+0164 LATIN CAPITAL LETTER T WITH CARON (define-keysym #x01ac "Zacute") ;U+0179 LATIN CAPITAL LETTER Z WITH ACUTE (define-keysym #x01ae "Zcaron") ;U+017D LATIN CAPITAL LETTER Z WITH CARON (define-keysym #x01af "Zabovedot") ;U+017B LATIN CAPITAL LETTER Z WITH DOT ABOVE (define-keysym #x01b1 "aogonek") ;U+0105 LATIN SMALL LETTER A WITH OGONEK (define-keysym #x01b2 "ogonek") ;U+02DB OGONEK (define-keysym #x01b3 "lstroke") ;U+0142 LATIN SMALL LETTER L WITH STROKE (define-keysym #x01b5 "lcaron") ;U+013E LATIN SMALL LETTER L WITH CARON (define-keysym #x01b6 "sacute") ;U+015B LATIN SMALL LETTER S WITH ACUTE (define-keysym #x01b7 "caron") ;U+02C7 CARON (define-keysym #x01b9 "scaron") ;U+0161 LATIN SMALL LETTER S WITH CARON (define-keysym #x01ba "scedilla") ;U+015F LATIN SMALL LETTER S WITH CEDILLA (define-keysym #x01bb "tcaron") ;U+0165 LATIN SMALL LETTER T WITH CARON (define-keysym #x01bc "zacute") ;U+017A LATIN SMALL LETTER Z WITH ACUTE (define-keysym #x01bd "doubleacute") ;U+02DD DOUBLE ACUTE ACCENT (define-keysym #x01be "zcaron") ;U+017E LATIN SMALL LETTER Z WITH CARON (define-keysym #x01bf "zabovedot") ;U+017C LATIN SMALL LETTER Z WITH DOT ABOVE (define-keysym #x01c0 "Racute") ;U+0154 LATIN CAPITAL LETTER R WITH ACUTE (define-keysym #x01c3 "Abreve") ;U+0102 LATIN CAPITAL LETTER A WITH BREVE (define-keysym #x01c5 "Lacute") ;U+0139 LATIN CAPITAL LETTER L WITH ACUTE (define-keysym #x01c6 "Cacute") ;U+0106 LATIN CAPITAL LETTER C WITH ACUTE (define-keysym #x01c8 "Ccaron") ;U+010C LATIN CAPITAL LETTER C WITH CARON (define-keysym #x01ca "Eogonek") ;U+0118 LATIN CAPITAL LETTER E WITH OGONEK (define-keysym #x01cc "Ecaron") ;U+011A LATIN CAPITAL LETTER E WITH CARON (define-keysym #x01cf "Dcaron") ;U+010E LATIN CAPITAL LETTER D WITH CARON (define-keysym #x01d0 "Dstroke") ;U+0110 LATIN CAPITAL LETTER D WITH STROKE (define-keysym #x01d1 "Nacute") ;U+0143 LATIN CAPITAL LETTER N WITH ACUTE (define-keysym #x01d2 "Ncaron") ;U+0147 LATIN CAPITAL LETTER N WITH CARON (define-keysym #x01d5 "Odoubleacute") ;U+0150 LATIN CAPITAL LETTER O WITH DOUBLE ACUTE (define-keysym #x01d8 "Rcaron") ;U+0158 LATIN CAPITAL LETTER R WITH CARON (define-keysym #x01d9 "Uring") ;U+016E LATIN CAPITAL LETTER U WITH RING ABOVE (define-keysym #x01db "Udoubleacute") ;U+0170 LATIN CAPITAL LETTER U WITH DOUBLE ACUTE (define-keysym #x01de "Tcedilla") ;U+0162 LATIN CAPITAL LETTER T WITH CEDILLA (define-keysym #x01e0 "racute") ;U+0155 LATIN SMALL LETTER R WITH ACUTE (define-keysym #x01e3 "abreve") ;U+0103 LATIN SMALL LETTER A WITH BREVE (define-keysym #x01e5 "lacute") ;U+013A LATIN SMALL LETTER L WITH ACUTE (define-keysym #x01e6 "cacute") ;U+0107 LATIN SMALL LETTER C WITH ACUTE (define-keysym #x01e8 "ccaron") ;U+010D LATIN SMALL LETTER C WITH CARON (define-keysym #x01ea "eogonek") ;U+0119 LATIN SMALL LETTER E WITH OGONEK (define-keysym #x01ec "ecaron") ;U+011B LATIN SMALL LETTER E WITH CARON (define-keysym #x01ef "dcaron") ;U+010F LATIN SMALL LETTER D WITH CARON (define-keysym #x01f0 "dstroke") ;U+0111 LATIN SMALL LETTER D WITH STROKE (define-keysym #x01f1 "nacute") ;U+0144 LATIN SMALL LETTER N WITH ACUTE (define-keysym #x01f2 "ncaron") ;U+0148 LATIN SMALL LETTER N WITH CARON (define-keysym #x01f5 "odoubleacute") ;U+0151 LATIN SMALL LETTER O WITH DOUBLE ACUTE (define-keysym #x01fb "udoubleacute") ;U+0171 LATIN SMALL LETTER U WITH DOUBLE ACUTE (define-keysym #x01f8 "rcaron") ;U+0159 LATIN SMALL LETTER R WITH CARON (define-keysym #x01f9 "uring") ;U+016F LATIN SMALL LETTER U WITH RING ABOVE (define-keysym #x01fe "tcedilla") ;U+0163 LATIN SMALL LETTER T WITH CEDILLA (define-keysym #x01ff "abovedot") ;U+02D9 DOT ABOVE (define-keysym #x02a1 "Hstroke") ;U+0126 LATIN CAPITAL LETTER H WITH STROKE (define-keysym #x02a6 "Hcircumflex") ;U+0124 LATIN CAPITAL LETTER H WITH CIRCUMFLEX (define-keysym #x02a9 "Iabovedot") ;U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE (define-keysym #x02ab "Gbreve") ;U+011E LATIN CAPITAL LETTER G WITH BREVE (define-keysym #x02ac "Jcircumflex") ;U+0134 LATIN CAPITAL LETTER J WITH CIRCUMFLEX (define-keysym #x02b1 "hstroke") ;U+0127 LATIN SMALL LETTER H WITH STROKE (define-keysym #x02b6 "hcircumflex") ;U+0125 LATIN SMALL LETTER H WITH CIRCUMFLEX (define-keysym #x02b9 "idotless") ;U+0131 LATIN SMALL LETTER DOTLESS I (define-keysym #x02bb "gbreve") ;U+011F LATIN SMALL LETTER G WITH BREVE (define-keysym #x02bc "jcircumflex") ;U+0135 LATIN SMALL LETTER J WITH CIRCUMFLEX (define-keysym #x02c5 "Cabovedot") ;U+010A LATIN CAPITAL LETTER C WITH DOT ABOVE (define-keysym #x02c6 "Ccircumflex") ;U+0108 LATIN CAPITAL LETTER C WITH CIRCUMFLEX (define-keysym #x02d5 "Gabovedot") ;U+0120 LATIN CAPITAL LETTER G WITH DOT ABOVE (define-keysym #x02d8 "Gcircumflex") ;U+011C LATIN CAPITAL LETTER G WITH CIRCUMFLEX (define-keysym #x02dd "Ubreve") ;U+016C LATIN CAPITAL LETTER U WITH BREVE (define-keysym #x02de "Scircumflex") ;U+015C LATIN CAPITAL LETTER S WITH CIRCUMFLEX (define-keysym #x02e5 "cabovedot") ;U+010B LATIN SMALL LETTER C WITH DOT ABOVE (define-keysym #x02e6 "ccircumflex") ;U+0109 LATIN SMALL LETTER C WITH CIRCUMFLEX (define-keysym #x02f5 "gabovedot") ;U+0121 LATIN SMALL LETTER G WITH DOT ABOVE (define-keysym #x02f8 "gcircumflex") ;U+011D LATIN SMALL LETTER G WITH CIRCUMFLEX (define-keysym #x02fd "ubreve") ;U+016D LATIN SMALL LETTER U WITH BREVE (define-keysym #x02fe "scircumflex") ;U+015D LATIN SMALL LETTER S WITH CIRCUMFLEX (define-keysym #x03a2 "kra") ;U+0138 LATIN SMALL LETTER KRA (define-keysym #x03a2 "kappa") ;deprecated (define-keysym #x03a3 "Rcedilla") ;U+0156 LATIN CAPITAL LETTER R WITH CEDILLA (define-keysym #x03a5 "Itilde") ;U+0128 LATIN CAPITAL LETTER I WITH TILDE (define-keysym #x03a6 "Lcedilla") ;U+013B LATIN CAPITAL LETTER L WITH CEDILLA (define-keysym #x03aa "Emacron") ;U+0112 LATIN CAPITAL LETTER E WITH MACRON (define-keysym #x03ab "Gcedilla") ;U+0122 LATIN CAPITAL LETTER G WITH CEDILLA (define-keysym #x03ac "Tslash") ;U+0166 LATIN CAPITAL LETTER T WITH STROKE (define-keysym #x03b3 "rcedilla") ;U+0157 LATIN SMALL LETTER R WITH CEDILLA (define-keysym #x03b5 "itilde") ;U+0129 LATIN SMALL LETTER I WITH TILDE (define-keysym #x03b6 "lcedilla") ;U+013C LATIN SMALL LETTER L WITH CEDILLA (define-keysym #x03ba "emacron") ;U+0113 LATIN SMALL LETTER E WITH MACRON (define-keysym #x03bb "gcedilla") ;U+0123 LATIN SMALL LETTER G WITH CEDILLA (define-keysym #x03bc "tslash") ;U+0167 LATIN SMALL LETTER T WITH STROKE (define-keysym #x03bd "ENG") ;U+014A LATIN CAPITAL LETTER ENG (define-keysym #x03bf "eng") ;U+014B LATIN SMALL LETTER ENG (define-keysym #x03c0 "Amacron") ;U+0100 LATIN CAPITAL LETTER A WITH MACRON (define-keysym #x03c7 "Iogonek") ;U+012E LATIN CAPITAL LETTER I WITH OGONEK (define-keysym #x03cc "Eabovedot") ;U+0116 LATIN CAPITAL LETTER E WITH DOT ABOVE (define-keysym #x03cf "Imacron") ;U+012A LATIN CAPITAL LETTER I WITH MACRON (define-keysym #x03d1 "Ncedilla") ;U+0145 LATIN CAPITAL LETTER N WITH CEDILLA (define-keysym #x03d2 "Omacron") ;U+014C LATIN CAPITAL LETTER O WITH MACRON (define-keysym #x03d3 "Kcedilla") ;U+0136 LATIN CAPITAL LETTER K WITH CEDILLA (define-keysym #x03d9 "Uogonek") ;U+0172 LATIN CAPITAL LETTER U WITH OGONEK (define-keysym #x03dd "Utilde") ;U+0168 LATIN CAPITAL LETTER U WITH TILDE (define-keysym #x03de "Umacron") ;U+016A LATIN CAPITAL LETTER U WITH MACRON (define-keysym #x03e0 "amacron") ;U+0101 LATIN SMALL LETTER A WITH MACRON (define-keysym #x03e7 "iogonek") ;U+012F LATIN SMALL LETTER I WITH OGONEK (define-keysym #x03ec "eabovedot") ;U+0117 LATIN SMALL LETTER E WITH DOT ABOVE (define-keysym #x03ef "imacron") ;U+012B LATIN SMALL LETTER I WITH MACRON (define-keysym #x03f1 "ncedilla") ;U+0146 LATIN SMALL LETTER N WITH CEDILLA (define-keysym #x03f2 "omacron") ;U+014D LATIN SMALL LETTER O WITH MACRON (define-keysym #x03f3 "kcedilla") ;U+0137 LATIN SMALL LETTER K WITH CEDILLA (define-keysym #x03f9 "uogonek") ;U+0173 LATIN SMALL LETTER U WITH OGONEK (define-keysym #x03fd "utilde") ;U+0169 LATIN SMALL LETTER U WITH TILDE (define-keysym #x03fe "umacron") ;U+016B LATIN SMALL LETTER U WITH MACRON (define-keysym #x1001e02 "Babovedot") ;U+1E02 LATIN CAPITAL LETTER B WITH DOT ABOVE (define-keysym #x1001e03 "babovedot") ;U+1E03 LATIN SMALL LETTER B WITH DOT ABOVE (define-keysym #x1001e0a "Dabovedot") ;U+1E0A LATIN CAPITAL LETTER D WITH DOT ABOVE (define-keysym #x1001e80 "Wgrave") ;U+1E80 LATIN CAPITAL LETTER W WITH GRAVE (define-keysym #x1001e82 "Wacute") ;U+1E82 LATIN CAPITAL LETTER W WITH ACUTE (define-keysym #x1001e0b "dabovedot") ;U+1E0B LATIN SMALL LETTER D WITH DOT ABOVE (define-keysym #x1001ef2 "Ygrave") ;U+1EF2 LATIN CAPITAL LETTER Y WITH GRAVE (define-keysym #x1001e1e "Fabovedot") ;U+1E1E LATIN CAPITAL LETTER F WITH DOT ABOVE (define-keysym #x1001e1f "fabovedot") ;U+1E1F LATIN SMALL LETTER F WITH DOT ABOVE (define-keysym #x1001e40 "Mabovedot") ;U+1E40 LATIN CAPITAL LETTER M WITH DOT ABOVE (define-keysym #x1001e41 "mabovedot") ;U+1E41 LATIN SMALL LETTER M WITH DOT ABOVE (define-keysym #x1001e56 "Pabovedot") ;U+1E56 LATIN CAPITAL LETTER P WITH DOT ABOVE (define-keysym #x1001e81 "wgrave") ;U+1E81 LATIN SMALL LETTER W WITH GRAVE (define-keysym #x1001e57 "pabovedot") ;U+1E57 LATIN SMALL LETTER P WITH DOT ABOVE (define-keysym #x1001e83 "wacute") ;U+1E83 LATIN SMALL LETTER W WITH ACUTE (define-keysym #x1001e60 "Sabovedot") ;U+1E60 LATIN CAPITAL LETTER S WITH DOT ABOVE (define-keysym #x1001ef3 "ygrave") ;U+1EF3 LATIN SMALL LETTER Y WITH GRAVE (define-keysym #x1001e84 "Wdiaeresis") ;U+1E84 LATIN CAPITAL LETTER W WITH DIAERESIS (define-keysym #x1001e85 "wdiaeresis") ;U+1E85 LATIN SMALL LETTER W WITH DIAERESIS (define-keysym #x1001e61 "sabovedot") ;U+1E61 LATIN SMALL LETTER S WITH DOT ABOVE (define-keysym #x1000174 "Wcircumflex") ;U+0174 LATIN CAPITAL LETTER W WITH CIRCUMFLEX (define-keysym #x1001e6a "Tabovedot") ;U+1E6A LATIN CAPITAL LETTER T WITH DOT ABOVE (define-keysym #x1000176 "Ycircumflex") ;U+0176 LATIN CAPITAL LETTER Y WITH CIRCUMFLEX (define-keysym #x1000175 "wcircumflex") ;U+0175 LATIN SMALL LETTER W WITH CIRCUMFLEX (define-keysym #x1001e6b "tabovedot") ;U+1E6B LATIN SMALL LETTER T WITH DOT ABOVE (define-keysym #x1000177 "ycircumflex") ;U+0177 LATIN SMALL LETTER Y WITH CIRCUMFLEX (define-keysym #x13bc "OE") ;U+0152 LATIN CAPITAL LIGATURE OE (define-keysym #x13bd "oe") ;U+0153 LATIN SMALL LIGATURE OE (define-keysym #x13be "Ydiaeresis") ;U+0178 LATIN CAPITAL LETTER Y WITH DIAERESIS (define-keysym #x047e "overline") ;U+203E OVERLINE (define-keysym #x04a1 "kana_fullstop") ;U+3002 IDEOGRAPHIC FULL STOP (define-keysym #x04a2 "kana_openingbracket") ;U+300C LEFT CORNER BRACKET (define-keysym #x04a3 "kana_closingbracket") ;U+300D RIGHT CORNER BRACKET (define-keysym #x04a4 "kana_comma") ;U+3001 IDEOGRAPHIC COMMA (define-keysym #x04a5 "kana_conjunctive") ;U+30FB KATAKANA MIDDLE DOT (define-keysym #x04a5 "kana_middledot") ;deprecated (define-keysym #x04a6 "kana_WO") ;U+30F2 KATAKANA LETTER WO (define-keysym #x04a7 "kana_a") ;U+30A1 KATAKANA LETTER SMALL A (define-keysym #x04a8 "kana_i") ;U+30A3 KATAKANA LETTER SMALL I (define-keysym #x04a9 "kana_u") ;U+30A5 KATAKANA LETTER SMALL U (define-keysym #x04aa "kana_e") ;U+30A7 KATAKANA LETTER SMALL E (define-keysym #x04ab "kana_o") ;U+30A9 KATAKANA LETTER SMALL O (define-keysym #x04ac "kana_ya") ;U+30E3 KATAKANA LETTER SMALL YA (define-keysym #x04ad "kana_yu") ;U+30E5 KATAKANA LETTER SMALL YU (define-keysym #x04ae "kana_yo") ;U+30E7 KATAKANA LETTER SMALL YO (define-keysym #x04af "kana_tsu") ;U+30C3 KATAKANA LETTER SMALL TU (define-keysym #x04af "kana_tu") ;deprecated (define-keysym #x04b0 "prolongedsound") ;U+30FC KATAKANA-HIRAGANA PROLONGED SOUND MARK (define-keysym #x04b1 "kana_A") ;U+30A2 KATAKANA LETTER A (define-keysym #x04b2 "kana_I") ;U+30A4 KATAKANA LETTER I (define-keysym #x04b3 "kana_U") ;U+30A6 KATAKANA LETTER U (define-keysym #x04b4 "kana_E") ;U+30A8 KATAKANA LETTER E (define-keysym #x04b5 "kana_O") ;U+30AA KATAKANA LETTER O (define-keysym #x04b6 "kana_KA") ;U+30AB KATAKANA LETTER KA (define-keysym #x04b7 "kana_KI") ;U+30AD KATAKANA LETTER KI (define-keysym #x04b8 "kana_KU") ;U+30AF KATAKANA LETTER KU (define-keysym #x04b9 "kana_KE") ;U+30B1 KATAKANA LETTER KE (define-keysym #x04ba "kana_KO") ;U+30B3 KATAKANA LETTER KO (define-keysym #x04bb "kana_SA") ;U+30B5 KATAKANA LETTER SA (define-keysym #x04bc "kana_SHI") ;U+30B7 KATAKANA LETTER SI (define-keysym #x04bd "kana_SU") ;U+30B9 KATAKANA LETTER SU (define-keysym #x04be "kana_SE") ;U+30BB KATAKANA LETTER SE (define-keysym #x04bf "kana_SO") ;U+30BD KATAKANA LETTER SO (define-keysym #x04c0 "kana_TA") ;U+30BF KATAKANA LETTER TA (define-keysym #x04c1 "kana_CHI") ;U+30C1 KATAKANA LETTER TI (define-keysym #x04c1 "kana_TI") ;deprecated (define-keysym #x04c2 "kana_TSU") ;U+30C4 KATAKANA LETTER TU (define-keysym #x04c2 "kana_TU") ;deprecated (define-keysym #x04c3 "kana_TE") ;U+30C6 KATAKANA LETTER TE (define-keysym #x04c4 "kana_TO") ;U+30C8 KATAKANA LETTER TO (define-keysym #x04c5 "kana_NA") ;U+30CA KATAKANA LETTER NA (define-keysym #x04c6 "kana_NI") ;U+30CB KATAKANA LETTER NI (define-keysym #x04c7 "kana_NU") ;U+30CC KATAKANA LETTER NU (define-keysym #x04c8 "kana_NE") ;U+30CD KATAKANA LETTER NE (define-keysym #x04c9 "kana_NO") ;U+30CE KATAKANA LETTER NO (define-keysym #x04ca "kana_HA") ;U+30CF KATAKANA LETTER HA (define-keysym #x04cb "kana_HI") ;U+30D2 KATAKANA LETTER HI (define-keysym #x04cc "kana_FU") ;U+30D5 KATAKANA LETTER HU (define-keysym #x04cc "kana_HU") ;deprecated (define-keysym #x04cd "kana_HE") ;U+30D8 KATAKANA LETTER HE (define-keysym #x04ce "kana_HO") ;U+30DB KATAKANA LETTER HO (define-keysym #x04cf "kana_MA") ;U+30DE KATAKANA LETTER MA (define-keysym #x04d0 "kana_MI") ;U+30DF KATAKANA LETTER MI (define-keysym #x04d1 "kana_MU") ;U+30E0 KATAKANA LETTER MU (define-keysym #x04d2 "kana_ME") ;U+30E1 KATAKANA LETTER ME (define-keysym #x04d3 "kana_MO") ;U+30E2 KATAKANA LETTER MO (define-keysym #x04d4 "kana_YA") ;U+30E4 KATAKANA LETTER YA (define-keysym #x04d5 "kana_YU") ;U+30E6 KATAKANA LETTER YU (define-keysym #x04d6 "kana_YO") ;U+30E8 KATAKANA LETTER YO (define-keysym #x04d7 "kana_RA") ;U+30E9 KATAKANA LETTER RA (define-keysym #x04d8 "kana_RI") ;U+30EA KATAKANA LETTER RI (define-keysym #x04d9 "kana_RU") ;U+30EB KATAKANA LETTER RU (define-keysym #x04da "kana_RE") ;U+30EC KATAKANA LETTER RE (define-keysym #x04db "kana_RO") ;U+30ED KATAKANA LETTER RO (define-keysym #x04dc "kana_WA") ;U+30EF KATAKANA LETTER WA (define-keysym #x04dd "kana_N") ;U+30F3 KATAKANA LETTER N (define-keysym #x04de "voicedsound") ;U+309B KATAKANA-HIRAGANA VOICED SOUND MARK (define-keysym #x04df "semivoicedsound") ;U+309C KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK (define-keysym #xff7e "kana_switch") ;Alias for mode_switch (define-keysym #x10006f0 "Farsi_0") ;U+06F0 EXTENDED ARABIC-INDIC DIGIT ZERO (define-keysym #x10006f1 "Farsi_1") ;U+06F1 EXTENDED ARABIC-INDIC DIGIT ONE (define-keysym #x10006f2 "Farsi_2") ;U+06F2 EXTENDED ARABIC-INDIC DIGIT TWO (define-keysym #x10006f3 "Farsi_3") ;U+06F3 EXTENDED ARABIC-INDIC DIGIT THREE (define-keysym #x10006f4 "Farsi_4") ;U+06F4 EXTENDED ARABIC-INDIC DIGIT FOUR (define-keysym #x10006f5 "Farsi_5") ;U+06F5 EXTENDED ARABIC-INDIC DIGIT FIVE (define-keysym #x10006f6 "Farsi_6") ;U+06F6 EXTENDED ARABIC-INDIC DIGIT SIX (define-keysym #x10006f7 "Farsi_7") ;U+06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN (define-keysym #x10006f8 "Farsi_8") ;U+06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT (define-keysym #x10006f9 "Farsi_9") ;U+06F9 EXTENDED ARABIC-INDIC DIGIT NINE (define-keysym #x100066a "Arabic_percent") ;U+066A ARABIC PERCENT SIGN (define-keysym #x1000670 "Arabic_superscript_alef") ;U+0670 ARABIC LETTER SUPERSCRIPT ALEF (define-keysym #x1000679 "Arabic_tteh") ;U+0679 ARABIC LETTER TTEH (define-keysym #x100067e "Arabic_peh") ;U+067E ARABIC LETTER PEH (define-keysym #x1000686 "Arabic_tcheh") ;U+0686 ARABIC LETTER TCHEH (define-keysym #x1000688 "Arabic_ddal") ;U+0688 ARABIC LETTER DDAL (define-keysym #x1000691 "Arabic_rreh") ;U+0691 ARABIC LETTER RREH (define-keysym #x05ac "Arabic_comma") ;U+060C ARABIC COMMA (define-keysym #x10006d4 "Arabic_fullstop") ;U+06D4 ARABIC FULL STOP (define-keysym #x1000660 "Arabic_0") ;U+0660 ARABIC-INDIC DIGIT ZERO (define-keysym #x1000661 "Arabic_1") ;U+0661 ARABIC-INDIC DIGIT ONE (define-keysym #x1000662 "Arabic_2") ;U+0662 ARABIC-INDIC DIGIT TWO (define-keysym #x1000663 "Arabic_3") ;U+0663 ARABIC-INDIC DIGIT THREE (define-keysym #x1000664 "Arabic_4") ;U+0664 ARABIC-INDIC DIGIT FOUR (define-keysym #x1000665 "Arabic_5") ;U+0665 ARABIC-INDIC DIGIT FIVE (define-keysym #x1000666 "Arabic_6") ;U+0666 ARABIC-INDIC DIGIT SIX (define-keysym #x1000667 "Arabic_7") ;U+0667 ARABIC-INDIC DIGIT SEVEN (define-keysym #x1000668 "Arabic_8") ;U+0668 ARABIC-INDIC DIGIT EIGHT (define-keysym #x1000669 "Arabic_9") ;U+0669 ARABIC-INDIC DIGIT NINE (define-keysym #x05bb "Arabic_semicolon") ;U+061B ARABIC SEMICOLON (define-keysym #x05bf "Arabic_question_mark") ;U+061F ARABIC QUESTION MARK (define-keysym #x05c1 "Arabic_hamza") ;U+0621 ARABIC LETTER HAMZA (define-keysym #x05c2 "Arabic_maddaonalef") ;U+0622 ARABIC LETTER ALEF WITH MADDA ABOVE (define-keysym #x05c3 "Arabic_hamzaonalef") ;U+0623 ARABIC LETTER ALEF WITH HAMZA ABOVE (define-keysym #x05c4 "Arabic_hamzaonwaw") ;U+0624 ARABIC LETTER WAW WITH HAMZA ABOVE (define-keysym #x05c5 "Arabic_hamzaunderalef") ;U+0625 ARABIC LETTER ALEF WITH HAMZA BELOW (define-keysym #x05c6 "Arabic_hamzaonyeh") ;U+0626 ARABIC LETTER YEH WITH HAMZA ABOVE (define-keysym #x05c7 "Arabic_alef") ;U+0627 ARABIC LETTER ALEF (define-keysym #x05c8 "Arabic_beh") ;U+0628 ARABIC LETTER BEH (define-keysym #x05c9 "Arabic_tehmarbuta") ;U+0629 ARABIC LETTER TEH MARBUTA (define-keysym #x05ca "Arabic_teh") ;U+062A ARABIC LETTER TEH (define-keysym #x05cb "Arabic_theh") ;U+062B ARABIC LETTER THEH (define-keysym #x05cc "Arabic_jeem") ;U+062C ARABIC LETTER JEEM (define-keysym #x05cd "Arabic_hah") ;U+062D ARABIC LETTER HAH (define-keysym #x05ce "Arabic_khah") ;U+062E ARABIC LETTER KHAH (define-keysym #x05cf "Arabic_dal") ;U+062F ARABIC LETTER DAL (define-keysym #x05d0 "Arabic_thal") ;U+0630 ARABIC LETTER THAL (define-keysym #x05d1 "Arabic_ra") ;U+0631 ARABIC LETTER REH (define-keysym #x05d2 "Arabic_zain") ;U+0632 ARABIC LETTER ZAIN (define-keysym #x05d3 "Arabic_seen") ;U+0633 ARABIC LETTER SEEN (define-keysym #x05d4 "Arabic_sheen") ;U+0634 ARABIC LETTER SHEEN (define-keysym #x05d5 "Arabic_sad") ;U+0635 ARABIC LETTER SAD (define-keysym #x05d6 "Arabic_dad") ;U+0636 ARABIC LETTER DAD (define-keysym #x05d7 "Arabic_tah") ;U+0637 ARABIC LETTER TAH (define-keysym #x05d8 "Arabic_zah") ;U+0638 ARABIC LETTER ZAH (define-keysym #x05d9 "Arabic_ain") ;U+0639 ARABIC LETTER AIN (define-keysym #x05da "Arabic_ghain") ;U+063A ARABIC LETTER GHAIN (define-keysym #x05e0 "Arabic_tatweel") ;U+0640 ARABIC TATWEEL (define-keysym #x05e1 "Arabic_feh") ;U+0641 ARABIC LETTER FEH (define-keysym #x05e2 "Arabic_qaf") ;U+0642 ARABIC LETTER QAF (define-keysym #x05e3 "Arabic_kaf") ;U+0643 ARABIC LETTER KAF (define-keysym #x05e4 "Arabic_lam") ;U+0644 ARABIC LETTER LAM (define-keysym #x05e5 "Arabic_meem") ;U+0645 ARABIC LETTER MEEM (define-keysym #x05e6 "Arabic_noon") ;U+0646 ARABIC LETTER NOON (define-keysym #x05e7 "Arabic_ha") ;U+0647 ARABIC LETTER HEH (define-keysym #x05e7 "Arabic_heh") ;deprecated (define-keysym #x05e8 "Arabic_waw") ;U+0648 ARABIC LETTER WAW (define-keysym #x05e9 "Arabic_alefmaksura") ;U+0649 ARABIC LETTER ALEF MAKSURA (define-keysym #x05ea "Arabic_yeh") ;U+064A ARABIC LETTER YEH (define-keysym #x05eb "Arabic_fathatan") ;U+064B ARABIC FATHATAN (define-keysym #x05ec "Arabic_dammatan") ;U+064C ARABIC DAMMATAN (define-keysym #x05ed "Arabic_kasratan") ;U+064D ARABIC KASRATAN (define-keysym #x05ee "Arabic_fatha") ;U+064E ARABIC FATHA (define-keysym #x05ef "Arabic_damma") ;U+064F ARABIC DAMMA (define-keysym #x05f0 "Arabic_kasra") ;U+0650 ARABIC KASRA (define-keysym #x05f1 "Arabic_shadda") ;U+0651 ARABIC SHADDA (define-keysym #x05f2 "Arabic_sukun") ;U+0652 ARABIC SUKUN (define-keysym #x1000653 "Arabic_madda_above") ;U+0653 ARABIC MADDAH ABOVE (define-keysym #x1000654 "Arabic_hamza_above") ;U+0654 ARABIC HAMZA ABOVE (define-keysym #x1000655 "Arabic_hamza_below") ;U+0655 ARABIC HAMZA BELOW (define-keysym #x1000698 "Arabic_jeh") ;U+0698 ARABIC LETTER JEH (define-keysym #x10006a4 "Arabic_veh") ;U+06A4 ARABIC LETTER VEH (define-keysym #x10006a9 "Arabic_keheh") ;U+06A9 ARABIC LETTER KEHEH (define-keysym #x10006af "Arabic_gaf") ;U+06AF ARABIC LETTER GAF (define-keysym #x10006ba "Arabic_noon_ghunna") ;U+06BA ARABIC LETTER NOON GHUNNA (define-keysym #x10006be "Arabic_heh_doachashmee") ;U+06BE ARABIC LETTER HEH DOACHASHMEE (define-keysym #x10006cc "Farsi_yeh") ;U+06CC ARABIC LETTER FARSI YEH (define-keysym #x10006cc "Arabic_farsi_yeh") ;U+06CC ARABIC LETTER FARSI YEH (define-keysym #x10006d2 "Arabic_yeh_baree") ;U+06D2 ARABIC LETTER YEH BARREE (define-keysym #x10006c1 "Arabic_heh_goal") ;U+06C1 ARABIC LETTER HEH GOAL (define-keysym #xff7e "Arabic_switch") ;Alias for mode_switch (define-keysym #x1000492 "Cyrillic_GHE_bar") ;U+0492 CYRILLIC CAPITAL LETTER GHE WITH STROKE (define-keysym #x1000493 "Cyrillic_ghe_bar") ;U+0493 CYRILLIC SMALL LETTER GHE WITH STROKE (define-keysym #x1000496 "Cyrillic_ZHE_descender") ;U+0496 CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER (define-keysym #x1000497 "Cyrillic_zhe_descender") ;U+0497 CYRILLIC SMALL LETTER ZHE WITH DESCENDER (define-keysym #x100049a "Cyrillic_KA_descender") ;U+049A CYRILLIC CAPITAL LETTER KA WITH DESCENDER (define-keysym #x100049b "Cyrillic_ka_descender") ;U+049B CYRILLIC SMALL LETTER KA WITH DESCENDER (define-keysym #x100049c "Cyrillic_KA_vertstroke") ;U+049C CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE (define-keysym #x100049d "Cyrillic_ka_vertstroke") ;U+049D CYRILLIC SMALL LETTER KA WITH VERTICAL STROKE (define-keysym #x10004a2 "Cyrillic_EN_descender") ;U+04A2 CYRILLIC CAPITAL LETTER EN WITH DESCENDER (define-keysym #x10004a3 "Cyrillic_en_descender") ;U+04A3 CYRILLIC SMALL LETTER EN WITH DESCENDER (define-keysym #x10004ae "Cyrillic_U_straight") ;U+04AE CYRILLIC CAPITAL LETTER STRAIGHT U (define-keysym #x10004af "Cyrillic_u_straight") ;U+04AF CYRILLIC SMALL LETTER STRAIGHT U (define-keysym #x10004b0 "Cyrillic_U_straight_bar") ;U+04B0 CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE (define-keysym #x10004b1 "Cyrillic_u_straight_bar") ;U+04B1 CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE (define-keysym #x10004b2 "Cyrillic_HA_descender") ;U+04B2 CYRILLIC CAPITAL LETTER HA WITH DESCENDER (define-keysym #x10004b3 "Cyrillic_ha_descender") ;U+04B3 CYRILLIC SMALL LETTER HA WITH DESCENDER (define-keysym #x10004b6 "Cyrillic_CHE_descender") ;U+04B6 CYRILLIC CAPITAL LETTER CHE WITH DESCENDER (define-keysym #x10004b7 "Cyrillic_che_descender") ;U+04B7 CYRILLIC SMALL LETTER CHE WITH DESCENDER (define-keysym #x10004b8 "Cyrillic_CHE_vertstroke") ;U+04B8 CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE (define-keysym #x10004b9 "Cyrillic_che_vertstroke") ;U+04B9 CYRILLIC SMALL LETTER CHE WITH VERTICAL STROKE (define-keysym #x10004ba "Cyrillic_SHHA") ;U+04BA CYRILLIC CAPITAL LETTER SHHA (define-keysym #x10004bb "Cyrillic_shha") ;U+04BB CYRILLIC SMALL LETTER SHHA (define-keysym #x10004d8 "Cyrillic_SCHWA") ;U+04D8 CYRILLIC CAPITAL LETTER SCHWA (define-keysym #x10004d9 "Cyrillic_schwa") ;U+04D9 CYRILLIC SMALL LETTER SCHWA (define-keysym #x10004e2 "Cyrillic_I_macron") ;U+04E2 CYRILLIC CAPITAL LETTER I WITH MACRON (define-keysym #x10004e3 "Cyrillic_i_macron") ;U+04E3 CYRILLIC SMALL LETTER I WITH MACRON (define-keysym #x10004e8 "Cyrillic_O_bar") ;U+04E8 CYRILLIC CAPITAL LETTER BARRED O (define-keysym #x10004e9 "Cyrillic_o_bar") ;U+04E9 CYRILLIC SMALL LETTER BARRED O (define-keysym #x10004ee "Cyrillic_U_macron") ;U+04EE CYRILLIC CAPITAL LETTER U WITH MACRON (define-keysym #x10004ef "Cyrillic_u_macron") ;U+04EF CYRILLIC SMALL LETTER U WITH MACRON (define-keysym #x06a1 "Serbian_dje") ;U+0452 CYRILLIC SMALL LETTER DJE (define-keysym #x06a2 "Macedonia_gje") ;U+0453 CYRILLIC SMALL LETTER GJE (define-keysym #x06a3 "Cyrillic_io") ;U+0451 CYRILLIC SMALL LETTER IO (define-keysym #x06a4 "Ukrainian_ie") ;U+0454 CYRILLIC SMALL LETTER UKRAINIAN IE (define-keysym #x06a4 "Ukranian_je") ;deprecated (define-keysym #x06a5 "Macedonia_dse") ;U+0455 CYRILLIC SMALL LETTER DZE (define-keysym #x06a6 "Ukrainian_i") ;U+0456 CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I (define-keysym #x06a6 "Ukranian_i") ;deprecated (define-keysym #x06a7 "Ukrainian_yi") ;U+0457 CYRILLIC SMALL LETTER YI (define-keysym #x06a7 "Ukranian_yi") ;deprecated (define-keysym #x06a8 "Cyrillic_je") ;U+0458 CYRILLIC SMALL LETTER JE (define-keysym #x06a8 "Serbian_je") ;deprecated (define-keysym #x06a9 "Cyrillic_lje") ;U+0459 CYRILLIC SMALL LETTER LJE (define-keysym #x06a9 "Serbian_lje") ;deprecated (define-keysym #x06aa "Cyrillic_nje") ;U+045A CYRILLIC SMALL LETTER NJE (define-keysym #x06aa "Serbian_nje") ;deprecated (define-keysym #x06ab "Serbian_tshe") ;U+045B CYRILLIC SMALL LETTER TSHE (define-keysym #x06ac "Macedonia_kje") ;U+045C CYRILLIC SMALL LETTER KJE (define-keysym #x06ad "Ukrainian_ghe_with_upturn") ;U+0491 CYRILLIC SMALL LETTER GHE WITH UPTURN (define-keysym #x06ae "Byelorussian_shortu") ;U+045E CYRILLIC SMALL LETTER SHORT U (define-keysym #x06af "Cyrillic_dzhe") ;U+045F CYRILLIC SMALL LETTER DZHE (define-keysym #x06af "Serbian_dze") ;deprecated (define-keysym #x06b0 "numerosign") ;U+2116 NUMERO SIGN (define-keysym #x06b1 "Serbian_DJE") ;U+0402 CYRILLIC CAPITAL LETTER DJE (define-keysym #x06b2 "Macedonia_GJE") ;U+0403 CYRILLIC CAPITAL LETTER GJE (define-keysym #x06b3 "Cyrillic_IO") ;U+0401 CYRILLIC CAPITAL LETTER IO (define-keysym #x06b4 "Ukrainian_IE") ;U+0404 CYRILLIC CAPITAL LETTER UKRAINIAN IE (define-keysym #x06b4 "Ukranian_JE") ;deprecated (define-keysym #x06b5 "Macedonia_DSE") ;U+0405 CYRILLIC CAPITAL LETTER DZE (define-keysym #x06b6 "Ukrainian_I") ;U+0406 CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I (define-keysym #x06b6 "Ukranian_I") ;deprecated (define-keysym #x06b7 "Ukrainian_YI") ;U+0407 CYRILLIC CAPITAL LETTER YI (define-keysym #x06b7 "Ukranian_YI") ;deprecated (define-keysym #x06b8 "Cyrillic_JE") ;U+0408 CYRILLIC CAPITAL LETTER JE (define-keysym #x06b8 "Serbian_JE") ;deprecated (define-keysym #x06b9 "Cyrillic_LJE") ;U+0409 CYRILLIC CAPITAL LETTER LJE (define-keysym #x06b9 "Serbian_LJE") ;deprecated (define-keysym #x06ba "Cyrillic_NJE") ;U+040A CYRILLIC CAPITAL LETTER NJE (define-keysym #x06ba "Serbian_NJE") ;deprecated (define-keysym #x06bb "Serbian_TSHE") ;U+040B CYRILLIC CAPITAL LETTER TSHE (define-keysym #x06bc "Macedonia_KJE") ;U+040C CYRILLIC CAPITAL LETTER KJE (define-keysym #x06bd "Ukrainian_GHE_WITH_UPTURN") ;U+0490 CYRILLIC CAPITAL LETTER GHE WITH UPTURN (define-keysym #x06be "Byelorussian_SHORTU") ;U+040E CYRILLIC CAPITAL LETTER SHORT U (define-keysym #x06bf "Cyrillic_DZHE") ;U+040F CYRILLIC CAPITAL LETTER DZHE (define-keysym #x06bf "Serbian_DZE") ;deprecated (define-keysym #x06c0 "Cyrillic_yu") ;U+044E CYRILLIC SMALL LETTER YU (define-keysym #x06c1 "Cyrillic_a") ;U+0430 CYRILLIC SMALL LETTER A (define-keysym #x06c2 "Cyrillic_be") ;U+0431 CYRILLIC SMALL LETTER BE (define-keysym #x06c3 "Cyrillic_tse") ;U+0446 CYRILLIC SMALL LETTER TSE (define-keysym #x06c4 "Cyrillic_de") ;U+0434 CYRILLIC SMALL LETTER DE (define-keysym #x06c5 "Cyrillic_ie") ;U+0435 CYRILLIC SMALL LETTER IE (define-keysym #x06c6 "Cyrillic_ef") ;U+0444 CYRILLIC SMALL LETTER EF (define-keysym #x06c7 "Cyrillic_ghe") ;U+0433 CYRILLIC SMALL LETTER GHE (define-keysym #x06c8 "Cyrillic_ha") ;U+0445 CYRILLIC SMALL LETTER HA (define-keysym #x06c9 "Cyrillic_i") ;U+0438 CYRILLIC SMALL LETTER I (define-keysym #x06ca "Cyrillic_shorti") ;U+0439 CYRILLIC SMALL LETTER SHORT I (define-keysym #x06cb "Cyrillic_ka") ;U+043A CYRILLIC SMALL LETTER KA (define-keysym #x06cc "Cyrillic_el") ;U+043B CYRILLIC SMALL LETTER EL (define-keysym #x06cd "Cyrillic_em") ;U+043C CYRILLIC SMALL LETTER EM (define-keysym #x06ce "Cyrillic_en") ;U+043D CYRILLIC SMALL LETTER EN (define-keysym #x06cf "Cyrillic_o") ;U+043E CYRILLIC SMALL LETTER O (define-keysym #x06d0 "Cyrillic_pe") ;U+043F CYRILLIC SMALL LETTER PE (define-keysym #x06d1 "Cyrillic_ya") ;U+044F CYRILLIC SMALL LETTER YA (define-keysym #x06d2 "Cyrillic_er") ;U+0440 CYRILLIC SMALL LETTER ER (define-keysym #x06d3 "Cyrillic_es") ;U+0441 CYRILLIC SMALL LETTER ES (define-keysym #x06d4 "Cyrillic_te") ;U+0442 CYRILLIC SMALL LETTER TE (define-keysym #x06d5 "Cyrillic_u") ;U+0443 CYRILLIC SMALL LETTER U (define-keysym #x06d6 "Cyrillic_zhe") ;U+0436 CYRILLIC SMALL LETTER ZHE (define-keysym #x06d7 "Cyrillic_ve") ;U+0432 CYRILLIC SMALL LETTER VE (define-keysym #x06d8 "Cyrillic_softsign") ;U+044C CYRILLIC SMALL LETTER SOFT SIGN (define-keysym #x06d9 "Cyrillic_yeru") ;U+044B CYRILLIC SMALL LETTER YERU (define-keysym #x06da "Cyrillic_ze") ;U+0437 CYRILLIC SMALL LETTER ZE (define-keysym #x06db "Cyrillic_sha") ;U+0448 CYRILLIC SMALL LETTER SHA (define-keysym #x06dc "Cyrillic_e") ;U+044D CYRILLIC SMALL LETTER E (define-keysym #x06dd "Cyrillic_shcha") ;U+0449 CYRILLIC SMALL LETTER SHCHA (define-keysym #x06de "Cyrillic_che") ;U+0447 CYRILLIC SMALL LETTER CHE (define-keysym #x06df "Cyrillic_hardsign") ;U+044A CYRILLIC SMALL LETTER HARD SIGN (define-keysym #x06e0 "Cyrillic_YU") ;U+042E CYRILLIC CAPITAL LETTER YU (define-keysym #x06e1 "Cyrillic_A") ;U+0410 CYRILLIC CAPITAL LETTER A (define-keysym #x06e2 "Cyrillic_BE") ;U+0411 CYRILLIC CAPITAL LETTER BE (define-keysym #x06e3 "Cyrillic_TSE") ;U+0426 CYRILLIC CAPITAL LETTER TSE (define-keysym #x06e4 "Cyrillic_DE") ;U+0414 CYRILLIC CAPITAL LETTER DE (define-keysym #x06e5 "Cyrillic_IE") ;U+0415 CYRILLIC CAPITAL LETTER IE (define-keysym #x06e6 "Cyrillic_EF") ;U+0424 CYRILLIC CAPITAL LETTER EF (define-keysym #x06e7 "Cyrillic_GHE") ;U+0413 CYRILLIC CAPITAL LETTER GHE (define-keysym #x06e8 "Cyrillic_HA") ;U+0425 CYRILLIC CAPITAL LETTER HA (define-keysym #x06e9 "Cyrillic_I") ;U+0418 CYRILLIC CAPITAL LETTER I (define-keysym #x06ea "Cyrillic_SHORTI") ;U+0419 CYRILLIC CAPITAL LETTER SHORT I (define-keysym #x06eb "Cyrillic_KA") ;U+041A CYRILLIC CAPITAL LETTER KA (define-keysym #x06ec "Cyrillic_EL") ;U+041B CYRILLIC CAPITAL LETTER EL (define-keysym #x06ed "Cyrillic_EM") ;U+041C CYRILLIC CAPITAL LETTER EM (define-keysym #x06ee "Cyrillic_EN") ;U+041D CYRILLIC CAPITAL LETTER EN (define-keysym #x06ef "Cyrillic_O") ;U+041E CYRILLIC CAPITAL LETTER O (define-keysym #x06f0 "Cyrillic_PE") ;U+041F CYRILLIC CAPITAL LETTER PE (define-keysym #x06f1 "Cyrillic_YA") ;U+042F CYRILLIC CAPITAL LETTER YA (define-keysym #x06f2 "Cyrillic_ER") ;U+0420 CYRILLIC CAPITAL LETTER ER (define-keysym #x06f3 "Cyrillic_ES") ;U+0421 CYRILLIC CAPITAL LETTER ES (define-keysym #x06f4 "Cyrillic_TE") ;U+0422 CYRILLIC CAPITAL LETTER TE (define-keysym #x06f5 "Cyrillic_U") ;U+0423 CYRILLIC CAPITAL LETTER U (define-keysym #x06f6 "Cyrillic_ZHE") ;U+0416 CYRILLIC CAPITAL LETTER ZHE (define-keysym #x06f7 "Cyrillic_VE") ;U+0412 CYRILLIC CAPITAL LETTER VE (define-keysym #x06f8 "Cyrillic_SOFTSIGN") ;U+042C CYRILLIC CAPITAL LETTER SOFT SIGN (define-keysym #x06f9 "Cyrillic_YERU") ;U+042B CYRILLIC CAPITAL LETTER YERU (define-keysym #x06fa "Cyrillic_ZE") ;U+0417 CYRILLIC CAPITAL LETTER ZE (define-keysym #x06fb "Cyrillic_SHA") ;U+0428 CYRILLIC CAPITAL LETTER SHA (define-keysym #x06fc "Cyrillic_E") ;U+042D CYRILLIC CAPITAL LETTER E (define-keysym #x06fd "Cyrillic_SHCHA") ;U+0429 CYRILLIC CAPITAL LETTER SHCHA (define-keysym #x06fe "Cyrillic_CHE") ;U+0427 CYRILLIC CAPITAL LETTER CHE (define-keysym #x06ff "Cyrillic_HARDSIGN") ;U+042A CYRILLIC CAPITAL LETTER HARD SIGN (define-keysym #x07a1 "Greek_ALPHAaccent") ;U+0386 GREEK CAPITAL LETTER ALPHA WITH TONOS (define-keysym #x07a2 "Greek_EPSILONaccent") ;U+0388 GREEK CAPITAL LETTER EPSILON WITH TONOS (define-keysym #x07a3 "Greek_ETAaccent") ;U+0389 GREEK CAPITAL LETTER ETA WITH TONOS (define-keysym #x07a4 "Greek_IOTAaccent") ;U+038A GREEK CAPITAL LETTER IOTA WITH TONOS (define-keysym #x07a5 "Greek_IOTAdieresis") ;U+03AA GREEK CAPITAL LETTER IOTA WITH DIALYTIKA (define-keysym #x07a5 "Greek_IOTAdiaeresis") ;old typo (define-keysym #x07a7 "Greek_OMICRONaccent") ;U+038C GREEK CAPITAL LETTER OMICRON WITH TONOS (define-keysym #x07a8 "Greek_UPSILONaccent") ;U+038E GREEK CAPITAL LETTER UPSILON WITH TONOS (define-keysym #x07a9 "Greek_UPSILONdieresis") ;U+03AB GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA (define-keysym #x07ab "Greek_OMEGAaccent") ;U+038F GREEK CAPITAL LETTER OMEGA WITH TONOS (define-keysym #x07ae "Greek_accentdieresis") ;U+0385 GREEK DIALYTIKA TONOS (define-keysym #x07af "Greek_horizbar") ;U+2015 HORIZONTAL BAR (define-keysym #x07b1 "Greek_alphaaccent") ;U+03AC GREEK SMALL LETTER ALPHA WITH TONOS (define-keysym #x07b2 "Greek_epsilonaccent") ;U+03AD GREEK SMALL LETTER EPSILON WITH TONOS (define-keysym #x07b3 "Greek_etaaccent") ;U+03AE GREEK SMALL LETTER ETA WITH TONOS (define-keysym #x07b4 "Greek_iotaaccent") ;U+03AF GREEK SMALL LETTER IOTA WITH TONOS (define-keysym #x07b5 "Greek_iotadieresis") ;U+03CA GREEK SMALL LETTER IOTA WITH DIALYTIKA (define-keysym #x07b6 "Greek_iotaaccentdieresis") ;U+0390 GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS (define-keysym #x07b7 "Greek_omicronaccent") ;U+03CC GREEK SMALL LETTER OMICRON WITH TONOS (define-keysym #x07b8 "Greek_upsilonaccent") ;U+03CD GREEK SMALL LETTER UPSILON WITH TONOS (define-keysym #x07b9 "Greek_upsilondieresis") ;U+03CB GREEK SMALL LETTER UPSILON WITH DIALYTIKA (define-keysym #x07ba "Greek_upsilonaccentdieresis") ;U+03B0 GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS (define-keysym #x07bb "Greek_omegaaccent") ;U+03CE GREEK SMALL LETTER OMEGA WITH TONOS (define-keysym #x07c1 "Greek_ALPHA") ;U+0391 GREEK CAPITAL LETTER ALPHA (define-keysym #x07c2 "Greek_BETA") ;U+0392 GREEK CAPITAL LETTER BETA (define-keysym #x07c3 "Greek_GAMMA") ;U+0393 GREEK CAPITAL LETTER GAMMA (define-keysym #x07c4 "Greek_DELTA") ;U+0394 GREEK CAPITAL LETTER DELTA (define-keysym #x07c5 "Greek_EPSILON") ;U+0395 GREEK CAPITAL LETTER EPSILON (define-keysym #x07c6 "Greek_ZETA") ;U+0396 GREEK CAPITAL LETTER ZETA (define-keysym #x07c7 "Greek_ETA") ;U+0397 GREEK CAPITAL LETTER ETA (define-keysym #x07c8 "Greek_THETA") ;U+0398 GREEK CAPITAL LETTER THETA (define-keysym #x07c9 "Greek_IOTA") ;U+0399 GREEK CAPITAL LETTER IOTA (define-keysym #x07ca "Greek_KAPPA") ;U+039A GREEK CAPITAL LETTER KAPPA (define-keysym #x07cb "Greek_LAMDA") ;U+039B GREEK CAPITAL LETTER LAMDA (define-keysym #x07cb "Greek_LAMBDA") ;U+039B GREEK CAPITAL LETTER LAMDA (define-keysym #x07cc "Greek_MU") ;U+039C GREEK CAPITAL LETTER MU (define-keysym #x07cd "Greek_NU") ;U+039D GREEK CAPITAL LETTER NU (define-keysym #x07ce "Greek_XI") ;U+039E GREEK CAPITAL LETTER XI (define-keysym #x07cf "Greek_OMICRON") ;U+039F GREEK CAPITAL LETTER OMICRON (define-keysym #x07d0 "Greek_PI") ;U+03A0 GREEK CAPITAL LETTER PI (define-keysym #x07d1 "Greek_RHO") ;U+03A1 GREEK CAPITAL LETTER RHO (define-keysym #x07d2 "Greek_SIGMA") ;U+03A3 GREEK CAPITAL LETTER SIGMA (define-keysym #x07d4 "Greek_TAU") ;U+03A4 GREEK CAPITAL LETTER TAU (define-keysym #x07d5 "Greek_UPSILON") ;U+03A5 GREEK CAPITAL LETTER UPSILON (define-keysym #x07d6 "Greek_PHI") ;U+03A6 GREEK CAPITAL LETTER PHI (define-keysym #x07d7 "Greek_CHI") ;U+03A7 GREEK CAPITAL LETTER CHI (define-keysym #x07d8 "Greek_PSI") ;U+03A8 GREEK CAPITAL LETTER PSI (define-keysym #x07d9 "Greek_OMEGA") ;U+03A9 GREEK CAPITAL LETTER OMEGA (define-keysym #x07e1 "Greek_alpha") ;U+03B1 GREEK SMALL LETTER ALPHA (define-keysym #x07e2 "Greek_beta") ;U+03B2 GREEK SMALL LETTER BETA (define-keysym #x07e3 "Greek_gamma") ;U+03B3 GREEK SMALL LETTER GAMMA (define-keysym #x07e4 "Greek_delta") ;U+03B4 GREEK SMALL LETTER DELTA (define-keysym #x07e5 "Greek_epsilon") ;U+03B5 GREEK SMALL LETTER EPSILON (define-keysym #x07e6 "Greek_zeta") ;U+03B6 GREEK SMALL LETTER ZETA (define-keysym #x07e7 "Greek_eta") ;U+03B7 GREEK SMALL LETTER ETA (define-keysym #x07e8 "Greek_theta") ;U+03B8 GREEK SMALL LETTER THETA (define-keysym #x07e9 "Greek_iota") ;U+03B9 GREEK SMALL LETTER IOTA (define-keysym #x07ea "Greek_kappa") ;U+03BA GREEK SMALL LETTER KAPPA (define-keysym #x07eb "Greek_lamda") ;U+03BB GREEK SMALL LETTER LAMDA (define-keysym #x07eb "Greek_lambda") ;U+03BB GREEK SMALL LETTER LAMDA (define-keysym #x07ec "Greek_mu") ;U+03BC GREEK SMALL LETTER MU (define-keysym #x07ed "Greek_nu") ;U+03BD GREEK SMALL LETTER NU (define-keysym #x07ee "Greek_xi") ;U+03BE GREEK SMALL LETTER XI (define-keysym #x07ef "Greek_omicron") ;U+03BF GREEK SMALL LETTER OMICRON (define-keysym #x07f0 "Greek_pi") ;U+03C0 GREEK SMALL LETTER PI (define-keysym #x07f1 "Greek_rho") ;U+03C1 GREEK SMALL LETTER RHO (define-keysym #x07f2 "Greek_sigma") ;U+03C3 GREEK SMALL LETTER SIGMA (define-keysym #x07f3 "Greek_finalsmallsigma") ;U+03C2 GREEK SMALL LETTER FINAL SIGMA (define-keysym #x07f4 "Greek_tau") ;U+03C4 GREEK SMALL LETTER TAU (define-keysym #x07f5 "Greek_upsilon") ;U+03C5 GREEK SMALL LETTER UPSILON (define-keysym #x07f6 "Greek_phi") ;U+03C6 GREEK SMALL LETTER PHI (define-keysym #x07f7 "Greek_chi") ;U+03C7 GREEK SMALL LETTER CHI (define-keysym #x07f8 "Greek_psi") ;U+03C8 GREEK SMALL LETTER PSI (define-keysym #x07f9 "Greek_omega") ;U+03C9 GREEK SMALL LETTER OMEGA (define-keysym #xff7e "Greek_switch") ;Alias for mode_switch (define-keysym #x08a1 "leftradical") ;U+23B7 RADICAL SYMBOL BOTTOM (define-keysym #x08a2 "topleftradical") ;(U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT) (define-keysym #x08a3 "horizconnector") ;(U+2500 BOX DRAWINGS LIGHT HORIZONTAL) (define-keysym #x08a4 "topintegral") ;U+2320 TOP HALF INTEGRAL (define-keysym #x08a5 "botintegral") ;U+2321 BOTTOM HALF INTEGRAL (define-keysym #x08a6 "vertconnector") ;(U+2502 BOX DRAWINGS LIGHT VERTICAL) (define-keysym #x08a7 "topleftsqbracket") ;U+23A1 LEFT SQUARE BRACKET UPPER CORNER (define-keysym #x08a8 "botleftsqbracket") ;U+23A3 LEFT SQUARE BRACKET LOWER CORNER (define-keysym #x08a9 "toprightsqbracket") ;U+23A4 RIGHT SQUARE BRACKET UPPER CORNER (define-keysym #x08aa "botrightsqbracket") ;U+23A6 RIGHT SQUARE BRACKET LOWER CORNER (define-keysym #x08ab "topleftparens") ;U+239B LEFT PARENTHESIS UPPER HOOK (define-keysym #x08ac "botleftparens") ;U+239D LEFT PARENTHESIS LOWER HOOK (define-keysym #x08ad "toprightparens") ;U+239E RIGHT PARENTHESIS UPPER HOOK (define-keysym #x08ae "botrightparens") ;U+23A0 RIGHT PARENTHESIS LOWER HOOK (define-keysym #x08af "leftmiddlecurlybrace") ;U+23A8 LEFT CURLY BRACKET MIDDLE PIECE (define-keysym #x08b0 "rightmiddlecurlybrace") ;U+23AC RIGHT CURLY BRACKET MIDDLE PIECE (define-keysym #x08b1 "topleftsummation") (define-keysym #x08b2 "botleftsummation") (define-keysym #x08b3 "topvertsummationconnector") (define-keysym #x08b4 "botvertsummationconnector") (define-keysym #x08b5 "toprightsummation") (define-keysym #x08b6 "botrightsummation") (define-keysym #x08b7 "rightmiddlesummation") (define-keysym #x08bc "lessthanequal") ;U+2264 LESS-THAN OR EQUAL TO (define-keysym #x08bd "notequal") ;U+2260 NOT EQUAL TO (define-keysym #x08be "greaterthanequal") ;U+2265 GREATER-THAN OR EQUAL TO (define-keysym #x08bf "integral") ;U+222B INTEGRAL (define-keysym #x08c0 "therefore") ;U+2234 THEREFORE (define-keysym #x08c1 "variation") ;U+221D PROPORTIONAL TO (define-keysym #x08c2 "infinity") ;U+221E INFINITY (define-keysym #x08c5 "nabla") ;U+2207 NABLA (define-keysym #x08c8 "approximate") ;U+223C TILDE OPERATOR (define-keysym #x08c9 "similarequal") ;U+2243 ASYMPTOTICALLY EQUAL TO (define-keysym #x08cd "ifonlyif") ;U+21D4 LEFT RIGHT DOUBLE ARROW (define-keysym #x08ce "implies") ;U+21D2 RIGHTWARDS DOUBLE ARROW (define-keysym #x08cf "identical") ;U+2261 IDENTICAL TO (define-keysym #x08d6 "radical") ;U+221A SQUARE ROOT (define-keysym #x08da "includedin") ;U+2282 SUBSET OF (define-keysym #x08db "includes") ;U+2283 SUPERSET OF (define-keysym #x08dc "intersection") ;U+2229 INTERSECTION (define-keysym #x08dd "union") ;U+222A UNION (define-keysym #x08de "logicaland") ;U+2227 LOGICAL AND (define-keysym #x08df "logicalor") ;U+2228 LOGICAL OR (define-keysym #x08ef "partialderivative") ;U+2202 PARTIAL DIFFERENTIAL (define-keysym #x08f6 "function") ;U+0192 LATIN SMALL LETTER F WITH HOOK (define-keysym #x08fb "leftarrow") ;U+2190 LEFTWARDS ARROW (define-keysym #x08fc "uparrow") ;U+2191 UPWARDS ARROW (define-keysym #x08fd "rightarrow") ;U+2192 RIGHTWARDS ARROW (define-keysym #x08fe "downarrow") ;U+2193 DOWNWARDS ARROW (define-keysym #x09df "blank") (define-keysym #x09e0 "soliddiamond") ;U+25C6 BLACK DIAMOND (define-keysym #x09e1 "checkerboard") ;U+2592 MEDIUM SHADE (define-keysym #x09e2 "ht") ;U+2409 SYMBOL FOR HORIZONTAL TABULATION (define-keysym #x09e3 "ff") ;U+240C SYMBOL FOR FORM FEED (define-keysym #x09e4 "cr") ;U+240D SYMBOL FOR CARRIAGE RETURN (define-keysym #x09e5 "lf") ;U+240A SYMBOL FOR LINE FEED (define-keysym #x09e8 "nl") ;U+2424 SYMBOL FOR NEWLINE (define-keysym #x09e9 "vt") ;U+240B SYMBOL FOR VERTICAL TABULATION (define-keysym #x09ea "lowrightcorner") ;U+2518 BOX DRAWINGS LIGHT UP AND LEFT (define-keysym #x09eb "uprightcorner") ;U+2510 BOX DRAWINGS LIGHT DOWN AND LEFT (define-keysym #x09ec "upleftcorner") ;U+250C BOX DRAWINGS LIGHT DOWN AND RIGHT (define-keysym #x09ed "lowleftcorner") ;U+2514 BOX DRAWINGS LIGHT UP AND RIGHT (define-keysym #x09ee "crossinglines") ;U+253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL (define-keysym #x09ef "horizlinescan1") ;U+23BA HORIZONTAL SCAN LINE-1 (define-keysym #x09f0 "horizlinescan3") ;U+23BB HORIZONTAL SCAN LINE-3 (define-keysym #x09f1 "horizlinescan5") ;U+2500 BOX DRAWINGS LIGHT HORIZONTAL (define-keysym #x09f2 "horizlinescan7") ;U+23BC HORIZONTAL SCAN LINE-7 (define-keysym #x09f3 "horizlinescan9") ;U+23BD HORIZONTAL SCAN LINE-9 (define-keysym #x09f4 "leftt") ;U+251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT (define-keysym #x09f5 "rightt") ;U+2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT (define-keysym #x09f6 "bott") ;U+2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL (define-keysym #x09f7 "topt") ;U+252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL (define-keysym #x09f8 "vertbar") ;U+2502 BOX DRAWINGS LIGHT VERTICAL (define-keysym #x0aa1 "emspace") ;U+2003 EM SPACE (define-keysym #x0aa2 "enspace") ;U+2002 EN SPACE (define-keysym #x0aa3 "em3space") ;U+2004 THREE-PER-EM SPACE (define-keysym #x0aa4 "em4space") ;U+2005 FOUR-PER-EM SPACE (define-keysym #x0aa5 "digitspace") ;U+2007 FIGURE SPACE (define-keysym #x0aa6 "punctspace") ;U+2008 PUNCTUATION SPACE (define-keysym #x0aa7 "thinspace") ;U+2009 THIN SPACE (define-keysym #x0aa8 "hairspace") ;U+200A HAIR SPACE (define-keysym #x0aa9 "emdash") ;U+2014 EM DASH (define-keysym #x0aaa "endash") ;U+2013 EN DASH (define-keysym #x0aac "signifblank") ;(U+2423 OPEN BOX) (define-keysym #x0aae "ellipsis") ;U+2026 HORIZONTAL ELLIPSIS (define-keysym #x0aaf "doubbaselinedot") ;U+2025 TWO DOT LEADER (define-keysym #x0ab0 "onethird") ;U+2153 VULGAR FRACTION ONE THIRD (define-keysym #x0ab1 "twothirds") ;U+2154 VULGAR FRACTION TWO THIRDS (define-keysym #x0ab2 "onefifth") ;U+2155 VULGAR FRACTION ONE FIFTH (define-keysym #x0ab3 "twofifths") ;U+2156 VULGAR FRACTION TWO FIFTHS (define-keysym #x0ab4 "threefifths") ;U+2157 VULGAR FRACTION THREE FIFTHS (define-keysym #x0ab5 "fourfifths") ;U+2158 VULGAR FRACTION FOUR FIFTHS (define-keysym #x0ab6 "onesixth") ;U+2159 VULGAR FRACTION ONE SIXTH (define-keysym #x0ab7 "fivesixths") ;U+215A VULGAR FRACTION FIVE SIXTHS (define-keysym #x0ab8 "careof") ;U+2105 CARE OF (define-keysym #x0abb "figdash") ;U+2012 FIGURE DASH (define-keysym #x0abc "leftanglebracket") ;(U+27E8 MATHEMATICAL LEFT ANGLE BRACKET) (define-keysym #x0abd "decimalpoint") ;(U+002E FULL STOP) (define-keysym #x0abe "rightanglebracket") ;(U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET) (define-keysym #x0abf "marker") (define-keysym #x0ac3 "oneeighth") ;U+215B VULGAR FRACTION ONE EIGHTH (define-keysym #x0ac4 "threeeighths") ;U+215C VULGAR FRACTION THREE EIGHTHS (define-keysym #x0ac5 "fiveeighths") ;U+215D VULGAR FRACTION FIVE EIGHTHS (define-keysym #x0ac6 "seveneighths") ;U+215E VULGAR FRACTION SEVEN EIGHTHS (define-keysym #x0ac9 "trademark") ;U+2122 TRADE MARK SIGN (define-keysym #x0aca "signaturemark") ;(U+2613 SALTIRE) (define-keysym #x0acb "trademarkincircle") (define-keysym #x0acc "leftopentriangle") ;(U+25C1 WHITE LEFT-POINTING TRIANGLE) (define-keysym #x0acd "rightopentriangle") ;(U+25B7 WHITE RIGHT-POINTING TRIANGLE) (define-keysym #x0ace "emopencircle") ;(U+25CB WHITE CIRCLE) (define-keysym #x0acf "emopenrectangle") ;(U+25AF WHITE VERTICAL RECTANGLE) (define-keysym #x0ad0 "leftsinglequotemark") ;U+2018 LEFT SINGLE QUOTATION MARK (define-keysym #x0ad1 "rightsinglequotemark") ;U+2019 RIGHT SINGLE QUOTATION MARK (define-keysym #x0ad2 "leftdoublequotemark") ;U+201C LEFT DOUBLE QUOTATION MARK (define-keysym #x0ad3 "rightdoublequotemark") ;U+201D RIGHT DOUBLE QUOTATION MARK (define-keysym #x0ad4 "prescription") ;U+211E PRESCRIPTION TAKE (define-keysym #x0ad6 "minutes") ;U+2032 PRIME (define-keysym #x0ad7 "seconds") ;U+2033 DOUBLE PRIME (define-keysym #x0ad9 "latincross") ;U+271D LATIN CROSS (define-keysym #x0ada "hexagram") (define-keysym #x0adb "filledrectbullet") ;(U+25AC BLACK RECTANGLE) (define-keysym #x0adc "filledlefttribullet") ;(U+25C0 BLACK LEFT-POINTING TRIANGLE) (define-keysym #x0add "filledrighttribullet") ;(U+25B6 BLACK RIGHT-POINTING TRIANGLE) (define-keysym #x0ade "emfilledcircle") ;(U+25CF BLACK CIRCLE) (define-keysym #x0adf "emfilledrect") ;(U+25AE BLACK VERTICAL RECTANGLE) (define-keysym #x0ae0 "enopencircbullet") ;(U+25E6 WHITE BULLET) (define-keysym #x0ae1 "enopensquarebullet") ;(U+25AB WHITE SMALL SQUARE) (define-keysym #x0ae2 "openrectbullet") ;(U+25AD WHITE RECTANGLE) (define-keysym #x0ae3 "opentribulletup") ;(U+25B3 WHITE UP-POINTING TRIANGLE) (define-keysym #x0ae4 "opentribulletdown") ;(U+25BD WHITE DOWN-POINTING TRIANGLE) (define-keysym #x0ae5 "openstar") ;(U+2606 WHITE STAR) (define-keysym #x0ae6 "enfilledcircbullet") ;(U+2022 BULLET) (define-keysym #x0ae7 "enfilledsqbullet") ;(U+25AA BLACK SMALL SQUARE) (define-keysym #x0ae8 "filledtribulletup") ;(U+25B2 BLACK UP-POINTING TRIANGLE) (define-keysym #x0ae9 "filledtribulletdown") ;(U+25BC BLACK DOWN-POINTING TRIANGLE) (define-keysym #x0aea "leftpointer") ;(U+261C WHITE LEFT POINTING INDEX) (define-keysym #x0aeb "rightpointer") ;(U+261E WHITE RIGHT POINTING INDEX) (define-keysym #x0aec "club") ;U+2663 BLACK CLUB SUIT (define-keysym #x0aed "diamond") ;U+2666 BLACK DIAMOND SUIT (define-keysym #x0aee "heart") ;U+2665 BLACK HEART SUIT (define-keysym #x0af0 "maltesecross") ;U+2720 MALTESE CROSS (define-keysym #x0af1 "dagger") ;U+2020 DAGGER (define-keysym #x0af2 "doubledagger") ;U+2021 DOUBLE DAGGER (define-keysym #x0af3 "checkmark") ;U+2713 CHECK MARK (define-keysym #x0af4 "ballotcross") ;U+2717 BALLOT X (define-keysym #x0af5 "musicalsharp") ;U+266F MUSIC SHARP SIGN (define-keysym #x0af6 "musicalflat") ;U+266D MUSIC FLAT SIGN (define-keysym #x0af7 "malesymbol") ;U+2642 MALE SIGN (define-keysym #x0af8 "femalesymbol") ;U+2640 FEMALE SIGN (define-keysym #x0af9 "telephone") ;U+260E BLACK TELEPHONE (define-keysym #x0afa "telephonerecorder") ;U+2315 TELEPHONE RECORDER (define-keysym #x0afb "phonographcopyright") ;U+2117 SOUND RECORDING COPYRIGHT (define-keysym #x0afc "caret") ;U+2038 CARET (define-keysym #x0afd "singlelowquotemark") ;U+201A SINGLE LOW-9 QUOTATION MARK (define-keysym #x0afe "doublelowquotemark") ;U+201E DOUBLE LOW-9 QUOTATION MARK (define-keysym #x0aff "cursor") (define-keysym #x0ba3 "leftcaret") ;(U+003C LESS-THAN SIGN) (define-keysym #x0ba6 "rightcaret") ;(U+003E GREATER-THAN SIGN) (define-keysym #x0ba8 "downcaret") ;(U+2228 LOGICAL OR) (define-keysym #x0ba9 "upcaret") ;(U+2227 LOGICAL AND) (define-keysym #x0bc0 "overbar") ;(U+00AF MACRON) (define-keysym #x0bc2 "downtack") ;U+22A5 UP TACK (define-keysym #x0bc3 "upshoe") ;(U+2229 INTERSECTION) (define-keysym #x0bc4 "downstile") ;U+230A LEFT FLOOR (define-keysym #x0bc6 "underbar") ;(U+005F LOW LINE) (define-keysym #x0bca "jot") ;U+2218 RING OPERATOR (define-keysym #x0bcc "quad") ;U+2395 APL FUNCTIONAL SYMBOL QUAD (define-keysym #x0bce "uptack") ;U+22A4 DOWN TACK (define-keysym #x0bcf "circle") ;U+25CB WHITE CIRCLE (define-keysym #x0bd3 "upstile") ;U+2308 LEFT CEILING (define-keysym #x0bd6 "downshoe") ;(U+222A UNION) (define-keysym #x0bd8 "rightshoe") ;(U+2283 SUPERSET OF) (define-keysym #x0bda "leftshoe") ;(U+2282 SUBSET OF) (define-keysym #x0bdc "lefttack") ;U+22A2 RIGHT TACK (define-keysym #x0bfc "righttack") ;U+22A3 LEFT TACK (define-keysym #x0cdf "hebrew_doublelowline") ;U+2017 DOUBLE LOW LINE (define-keysym #x0ce0 "hebrew_aleph") ;U+05D0 HEBREW LETTER ALEF (define-keysym #x0ce1 "hebrew_bet") ;U+05D1 HEBREW LETTER BET (define-keysym #x0ce1 "hebrew_beth") ;deprecated (define-keysym #x0ce2 "hebrew_gimel") ;U+05D2 HEBREW LETTER GIMEL (define-keysym #x0ce2 "hebrew_gimmel") ;deprecated (define-keysym #x0ce3 "hebrew_dalet") ;U+05D3 HEBREW LETTER DALET (define-keysym #x0ce3 "hebrew_daleth") ;deprecated (define-keysym #x0ce4 "hebrew_he") ;U+05D4 HEBREW LETTER HE (define-keysym #x0ce5 "hebrew_waw") ;U+05D5 HEBREW LETTER VAV (define-keysym #x0ce6 "hebrew_zain") ;U+05D6 HEBREW LETTER ZAYIN (define-keysym #x0ce6 "hebrew_zayin") ;deprecated (define-keysym #x0ce7 "hebrew_chet") ;U+05D7 HEBREW LETTER HET (define-keysym #x0ce7 "hebrew_het") ;deprecated (define-keysym #x0ce8 "hebrew_tet") ;U+05D8 HEBREW LETTER TET (define-keysym #x0ce8 "hebrew_teth") ;deprecated (define-keysym #x0ce9 "hebrew_yod") ;U+05D9 HEBREW LETTER YOD (define-keysym #x0cea "hebrew_finalkaph") ;U+05DA HEBREW LETTER FINAL KAF (define-keysym #x0ceb "hebrew_kaph") ;U+05DB HEBREW LETTER KAF (define-keysym #x0cec "hebrew_lamed") ;U+05DC HEBREW LETTER LAMED (define-keysym #x0ced "hebrew_finalmem") ;U+05DD HEBREW LETTER FINAL MEM (define-keysym #x0cee "hebrew_mem") ;U+05DE HEBREW LETTER MEM (define-keysym #x0cef "hebrew_finalnun") ;U+05DF HEBREW LETTER FINAL NUN (define-keysym #x0cf0 "hebrew_nun") ;U+05E0 HEBREW LETTER NUN (define-keysym #x0cf1 "hebrew_samech") ;U+05E1 HEBREW LETTER SAMEKH (define-keysym #x0cf1 "hebrew_samekh") ;deprecated (define-keysym #x0cf2 "hebrew_ayin") ;U+05E2 HEBREW LETTER AYIN (define-keysym #x0cf3 "hebrew_finalpe") ;U+05E3 HEBREW LETTER FINAL PE (define-keysym #x0cf4 "hebrew_pe") ;U+05E4 HEBREW LETTER PE (define-keysym #x0cf5 "hebrew_finalzade") ;U+05E5 HEBREW LETTER FINAL TSADI (define-keysym #x0cf5 "hebrew_finalzadi") ;deprecated (define-keysym #x0cf6 "hebrew_zade") ;U+05E6 HEBREW LETTER TSADI (define-keysym #x0cf6 "hebrew_zadi") ;deprecated (define-keysym #x0cf7 "hebrew_qoph") ;U+05E7 HEBREW LETTER QOF (define-keysym #x0cf7 "hebrew_kuf") ;deprecated (define-keysym #x0cf8 "hebrew_resh") ;U+05E8 HEBREW LETTER RESH (define-keysym #x0cf9 "hebrew_shin") ;U+05E9 HEBREW LETTER SHIN (define-keysym #x0cfa "hebrew_taw") ;U+05EA HEBREW LETTER TAV (define-keysym #x0cfa "hebrew_taf") ;deprecated (define-keysym #xff7e "Hebrew_switch") ;Alias for mode_switch (define-keysym #x0da1 "Thai_kokai") ;U+0E01 THAI CHARACTER KO KAI (define-keysym #x0da2 "Thai_khokhai") ;U+0E02 THAI CHARACTER KHO KHAI (define-keysym #x0da3 "Thai_khokhuat") ;U+0E03 THAI CHARACTER KHO KHUAT (define-keysym #x0da4 "Thai_khokhwai") ;U+0E04 THAI CHARACTER KHO KHWAI (define-keysym #x0da5 "Thai_khokhon") ;U+0E05 THAI CHARACTER KHO KHON (define-keysym #x0da6 "Thai_khorakhang") ;U+0E06 THAI CHARACTER KHO RAKHANG (define-keysym #x0da7 "Thai_ngongu") ;U+0E07 THAI CHARACTER NGO NGU (define-keysym #x0da8 "Thai_chochan") ;U+0E08 THAI CHARACTER CHO CHAN (define-keysym #x0da9 "Thai_choching") ;U+0E09 THAI CHARACTER CHO CHING (define-keysym #x0daa "Thai_chochang") ;U+0E0A THAI CHARACTER CHO CHANG (define-keysym #x0dab "Thai_soso") ;U+0E0B THAI CHARACTER SO SO (define-keysym #x0dac "Thai_chochoe") ;U+0E0C THAI CHARACTER CHO CHOE (define-keysym #x0dad "Thai_yoying") ;U+0E0D THAI CHARACTER YO YING (define-keysym #x0dae "Thai_dochada") ;U+0E0E THAI CHARACTER DO CHADA (define-keysym #x0daf "Thai_topatak") ;U+0E0F THAI CHARACTER TO PATAK (define-keysym #x0db0 "Thai_thothan") ;U+0E10 THAI CHARACTER THO THAN (define-keysym #x0db1 "Thai_thonangmontho") ;U+0E11 THAI CHARACTER THO NANGMONTHO (define-keysym #x0db2 "Thai_thophuthao") ;U+0E12 THAI CHARACTER THO PHUTHAO (define-keysym #x0db3 "Thai_nonen") ;U+0E13 THAI CHARACTER NO NEN (define-keysym #x0db4 "Thai_dodek") ;U+0E14 THAI CHARACTER DO DEK (define-keysym #x0db5 "Thai_totao") ;U+0E15 THAI CHARACTER TO TAO (define-keysym #x0db6 "Thai_thothung") ;U+0E16 THAI CHARACTER THO THUNG (define-keysym #x0db7 "Thai_thothahan") ;U+0E17 THAI CHARACTER THO THAHAN (define-keysym #x0db8 "Thai_thothong") ;U+0E18 THAI CHARACTER THO THONG (define-keysym #x0db9 "Thai_nonu") ;U+0E19 THAI CHARACTER NO NU (define-keysym #x0dba "Thai_bobaimai") ;U+0E1A THAI CHARACTER BO BAIMAI (define-keysym #x0dbb "Thai_popla") ;U+0E1B THAI CHARACTER PO PLA (define-keysym #x0dbc "Thai_phophung") ;U+0E1C THAI CHARACTER PHO PHUNG (define-keysym #x0dbd "Thai_fofa") ;U+0E1D THAI CHARACTER FO FA (define-keysym #x0dbe "Thai_phophan") ;U+0E1E THAI CHARACTER PHO PHAN (define-keysym #x0dbf "Thai_fofan") ;U+0E1F THAI CHARACTER FO FAN (define-keysym #x0dc0 "Thai_phosamphao") ;U+0E20 THAI CHARACTER PHO SAMPHAO (define-keysym #x0dc1 "Thai_moma") ;U+0E21 THAI CHARACTER MO MA (define-keysym #x0dc2 "Thai_yoyak") ;U+0E22 THAI CHARACTER YO YAK (define-keysym #x0dc3 "Thai_rorua") ;U+0E23 THAI CHARACTER RO RUA (define-keysym #x0dc4 "Thai_ru") ;U+0E24 THAI CHARACTER RU (define-keysym #x0dc5 "Thai_loling") ;U+0E25 THAI CHARACTER LO LING (define-keysym #x0dc6 "Thai_lu") ;U+0E26 THAI CHARACTER LU (define-keysym #x0dc7 "Thai_wowaen") ;U+0E27 THAI CHARACTER WO WAEN (define-keysym #x0dc8 "Thai_sosala") ;U+0E28 THAI CHARACTER SO SALA (define-keysym #x0dc9 "Thai_sorusi") ;U+0E29 THAI CHARACTER SO RUSI (define-keysym #x0dca "Thai_sosua") ;U+0E2A THAI CHARACTER SO SUA (define-keysym #x0dcb "Thai_hohip") ;U+0E2B THAI CHARACTER HO HIP (define-keysym #x0dcc "Thai_lochula") ;U+0E2C THAI CHARACTER LO CHULA (define-keysym #x0dcd "Thai_oang") ;U+0E2D THAI CHARACTER O ANG (define-keysym #x0dce "Thai_honokhuk") ;U+0E2E THAI CHARACTER HO NOKHUK (define-keysym #x0dcf "Thai_paiyannoi") ;U+0E2F THAI CHARACTER PAIYANNOI (define-keysym #x0dd0 "Thai_saraa") ;U+0E30 THAI CHARACTER SARA A (define-keysym #x0dd1 "Thai_maihanakat") ;U+0E31 THAI CHARACTER MAI HAN-AKAT (define-keysym #x0dd2 "Thai_saraaa") ;U+0E32 THAI CHARACTER SARA AA (define-keysym #x0dd3 "Thai_saraam") ;U+0E33 THAI CHARACTER SARA AM (define-keysym #x0dd4 "Thai_sarai") ;U+0E34 THAI CHARACTER SARA I (define-keysym #x0dd5 "Thai_saraii") ;U+0E35 THAI CHARACTER SARA II (define-keysym #x0dd6 "Thai_saraue") ;U+0E36 THAI CHARACTER SARA UE (define-keysym #x0dd7 "Thai_sarauee") ;U+0E37 THAI CHARACTER SARA UEE (define-keysym #x0dd8 "Thai_sarau") ;U+0E38 THAI CHARACTER SARA U (define-keysym #x0dd9 "Thai_sarauu") ;U+0E39 THAI CHARACTER SARA UU (define-keysym #x0dda "Thai_phinthu") ;U+0E3A THAI CHARACTER PHINTHU (define-keysym #x0dde "Thai_maihanakat_maitho") (define-keysym #x0ddf "Thai_baht") ;U+0E3F THAI CURRENCY SYMBOL BAHT (define-keysym #x0de0 "Thai_sarae") ;U+0E40 THAI CHARACTER SARA E (define-keysym #x0de1 "Thai_saraae") ;U+0E41 THAI CHARACTER SARA AE (define-keysym #x0de2 "Thai_sarao") ;U+0E42 THAI CHARACTER SARA O (define-keysym #x0de3 "Thai_saraaimaimuan") ;U+0E43 THAI CHARACTER SARA AI MAIMUAN (define-keysym #x0de4 "Thai_saraaimaimalai") ;U+0E44 THAI CHARACTER SARA AI MAIMALAI (define-keysym #x0de5 "Thai_lakkhangyao") ;U+0E45 THAI CHARACTER LAKKHANGYAO (define-keysym #x0de6 "Thai_maiyamok") ;U+0E46 THAI CHARACTER MAIYAMOK (define-keysym #x0de7 "Thai_maitaikhu") ;U+0E47 THAI CHARACTER MAITAIKHU (define-keysym #x0de8 "Thai_maiek") ;U+0E48 THAI CHARACTER MAI EK (define-keysym #x0de9 "Thai_maitho") ;U+0E49 THAI CHARACTER MAI THO (define-keysym #x0dea "Thai_maitri") ;U+0E4A THAI CHARACTER MAI TRI (define-keysym #x0deb "Thai_maichattawa") ;U+0E4B THAI CHARACTER MAI CHATTAWA (define-keysym #x0dec "Thai_thanthakhat") ;U+0E4C THAI CHARACTER THANTHAKHAT (define-keysym #x0ded "Thai_nikhahit") ;U+0E4D THAI CHARACTER NIKHAHIT (define-keysym #x0df0 "Thai_leksun") ;U+0E50 THAI DIGIT ZERO (define-keysym #x0df1 "Thai_leknung") ;U+0E51 THAI DIGIT ONE (define-keysym #x0df2 "Thai_leksong") ;U+0E52 THAI DIGIT TWO (define-keysym #x0df3 "Thai_leksam") ;U+0E53 THAI DIGIT THREE (define-keysym #x0df4 "Thai_leksi") ;U+0E54 THAI DIGIT FOUR (define-keysym #x0df5 "Thai_lekha") ;U+0E55 THAI DIGIT FIVE (define-keysym #x0df6 "Thai_lekhok") ;U+0E56 THAI DIGIT SIX (define-keysym #x0df7 "Thai_lekchet") ;U+0E57 THAI DIGIT SEVEN (define-keysym #x0df8 "Thai_lekpaet") ;U+0E58 THAI DIGIT EIGHT (define-keysym #x0df9 "Thai_lekkao") ;U+0E59 THAI DIGIT NINE (define-keysym #xff31 "Hangul") ;Hangul start/stop(toggle) (define-keysym #xff32 "Hangul_Start") ;Hangul start (define-keysym #xff33 "Hangul_End") ;Hangul end, English start (define-keysym #xff34 "Hangul_Hanja") ;Start Hangul->Hanja Conversion (define-keysym #xff35 "Hangul_Jamo") ;Hangul Jamo mode (define-keysym #xff36 "Hangul_Romaja") ;Hangul Romaja mode (define-keysym #xff37 "Hangul_Codeinput") ;Hangul code input mode (define-keysym #xff38 "Hangul_Jeonja") ;Jeonja mode (define-keysym #xff39 "Hangul_Banja") ;Banja mode (define-keysym #xff3a "Hangul_PreHanja") ;Pre Hanja conversion (define-keysym #xff3b "Hangul_PostHanja") ;Post Hanja conversion (define-keysym #xff3c "Hangul_SingleCandidate") ;Single candidate (define-keysym #xff3d "Hangul_MultipleCandidate") ;Multiple candidate (define-keysym #xff3e "Hangul_PreviousCandidate") ;Previous candidate (define-keysym #xff3f "Hangul_Special") ;Special symbols (define-keysym #xff7e "Hangul_switch") ;Alias for mode_switch (define-keysym #x0ea1 "Hangul_Kiyeog") (define-keysym #x0ea2 "Hangul_SsangKiyeog") (define-keysym #x0ea3 "Hangul_KiyeogSios") (define-keysym #x0ea4 "Hangul_Nieun") (define-keysym #x0ea5 "Hangul_NieunJieuj") (define-keysym #x0ea6 "Hangul_NieunHieuh") (define-keysym #x0ea7 "Hangul_Dikeud") (define-keysym #x0ea8 "Hangul_SsangDikeud") (define-keysym #x0ea9 "Hangul_Rieul") (define-keysym #x0eaa "Hangul_RieulKiyeog") (define-keysym #x0eab "Hangul_RieulMieum") (define-keysym #x0eac "Hangul_RieulPieub") (define-keysym #x0ead "Hangul_RieulSios") (define-keysym #x0eae "Hangul_RieulTieut") (define-keysym #x0eaf "Hangul_RieulPhieuf") (define-keysym #x0eb0 "Hangul_RieulHieuh") (define-keysym #x0eb1 "Hangul_Mieum") (define-keysym #x0eb2 "Hangul_Pieub") (define-keysym #x0eb3 "Hangul_SsangPieub") (define-keysym #x0eb4 "Hangul_PieubSios") (define-keysym #x0eb5 "Hangul_Sios") (define-keysym #x0eb6 "Hangul_SsangSios") (define-keysym #x0eb7 "Hangul_Ieung") (define-keysym #x0eb8 "Hangul_Jieuj") (define-keysym #x0eb9 "Hangul_SsangJieuj") (define-keysym #x0eba "Hangul_Cieuc") (define-keysym #x0ebb "Hangul_Khieuq") (define-keysym #x0ebc "Hangul_Tieut") (define-keysym #x0ebd "Hangul_Phieuf") (define-keysym #x0ebe "Hangul_Hieuh") (define-keysym #x0ebf "Hangul_A") (define-keysym #x0ec0 "Hangul_AE") (define-keysym #x0ec1 "Hangul_YA") (define-keysym #x0ec2 "Hangul_YAE") (define-keysym #x0ec3 "Hangul_EO") (define-keysym #x0ec4 "Hangul_E") (define-keysym #x0ec5 "Hangul_YEO") (define-keysym #x0ec6 "Hangul_YE") (define-keysym #x0ec7 "Hangul_O") (define-keysym #x0ec8 "Hangul_WA") (define-keysym #x0ec9 "Hangul_WAE") (define-keysym #x0eca "Hangul_OE") (define-keysym #x0ecb "Hangul_YO") (define-keysym #x0ecc "Hangul_U") (define-keysym #x0ecd "Hangul_WEO") (define-keysym #x0ece "Hangul_WE") (define-keysym #x0ecf "Hangul_WI") (define-keysym #x0ed0 "Hangul_YU") (define-keysym #x0ed1 "Hangul_EU") (define-keysym #x0ed2 "Hangul_YI") (define-keysym #x0ed3 "Hangul_I") (define-keysym #x0ed4 "Hangul_J_Kiyeog") (define-keysym #x0ed5 "Hangul_J_SsangKiyeog") (define-keysym #x0ed6 "Hangul_J_KiyeogSios") (define-keysym #x0ed7 "Hangul_J_Nieun") (define-keysym #x0ed8 "Hangul_J_NieunJieuj") (define-keysym #x0ed9 "Hangul_J_NieunHieuh") (define-keysym #x0eda "Hangul_J_Dikeud") (define-keysym #x0edb "Hangul_J_Rieul") (define-keysym #x0edc "Hangul_J_RieulKiyeog") (define-keysym #x0edd "Hangul_J_RieulMieum") (define-keysym #x0ede "Hangul_J_RieulPieub") (define-keysym #x0edf "Hangul_J_RieulSios") (define-keysym #x0ee0 "Hangul_J_RieulTieut") (define-keysym #x0ee1 "Hangul_J_RieulPhieuf") (define-keysym #x0ee2 "Hangul_J_RieulHieuh") (define-keysym #x0ee3 "Hangul_J_Mieum") (define-keysym #x0ee4 "Hangul_J_Pieub") (define-keysym #x0ee5 "Hangul_J_PieubSios") (define-keysym #x0ee6 "Hangul_J_Sios") (define-keysym #x0ee7 "Hangul_J_SsangSios") (define-keysym #x0ee8 "Hangul_J_Ieung") (define-keysym #x0ee9 "Hangul_J_Jieuj") (define-keysym #x0eea "Hangul_J_Cieuc") (define-keysym #x0eeb "Hangul_J_Khieuq") (define-keysym #x0eec "Hangul_J_Tieut") (define-keysym #x0eed "Hangul_J_Phieuf") (define-keysym #x0eee "Hangul_J_Hieuh") (define-keysym #x0eef "Hangul_RieulYeorinHieuh") (define-keysym #x0ef0 "Hangul_SunkyeongeumMieum") (define-keysym #x0ef1 "Hangul_SunkyeongeumPieub") (define-keysym #x0ef2 "Hangul_PanSios") (define-keysym #x0ef3 "Hangul_KkogjiDalrinIeung") (define-keysym #x0ef4 "Hangul_SunkyeongeumPhieuf") (define-keysym #x0ef5 "Hangul_YeorinHieuh") (define-keysym #x0ef6 "Hangul_AraeA") (define-keysym #x0ef7 "Hangul_AraeAE") (define-keysym #x0ef8 "Hangul_J_PanSios") (define-keysym #x0ef9 "Hangul_J_KkogjiDalrinIeung") (define-keysym #x0efa "Hangul_J_YeorinHieuh") (define-keysym #x0eff "Korean_Won") ;(U+20A9 WON SIGN) (define-keysym #x1000587 "Armenian_ligature_ew") ;U+0587 ARMENIAN SMALL LIGATURE ECH YIWN (define-keysym #x1000589 "Armenian_full_stop") ;U+0589 ARMENIAN FULL STOP (define-keysym #x1000589 "Armenian_verjaket") ;U+0589 ARMENIAN FULL STOP (define-keysym #x100055d "Armenian_separation_mark") ;U+055D ARMENIAN COMMA (define-keysym #x100055d "Armenian_but") ;U+055D ARMENIAN COMMA (define-keysym #x100058a "Armenian_hyphen") ;U+058A ARMENIAN HYPHEN (define-keysym #x100058a "Armenian_yentamna") ;U+058A ARMENIAN HYPHEN (define-keysym #x100055c "Armenian_exclam") ;U+055C ARMENIAN EXCLAMATION MARK (define-keysym #x100055c "Armenian_amanak") ;U+055C ARMENIAN EXCLAMATION MARK (define-keysym #x100055b "Armenian_accent") ;U+055B ARMENIAN EMPHASIS MARK (define-keysym #x100055b "Armenian_shesht") ;U+055B ARMENIAN EMPHASIS MARK (define-keysym #x100055e "Armenian_question") ;U+055E ARMENIAN QUESTION MARK (define-keysym #x100055e "Armenian_paruyk") ;U+055E ARMENIAN QUESTION MARK (define-keysym #x1000531 "Armenian_AYB") ;U+0531 ARMENIAN CAPITAL LETTER AYB (define-keysym #x1000561 "Armenian_ayb") ;U+0561 ARMENIAN SMALL LETTER AYB (define-keysym #x1000532 "Armenian_BEN") ;U+0532 ARMENIAN CAPITAL LETTER BEN (define-keysym #x1000562 "Armenian_ben") ;U+0562 ARMENIAN SMALL LETTER BEN (define-keysym #x1000533 "Armenian_GIM") ;U+0533 ARMENIAN CAPITAL LETTER GIM (define-keysym #x1000563 "Armenian_gim") ;U+0563 ARMENIAN SMALL LETTER GIM (define-keysym #x1000534 "Armenian_DA") ;U+0534 ARMENIAN CAPITAL LETTER DA (define-keysym #x1000564 "Armenian_da") ;U+0564 ARMENIAN SMALL LETTER DA (define-keysym #x1000535 "Armenian_YECH") ;U+0535 ARMENIAN CAPITAL LETTER ECH (define-keysym #x1000565 "Armenian_yech") ;U+0565 ARMENIAN SMALL LETTER ECH (define-keysym #x1000536 "Armenian_ZA") ;U+0536 ARMENIAN CAPITAL LETTER ZA (define-keysym #x1000566 "Armenian_za") ;U+0566 ARMENIAN SMALL LETTER ZA (define-keysym #x1000537 "Armenian_E") ;U+0537 ARMENIAN CAPITAL LETTER EH (define-keysym #x1000567 "Armenian_e") ;U+0567 ARMENIAN SMALL LETTER EH (define-keysym #x1000538 "Armenian_AT") ;U+0538 ARMENIAN CAPITAL LETTER ET (define-keysym #x1000568 "Armenian_at") ;U+0568 ARMENIAN SMALL LETTER ET (define-keysym #x1000539 "Armenian_TO") ;U+0539 ARMENIAN CAPITAL LETTER TO (define-keysym #x1000569 "Armenian_to") ;U+0569 ARMENIAN SMALL LETTER TO (define-keysym #x100053a "Armenian_ZHE") ;U+053A ARMENIAN CAPITAL LETTER ZHE (define-keysym #x100056a "Armenian_zhe") ;U+056A ARMENIAN SMALL LETTER ZHE (define-keysym #x100053b "Armenian_INI") ;U+053B ARMENIAN CAPITAL LETTER INI (define-keysym #x100056b "Armenian_ini") ;U+056B ARMENIAN SMALL LETTER INI (define-keysym #x100053c "Armenian_LYUN") ;U+053C ARMENIAN CAPITAL LETTER LIWN (define-keysym #x100056c "Armenian_lyun") ;U+056C ARMENIAN SMALL LETTER LIWN (define-keysym #x100053d "Armenian_KHE") ;U+053D ARMENIAN CAPITAL LETTER XEH (define-keysym #x100056d "Armenian_khe") ;U+056D ARMENIAN SMALL LETTER XEH (define-keysym #x100053e "Armenian_TSA") ;U+053E ARMENIAN CAPITAL LETTER CA (define-keysym #x100056e "Armenian_tsa") ;U+056E ARMENIAN SMALL LETTER CA (define-keysym #x100053f "Armenian_KEN") ;U+053F ARMENIAN CAPITAL LETTER KEN (define-keysym #x100056f "Armenian_ken") ;U+056F ARMENIAN SMALL LETTER KEN (define-keysym #x1000540 "Armenian_HO") ;U+0540 ARMENIAN CAPITAL LETTER HO (define-keysym #x1000570 "Armenian_ho") ;U+0570 ARMENIAN SMALL LETTER HO (define-keysym #x1000541 "Armenian_DZA") ;U+0541 ARMENIAN CAPITAL LETTER JA (define-keysym #x1000571 "Armenian_dza") ;U+0571 ARMENIAN SMALL LETTER JA (define-keysym #x1000542 "Armenian_GHAT") ;U+0542 ARMENIAN CAPITAL LETTER GHAD (define-keysym #x1000572 "Armenian_ghat") ;U+0572 ARMENIAN SMALL LETTER GHAD (define-keysym #x1000543 "Armenian_TCHE") ;U+0543 ARMENIAN CAPITAL LETTER CHEH (define-keysym #x1000573 "Armenian_tche") ;U+0573 ARMENIAN SMALL LETTER CHEH (define-keysym #x1000544 "Armenian_MEN") ;U+0544 ARMENIAN CAPITAL LETTER MEN (define-keysym #x1000574 "Armenian_men") ;U+0574 ARMENIAN SMALL LETTER MEN (define-keysym #x1000545 "Armenian_HI") ;U+0545 ARMENIAN CAPITAL LETTER YI (define-keysym #x1000575 "Armenian_hi") ;U+0575 ARMENIAN SMALL LETTER YI (define-keysym #x1000546 "Armenian_NU") ;U+0546 ARMENIAN CAPITAL LETTER NOW (define-keysym #x1000576 "Armenian_nu") ;U+0576 ARMENIAN SMALL LETTER NOW (define-keysym #x1000547 "Armenian_SHA") ;U+0547 ARMENIAN CAPITAL LETTER SHA (define-keysym #x1000577 "Armenian_sha") ;U+0577 ARMENIAN SMALL LETTER SHA (define-keysym #x1000548 "Armenian_VO") ;U+0548 ARMENIAN CAPITAL LETTER VO (define-keysym #x1000578 "Armenian_vo") ;U+0578 ARMENIAN SMALL LETTER VO (define-keysym #x1000549 "Armenian_CHA") ;U+0549 ARMENIAN CAPITAL LETTER CHA (define-keysym #x1000579 "Armenian_cha") ;U+0579 ARMENIAN SMALL LETTER CHA (define-keysym #x100054a "Armenian_PE") ;U+054A ARMENIAN CAPITAL LETTER PEH (define-keysym #x100057a "Armenian_pe") ;U+057A ARMENIAN SMALL LETTER PEH (define-keysym #x100054b "Armenian_JE") ;U+054B ARMENIAN CAPITAL LETTER JHEH (define-keysym #x100057b "Armenian_je") ;U+057B ARMENIAN SMALL LETTER JHEH (define-keysym #x100054c "Armenian_RA") ;U+054C ARMENIAN CAPITAL LETTER RA (define-keysym #x100057c "Armenian_ra") ;U+057C ARMENIAN SMALL LETTER RA (define-keysym #x100054d "Armenian_SE") ;U+054D ARMENIAN CAPITAL LETTER SEH (define-keysym #x100057d "Armenian_se") ;U+057D ARMENIAN SMALL LETTER SEH (define-keysym #x100054e "Armenian_VEV") ;U+054E ARMENIAN CAPITAL LETTER VEW (define-keysym #x100057e "Armenian_vev") ;U+057E ARMENIAN SMALL LETTER VEW (define-keysym #x100054f "Armenian_TYUN") ;U+054F ARMENIAN CAPITAL LETTER TIWN (define-keysym #x100057f "Armenian_tyun") ;U+057F ARMENIAN SMALL LETTER TIWN (define-keysym #x1000550 "Armenian_RE") ;U+0550 ARMENIAN CAPITAL LETTER REH (define-keysym #x1000580 "Armenian_re") ;U+0580 ARMENIAN SMALL LETTER REH (define-keysym #x1000551 "Armenian_TSO") ;U+0551 ARMENIAN CAPITAL LETTER CO (define-keysym #x1000581 "Armenian_tso") ;U+0581 ARMENIAN SMALL LETTER CO (define-keysym #x1000552 "Armenian_VYUN") ;U+0552 ARMENIAN CAPITAL LETTER YIWN (define-keysym #x1000582 "Armenian_vyun") ;U+0582 ARMENIAN SMALL LETTER YIWN (define-keysym #x1000553 "Armenian_PYUR") ;U+0553 ARMENIAN CAPITAL LETTER PIWR (define-keysym #x1000583 "Armenian_pyur") ;U+0583 ARMENIAN SMALL LETTER PIWR (define-keysym #x1000554 "Armenian_KE") ;U+0554 ARMENIAN CAPITAL LETTER KEH (define-keysym #x1000584 "Armenian_ke") ;U+0584 ARMENIAN SMALL LETTER KEH (define-keysym #x1000555 "Armenian_O") ;U+0555 ARMENIAN CAPITAL LETTER OH (define-keysym #x1000585 "Armenian_o") ;U+0585 ARMENIAN SMALL LETTER OH (define-keysym #x1000556 "Armenian_FE") ;U+0556 ARMENIAN CAPITAL LETTER FEH (define-keysym #x1000586 "Armenian_fe") ;U+0586 ARMENIAN SMALL LETTER FEH (define-keysym #x100055a "Armenian_apostrophe") ;U+055A ARMENIAN APOSTROPHE (define-keysym #x10010d0 "Georgian_an") ;U+10D0 GEORGIAN LETTER AN (define-keysym #x10010d1 "Georgian_ban") ;U+10D1 GEORGIAN LETTER BAN (define-keysym #x10010d2 "Georgian_gan") ;U+10D2 GEORGIAN LETTER GAN (define-keysym #x10010d3 "Georgian_don") ;U+10D3 GEORGIAN LETTER DON (define-keysym #x10010d4 "Georgian_en") ;U+10D4 GEORGIAN LETTER EN (define-keysym #x10010d5 "Georgian_vin") ;U+10D5 GEORGIAN LETTER VIN (define-keysym #x10010d6 "Georgian_zen") ;U+10D6 GEORGIAN LETTER ZEN (define-keysym #x10010d7 "Georgian_tan") ;U+10D7 GEORGIAN LETTER TAN (define-keysym #x10010d8 "Georgian_in") ;U+10D8 GEORGIAN LETTER IN (define-keysym #x10010d9 "Georgian_kan") ;U+10D9 GEORGIAN LETTER KAN (define-keysym #x10010da "Georgian_las") ;U+10DA GEORGIAN LETTER LAS (define-keysym #x10010db "Georgian_man") ;U+10DB GEORGIAN LETTER MAN (define-keysym #x10010dc "Georgian_nar") ;U+10DC GEORGIAN LETTER NAR (define-keysym #x10010dd "Georgian_on") ;U+10DD GEORGIAN LETTER ON (define-keysym #x10010de "Georgian_par") ;U+10DE GEORGIAN LETTER PAR (define-keysym #x10010df "Georgian_zhar") ;U+10DF GEORGIAN LETTER ZHAR (define-keysym #x10010e0 "Georgian_rae") ;U+10E0 GEORGIAN LETTER RAE (define-keysym #x10010e1 "Georgian_san") ;U+10E1 GEORGIAN LETTER SAN (define-keysym #x10010e2 "Georgian_tar") ;U+10E2 GEORGIAN LETTER TAR (define-keysym #x10010e3 "Georgian_un") ;U+10E3 GEORGIAN LETTER UN (define-keysym #x10010e4 "Georgian_phar") ;U+10E4 GEORGIAN LETTER PHAR (define-keysym #x10010e5 "Georgian_khar") ;U+10E5 GEORGIAN LETTER KHAR (define-keysym #x10010e6 "Georgian_ghan") ;U+10E6 GEORGIAN LETTER GHAN (define-keysym #x10010e7 "Georgian_qar") ;U+10E7 GEORGIAN LETTER QAR (define-keysym #x10010e8 "Georgian_shin") ;U+10E8 GEORGIAN LETTER SHIN (define-keysym #x10010e9 "Georgian_chin") ;U+10E9 GEORGIAN LETTER CHIN (define-keysym #x10010ea "Georgian_can") ;U+10EA GEORGIAN LETTER CAN (define-keysym #x10010eb "Georgian_jil") ;U+10EB GEORGIAN LETTER JIL (define-keysym #x10010ec "Georgian_cil") ;U+10EC GEORGIAN LETTER CIL (define-keysym #x10010ed "Georgian_char") ;U+10ED GEORGIAN LETTER CHAR (define-keysym #x10010ee "Georgian_xan") ;U+10EE GEORGIAN LETTER XAN (define-keysym #x10010ef "Georgian_jhan") ;U+10EF GEORGIAN LETTER JHAN (define-keysym #x10010f0 "Georgian_hae") ;U+10F0 GEORGIAN LETTER HAE (define-keysym #x10010f1 "Georgian_he") ;U+10F1 GEORGIAN LETTER HE (define-keysym #x10010f2 "Georgian_hie") ;U+10F2 GEORGIAN LETTER HIE (define-keysym #x10010f3 "Georgian_we") ;U+10F3 GEORGIAN LETTER WE (define-keysym #x10010f4 "Georgian_har") ;U+10F4 GEORGIAN LETTER HAR (define-keysym #x10010f5 "Georgian_hoe") ;U+10F5 GEORGIAN LETTER HOE (define-keysym #x10010f6 "Georgian_fi") ;U+10F6 GEORGIAN LETTER FI (define-keysym #x1001e8a "Xabovedot") ;U+1E8A LATIN CAPITAL LETTER X WITH DOT ABOVE (define-keysym #x100012c "Ibreve") ;U+012C LATIN CAPITAL LETTER I WITH BREVE (define-keysym #x10001b5 "Zstroke") ;U+01B5 LATIN CAPITAL LETTER Z WITH STROKE (define-keysym #x10001e6 "Gcaron") ;U+01E6 LATIN CAPITAL LETTER G WITH CARON (define-keysym #x10001d1 "Ocaron") ;U+01D2 LATIN CAPITAL LETTER O WITH CARON (define-keysym #x100019f "Obarred") ;U+019F LATIN CAPITAL LETTER O WITH MIDDLE TILDE (define-keysym #x1001e8b "xabovedot") ;U+1E8B LATIN SMALL LETTER X WITH DOT ABOVE (define-keysym #x100012d "ibreve") ;U+012D LATIN SMALL LETTER I WITH BREVE (define-keysym #x10001b6 "zstroke") ;U+01B6 LATIN SMALL LETTER Z WITH STROKE (define-keysym #x10001e7 "gcaron") ;U+01E7 LATIN SMALL LETTER G WITH CARON (define-keysym #x10001d2 "ocaron") ;U+01D2 LATIN SMALL LETTER O WITH CARON (define-keysym #x1000275 "obarred") ;U+0275 LATIN SMALL LETTER BARRED O (define-keysym #x100018f "SCHWA") ;U+018F LATIN CAPITAL LETTER SCHWA (define-keysym #x1000259 "schwa") ;U+0259 LATIN SMALL LETTER SCHWA (define-keysym #x1001e36 "Lbelowdot") ;U+1E36 LATIN CAPITAL LETTER L WITH DOT BELOW (define-keysym #x1001e37 "lbelowdot") ;U+1E37 LATIN SMALL LETTER L WITH DOT BELOW (define-keysym #x1001ea0 "Abelowdot") ;U+1EA0 LATIN CAPITAL LETTER A WITH DOT BELOW (define-keysym #x1001ea1 "abelowdot") ;U+1EA1 LATIN SMALL LETTER A WITH DOT BELOW (define-keysym #x1001ea2 "Ahook") ;U+1EA2 LATIN CAPITAL LETTER A WITH HOOK ABOVE (define-keysym #x1001ea3 "ahook") ;U+1EA3 LATIN SMALL LETTER A WITH HOOK ABOVE (define-keysym #x1001ea4 "Acircumflexacute") ;U+1EA4 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE (define-keysym #x1001ea5 "acircumflexacute") ;U+1EA5 LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE (define-keysym #x1001ea6 "Acircumflexgrave") ;U+1EA6 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE (define-keysym #x1001ea7 "acircumflexgrave") ;U+1EA7 LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE (define-keysym #x1001ea8 "Acircumflexhook") ;U+1EA8 LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE (define-keysym #x1001ea9 "acircumflexhook") ;U+1EA9 LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE (define-keysym #x1001eaa "Acircumflextilde") ;U+1EAA LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE (define-keysym #x1001eab "acircumflextilde") ;U+1EAB LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE (define-keysym #x1001eac "Acircumflexbelowdot") ;U+1EAC LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW (define-keysym #x1001ead "acircumflexbelowdot") ;U+1EAD LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW (define-keysym #x1001eae "Abreveacute") ;U+1EAE LATIN CAPITAL LETTER A WITH BREVE AND ACUTE (define-keysym #x1001eaf "abreveacute") ;U+1EAF LATIN SMALL LETTER A WITH BREVE AND ACUTE (define-keysym #x1001eb0 "Abrevegrave") ;U+1EB0 LATIN CAPITAL LETTER A WITH BREVE AND GRAVE (define-keysym #x1001eb1 "abrevegrave") ;U+1EB1 LATIN SMALL LETTER A WITH BREVE AND GRAVE (define-keysym #x1001eb2 "Abrevehook") ;U+1EB2 LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE (define-keysym #x1001eb3 "abrevehook") ;U+1EB3 LATIN SMALL LETTER A WITH BREVE AND HOOK ABOVE (define-keysym #x1001eb4 "Abrevetilde") ;U+1EB4 LATIN CAPITAL LETTER A WITH BREVE AND TILDE (define-keysym #x1001eb5 "abrevetilde") ;U+1EB5 LATIN SMALL LETTER A WITH BREVE AND TILDE (define-keysym #x1001eb6 "Abrevebelowdot") ;U+1EB6 LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW (define-keysym #x1001eb7 "abrevebelowdot") ;U+1EB7 LATIN SMALL LETTER A WITH BREVE AND DOT BELOW (define-keysym #x1001eb8 "Ebelowdot") ;U+1EB8 LATIN CAPITAL LETTER E WITH DOT BELOW (define-keysym #x1001eb9 "ebelowdot") ;U+1EB9 LATIN SMALL LETTER E WITH DOT BELOW (define-keysym #x1001eba "Ehook") ;U+1EBA LATIN CAPITAL LETTER E WITH HOOK ABOVE (define-keysym #x1001ebb "ehook") ;U+1EBB LATIN SMALL LETTER E WITH HOOK ABOVE (define-keysym #x1001ebc "Etilde") ;U+1EBC LATIN CAPITAL LETTER E WITH TILDE (define-keysym #x1001ebd "etilde") ;U+1EBD LATIN SMALL LETTER E WITH TILDE (define-keysym #x1001ebe "Ecircumflexacute") ;U+1EBE LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE (define-keysym #x1001ebf "ecircumflexacute") ;U+1EBF LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE (define-keysym #x1001ec0 "Ecircumflexgrave") ;U+1EC0 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE (define-keysym #x1001ec1 "ecircumflexgrave") ;U+1EC1 LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE (define-keysym #x1001ec2 "Ecircumflexhook") ;U+1EC2 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE (define-keysym #x1001ec3 "ecircumflexhook") ;U+1EC3 LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE (define-keysym #x1001ec4 "Ecircumflextilde") ;U+1EC4 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE (define-keysym #x1001ec5 "ecircumflextilde") ;U+1EC5 LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE (define-keysym #x1001ec6 "Ecircumflexbelowdot") ;U+1EC6 LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW (define-keysym #x1001ec7 "ecircumflexbelowdot") ;U+1EC7 LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW (define-keysym #x1001ec8 "Ihook") ;U+1EC8 LATIN CAPITAL LETTER I WITH HOOK ABOVE (define-keysym #x1001ec9 "ihook") ;U+1EC9 LATIN SMALL LETTER I WITH HOOK ABOVE (define-keysym #x1001eca "Ibelowdot") ;U+1ECA LATIN CAPITAL LETTER I WITH DOT BELOW (define-keysym #x1001ecb "ibelowdot") ;U+1ECB LATIN SMALL LETTER I WITH DOT BELOW (define-keysym #x1001ecc "Obelowdot") ;U+1ECC LATIN CAPITAL LETTER O WITH DOT BELOW (define-keysym #x1001ecd "obelowdot") ;U+1ECD LATIN SMALL LETTER O WITH DOT BELOW (define-keysym #x1001ece "Ohook") ;U+1ECE LATIN CAPITAL LETTER O WITH HOOK ABOVE (define-keysym #x1001ecf "ohook") ;U+1ECF LATIN SMALL LETTER O WITH HOOK ABOVE (define-keysym #x1001ed0 "Ocircumflexacute") ;U+1ED0 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE (define-keysym #x1001ed1 "ocircumflexacute") ;U+1ED1 LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE (define-keysym #x1001ed2 "Ocircumflexgrave") ;U+1ED2 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE (define-keysym #x1001ed3 "ocircumflexgrave") ;U+1ED3 LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE (define-keysym #x1001ed4 "Ocircumflexhook") ;U+1ED4 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE (define-keysym #x1001ed5 "ocircumflexhook") ;U+1ED5 LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE (define-keysym #x1001ed6 "Ocircumflextilde") ;U+1ED6 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE (define-keysym #x1001ed7 "ocircumflextilde") ;U+1ED7 LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE (define-keysym #x1001ed8 "Ocircumflexbelowdot") ;U+1ED8 LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW (define-keysym #x1001ed9 "ocircumflexbelowdot") ;U+1ED9 LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW (define-keysym #x1001eda "Ohornacute") ;U+1EDA LATIN CAPITAL LETTER O WITH HORN AND ACUTE (define-keysym #x1001edb "ohornacute") ;U+1EDB LATIN SMALL LETTER O WITH HORN AND ACUTE (define-keysym #x1001edc "Ohorngrave") ;U+1EDC LATIN CAPITAL LETTER O WITH HORN AND GRAVE (define-keysym #x1001edd "ohorngrave") ;U+1EDD LATIN SMALL LETTER O WITH HORN AND GRAVE (define-keysym #x1001ede "Ohornhook") ;U+1EDE LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE (define-keysym #x1001edf "ohornhook") ;U+1EDF LATIN SMALL LETTER O WITH HORN AND HOOK ABOVE (define-keysym #x1001ee0 "Ohorntilde") ;U+1EE0 LATIN CAPITAL LETTER O WITH HORN AND TILDE (define-keysym #x1001ee1 "ohorntilde") ;U+1EE1 LATIN SMALL LETTER O WITH HORN AND TILDE (define-keysym #x1001ee2 "Ohornbelowdot") ;U+1EE2 LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW (define-keysym #x1001ee3 "ohornbelowdot") ;U+1EE3 LATIN SMALL LETTER O WITH HORN AND DOT BELOW (define-keysym #x1001ee4 "Ubelowdot") ;U+1EE4 LATIN CAPITAL LETTER U WITH DOT BELOW (define-keysym #x1001ee5 "ubelowdot") ;U+1EE5 LATIN SMALL LETTER U WITH DOT BELOW (define-keysym #x1001ee6 "Uhook") ;U+1EE6 LATIN CAPITAL LETTER U WITH HOOK ABOVE (define-keysym #x1001ee7 "uhook") ;U+1EE7 LATIN SMALL LETTER U WITH HOOK ABOVE (define-keysym #x1001ee8 "Uhornacute") ;U+1EE8 LATIN CAPITAL LETTER U WITH HORN AND ACUTE (define-keysym #x1001ee9 "uhornacute") ;U+1EE9 LATIN SMALL LETTER U WITH HORN AND ACUTE (define-keysym #x1001eea "Uhorngrave") ;U+1EEA LATIN CAPITAL LETTER U WITH HORN AND GRAVE (define-keysym #x1001eeb "uhorngrave") ;U+1EEB LATIN SMALL LETTER U WITH HORN AND GRAVE (define-keysym #x1001eec "Uhornhook") ;U+1EEC LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE (define-keysym #x1001eed "uhornhook") ;U+1EED LATIN SMALL LETTER U WITH HORN AND HOOK ABOVE (define-keysym #x1001eee "Uhorntilde") ;U+1EEE LATIN CAPITAL LETTER U WITH HORN AND TILDE (define-keysym #x1001eef "uhorntilde") ;U+1EEF LATIN SMALL LETTER U WITH HORN AND TILDE (define-keysym #x1001ef0 "Uhornbelowdot") ;U+1EF0 LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW (define-keysym #x1001ef1 "uhornbelowdot") ;U+1EF1 LATIN SMALL LETTER U WITH HORN AND DOT BELOW (define-keysym #x1001ef4 "Ybelowdot") ;U+1EF4 LATIN CAPITAL LETTER Y WITH DOT BELOW (define-keysym #x1001ef5 "ybelowdot") ;U+1EF5 LATIN SMALL LETTER Y WITH DOT BELOW (define-keysym #x1001ef6 "Yhook") ;U+1EF6 LATIN CAPITAL LETTER Y WITH HOOK ABOVE (define-keysym #x1001ef7 "yhook") ;U+1EF7 LATIN SMALL LETTER Y WITH HOOK ABOVE (define-keysym #x1001ef8 "Ytilde") ;U+1EF8 LATIN CAPITAL LETTER Y WITH TILDE (define-keysym #x1001ef9 "ytilde") ;U+1EF9 LATIN SMALL LETTER Y WITH TILDE (define-keysym #x10001a0 "Ohorn") ;U+01A0 LATIN CAPITAL LETTER O WITH HORN (define-keysym #x10001a1 "ohorn") ;U+01A1 LATIN SMALL LETTER O WITH HORN (define-keysym #x10001af "Uhorn") ;U+01AF LATIN CAPITAL LETTER U WITH HORN (define-keysym #x10001b0 "uhorn") ;U+01B0 LATIN SMALL LETTER U WITH HORN (define-keysym #x10020a0 "EcuSign") ;U+20A0 EURO-CURRENCY SIGN (define-keysym #x10020a1 "ColonSign") ;U+20A1 COLON SIGN (define-keysym #x10020a2 "CruzeiroSign") ;U+20A2 CRUZEIRO SIGN (define-keysym #x10020a3 "FFrancSign") ;U+20A3 FRENCH FRANC SIGN (define-keysym #x10020a4 "LiraSign") ;U+20A4 LIRA SIGN (define-keysym #x10020a5 "MillSign") ;U+20A5 MILL SIGN (define-keysym #x10020a6 "NairaSign") ;U+20A6 NAIRA SIGN (define-keysym #x10020a7 "PesetaSign") ;U+20A7 PESETA SIGN (define-keysym #x10020a8 "RupeeSign") ;U+20A8 RUPEE SIGN (define-keysym #x10020a9 "WonSign") ;U+20A9 WON SIGN (define-keysym #x10020aa "NewSheqelSign") ;U+20AA NEW SHEQEL SIGN (define-keysym #x10020ab "DongSign") ;U+20AB DONG SIGN (define-keysym #x20ac "EuroSign") ;U+20AC EURO SIGN (define-keysym #x1002070 "zerosuperior") ;U+2070 SUPERSCRIPT ZERO (define-keysym #x1002074 "foursuperior") ;U+2074 SUPERSCRIPT FOUR (define-keysym #x1002075 "fivesuperior") ;U+2075 SUPERSCRIPT FIVE (define-keysym #x1002076 "sixsuperior") ;U+2076 SUPERSCRIPT SIX (define-keysym #x1002077 "sevensuperior") ;U+2077 SUPERSCRIPT SEVEN (define-keysym #x1002078 "eightsuperior") ;U+2078 SUPERSCRIPT EIGHT (define-keysym #x1002079 "ninesuperior") ;U+2079 SUPERSCRIPT NINE (define-keysym #x1002080 "zerosubscript") ;U+2080 SUBSCRIPT ZERO (define-keysym #x1002081 "onesubscript") ;U+2081 SUBSCRIPT ONE (define-keysym #x1002082 "twosubscript") ;U+2082 SUBSCRIPT TWO (define-keysym #x1002083 "threesubscript") ;U+2083 SUBSCRIPT THREE (define-keysym #x1002084 "foursubscript") ;U+2084 SUBSCRIPT FOUR (define-keysym #x1002085 "fivesubscript") ;U+2085 SUBSCRIPT FIVE (define-keysym #x1002086 "sixsubscript") ;U+2086 SUBSCRIPT SIX (define-keysym #x1002087 "sevensubscript") ;U+2087 SUBSCRIPT SEVEN (define-keysym #x1002088 "eightsubscript") ;U+2088 SUBSCRIPT EIGHT (define-keysym #x1002089 "ninesubscript") ;U+2089 SUBSCRIPT NINE (define-keysym #x1002202 "partdifferential") ;U+2202 PARTIAL DIFFERENTIAL (define-keysym #x1002205 "emptyset") ;U+2205 NULL SET (define-keysym #x1002208 "elementof") ;U+2208 ELEMENT OF (define-keysym #x1002209 "notelementof") ;U+2209 NOT AN ELEMENT OF (define-keysym #x100220B "containsas") ;U+220B CONTAINS AS MEMBER (define-keysym #x100221A "squareroot") ;U+221A SQUARE ROOT (define-keysym #x100221B "cuberoot") ;U+221B CUBE ROOT (define-keysym #x100221C "fourthroot") ;U+221C FOURTH ROOT (define-keysym #x100222C "dintegral") ;U+222C DOUBLE INTEGRAL (define-keysym #x100222D "tintegral") ;U+222D TRIPLE INTEGRAL (define-keysym #x1002235 "because") ;U+2235 BECAUSE (define-keysym #x1002248 "approxeq") ;U+2245 ALMOST EQUAL TO (define-keysym #x1002247 "notapproxeq") ;U+2247 NOT ALMOST EQUAL TO (define-keysym #x1002262 "notidentical") ;U+2262 NOT IDENTICAL TO (define-keysym #x1002263 "stricteq") ;U+2263 STRICTLY EQUIVALENT TO ;; A bunch of extended keysyms (define-keysym #x100000A8 "hpmute_acute") (define-keysym #x100000A9 "hpmute_grave") (define-keysym #x100000AA "hpmute_asciicircum") (define-keysym #x100000AB "hpmute_diaeresis") (define-keysym #x100000AC "hpmute_asciitilde") (define-keysym #x100000AF "hplira") (define-keysym #x100000BE "hpguilder") (define-keysym #x100000EE "hpYdiaeresis") (define-keysym #x100000EE "hpIO") (define-keysym #x100000F6 "hplongminus") (define-keysym #x100000FC "hpblock") (define-keysym #x1000FF00 "apLineDel") (define-keysym #x1000FF01 "apCharDel") (define-keysym #x1000FF02 "apCopy") (define-keysym #x1000FF03 "apCut") (define-keysym #x1000FF04 "apPaste") (define-keysym #x1000FF05 "apMove") (define-keysym #x1000FF06 "apGrow") (define-keysym #x1000FF07 "apCmd") (define-keysym #x1000FF08 "apShell") (define-keysym #x1000FF09 "apLeftBar") (define-keysym #x1000FF0A "apRightBar") (define-keysym #x1000FF0B "apLeftBox") (define-keysym #x1000FF0C "apRightBox") (define-keysym #x1000FF0D "apUpBox") (define-keysym #x1000FF0E "apDownBox") (define-keysym #x1000FF0F "apPop") (define-keysym #x1000FF10 "apRead") (define-keysym #x1000FF11 "apEdit") (define-keysym #x1000FF12 "apSave") (define-keysym #x1000FF13 "apExit") (define-keysym #x1000FF14 "apRepeat") (define-keysym #x1000FF48 "hpModelock1") (define-keysym #x1000FF49 "hpModelock2") (define-keysym #x1000FF6C "hpReset") (define-keysym #x1000FF6D "hpSystem") (define-keysym #x1000FF6E "hpUser") (define-keysym #x1000FF6F "hpClearLine") (define-keysym #x1000FF70 "hpInsertLine") (define-keysym #x1000FF71 "hpDeleteLine") (define-keysym #x1000FF72 "hpInsertChar") (define-keysym #x1000FF73 "hpDeleteChar") (define-keysym #x1000FF74 "hpBackTab") (define-keysym #x1000FF75 "hpKP_BackTab") (define-keysym #x1000FFA8 "apKP_parenleft") (define-keysym #x1000FFA9 "apKP_parenright") (define-keysym #x10004001 "I2ND_FUNC_L") (define-keysym #x10004002 "I2ND_FUNC_R") (define-keysym #x10004003 "IREMOVE") (define-keysym #x10004004 "IREPEAT") (define-keysym #x10004101 "IA1") (define-keysym #x10004102 "IA2") (define-keysym #x10004103 "IA3") (define-keysym #x10004104 "IA4") (define-keysym #x10004105 "IA5") (define-keysym #x10004106 "IA6") (define-keysym #x10004107 "IA7") (define-keysym #x10004108 "IA8") (define-keysym #x10004109 "IA9") (define-keysym #x1000410A "IA10") (define-keysym #x1000410B "IA11") (define-keysym #x1000410C "IA12") (define-keysym #x1000410D "IA13") (define-keysym #x1000410E "IA14") (define-keysym #x1000410F "IA15") (define-keysym #x10004201 "IB1") (define-keysym #x10004202 "IB2") (define-keysym #x10004203 "IB3") (define-keysym #x10004204 "IB4") (define-keysym #x10004205 "IB5") (define-keysym #x10004206 "IB6") (define-keysym #x10004207 "IB7") (define-keysym #x10004208 "IB8") (define-keysym #x10004209 "IB9") (define-keysym #x1000420A "IB10") (define-keysym #x1000420B "IB11") (define-keysym #x1000420C "IB12") (define-keysym #x1000420D "IB13") (define-keysym #x1000420E "IB14") (define-keysym #x1000420F "IB15") (define-keysym #x10004210 "IB16") (define-keysym #x1000FF00 "DRemove") (define-keysym #x1000FEB0 "Dring_accent") (define-keysym #x1000FE5E "Dcircumflex_accent") (define-keysym #x1000FE2C "Dcedilla_accent") (define-keysym #x1000FE27 "Dacute_accent") (define-keysym #x1000FE60 "Dgrave_accent") (define-keysym #x1000FE7E "Dtilde") (define-keysym #x1000FE22 "Ddiaeresis") (define-keysym #x1004FF02 "osfCopy") (define-keysym #x1004FF03 "osfCut") (define-keysym #x1004FF04 "osfPaste") (define-keysym #x1004FF07 "osfBackTab") (define-keysym #x1004FF08 "osfBackSpace") (define-keysym #x1004FF0B "osfClear") (define-keysym #x1004FF1B "osfEscape") (define-keysym #x1004FF31 "osfAddMode") (define-keysym #x1004FF32 "osfPrimaryPaste") (define-keysym #x1004FF33 "osfQuickPaste") (define-keysym #x1004FF40 "osfPageLeft") (define-keysym #x1004FF41 "osfPageUp") (define-keysym #x1004FF42 "osfPageDown") (define-keysym #x1004FF43 "osfPageRight") (define-keysym #x1004FF44 "osfActivate") (define-keysym #x1004FF45 "osfMenuBar") (define-keysym #x1004FF51 "osfLeft") (define-keysym #x1004FF52 "osfUp") (define-keysym #x1004FF53 "osfRight") (define-keysym #x1004FF54 "osfDown") (define-keysym #x1004FF55 "osfPrior") (define-keysym #x1004FF56 "osfNext") (define-keysym #x1004FF57 "osfEndLine") (define-keysym #x1004FF58 "osfBeginLine") (define-keysym #x1004FF59 "osfEndData") (define-keysym #x1004FF5A "osfBeginData") (define-keysym #x1004FF5B "osfPrevMenu") (define-keysym #x1004FF5C "osfNextMenu") (define-keysym #x1004FF5D "osfPrevField") (define-keysym #x1004FF5E "osfNextField") (define-keysym #x1004FF60 "osfSelect") (define-keysym #x1004FF63 "osfInsert") (define-keysym #x1004FF65 "osfUndo") (define-keysym #x1004FF67 "osfMenu") (define-keysym #x1004FF69 "osfCancel") (define-keysym #x1004FF6A "osfHelp") (define-keysym #x1004FF71 "osfSelectAll") (define-keysym #x1004FF72 "osfDeselectAll") (define-keysym #x1004FF73 "osfReselect") (define-keysym #x1004FF74 "osfExtend") (define-keysym #x1004FF78 "osfRestore") (define-keysym #x1004FF7E "osfSwitchDirection") (define-keysym #x1004FFF5 "osfPriorMinor") (define-keysym #x1004FFF6 "osfNextMinor") (define-keysym #x1004FFF7 "osfRightLine") (define-keysym #x1004FFF8 "osfLeftLine") (define-keysym #x1004FFFF "osfDelete") (define-keysym #x1005FF00 "SunFA_Grave") (define-keysym #x1005FF01 "SunFA_Circum") (define-keysym #x1005FF02 "SunFA_Tilde") (define-keysym #x1005FF03 "SunFA_Acute") (define-keysym #x1005FF04 "SunFA_Diaeresis") (define-keysym #x1005FF05 "SunFA_Cedilla") (define-keysym #x1005FF10 "SunF36") (define-keysym #x1005FF11 "SunF37") (define-keysym #x1005FF60 "SunSys_Req") (define-keysym #x1005FF70 "SunProps") (define-keysym #x1005FF71 "SunFront") (define-keysym #x1005FF72 "SunCopy") (define-keysym #x1005FF73 "SunOpen") (define-keysym #x1005FF74 "SunPaste") (define-keysym #x1005FF75 "SunCut") (define-keysym #x1005FF76 "SunPowerSwitch") (define-keysym #x1005FF77 "SunAudioLowerVolume") (define-keysym #x1005FF78 "SunAudioMute") (define-keysym #x1005FF79 "SunAudioRaiseVolume") (define-keysym #x1005FF7A "SunVideoDegauss") (define-keysym #x1005FF7B "SunVideoLowerBrightness") (define-keysym #x1005FF7C "SunVideoRaiseBrightness") (define-keysym #x1005FF7D "SunPowerSwitchShift") (define-keysym #xFF20 "SunCompose") (define-keysym #xFF55 "SunPageUp") (define-keysym #xFF56 "SunPageDown") (define-keysym #xFF61 "SunPrint_Screen") (define-keysym #xFF65 "SunUndo") (define-keysym #xFF66 "SunAgain") (define-keysym #xFF68 "SunFind") (define-keysym #xFF69 "SunStop") (define-keysym #xFF7E "SunAltGraph") (define-keysym #x1006FF00 "WYSetup") (define-keysym #x1006FF00 "ncdSetup") (define-keysym #x10070001 "XeroxPointerButton1") (define-keysym #x10070002 "XeroxPointerButton2") (define-keysym #x10070003 "XeroxPointerButton3") (define-keysym #x10070004 "XeroxPointerButton4") (define-keysym #x10070005 "XeroxPointerButton5") (define-keysym #x1008FF01 "XF86ModeLock") (define-keysym #x1008FF10 "XF86Standby") (define-keysym #x1008FF11 "XF86AudioLowerVolume") (define-keysym #x1008FF12 "XF86AudioMute") (define-keysym #x1008FF13 "XF86AudioRaiseVolume") (define-keysym #x1008FF14 "XF86AudioPlay") (define-keysym #x1008FF15 "XF86AudioStop") (define-keysym #x1008FF16 "XF86AudioPrev") (define-keysym #x1008FF17 "XF86AudioNext") (define-keysym #x1008FF18 "XF86HomePage") (define-keysym #x1008FF19 "XF86Mail") (define-keysym #x1008FF1A "XF86Start") (define-keysym #x1008FF1B "XF86Search") (define-keysym #x1008FF1C "XF86AudioRecord") (define-keysym #x1008FF1D "XF86Calculator") (define-keysym #x1008FF1E "XF86Memo") (define-keysym #x1008FF1F "XF86ToDoList") (define-keysym #x1008FF20 "XF86Calendar") (define-keysym #x1008FF21 "XF86PowerDown") (define-keysym #x1008FF22 "XF86ContrastAdjust") (define-keysym #x1008FF23 "XF86RockerUp") (define-keysym #x1008FF24 "XF86RockerDown") (define-keysym #x1008FF25 "XF86RockerEnter") (define-keysym #x1008FF26 "XF86Back") (define-keysym #x1008FF27 "XF86Forward") (define-keysym #x1008FF28 "XF86Stop") (define-keysym #x1008FF29 "XF86Refresh") (define-keysym #x1008FF2A "XF86PowerOff") (define-keysym #x1008FF2B "XF86WakeUp") (define-keysym #x1008FF2C "XF86Eject") (define-keysym #x1008FF2D "XF86ScreenSaver") (define-keysym #x1008FF2E "XF86WWW") (define-keysym #x1008FF2F "XF86Sleep") (define-keysym #x1008FF30 "XF86Favorites") (define-keysym #x1008FF31 "XF86AudioPause") (define-keysym #x1008FF32 "XF86AudioMedia") (define-keysym #x1008FF33 "XF86MyComputer") (define-keysym #x1008FF34 "XF86VendorHome") (define-keysym #x1008FF35 "XF86LightBulb") (define-keysym #x1008FF36 "XF86Shop") (define-keysym #x1008FF37 "XF86History") (define-keysym #x1008FF38 "XF86OpenURL") (define-keysym #x1008FF39 "XF86AddFavorite") (define-keysym #x1008FF3A "XF86HotLinks") (define-keysym #x1008FF3B "XF86BrightnessAdjust") (define-keysym #x1008FF3C "XF86Finance") (define-keysym #x1008FF3D "XF86Community") (define-keysym #x1008FF3E "XF86AudioRewind") (define-keysym #x1008FF3F "XF86BackForward") (define-keysym #x1008FF40 "XF86Launch0") (define-keysym #x1008FF41 "XF86Launch1") (define-keysym #x1008FF42 "XF86Launch2") (define-keysym #x1008FF43 "XF86Launch3") (define-keysym #x1008FF44 "XF86Launch4") (define-keysym #x1008FF45 "XF86Launch5") (define-keysym #x1008FF46 "XF86Launch6") (define-keysym #x1008FF47 "XF86Launch7") (define-keysym #x1008FF48 "XF86Launch8") (define-keysym #x1008FF49 "XF86Launch9") (define-keysym #x1008FF4A "XF86LaunchA") (define-keysym #x1008FF4B "XF86LaunchB") (define-keysym #x1008FF4C "XF86LaunchC") (define-keysym #x1008FF4D "XF86LaunchD") (define-keysym #x1008FF4E "XF86LaunchE") (define-keysym #x1008FF4F "XF86LaunchF") (define-keysym #x1008FF50 "XF86ApplicationLeft") (define-keysym #x1008FF51 "XF86ApplicationRight") (define-keysym #x1008FF52 "XF86Book") (define-keysym #x1008FF53 "XF86CD") (define-keysym #x1008FF54 "XF86Calculater") (define-keysym #x1008FF55 "XF86Clear") (define-keysym #x1008FF56 "XF86Close") (define-keysym #x1008FF57 "XF86Copy") (define-keysym #x1008FF58 "XF86Cut") (define-keysym #x1008FF59 "XF86Display") (define-keysym #x1008FF5A "XF86DOS") (define-keysym #x1008FF5B "XF86Documents") (define-keysym #x1008FF5C "XF86Excel") (define-keysym #x1008FF5D "XF86Explorer") (define-keysym #x1008FF5E "XF86Game") (define-keysym #x1008FF5F "XF86Go") (define-keysym #x1008FF60 "XF86iTouch") (define-keysym #x1008FF61 "XF86LogOff") (define-keysym #x1008FF62 "XF86Market") (define-keysym #x1008FF63 "XF86Meeting") (define-keysym #x1008FF65 "XF86MenuKB") (define-keysym #x1008FF66 "XF86MenuPB") (define-keysym #x1008FF67 "XF86MySites") (define-keysym #x1008FF68 "XF86New") (define-keysym #x1008FF69 "XF86News") (define-keysym #x1008FF6A "XF86OfficeHome") (define-keysym #x1008FF6B "XF86Open") (define-keysym #x1008FF6C "XF86Option") (define-keysym #x1008FF6D "XF86Paste") (define-keysym #x1008FF6E "XF86Phone") (define-keysym #x1008FF70 "XF86Q") (define-keysym #x1008FF72 "XF86Reply") (define-keysym #x1008FF73 "XF86Reload") (define-keysym #x1008FF74 "XF86RotateWindows") (define-keysym #x1008FF75 "XF86RotationPB") (define-keysym #x1008FF76 "XF86RotationKB") (define-keysym #x1008FF77 "XF86Save") (define-keysym #x1008FF78 "XF86ScrollUp") (define-keysym #x1008FF79 "XF86ScrollDown") (define-keysym #x1008FF7A "XF86ScrollClick") (define-keysym #x1008FF7B "XF86Send") (define-keysym #x1008FF7C "XF86Spell") (define-keysym #x1008FF7D "XF86SplitScreen") (define-keysym #x1008FF7E "XF86Support") (define-keysym #x1008FF7F "XF86TaskPane") (define-keysym #x1008FF80 "XF86Terminal") (define-keysym #x1008FF81 "XF86Tools") (define-keysym #x1008FF82 "XF86Travel") (define-keysym #x1008FF84 "XF86UserPB") (define-keysym #x1008FF85 "XF86User1KB") (define-keysym #x1008FF86 "XF86User2KB") (define-keysym #x1008FF87 "XF86Video") (define-keysym #x1008FF88 "XF86WheelButton") (define-keysym #x1008FF89 "XF86Word") (define-keysym #x1008FF8A "XF86Xfer") (define-keysym #x1008FF8B "XF86ZoomIn") (define-keysym #x1008FF8C "XF86ZoomOut") (define-keysym #x1008FF8D "XF86Away") (define-keysym #x1008FF8E "XF86Messenger") (define-keysym #x1008FF8F "XF86WebCam") (define-keysym #x1008FF90 "XF86MailForward") (define-keysym #x1008FF91 "XF86Pictures") (define-keysym #x1008FF92 "XF86Music") (define-keysym #x1008FE01 "XF86_Switch_VT_1") (define-keysym #x1008FE02 "XF86_Switch_VT_2") (define-keysym #x1008FE03 "XF86_Switch_VT_3") (define-keysym #x1008FE04 "XF86_Switch_VT_4") (define-keysym #x1008FE05 "XF86_Switch_VT_5") (define-keysym #x1008FE06 "XF86_Switch_VT_6") (define-keysym #x1008FE07 "XF86_Switch_VT_7") (define-keysym #x1008FE08 "XF86_Switch_VT_8") (define-keysym #x1008FE09 "XF86_Switch_VT_9") (define-keysym #x1008FE0A "XF86_Switch_VT_10") (define-keysym #x1008FE0B "XF86_Switch_VT_11") (define-keysym #x1008FE0C "XF86_Switch_VT_12") (define-keysym #x1008FE20 "XF86_Ungrab") (define-keysym #x1008FE21 "XF86_ClearGrab") (define-keysym #x1008FE22 "XF86_Next_VMode") (define-keysym #x1008FE23 "XF86_Prev_VMode") (define-keysym #x100000A8 "usldead_acute") (define-keysym #x100000A9 "usldead_grave") (define-keysym #x100000AB "usldead_diaeresis") (define-keysym #x100000AA "usldead_asciicircum") (define-keysym #x100000AC "usldead_asciitilde") (define-keysym #x1000FE2C "usldead_cedilla") (define-keysym #x1000FEB0 "usldead_ring")
125,445
Common Lisp
.lisp
2,052
60.104288
112
0.751755
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
ec4c5c5df868567bb02d2c3f21ed877f2b3524ba3f0c00305b3b9288dc7ec57e
7,264
[ -1 ]
7,265
floating-group.lisp
blitz_stumpwm/floating-group.lisp
;;; implementation of a floating style window management group (in-package :stumpwm) ;;; floating window (defclass float-window (window) ((last-width :initform 0 :accessor float-window-last-width) (last-height :initform 0 :accessor float-window-last-height) (last-x :initform 0 :accessor float-window-last-x) (last-y :initform 0 :accessor float-window-last-y)) ) (defvar *float-window-border* 1) (defvar *float-window-title-height* 10) ;; some book keeping functions (defmethod (setf window-x) :before (val (window float-window)) (unless (eql (window-x window) val) (setf (float-window-last-x window) (window-x window)))) (defmethod (setf window-y) :before (val (window float-window)) (unless (eql (window-y window) val) (setf (float-window-last-y window) (window-y window)))) (defmethod (setf window-width) :before (val (window float-window)) (unless (eql (window-width window) val) (setf (float-window-last-width window) (window-width window)))) (defmethod (setf window-height) :before (val (window float-window)) (unless (eql (window-height window) val) (setf (float-window-last-height window) (window-height window)))) (defun float-window-move-resize (win &key x y width height (border *float-window-border*)) ;; x and y position the parent window while width, height resize the ;; xwin (meaning the parent will have a larger width). (with-slots (xwin parent) win (xlib:with-state (parent) (xlib:with-state (xwin) (when x (setf (xlib:drawable-x parent) x (window-x win) x)) (when y (setf (xlib:drawable-y parent) y (window-y win) y)) (when width (setf (xlib:drawable-width parent) (+ (xlib:drawable-x xwin) width border) (xlib:drawable-width xwin) width (window-width win) width)) (when height (setf (xlib:drawable-height parent) (+ (xlib:drawable-y xwin) height border) (xlib:drawable-height xwin) height (window-height win) height)))))) (defmethod update-decoration ((window float-window)) (let ((group (window-group window))) (setf (xlib:window-background (window-parent window)) (xlib:alloc-color (xlib:screen-default-colormap (screen-number (window-screen window))) (if (eq (group-current-window group) window) "Orange" "SteelBlue4"))) (xlib:clear-area (window-parent window)))) (defmethod window-sync ((window float-window) hint) (declare (ignore hint)) ) (defmethod window-head ((window float-window)) (dolist (head (screen-heads (group-screen (window-group window)))) (when (and (>= (window-x window) (frame-x head)) (>= (window-y window) (frame-y head)) (<= (+ (window-x window) (window-width window)) (+ (frame-x head) (frame-width head))) (<= (+ (window-y window) (window-height window)) (+ (frame-y head) (frame-height head)))) (return head)))) (defmethod window-visible-p ((win float-window)) (eql (window-state win) +normal-state+)) (defmethod (setf window-fullscreen) :after (val (window float-window)) (with-slots (last-x last-y last-width last-height parent) window (if val (let ((head (window-head window))) (with-slots (x y width height) window (format t "major on: ~a ~a ~a ~a~%" x y width height)) (set-window-geometry window :x 0 :y 0) (float-window-move-resize window :x (frame-x head) :y (frame-y head) :width (frame-width head) :height (frame-height head) :border 0) (format t "loot after: ~a ~a ~a ~a~%" last-x last-y last-width last-height)) (progn (format t "fullscreenage: ~a ~a ~a ~a~%" last-x last-y last-width last-height) ;; restore the position (set-window-geometry window :x *float-window-border* :y *float-window-title-height*) (float-window-move-resize window :x last-x :y last-y :width last-width :height last-height))))) ;;; floating group (defclass float-group (group) ((current-window :accessor float-group-current-window)) ) (defmethod group-add-window ((group float-group) window &key &allow-other-keys) (change-class window 'float-window) (float-window-align window) (focus-window window)) (defun &float-focus-next (group) (if (group-windows group) (focus-window (first (group-windows group))) (no-focus group nil))) (defmethod group-delete-window ((group float-group) window) (declare (ignore window)) (&float-focus-next group)) (defmethod group-wake-up ((group float-group)) (&float-focus-next group)) (defmethod group-suspend ((group float-group)) ) (defmethod group-current-window ((group float-group)) (screen-focus (group-screen group))) (defmethod group-current-head ((group float-group)) (first (screen-heads (group-screen group)))) (defun float-window-align (window) (with-slots (parent xwin width height) window (set-window-geometry window :x *float-window-border* :y *float-window-title-height*) (xlib:with-state (parent) (setf (xlib:drawable-width parent) (+ width (* 2 *float-window-border*)) (xlib:drawable-height parent) (+ height *float-window-title-height* *float-window-border*) (xlib:window-background parent) (xlib:alloc-color (xlib:screen-default-colormap (screen-number (window-screen window))) "Orange"))) (xlib:clear-area (window-parent window)))) (defmethod group-resize-request ((group float-group) window width height) (float-window-move-resize window :width width :height height)) (defmethod group-move-request ((group float-group) window x y relative-to) (declare (ignore relative-to)) (float-window-move-resize window :x x :y y)) (defmethod group-raise-request ((group float-group) window type) (declare (ignore type)) (focus-window window)) (defmethod group-lost-focus ((group float-group)) (&float-focus-next group)) (defmethod group-indicate-focus ((group float-group)) ) (defmethod group-focus-window ((group float-group) window) (focus-window window)) (defmethod group-root-exposure ((group float-group)) ) (defmethod group-add-head ((group float-group)) ) (defmethod group-sync-head ((group float-group) head) (declare (ignore head)) ) (defmethod group-button-press ((group float-group) x y (window float-window)) (let ((screen (group-screen group))) (cond ((or (< x (xlib:drawable-x (window-xwin window))) (> x (+ (xlib:drawable-width (window-xwin window)) (xlib:drawable-x (window-xwin window)))) (< y (xlib:drawable-y (window-xwin window))) (> y (+ (xlib:drawable-height (window-xwin window)) (xlib:drawable-y (window-xwin window))))) (multiple-value-bind (relx rely same-screen-p child state-mask) (xlib:query-pointer (window-parent window)) (declare (ignore same-screen-p child)) (let ((initial-width (xlib:drawable-width (slot-value window 'parent))) (initial-height (xlib:drawable-height (slot-value window 'parent)))) (labels ((move-window-event-handler (&rest event-slots &key event-key &allow-other-keys) (case event-key (:button-release :done) (:motion-notify (with-slots (parent) window (xlib:with-state (parent) ;; Either move or resize the window (cond ((find :button-1 (xlib:make-state-keys state-mask)) (setf (xlib:drawable-x parent) (- (getf event-slots :x) relx) (xlib:drawable-y parent) (- (getf event-slots :y) rely))) ((find :button-3 (xlib:make-state-keys state-mask)) (let ((w (+ initial-width (- (getf event-slots :x) relx (xlib:drawable-x parent)))) (h (+ initial-height (- (getf event-slots :y) rely (xlib:drawable-y parent) *float-window-title-height*)))) ;; Don't let the window become too small (float-window-move-resize window :width (max w *min-frame-width*) :height (max h *min-frame-height*))))))) t) ;; We need to eat these events or they'll ALL ;; come blasting in later. Also things start ;; lagging hard if we don't (on clisp anyway). (:configure-notify t) (:exposure t) (t nil)))) (xlib:grab-pointer (screen-root screen) '(:button-release :pointer-motion)) (unwind-protect ;; Wait until the mouse button is released (loop for ev = (xlib:process-event *display* :handler #'move-window-event-handler :timeout nil :discard-p t) until (eq ev :done)) (ungrab-pointer)) ;; don't forget to update the cache (setf (window-x window) (xlib:drawable-x (window-parent window)) (window-y window) (xlib:drawable-y (window-parent window))))))) (t (when (eq *mouse-focus-policy* :click) (focus-window window)))))) (defmethod group-button-press ((group float-group) x y where) (declare (ignore x y where)) ) (defcommand gnew-float (name) ((:rest "Group Name: ")) "Create a floating window group with the specified name and switch to it." (add-group (current-screen) name :type 'float-group)) (defcommand gnewbg-float (name) ((:rest "Group Name: ")) "Create a floating window group with the specified name, but do not switch to it." (add-group (current-screen) name :background t :type 'float-group))
11,062
Common Lisp
.lisp
215
38.093023
131
0.563564
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
031f12f5268ec28f4f0b814c04e721efb415e3145fedf6e5dd4ce9a4ddfa370b
7,265
[ -1 ]
7,266
pathnames.lisp
blitz_stumpwm/pathnames.lisp
;;; -*- Mode: Lisp -*- ;;; This code is taken from CL-FAD. Original copyright notice follows: ;;; $Header: /usr/local/cvsrep/cl-fad/fad.lisp,v 1.35 2009/09/30 14:23:10 edi Exp $ ;;; Copyright (c) 2004, Peter Seibel. All rights reserved. ;;; Copyright (c) 2004-2009, Dr. Edmund Weitz. All rights reserved. ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; * Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; * Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials ;;; provided with the distribution. ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHORS 'AS IS' AND ANY EXPRESSED ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. (in-package :stumpwm) (export '(list-directory)) (defun component-present-p (value) "Helper function for DIRECTORY-PATHNAME-P which checks whether VALUE is neither NIL nor the keyword :UNSPECIFIC." (and value (not (eql value :unspecific)))) (defun directory-pathname-p (pathspec) "Returns NIL if PATHSPEC \(a pathname designator) does not designate a directory, PATHSPEC otherwise. It is irrelevant whether file or directory designated by PATHSPEC does actually exist." (and (not (component-present-p (pathname-name pathspec))) (not (component-present-p (pathname-type pathspec))) pathspec)) (defun pathname-as-directory (pathspec) "Converts the non-wild pathname designator PATHSPEC to directory form." (let ((pathname (pathname pathspec))) (when (wild-pathname-p pathname) (error "Can't reliably convert wild pathnames.")) (cond ((not (directory-pathname-p pathspec)) (make-pathname :directory (append (or (pathname-directory pathname) (list :relative)) (list (file-namestring pathname))) :name nil :type nil :defaults pathname)) (t pathname)))) (defun directory-wildcard (dirname) "Returns a wild pathname designator that designates all files within the directory named by the non-wild pathname designator DIRNAME." (when (wild-pathname-p dirname) (error "Can only make wildcard directories from non-wildcard directories.")) (make-pathname :name #-:cormanlisp :wild #+:cormanlisp "*" :type #-(or :clisp :cormanlisp) :wild #+:clisp nil #+:cormanlisp "*" :defaults (pathname-as-directory dirname))) #+:clisp (defun clisp-subdirectories-wildcard (wildcard) "Creates a wild pathname specifically for CLISP such that sub-directories are returned by DIRECTORY." (make-pathname :directory (append (pathname-directory wildcard) (list :wild)) :name nil :type nil :defaults wildcard)) (defun list-directory (dirname) "Returns a fresh list of pathnames corresponding to the truenames of all files within the directory named by the non-wild pathname designator DIRNAME. The pathnames of sub-directories are returned in directory form - see PATHNAME-AS-DIRECTORY." (when (wild-pathname-p dirname) (error "Can only list concrete directory names.")) #+:ecl (let ((dir (pathname-as-directory dirname))) (concatenate 'list (directory (merge-pathnames (pathname "*/") dir)) (directory (merge-pathnames (pathname "*.*") dir)))) #-:ecl (let ((wildcard (directory-wildcard dirname))) #+:abcl (system::list-directory dirname) #+(or :sbcl :cmu :scl :lispworks) (directory wildcard) #+(or :openmcl :digitool) (directory wildcard :directories t) #+:allegro (directory wildcard :directories-are-files nil) #+:clisp (nconc (directory wildcard :if-does-not-exist :keep) (directory (clisp-subdirectories-wildcard wildcard))) #+:cormanlisp (nconc (directory wildcard) (cl::directory-subdirs dirname))) #-(or :sbcl :cmu :scl :lispworks :openmcl :allegro :clisp :cormanlisp :ecl :abcl :digitool) (error "LIST-DIRECTORY not implemented")) ;;; EOF
5,064
Common Lisp
.lisp
97
45.463918
93
0.684572
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
ce38d3b796e0aa39e3df1da5af49b6320858144191c8a274c3a86004b1bf4973
7,266
[ -1 ]
7,267
make-image.lisp.in
blitz_stumpwm/make-image.lisp.in
;;; SBCL #+sbcl (progn (require 'asdf) (require 'stumpwm)) #+sbcl (progn (load "stumpwm.asd") (sb-ext:save-lisp-and-die "stumpwm" :toplevel (lambda () ;; asdf requires sbcl_home to be set, so set it to the value when the image was built (sb-posix:putenv (format nil "SBCL_HOME=~A" #.(sb-ext:posix-getenv "SBCL_HOME"))) (stumpwm:stumpwm) 0) :executable t)) ;;; CLISP ;; Is there a better way to use asdf.lisp than including it with stumpwm? #+clisp (progn (require 'asdf '("asdf.lisp")) (load "stumpwm.asd") (load "@PPCRE_PATH@/cl-ppcre.asd")) #+clisp (progn (asdf:oos 'asdf:load-op 'stumpwm)) #+clisp (progn (ext:saveinitmem "stumpwm" :init-function (lambda () (stumpwm:stumpwm) (ext:quit)) :executable t :keep-global-handlers t :norc t :documentation "The StumpWM Executable")) ;;; OPENMCL ;; Is there a better way to use asdf.lisp than including it with stumpwm? #+openmcl (progn (require 'asdf) (load "stumpwm.asd")) #+openmcl (progn (asdf:oos 'asdf:load-op 'stumpwm)) #+openmcl (progn (ccl:save-application "stumpwm" :prepend-kernel t :toplevel-function #'stumpwm:stumpwm)) ;;; ECL #+ ecl (progn (require 'asdf) (load "@PPCRE_PATH@/cl-ppcre.asd")) #+ ecl (asdf:make-build 'stumpwm :type :program :monolithic t :move-here t :epilogue-code '(progn (funcall (intern "STUMPWM" (find-package "STUMPWM"))) 0)) #+ ecl (when (probe-file "stumpwm-mono") (when (probe-file "stumpwm") (delete-file "stumpwm")) (rename-file "stumpwm-mono" "stumpwm")) #-(or sbcl clisp openmcl ecl) (error "This lisp implementation is not supported.")
2,010
Common Lisp
.lisp
58
25.310345
135
0.551209
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
dbe53e6d66344e287d98bd99385c9cfe618672ca87645b46035aa314c89b746f
7,267
[ -1 ]
7,268
mem.lisp
blitz_stumpwm/contrib/mem.lisp
;;; MEM formatters for the mode-line ;;; ;;; Copyright 2009 Vitaly Mayatskikh ;;; ;;; Maintainer: ;;; ;;; This module 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 module 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 software; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; ;;; USAGE: ;;; ;;; Put: ;;; ;;; (load "/path/to/mem.lisp") ;;; ;;; In your ~/.stumpwmrc ;;; ;;; Then you can use "%M" and/or "%N in your mode line format. ;;; ;;; NOTES: ;;; ;;; This is specific to Linux. (defpackage :stumpwm.contrib.mem (:use :common-lisp :stumpwm :cl-ppcre)) (in-package :stumpwm.contrib.mem) ;; Install formatters. (dolist (a '((#\M fmt-mem-usage) (#\N fmt-mem-usage-bar))) (pushnew a *screen-mode-line-formatters* :test 'equal)) ;; Defaults arguments for fmt-mem-usage-bar (defvar *mem-usage-bar-width* 10) (defvar *mem-usage-bar-full* #\#) (defvar *mem-usage-bar-empty* #\:) (defun get-proc-fd-field (s field) (if s (do ((line (read-line s nil nil) (read-line s nil nil))) ((null line) nil) (let ((split (cl-ppcre:split "\\s*:\\s*" line))) (when (string= (car split) field) (return (cadr split))))) "")) (defun mem-usage () "Returns a list containing 3 values: total amount of memory, allocated memory, allocated/total ratio" (let ((allocated 0)) (multiple-value-bind (mem-total mem-free buffers cached) (with-open-file (file #P"/proc/meminfo" :if-does-not-exist nil) (values (read-from-string (get-proc-fd-field file "MemTotal")) (read-from-string (get-proc-fd-field file "MemFree")) (read-from-string (get-proc-fd-field file "Buffers")) (read-from-string (get-proc-fd-field file "Cached")))) (setq allocated (- mem-total (+ mem-free buffers cached))) (list mem-total allocated (/ allocated mem-total))))) (defun fmt-mem-usage (ml) "Returns a string representing the current percent of used memory." (declare (ignore ml)) (let* ((mem (mem-usage)) (|%| (truncate (* 100 (nth 2 mem)))) (allocated (truncate (/ (nth 1 mem) 1000)))) (format nil "MEM: ~4D mb ^[~A~3D%^] " allocated (bar-zone-color |%|) |%|))) (defun fmt-mem-usage-bar (ml &optional (width *mem-usage-bar-width*) (full *mem-usage-bar-full*) (empty *mem-usage-bar-empty*)) "Returns a coloured bar-graph representing the current allocation of memory." (declare (ignore ml)) (let ((cpu (truncate (* 100 (nth 2 (mem-usage)))))) (stumpwm::bar cpu width full empty)))
3,002
Common Lisp
.lisp
77
36.545455
127
0.678326
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
d8ce1316334d1e64692e7a2ff07fb0be0f191ee1cce0787e418afa6778583595
7,268
[ -1 ]
7,269
battery.lisp
blitz_stumpwm/contrib/battery.lisp
;;; Battery charge formatters for the mode-line ;;; ;;; Copyright 2008 Vitaly Mayatskikh ;;; ;;; Maintainer: Julian Stecklina ;;; ;;; This module 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 module 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 software; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; ;;; USAGE: ;;; ;;; Put: ;;; ;;; (load "/path/to/battery.lisp") ;;; ;;; In your ~/.stumpwmrc ;;; ;;; Then you can use "%b" in your mode line format. ;;; ;;; NOTES: ;;; ;;; This is specific to Linux. (in-package :stumpwm) (export '(*battery-name*)) (dolist (a '((#\b fmt-bat-charge))) (pushnew a *screen-mode-line-formatters* :test 'equal)) (defvar *bat-state* nil) (defvar *bat-remain* 0) (defvar *bat-remain-time* nil) (defvar *bat-prev-time* 0) (defvar *battery-name* "BAT0") (defun read-battery-file (battery fname) (let ((fields (make-hash-table :test #'equal))) (with-open-file (s (concatenate 'string "/proc/acpi/battery/" battery "/" fname) :if-does-not-exist nil) (if s (do ((line (read-line s nil nil) (read-line s nil nil))) ((null line) fields) (let ((split (cl-ppcre:split ":\\s*" line))) (setf (gethash (string-trim '(#\Space) (car split)) fields) (string-trim '(#\Space) (cadr split))))) "")))) (defun current-battery-charge () "Calculate remaining battery charge. Don't make calculation more than once in 15 seconds." (let ((now (/ (get-internal-real-time) internal-time-units-per-second))) (when (or (= 0 *bat-prev-time*) (>= (- now *bat-prev-time*) 15)) (setf *bat-prev-time* now) (let ((battery-state (read-battery-file *battery-name* "state")) (battery-info (read-battery-file *battery-name* "info"))) (if (string= "no" (gethash "present" battery-state)) (setf *bat-state* nil) (let ((charge-state (gethash "charging state" battery-state)) (remain (parse-integer (gethash "remaining capacity" battery-state) :junk-allowed t)) (rate (/ (or (parse-integer (gethash "present rate" battery-state) :junk-allowed t) 0) 60)) (full (parse-integer (gethash "last full capacity" battery-info) :junk-allowed t))) (setf *bat-remain* (round (/ (* 100 remain) full)) *bat-state* charge-state *bat-remain-time* nil) (when (> rate 0) (let* ((online (round (/ (if (string= "charging" *bat-state*) (- full remain) remain) rate)))) (setf *bat-remain-time* (multiple-value-bind (h m) (truncate online 60) (list h m))))))))))) (defun fmt-bat-charge (ml) "Returns a string representing the remaining battery charge (for laptop users.)" (declare (ignore ml)) (current-battery-charge) (if *bat-state* (format nil "BAT: ^[~A~D%^]~A" (bar-zone-color *bat-remain* 50 30 10 t) *bat-remain* (if *bat-remain-time* (format nil " (~2,'0d:~2,'0d) ~A" (car *bat-remain-time*) (cadr *bat-remain-time*) *bat-state*) "")) "no battery")) ;; Alternative display: ;; ;; TT: RRR% (HH:MM) [or "NO BAT" if present = no] ;; ;; TT = AC/DC (AC if charging state = charged/charging, ;; DC if charging state = discharging) ;; ;; RRR = remain/full ;; ;; HH:MM = time until charged/discharged (present when state is charging ;; or discharging) ;; ;; (defun fmt-bat-charge (ml) ;; "Returns a string representing the remaining battery charge (for laptop users.)" ;; (declare (ignore ml)) ;; (current-battery-charge) ;; (if (not *bat-state*) ;; "NO BAT" ;; (format nil "~A:~D%~A" ;; (if (or (string= *bat-state* "charging") ;; (string= *bat-state* "charged")) ;; "AC" "DC") ;; *bat-remain* ;; (if (and (string/= *bat-state* "charged") *bat-remain-time*) ;; (format nil (if (and (= (car *bat-remain-time*) 0) ;; (< (cadr *bat-remain-time*) 30)) ;; " (^[^B^1*~2,'0d:~2,'0d^])" " (~2,'0d:~2,'0d)") ;; (car *bat-remain-time*) ;; (cadr *bat-remain-time*)) ;; ""))))
5,239
Common Lisp
.lisp
120
36.725
134
0.542589
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
feb41ed80f51b0be92ea8a0943380dc3806f51d9e7c6348aba2ccdd095cca7f8
7,269
[ -1 ]
7,270
amixer.lisp
blitz_stumpwm/contrib/amixer.lisp
;;; Amixer module for StumpWM. ;;; ;;; Copyright 2007 Amy Templeton, Jonathan Moore Liles, Ivy Foster. ;;; ;;; Maintainer: Ivy Foster ;;; ;;; This module 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 module 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 software; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; ;;; USAGE: ;;; ;;; Make sure you have your media keys (or whatever) mapped to the appropriate ;;; keysyms (using xmodmap), then put: ;;; ;;; (load "/path/to/amixer.lisp") ;;; ;;; ...in your ~/.stumpwmrc, followed by some keybindings (according ;;; to your preference) ;;; TODO: ;;; ;;; Make the `defvolcontrol' macro create all the necessary commands at once. ;;; ;;; - Should it just create, say, amixer-pcm, which would be passed an ;;; argument? i.e., (define-key *this-map* (kbd "e") "amixer-pcm 1-") ;;; ;;; - Else, figure out how to make the macro not error when converting a ;;; string to a symbol for the name of the command ;;; Code: (in-package :stumpwm) (defun volcontrol (channel amount) (let ((percent (parse-integer (run-shell-command (concat "amixer sset " channel " " (or amount "toggle") "| tail -1" "| sed 's/^.*\\[\\([[:digit:]]\\+\\)%\\].*$/\\1/'") t)))) (message (concat "Mixer: " channel " " (or amount "toggled") (format nil "~C^B~A%" #\Newline percent) "^b [^[^7*" (bar percent 50 #\# #\:) "^]]")))) (defmacro defvolcontrol (name channel valence) `(defcommand ,name () () (volcontrol ,channel ,valence))) (defvolcontrol amixer-PCM-1- "PCM" "1-") (defvolcontrol amixer-PCM-1+ "PCM" "1+") (defvolcontrol amixer-PCM-toggle "PCM" "toggle") (defvolcontrol amixer-Front-1- "Front" "1-") (defvolcontrol amixer-Front-1+ "Front" "1+") (defvolcontrol amixer-Front-toggle "Front" "toggle") (defvolcontrol amixer-Master-1- "Master" "1-") (defvolcontrol amixer-Master-1+ "Master" "1+") (defvolcontrol amixer-Master-toggle "Master" "toggle") (defvolcontrol amixer-Headphone-1- "Headphone" "1-") (defvolcontrol amixer-Headphone-1+ "Headphone" "1+") (defvolcontrol amixer-Headphone-toggle "Headphone" "toggle") (defcommand amixer-sense-toggle () () (message (concat "Headphone Jack Sense toggled" (run-shell-command "amixer sset 'Headphone Jack Sense' toggle" t)))) ;;; End of file
2,874
Common Lisp
.lisp
72
37.652778
79
0.682437
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
64e35e1c2dcb7a155f241b9709945bae68e934248c32c8c37e082949f48cf1e3
7,270
[ -1 ]
7,271
wmii-like-stumpwmrc.lisp
blitz_stumpwm/contrib/wmii-like-stumpwmrc.lisp
;;; -*- Mode: Lisp -*- ;;; Written by Julian Stecklina, based on sample-stumpwmrc.lisp. ;;; This is a sample Wmii-like .stumpwmrc file using Super as modifier ;;; (which happens to be the Windows key on my keyboard). It doesn't ;;; cover the whole Wmii command set, but it will ease the transition ;;; to StumpWM for people coming from Wmii. ;;; ;;; The "normal" StumpWM commands are still available with their ;;; default keybindings (see the manual) and you will probably need ;;; them. So go read the manual. :) (in-package :stumpwm) ;;; A mode line showing all groups in its first and all windows in the ;;; current group in the second line. (setq *screen-mode-line-format* (format nil "%g~%%W")) ;;; Wmii-like keybindings (defvar *terminal* "xterm" "The command used to start a terminal. It should understand the -e parameter.") ;; Use focus-follows-mouse, like wmii does. (setq *mouse-focus-policy* :sloppy) ;; Change the prefix key to something else. The default is C-t. Use ;; this to access stumpwm's original keybindings. ;(set-prefix-key (kbd "Menu")) ;;; If you like Meta (most probably alt on your keyboard) more than ;;; Super (which is the Windows key on mine), change 's-' into 'M-'. (define-key *top-map* (kbd "s-RET") (format nil "exec ~A" *terminal*)) (define-key *top-map* (kbd "s-S-RET") "exec-in-terminal") (define-key *top-map* (kbd "s-C") "delete") (define-key *top-map* (kbd "s-p") "exec") (define-key *top-map* (kbd "s-d") "vsplit") (define-key *top-map* (kbd "s-D") "hsplit") (define-key *top-map* (kbd "s-R") "remove") (define-key *top-map* (kbd "s-SPC") "pull-hidden-next") ;;; s-DIGIT moves or creates to a numbered group. (dotimes (i 9) (define-key *top-map* (kbd (format nil "s-~A" (1+ i))) (format nil "gselect-or-create ~A" (1+ i)))) ;;; s-[hjkl] navigate through frames. If you press shift, it will move ;;; the current window in that direction. (loop for (vi-key name) in '(("k" "up") ("j" "down") ("h" "left") ("l" "right")) do (let ((key-combo (format nil "s-~A" vi-key)) (shifted-key-combo (format nil "s-~A" (string-upcase vi-key)))) (define-key *top-map* (kbd key-combo) (format nil "move-focus ~A" name)) (define-key *top-map* (kbd shifted-key-combo) (format nil "move-window ~A" name)))) (defcommand gselect-or-create (group-number) ((:number "Group number: ")) (gselect (or (select-group (current-screen) (format nil "~A" group-number) ) (let ((group (add-group (current-screen) (format nil "unnamed~A" group-number)))) ;; number should be free, since select-group failed. (setf (group-number group) group-number) group)))) (defcommand exec-in-terminal (cmd) ((:string "Command: ")) (run-shell-command (format nil "~A -e ~A" *terminal* cmd))) ;;; EOF
2,802
Common Lisp
.lisp
60
43.916667
73
0.668622
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
20e9006649b2dd00b92e69a6991abba358a4601e94da047998c471c625c6de86
7,271
[ 76605 ]
7,272
aumix.lisp
blitz_stumpwm/contrib/aumix.lisp
;;; Aumix front end module for stumpwm ;;; ;;; Copyright (C) 2008 Fredrik Tolf ;;; ;;; Maintainer: Fredrik Tolf ;;; ;;; This module 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 module 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 software; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; ;;; USAGE: ;;; ;;; Put: ;;; ;;; (load-module "aumix") ;;; ;;; In your ~/.stumpwmrc (in-package :stumpwm-user) (defvar *aumix-program* "/usr/bin/aumix") (defvar *aumix-channels* '((:pcm . "w") (:master . "v") (:alt-pcm . "W") (:line . "l"))) (defun assert-ret (val) (assert val) val) (defun process-aumix-volstring (output) (do* ((i 0 (+ i 1)) (ch (aref output i) (aref output i)) (st 'ch) (buf "") left right) (nil) (setq st (case st ((ch) (if (eql ch #\space) 'left 'ch)) ((left) (if (digit-char-p ch) (progn (setq buf (concatenate 'string buf (string ch))) 'left) (progn (setq left (/ (parse-integer buf) 100)) 'space))) ((space) (if (eql ch #\space) (progn (setq buf "") 'right) (error "Invalid output from aumix"))) ((right) (if (digit-char-p ch) (progn (setq buf (concatenate 'string buf (string ch))) 'right) (progn (setq right (/ (parse-integer buf) 100)) (return (values (/ (+ left right) 2) left right))))) (t (error "Invalid output from aumix")))))) (defun aumix-call (channel op amount) (let* ((ch (assert-ret (cdr (assoc channel *aumix-channels*)))) (opstr (concat (case op ((:up) "+") ((:down) "-") ((:set) "") (t (error "Unknown volume operation"))) (format nil "~D" (round (* 100 amount))))) (output (stumpwm::run-prog-collect-output *aumix-program* (concat "-" ch opstr) (concat "-" ch "q")))) (process-aumix-volstring output))) (defun aumix-get (channel) (process-aumix-volstring (stumpwm::run-prog-collect-output *aumix-program* (concat "-" (assert-ret (cdr (assoc channel *aumix-channels*))) "q")))) (define-stumpwm-type :mixer-channel (input prompt) (let ((n (or (argument-pop input) (completing-read (current-screen) prompt (mapcar (lambda (sym) (string-downcase (symbol-name (car sym)))) *aumix-channels*))))) (intern (string-upcase n) 'keyword))) (defcommand mixer (channel opstr) ((:mixer-channel "Channel: ") (:rest "Op: ")) "Change mixer channel." (let* ((fc (aref opstr 0)) (op (cond ((eql fc #\+) (setq opstr (subseq opstr 1)) :up) ((eql fc #\-) (setq opstr (subseq opstr 1)) :down) ((eql fc #\=) (setq opstr (subseq opstr 1)) :set) ((digit-char-p fc) :set) (t (error "Illegal mixer operation")))) (amount (parse-integer opstr))) (message "~A: ~D%" (symbol-name channel) (round (* (aumix-call channel op (/ amount 100)) 100)))))
3,863
Common Lisp
.lisp
91
33.241758
111
0.545455
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
802eccfd89bc61aff38cdb209898e45ef2f0d6291e76497f43978592ebb2434e
7,272
[ -1 ]
7,273
sbclfix.lisp
blitz_stumpwm/contrib/sbclfix.lisp
;;; Amixer module for StumpWM. ;;; ;;; Copyright 2008 Julian Stecklina ;;; ;;; Maintainer: Julian Stecklina ;;; ;;; This module 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 module 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 software; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; ;;; Thanks to Fredrik Tolf for formatting it as a stumpwm module. (in-package :stumpwm-user) ;;; Overview of the Problem ;;; ;;; Stumpwm's EXEC-AND-COLLECT-OUTPUT tends to hang in all recent SBCL ;;; versions (at least until 1.0.22) in rare cases which in turn ;;; causes stumpwm to stop servicing requests and generally freezes ;;; your desktop. The problem is a unsafe signal handler in SBCL's ;;; RUN-PROGRAM. To quote François-René Rideau from the SBCL-DEVEL ;;; mailing list: ;;; ;;; [...] Long story short: SBCL tries to do excessively clever ;;; things inside signal handlers to track the status of children ;;; processes. This is a bad idea, because a signal handler can ;;; catch the Lisp with its pants down [...] ;;; ;;; The whole thread can be found at: ;;; http://sourceforge.net/mailarchive/message.php?msg_id=87wsgazm20.fsf%40tabernacle.localnet ;;; ;;; Based on explanations in the above mentioned thread, I implemented ;;; a workaround without using signals for ;;; EXEC-AND-COLLECT-OUTPUT. Stumpwm's RUN-PROG should not be affected ;;; by this bug. #+sbcl (progn (defun exec-and-collect-output (name args env) "Runs the command NAME with ARGS as parameters and return everything the command has printed on stdout as string." (flet ((to-simple-strings (string-list) (mapcar (lambda (x) (coerce x 'simple-string)) string-list))) (let ((simplified-args (to-simple-strings (cons name args))) (simplified-env (to-simple-strings env)) (progname (sb-impl::native-namestring name)) (devnull (sb-posix:open "/dev/null" sb-posix:o-rdwr))) (multiple-value-bind (pipe-read pipe-write) (sb-posix:pipe) (unwind-protect (let ((child ;; Any nicer way to do this? (sb-sys:without-gcing (sb-impl::with-c-strvec (c-argv simplified-args) (sb-impl::with-c-strvec (c-env simplified-env) (sb-impl::spawn progname c-argv devnull pipe-write ; stdout devnull 1 c-env nil ; PTY 1 ; wait? (seems to do nothing) )))))) (when (= child -1) (error "Starting ~A failed." name)) ;; We need to close this end of the pipe to get EOF when the child is done. (sb-posix:close pipe-write) (setq pipe-write nil) (with-output-to-string (out) ;; XXX Could probably be optimized. But shouldn't ;; make a difference for our use case. (loop with in-stream = (sb-sys:make-fd-stream pipe-read :buffering :none) for char = (read-char in-stream nil nil) while char do (write-char char out)) ;; The child is now finished. Call waitpid to avoid ;; creating zombies. (handler-case (sb-posix:waitpid child 0) (sb-posix:syscall-error () ;; If we get a syscall-error, RUN-PROGRAM's ;; SIGCHLD handler probably retired our child ;; already. So we are fine here to ignore this. nil)))) ;; Cleanup (sb-posix:close pipe-read) (when pipe-write (sb-posix:close pipe-write)) (sb-posix:close devnull)))))) (defun stumpwm::run-prog-collect-output (prog &rest args) "run a command and read its output." (exec-and-collect-output prog args (cons (stumpwm::screen-display-string (current-screen)) (remove-if (lambda (str) (string= "DISPLAY=" str :end2 (min 8 (length str)))) (sb-ext:posix-environ)))))) ;;; EOF
4,317
Common Lisp
.lisp
107
35.635514
94
0.674917
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
6302c6de710422930ace663dfd6a3d64d118842ba71260f7e984b3d95c354678
7,273
[ -1 ]
7,274
surfraw.lisp
blitz_stumpwm/contrib/surfraw.lisp
;; SURFRAW module for StumpWM. ;; ;; Copyright (C) 2008 Ivy Foster ;; ;; Maintainer: Ivy Foster ;; ;; This module 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 module 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;;; Commentary: ;; ;; I like surfraw (http://surfraw.alioth.debian.org). If you're ;; reading this, you probably like surfraw. I've got surfraw-related ;; code in my .stumpwmrc, and (judging from some judicious googling ;; for RC files early on in my use of stumpwm) I know that I'm not the ;; only one. So it seemed like a good idea to just put that code in ;; a library. ;;; Usage: ;; ;; Just add the following line to your .stumpwmrc file: ;; ;; (load "/path/to/stumpwm/contrib/surfraw.lisp") ;; ;; ...and then either call the functions here with "colon" (C-t ;) or ;; bind them to a key. I figure other people will probably have ;; different key preferences than I have, so I leave them entirely up ;; to you. ;; ;; If you want to use the bookmark functions, don't forget to tell ;; stumpwm where your *surfraw-bookmark-file* is. ;; ;; Note that there are also "surfraw-selection" variants on each ;; command that work on the X selection. ;;; FIXME: ;; ;; - Not all elvi are supported yet. Do they need to be? ;; - It would be pretty cool to have a macro like the ;; surfraw-selection one but for regular surfraw commands. ;; Supported elvi (feel free to add more): ;; ;; - Alioth ;; - Amazon ;; - Archpkg ;; - BBCNews ;; - CDDB ;; - CNN ;; - DebBugs ;; - Deja ;; - Ebay ;; - Etym ;; - FreeBSD ;; - Freshmeat ;; - GenPkg ;; - Google ;; - Thesaurus ;; - Wayback ;; - Webster ;; - Wikipedia ;;; Code: ;;; Regular surfraw commands (defcommand surfraw (engine search) ((:string "What engine? ") (:string "Search for what? ")) "Use SURFRAW to surf the net; reclaim heathen lands." (check-type engine string) (check-type search string) (run-shell-command (concat "exec surfraw -g " engine " " search))) (defcommand alioth (search) ((:string "Search Alioth: ")) (surfraw "alioth" search)) (defcommand amazon (search) ((:string "Search Amazon: ")) (surfraw "amazon" search)) (defcommand archpkg (search) ((:string "Search Arch Linux packages: ")) (surfraw "archpkg" search)) (defcommand bbcnews (search) ((:string "Search BBC News: ")) (surfraw "bbcnews" search)) (defcommand cddb (search) ((:string "Search the CDDB: ")) (surfraw "cddb" search)) (defcommand cnn (search) ((:string "Search CNN: ")) (surfraw "cnn" search)) (defcommand debbugs (search) ((:string "Search the Debian BTS: ")) (surfraw "debbugs" search)) (defcommand deja (search) ((:string "Search Google Groups: ")) (surfraw "deja" search)) (defcommand ebay (search) ((:string "Search Ebay: ")) (surfraw "ebay" search)) (defcommand etym (search) ((:string "Search Etymology Online: ")) (surfraw "etym" search)) (defcommand freebsd (search) ((:string "Search FreeBSD info: ")) (surfraw "freebsd" search)) (defcommand freshmeat (search) ((:string "Search Freshmeat: ")) (surfraw "freshmeat" search)) (defcommand genpkg (search) ((:string "Search Gentoo packages: ")) (surfraw "genpkg" search)) (defcommand google (search) ((:string "Search google: ")) (surfraw "google" search)) (defcommand thesaurus (search) ((:string "Search a thesaurus: ")) (surfraw "thesaurus" search)) (defcommand wayback (search) ((:string "Search wayback: ")) (surfraw "wayback" search)) (defcommand webster (search) ((:string "Search the Merriam-Webster Dictionary: ")) (surfraw "webster" search)) (defcommand wikipedia (search) ((:string "Search wikipedia: ")) (surfraw "wikipedia" search)) ;;; X selection (defmacro surfraw-selection (name engine) `(defcommand ,name () () (surfraw ,engine (get-x-selection)))) (surfraw-selection alioth-selection "alioth") (surfraw-selection amazon-selection "amazon") (surfraw-selection archpkg-selection "archpkg") (surfraw-selection bbcnews-selection "bbcnews") (surfraw-selection cddb-selection "cddb") (surfraw-selection cnn-selection "cnn") (surfraw-selection debbugs-selection "debbugs") (surfraw-selection deja-selection "deja") (surfraw-selection ebay-selection "ebay") (surfraw-selection etym-selection "etym") (surfraw-selection freebsd-selection "freebsd") (surfraw-selection freshmeat-selection "freshmeat") (surfraw-selection genpkg-selection "genpkg") (surfraw-selection google-selection "google") (surfraw-selection thesaurus-selection "thesaurus") (surfraw-selection wayback-selection "wayback") (surfraw-selection webster-selection "webster") (surfraw-selection wikipedia-selection "wikipedia") ;;; Bookmarks (defun display-file (file) "Display a file in the message area." (if (probe-file file) (run-shell-command (concat "cat " file) t) (message "The file ~a does not exist." file))) (defvar *surfraw-bookmark-file* nil "The surfraw bookmark file") (defcommand sr-bookmark (bmk) ((:string "Bookmark: ")) (surfraw "" bmk)) (defcommand sr-bookmark-file-display () () (display-file *surfraw-bookmark-file*)) ;;; surfraw.lisp ends here
5,784
Common Lisp
.lisp
166
32.921687
71
0.712034
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
7b9adcb4c09f1a7108393768c8f885764e28f57a8bc2d5ba75d42bb57d96e487
7,274
[ -1 ]
7,275
cpu.lisp
blitz_stumpwm/contrib/cpu.lisp
;;; CPU formatters for the mode-line ;;; ;;; Copyright 2007 Anonymous Coward, Jonathan Moore Liles. ;;; ;;; Maintainer: Julian Stecklina ;;; ;;; This module 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 module 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 software; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; ;;; USAGE: ;;; ;;; Put: ;;; ;;; (load "/path/to/cpu.lisp") ;;; ;;; In your ~/.stumpwmrc ;;; ;;; Then you can use "%c %t" in your mode line format. ;;; ;;; NOTES: ;;; ;;; This is specific to Linux. (in-package :stumpwm) (export '(*acpi-thermal-zone*)) ;; Install formatters. (dolist (a '((#\c fmt-cpu-usage) (#\C fmt-cpu-usage-bar) (#\f fmt-cpu-freq) (#\t fmt-cpu-temp))) (pushnew a *screen-mode-line-formatters* :test 'equal)) ;; Defaults arguments for fmt-cpu-usage-bar (defvar *cpu-usage-bar-width* 10) (defvar *cpu-usage-bar-full* #\#) (defvar *cpu-usage-bar-empty* #\:) (defvar *prev-user-cpu* 0) (defvar *prev-sys-cpu* 0) (defvar *prev-idle-cpu* 0) (defvar *prev-iowait* 0) (defvar *prev-result* '(0 0 0)) (defvar *prev-time* 0) ;; More or less yanked from the wiki. (defun current-cpu-usage () "Return the average CPU usage since the last call. First value is percent of CPU in use. Second value is percent of CPU in use by system processes. Third value is percent of time since last call spent waiting for IO (or 0 if not available). Don't make calculation more than once a second." (let ((cpu-result 0) (sys-result 0) (io-result nil) (now (/ (get-internal-real-time) internal-time-units-per-second))) (when (>= (- now *prev-time*) 1) (setf *prev-time* now) (with-open-file (in #P"/proc/stat" :direction :input) (read in) (let* ((norm-user (read in)) (nice-user (read in)) (user (+ norm-user nice-user)) (sys (read in)) (idle (read in)) (iowait (or (ignore-errors (read in)) 0)) (step-denom (- (+ user sys idle iowait) (+ *prev-user-cpu* *prev-sys-cpu* *prev-idle-cpu* *prev-iowait*)))) (setf cpu-result (/ (- (+ user sys) (+ *prev-user-cpu* *prev-sys-cpu*)) step-denom) sys-result (/ (- sys *prev-sys-cpu*) step-denom) io-result (/ (- iowait *prev-iowait*) step-denom) *prev-user-cpu* user *prev-sys-cpu* sys *prev-idle-cpu* idle *prev-iowait* iowait *prev-result* (list cpu-result sys-result io-result)))))) (apply 'values *prev-result*)) (defun fmt-cpu-usage (ml) "Returns a string representing current the percent of average CPU utilization." (declare (ignore ml)) (let ((cpu (truncate (* 100 (current-cpu-usage))))) (format nil "CPU: ^[~A~3D%^] " (bar-zone-color cpu) cpu))) (defun fmt-cpu-usage-bar (ml &optional (width *cpu-usage-bar-width*) (full *cpu-usage-bar-full*) (empty *cpu-usage-bar-empty*)) "Returns a coloured bar-graph representing the current percent of average CPU utilization." (declare (ignore ml)) (let ((cpu (truncate (* 100 (current-cpu-usage))))) (bar cpu width full empty))) (defun get-proc-file-field (fname field) (with-open-file (s fname :if-does-not-exist nil) ; (if s (do ((line (read-line s nil nil) (read-line s nil nil))) ((null line) nil) (let ((split (cl-ppcre:split "\\s*:\\s*" line))) (when (string= (car split) field) (return (cadr split))))) ""))) (defun fmt-cpu-freq (ml) "Returns a string representing the current CPU frequency (especially useful for laptop users.)" (declare (ignore ml)) (let ((mhz (parse-integer (get-proc-file-field "/proc/cpuinfo" "cpu MHz") :junk-allowed t))) (if (>= mhz 1000) (format nil "~,2FGHz" (/ mhz 1000)) (format nil "~DMHz" mhz)))) (defvar *acpi-thermal-zone* (first (last (pathname-directory (first (list-directory "/proc/acpi/thermal_zone/")))))) (defun fmt-cpu-temp (ml) "Returns a string representing the current CPU temperature." (declare (ignore ml)) (get-proc-file-field (concatenate 'string "/proc/acpi/thermal_zone/" *acpi-thermal-zone* "/temperature") "temperature"))
5,028
Common Lisp
.lisp
124
34.056452
127
0.608589
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
71e9d8ca0ad94f27979bf1745a1a7c2d94dff049bf5a2741abea098d25d907cf
7,275
[ -1 ]
7,276
maildir.lisp
blitz_stumpwm/contrib/maildir.lisp
;;; Maildir monitoring for stumpwm's modeline ;;; ;;; Copyright 2007 Morgan Veyret. ;;; ;;; Maintainer: Morgan Veyret ;;; ;;; This module 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 module 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 software; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; ;;; USAGE: ;;; ;;; Put: ;;; ;;; (load-module "maildir") ;;; ;;; ...into your ~/.stumpwmrc ;;; ;;; Then you can use "%M" in your mode line format. ;;; You can customize the modeline format (*maildir-modeline-fmt*). See the ;;; documentation for *maildir-modeline-fmt* for more information. ;;; TODO: ;;; ;;; - Add per mailbox formatter ;;; CODE: (in-package :stumpwm) (dolist (a '((#\M maildir-modeline))) (pushnew a *screen-mode-line-formatters* :test 'equal)) (defvar *maildir-timer* nil) (defvar *maildir-update-time* 900 "Time between two updates of the maildir informations (in seconds).") (defun maildir-set-update-time (time-in-seconds) "Set the maildir informations update interval." (when *maildir-timer* (cancel-timer *maildir-timer*)) (setf *maildir-update-time* time-in-seconds) (setf *maildir-timer* (run-with-timer *maildir-update-time* *maildir-update-time* 'update-maildir-infos))) (defvar *maildir-path* (merge-pathnames (make-pathname :directory '(:relative "Mail")) (user-homedir-pathname)) "Pathname to the mail directory. Defaults to ~/Mail.") (defun maildir-mailboxes (maildir) "Returns a list of all mailboxes in *maildir-path*." (directory (merge-pathnames (make-pathname :directory '(:relative :wild)) maildir))) (defun maildir-mailbox-dir (mailbox dir-name) "Returns the specified sub-directory pathname for the provided mailbox." (merge-pathnames (make-pathname :directory (list :relative dir-name) :name :wild) mailbox)) (defvar *maildir-new* '() "Number of new mails for each mailbox.") (defvar *maildir-cur* '() "Number of mails for each mailbox.") (defvar *maildir-tmp* '() "Number of tmp mails for each mailbox.") (defun update-maildir-infos () "Update mail counts for *maildir-path*." (loop for m in (maildir-mailboxes *maildir-path*) collect (length (directory (maildir-mailbox-dir m "new"))) into nb-new collect (length (directory (maildir-mailbox-dir m "cur"))) into nb-cur collect (length (directory (maildir-mailbox-dir m "tmp"))) into nb-tmp finally (progn (setf *maildir-new* nb-new) (setf *maildir-cur* nb-cur) (setf *maildir-tmp* nb-tmp)))) ;; modeline formatter (defun maildir-modeline (ml) (declare (ignore ml)) ;; setup a timer to check every *maildir-update-time* seconds ;; disk access are slow and you obviously don't need to check ;; emails every time the modeline gets updated (unless *maildir-timer* (update-maildir-infos) (setf *maildir-timer* (run-with-timer *maildir-update-time* *maildir-update-time* 'update-maildir-infos))) (format-expand *maildir-formatters-alist* *maildir-modeline-fmt*)) (defun maildir-get-new () (let ((total-new (reduce #'+ *maildir-new*))) (format nil "~D" total-new))) (defun maildir-get-cur () (let ((total-cur (reduce #'+ *maildir-cur*))) (format nil "~D" total-cur))) (defun maildir-get-tmp () (let ((total-tmp (reduce #'+ *maildir-tmp*))) (format nil "~D" total-tmp))) (defvar *maildir-formatters-alist* '((#\n maildir-get-new) (#\c maildir-get-cur) (#\t maildir-get-tmp))) (defvar *maildir-modeline-fmt* "%n %c" "The default value for displaying maildir information on the modeline. @table @asis @item %% A literal '%' @item %n New mails number @item %c Current mails number @item %t Temporary mails number @end table ")
4,444
Common Lisp
.lisp
120
32.925
76
0.676505
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
55bf8d589a82e6382c414eb5e23e169ace4b616f53a56e6828dd68dac0ff6d94
7,276
[ -1 ]
7,277
g15-keysyms.lisp
blitz_stumpwm/contrib/g15-keysyms.lisp
;;; keysyms for the Logitech G15 keyboard ;;; ;;; Copyright 2008 Ted Zlatanov ;;; ;;; Maintainer: ;;; ;;; This module 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 module 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 software; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; ;;; USAGE: ;;; ;;; Put: ;;; ;;; (load "/path/to/g15-keysyms.lisp") ;;; (g15-original) or (g15-revised) deppending of the model you have. ;;; In your ~/.stumpwmrc ;;; (in-package #:stumpwm) (defun g15-original () (define-keysym #x15000001 "G1") (define-keysym #x15000002 "G2") (define-keysym #x15000003 "G3") (define-keysym #x15000004 "G4") (define-keysym #x15000005 "G5") (define-keysym #x15000006 "G6") (define-keysym #x15000007 "G7") (define-keysym #x15000008 "G8") (define-keysym #x15000009 "G9") (define-keysym #x15000010 "G10") (define-keysym #x15000011 "G11") (define-keysym #x15000012 "G12") (define-keysym #x15000013 "G13") (define-keysym #x15000014 "G14") (define-keysym #x15000015 "G15") (define-keysym #x15000016 "G16") (define-keysym #x15000017 "G17") (define-keysym #x15000018 "G18") (define-keysym #x15000019 "M1") (define-keysym #x1500001a "M2") (define-keysym #x1500001b "M3") (define-keysym #x1500001d "LCD0") (define-keysym #x1500001e "LCD1") (define-keysym #x1500001f "LCD2") (define-keysym #x15000020 "LCD3") (define-keysym #x15000021 "LCD4")) (defun g15-revised () ;; the orange version (let ((gkeycodes '(177 152 190 208 129 178)) ;; These are the keycodes G keys in order (mediakeycodes '((144 "Prev") (153 "Next") (160 "Mute") (162 "Play") (164 "Stop") (174 "LowerVolume") (176 "RaiseVolume")))) (dotimes (i (length gkeycodes)) (run-shell-command (concatenate 'string "xmodmap -e 'keycode " (write-to-string (nth i gkeycodes)) " = XF86Launch" (write-to-string (1+ i)) "'")) (define-keysym (+ (keysym-name->keysym "XF86Launch1") i) (concatenate 'string "G" (write-to-string (1+ i))))) (dotimes (i (length mediakeycodes)) (run-shell-command (concatenate 'string "xmodmap -e 'keycode " (write-to-string (first (nth i mediakeycodes))) " = XF86Audio" (second (nth i mediakeycodes)) "'")))))
2,844
Common Lisp
.lisp
81
31.82716
88
0.67307
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
7bf9e1be17ea63556629be4828a319160cc26a556135ef230d4599fc99791e80
7,277
[ -1 ]
7,278
net.lisp
blitz_stumpwm/contrib/net.lisp
;;; Network activity formatter for the mode-line ;;; ;;; Copyright 2009 Vitaly Mayatskikh ;;; ;;; Maintainer: ;;; ;;; This module 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 module 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 software; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; ;;; USAGE: ;;; ;;; Put: ;;; ;;; (load "/path/to/net.lisp") ;;; ;;; In your ~/.stumpwmrc ;;; ;;; Then you can use "%l" in your mode line format. ;;; ;;; NOTES: ;;; ;;; This is specific to Linux. (defpackage :stumpwm.contrib.net (:use :common-lisp :stumpwm :cl-ppcre) (:export #:*net-device*)) (in-package :stumpwm.contrib.net) ;; Install formatters. (dolist (a '((#\l fmt-net-usage))) (pushnew a *screen-mode-line-formatters* :test 'equal)) (defvar *net-device* nil) ; nil means auto. or specify explicitly, i.e. "wlan0" (defvar *net-last-rx* 0) (defvar *net-last-tx* 0) (defvar *net-last-time* nil) (defvar *net-rx* nil) (defvar *net-tx* nil) (defvar *net-time* nil) ;; stuff for parsing /proc/net/route (defconstant +iface+ 0) (defconstant +destination+ 1) (defconstant +gateway+ 2) (defconstant +flags+ 3) (defconstant +mask+ 7) (defconstant +ipv4-zero+ "00000000") (defun now () (/ (get-internal-real-time) internal-time-units-per-second)) (defvar *last-route-rescan-time* (now)) (defvar *last-route-device* nil) (defun find-default () "Tries to found device with default route. NIL if none." (with-open-file (file #P"/proc/net/route" :if-does-not-exist nil) (when file (read-line file nil) ; skip desc (loop :as line = (read-line file nil) :when (null line) :return nil :do (let ((split (cl-ppcre:split "\\s+" line))) (when (and (string= (nth +destination+ split) +ipv4-zero+) (string= (nth +mask+ split) +ipv4-zero+) (logand (parse-integer (nth +flags+ split) :junk-allowed t) 2)) (return (nth +iface+ split)))))))) (defun net-device () "Returns statically assigned device name or tries to find it be default gw. For the second case rescans route table every minute." (if *net-device* *net-device* (if (and *last-route-device* (< (- (now) *last-route-rescan-time*) 60)) *last-route-device* (let ((new-device (or (find-default) "lo"))) (when (string/= new-device *last-route-device*) (setq *net-last-tx* 0 *net-last-rx* 0 *net-last-time* nil *net-rx* nil *net-tx* nil *net-time* nil)) (setq *last-route-rescan-time* (now) *last-route-device* new-device))))) (defun net-sys-stat-read (device stat-file) (with-open-file (file (concatenate 'string "/sys/class/net/" device "/statistics/" stat-file) :if-does-not-exist nil) (if file (parse-integer (read-line-from-sysfs file) :junk-allowed t) (progn (setq *net-device* nil *last-route-device* nil) 0)))) (defun net-usage () "Returns a list of 2 values: rx and tx bytes/second." (let ((now (now)) (rx-s 0.0) (tx-s 0.0) (t-s 0.1) ; don't want division by zero (rx (net-sys-stat-read (net-device) "rx_bytes")) (tx (net-sys-stat-read (net-device) "tx_bytes"))) (when (and *net-last-time* (> (- now *net-last-time*) 0.0)) (let ((drx (/ (- rx *net-last-rx*) (- now *net-last-time*))) (dtx (/ (- tx *net-last-tx*) (- now *net-last-time*)))) (push drx *net-rx*) (push dtx *net-tx*) (push now *net-time*) (when (> (length *net-time*) 1) (dotimes (i (1- (length *net-time*))) (let ((dt (- (nth (1+ i) *net-time*) (nth i *net-time*))) (rx (nth i *net-rx*)) (tx (nth i *net-tx*))) (incf rx-s (* rx dt)) (incf tx-s (* tx dt)) (incf t-s dt))) ;; cut off old values (when (> (length *net-time*) 5) (pop *net-rx*) (pop *net-tx*) (pop *net-time*))))) (setq *net-last-rx* rx *net-last-tx* tx *net-last-time* now) (list (round (/ rx-s t-s)) (round (/ tx-s t-s))))) (defun fmt-net-usage (ml) "Returns a string representing the current network activity." (declare (ignore ml)) (let ((net (net-usage)) dn up) (defun kbmb (x y) (if (>= (/ x 1e6) y) (list (/ x 1e6) "m") (list (/ x 1e3) "k"))) (setq dn (kbmb (car net) 0.1) up (kbmb (cadr net) 0.1)) (format nil "~A: ~5,2F~A/~5,2F~A " (net-device) (car dn) (cadr dn) (car up) (cadr up))))
4,904
Common Lisp
.lisp
148
29.554054
79
0.626636
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
57cfbb87ab47c3516a0dacc6dff4b57b9813c72615bd7c29892daf79db915ed9
7,278
[ -1 ]
7,279
productivity.lisp
blitz_stumpwm/contrib/productivity.lisp
;; Productivity module for StumpWM. ;; ;; Copyright (C) 2008 Ivy Foster ;; ;; Maintainer: Ivy Foster ;; ;; This module 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 module 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 software; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;; Boston, MA 02111-1307 USA ;;; Commentary: ;; ;; There are those for whom simply using a window manager like StumpWM ;; is enough to force them to buckle down and work, mostly because ;; they don't know how to play around with it (due to a lack of ;; frills). However, there are also those who know how to move around ;; in StumpWM and who may find themselves falling into the same bad ;; habits as those who use "normal" WMs; that is, switching between ;; windows a lot and fiddling with random functions the WM has ;; available. This fixes that by temporarily disabling StumpWM. ;; ;; Incidentally, I'm not positive, but I believe that this may be ;; StumpWM's first Minor Mode. ;;; Usage: ;; ;; Just add the following line to your .stumpwmrc file: ;; ;; (load-module "productivity") ;; ;; ...and then bind `productivity-mode-toggle' to a key in your ;; *top-map*. I recommend H-# (Hyper-shift-3). ;; ;; When you activate productivity-mode, you won't be able to access ;; any of your StumpWM keymaps. That's right--the window manager is ;; effectively disabled! If you try to leave the window, or display ;; the time, or go to another group, or control MPD, or switch frames, ;; or whatever, you will instead be presented with a curt reminder of ;; what you're supposed to be doing. To escape from this mode, just ;; hit the key you have `productivity-mode-toggle' bound to again. ;; ;; Absolutely DO NOT start productivity-mode from your .stumpwmrc file ;; unless you (a) are absolutely *sure* you have ;; productivity-mode-toggle bound to a key already, (b) automatically ;; switch to a window capable of controlling StumpWM (i.e., Emacs or a ;; terminal) in your .stumpwmrc, (c) want to convince your friends ;; your computer is broken, or (d) are crazy. ;;; Configuration: ;; ;; The following can be customized. If no example is given, please see ;; the code. ;; ;; `*productivity-keys*': Any and all keys you have bound to the ;; *top-map* and their associated commands. ;; ex: ;; (setf *productivity-keys* ;; '(("H-t" *root-map*) ;; ("C-;" *rat-map*) ;; ("Print" "screenshot"))) ;; ;; `*productivity-start-message*': What StumpWM should print when you ;; start productivity-mode. ;; ;; `*productivity-stop-message*': What StumpWM should print when you ;; stop productivity-mode ;; ;; `*productivity-back-to-work-message*': What StumpWM should print ;; when you attempt to waste time (you lazy, lazy, um...lazy ;; person). ;;; TODO: ;; ;; - [ ] Add an option to toggle the mode-line on and off. ;; ;; - [ ] Add an option to display a notifier for this mode, when on, ;; in the mode-line (a la Emacs' minor modes). ;; ;; - Perhaps this could be integrated into a "minor modes" ;; package? (Just in case somebody insinuates that StumpWM ;; doesn't have *everything*.) ;; ;; - [ ] Add a timer feature (i.e., have it toggle itself at a given ;; interval or hour, so you can have your work time and ;; messing-around-on-the-computer time predetermined). ;; ;; - [ ] Add an option to disable stumpish, slime and/or ;; stumpwm-mode.el (choose your poison/s). ;; ;; - [ ] Make it do your work for you. ;; ;; - Note to self: Finish this one first, then have it write the ;; rest for you. ;;; Code: (defvar *productivity-mode-is-on* nil "Is productivity-mode on? Do not customize by hand unless you're crazy.") (defvar *productivity-keys* '(("C-t" *root-map*)) "List of all the keys you have bound to your `*top-map*' and their associated commands.") (defvar *productivity-stop-message* "Break time!" "What should StumpWM print when you stop productivity-mode?") (defvar *productivity-start-message* "Get to work!" "What should StumpWM print when you start productivity-mode?") (defvar *productivity-back-to-work-message* "Get back to work!" "What should StumpWM print when you attempt to waste time?") (defcommand productivity-back-to-work () () (message *productivity-back-to-work-message*)) (defun productivity-mode-on () "Turns on productivity mode. Do not call interactively." (setf *productivity-mode-is-on* t) (dolist (key *productivity-keys*) (define-key *top-map* (kbd (car key)) "productivity-back-to-work")) (message *productivity-start-message*)) (defun productivity-mode-off () "Turns off productivity mode. Do not call interactively." (setf *productivity-mode-is-on* nil) (dolist (key *productivity-keys*) (define-key *top-map* (kbd (car key)) (cadr key))) (message *productivity-stop-message*)) (defcommand productivity-mode-toggle () () "Toggles productivity mode." (if *productivity-mode-is-on* (productivity-mode-off) (productivity-mode-on))) ;;; End of file
5,560
Common Lisp
.lisp
133
40.308271
71
0.712676
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
f28abccc927af18fd606aef149d311e8e18924b8e4b3e3188a6084f025a1142e
7,279
[ -1 ]
7,280
battery-portable.lisp
blitz_stumpwm/contrib/battery-portable.lisp
;;; Portable battery information for StumpWM's mode-line. ;;; ;;; Written by Julian Stecklina with inspiration from John Li and ;;; Rupert Swarbrick. ;;; ;;; Copyright (c) 2008 Julian Stecklina ;;; ;;; Permission is hereby granted, free of charge, to any person ;;; obtaining a copy of this software and associated documentation ;;; files (the "Software"), to deal in the Software without ;;; restriction, including without limitation the rights to use, copy, ;;; modify, merge, publish, distribute, sublicense, and/or sell copies ;;; of the Software, and to permit persons to whom the Software is ;;; furnished to do so, subject to the following conditions: ;;; ;;; The above copyright notice and this permission notice shall be ;;; included in all copies or substantial portions of the Software. ;;; ;;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ;;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ;;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND ;;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT ;;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, ;;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ;;; DEALINGS IN THE SOFTWARE. ;;; ;;; ;;; To load this module, place ;;; ;;; (load-module "battery-portable") ;;; ;;; in your .stumpwmrc. Battery information is then available via %B ;;; in your mode-line config. ;;; ;;; If you have an older kernel and the above doesn't work, add ;;; ;;; (setf stumpwm.contrib.battery-portable:*prefer-sysfs* nil) ;;; ;;; below the above line. (defpackage :stumpwm.contrib.battery-portable (:use :common-lisp :stumpwm :cl-ppcre) (:export #:*refresh-time* #:*prefer-sysfs* )) (in-package :stumpwm.contrib.battery-portable) ;;; CLISP doesn't include :linux in *features* even if it runs on ;;; Linux. :-/ ;;; Configuration (defvar *refresh-time* 5 "Time in seconds between updates of battery information.") (defvar *prefer-sysfs* t "Prefer sysfs over procfs for information gathering. This has effect only on Linux.") ;;; Method base class (defclass battery-method () () (:documentation "Base class for battery information retrieval")) (defgeneric all-batteries (method) (:documentation "Returns all recognized batteries.")) (defun preferred-battery-method () #- linux nil #+ linux (if *prefer-sysfs* (make-instance 'sysfs-method) (make-instance 'procfs-method))) ;;; Battery class (defclass battery () () (:documentation "Base class for battery information.")) (defgeneric state-of (battery) (:documentation "Returns either :UNKNOWN, :CHARGED, :CHARGING, or :DISCHARGING with the obvious meanings. If the state is not :UNKNOWN, returns the battery fill percentage. If the state is :CHARGING or :DISCHARGING, this function returns a third value indicating the corresponding time in seconds.")) ;;; Linux procfs implementation #+ linux (progn (defclass procfs-method (battery-method) () (:documentation "Collect battery information through Linux' procfs interface.")) (defclass procfs-battery (battery) ((path :initarg :path :initform (error ":path missing") :reader path-of) (info-hash :initform (make-hash-table :test 'equal) :reader info-hash-of))) (defmethod update-info ((battery procfs-battery)) (clrhash (info-hash-of battery)) (loop for filename in '("state" "info") do (with-open-file (file (merge-pathnames (make-pathname :name filename) (path-of battery))) (loop for line = (read-line file nil nil) while line do (multiple-value-bind (match? matches) (scan-to-strings "^([^:]+):\\s*([^\\s]+)(\\s.*)?$" line) (if (not match?) (format t "Unrecognized line: ~S~%" line) (setf (gethash (aref matches 0) (info-hash-of battery)) (aref matches 1)))))))) (define-condition info-value-not-present (error) ()) (defmethod info-value ((battery procfs-battery) key) (multiple-value-bind (val found?) (gethash key (info-hash-of battery)) (if found? val (error 'info-value-not-present)))) (defmethod info-value-int ((battery procfs-battery) key) (values (parse-integer (info-value battery key)))) (defmethod all-batteries ((method procfs-method)) (mapcar (lambda (p) (make-instance 'procfs-battery :path p)) (list-directory "/proc/acpi/battery/"))) (defmethod state-of ((battery procfs-battery)) (handler-case (progn (update-info battery) (if (string/= (info-value battery "present") "yes") :unknown (let* ((state (info-value battery "charging state"))) (flet ((percent () (/ (info-value-int battery "remaining capacity") (info-value-int battery "last full capacity")))) (cond ((string= state "charged") (values :charged (percent))) ((string= state "discharging") (values :discharging (percent) (* 3600 (/ (info-value-int battery "remaining capacity") (info-value-int battery "present rate"))))) ((string= state "charging") (values :charging (percent) (* 3600 (/ (- (info-value-int battery "last full capacity") (info-value-int battery "remaining capacity")) (info-value-int battery "present rate"))))) (t :unknown)))))) (t () :unknown)))) ;;; Linux sysfs implementation #+ linux (progn (defclass sysfs-method (battery-method) () (:documentation "Collect battery information through Linux' class-based sysfs interface.")) (defclass sysfs-battery (battery) ((path :initarg :path :initform (error ":path missing") :reader path-of))) (defun sysfs-field-exists? (path name) (probe-file (merge-pathnames (make-pathname :name name) path))) (defun sysfs-field (path name) (with-open-file (file (merge-pathnames (make-pathname :name name) path)) (read-line-from-sysfs file))) (defun sysfs-int-field (path name) (parse-integer (sysfs-field path name) :junk-allowed t)) (defun sysfs-int-field-or-nil (path name) (if (sysfs-field-exists? path name) (sysfs-int-field path name) nil)) (defmethod all-batteries ((m sysfs-method)) (remove nil (mapcar (lambda (path) (handler-case (when (string= "Battery" (sysfs-field path "type")) (make-instance 'sysfs-battery :path path)) (file-error () nil))) (list-directory "/sys/class/power_supply/")))) (defmethod state-of ((battery sysfs-battery)) (handler-case (let ((path (path-of battery))) (if (string= (sysfs-field path "present") "0") :unknown (let* ((state (sysfs-field path "status")) (consumption (sysfs-int-field path "current_now")) (curr (or (sysfs-int-field-or-nil path "energy_now") ;; energy_* seems not to be there on ;; some boxes. Strange... (sysfs-int-field-or-nil path "charge_now") (return-from state-of :unknown))) (full (or (sysfs-int-field-or-nil path "energy_full") (sysfs-int-field-or-nil path "charge_full") (return-from state-of :unknown))) (percent (* 100 (/ curr full)))) (cond ((string= state "Full") (values :charged percent)) ((string= state "Discharging") (values :discharging percent (if (zerop consumption) 0 (* 3600 (/ curr consumption))))) ((string= state "Charging") (values :charging percent (if (zerop consumption) 0 (* 3600 (/ (- full curr) consumption))))) (t :unknown))))) (t () :unknown)))) ;;; Interface to the outside world. (defun fmt-time (stream arg colonp atp) (declare (ignore colonp atp)) (multiple-value-bind (hours rest) (truncate arg 3600) (format stream "~D:~2,'0D" hours (floor rest 60)))) (defun battery-info-string () "Compiles a string suitable for StumpWM's mode-line." (with-output-to-string (fmt) (let ((batteries (all-batteries (or (preferred-battery-method) (return-from battery-info-string "(not implemented)"))))) (if (endp batteries) (format fmt "(no battery)") (loop for bat in batteries do (multiple-value-bind (state perc time) (state-of bat) (ecase state (:unknown (format fmt "(no info)")) (:charged (format fmt "~~ ~D%" (round perc))) ((:charging :discharging) (format fmt "~/stumpwm.contrib.battery-portable::fmt-time/~A ^[~A~D%^]" time (if (eq state :charging) #\+ #\-) (bar-zone-color perc 90 50 20 t) (round perc)))))))))) ;;; The actual mode-line format function. A bit ugly... (let ((next 0) (last-value "")) (defun fmt-bat (ml) (declare (ignore ml)) ;; Return the last info again, if we are called too quickly. (let ((now (get-universal-time))) (when (< now next) (return-from fmt-bat last-value)) (setf next (+ now *refresh-time*))) ;; Generate info string. (setf last-value (battery-info-string)))) ;;; Put this at the end to avoid evaluating it when the core above ;;; throws an error. (add-screen-mode-line-formatter #\B #'fmt-bat) ;;; EOF
10,728
Common Lisp
.lisp
246
32.955285
92
0.569951
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0690f94d05c399e318a79c4d882b611fa161916c97e3d363e4d8c1127521db7d
7,280
[ -1 ]
7,281
wifi.lisp
blitz_stumpwm/contrib/wifi.lisp
;;; Wifi formatter for the mode-line ;;; ;;; Copyright 2008 John Li ;;; ;;; Maintainer: John Li ;;; ;;; This module 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 module 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 software; see the file COPYING. If not, write to ;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, ;;; Boston, MA 02111-1307 USA ;;; ;;; WARNING: ;;; ;;; This triggers a yet to be discovered bug in SBCL, which causes ;;; stumpwm to freeze. ;;; USAGE: ;;; ;;; Place the following in your ~/.stumpwmrc file: ;;; ;;; (load-module "wifi") ;;; ;;; Then you can use "%I" in your mode line format (both "w" and "W" ;;; were taken. Think _I_EEE 802.11 :-)). ;;; ;;; Notes: This gets information through sysfs, so it only works on ;;; Linux with a mounted sysfs. (defpackage :stumpwm.contrib.wifi (:use :common-lisp :stumpwm ) (:export #:*iwconfig-path* #:*wireless-device*)) (in-package :stumpwm.contrib.wifi) (defvar *iwconfig-path* "/sbin/iwconfig" "Location if iwconfig, defaults to /sbin/iwconfig.") (defvar *wireless-device* nil "Set to the name of the wireless device you want to monitor. If set to NIL, try to guess.") (defmacro defun-cached (name interval arglist &body body) "Creates a function that does simple caching. The body must be written in a functional style - the value returned is set as the prev-val." (let ((prev-time (gensym "PREV-TIME")) (prev-val (gensym "PREV-VAL")) (now (gensym "NOW")) (docstring (when (stringp (car body)) (pop body)))) `(let ((,prev-time 0) (,prev-val nil)) (defun ,name ,arglist ;; if no docstring, return nothing (not even nil) ,@(when docstring (list docstring)) (let ((,now (get-internal-real-time))) (when (>= (- ,now ,prev-time) (* ,interval internal-time-units-per-second)) (setf ,prev-time ,now) (setf ,prev-val (locally ,@body))) ,prev-val))))) (defun guess-wireless-device () (or (loop for path in (list-directory "/sys/class/net/") thereis (let ((device-name (car (last (pathname-directory path))))) (if (probe-file (merge-pathnames (make-pathname :directory '(:relative "wireless") :name "status") path)) device-name nil))) (error "No wireless device found."))) (defun read-wifi-info (device what) (let ((path (make-pathname :directory `(:absolute "sys" "class" "net" ,device "wireless")))) (with-open-file (in (merge-pathnames (make-pathname :name what) path)) (read-line-from-sysfs in)))) (defun read-wifi-info-int (device what) (parse-integer (read-wifi-info device what))) (defun-cached fmt-wifi 5 (ml) "Formatter for wifi status. Displays the ESSID of the access point you're connected to as well as the signal strength. When no valid data is found, just displays nil." (declare (ignore ml)) (handler-case (let* ((device (or *wireless-device* (guess-wireless-device))) (essid (multiple-value-bind (match? sub) (cl-ppcre:scan-to-strings "ESSID:\"(.*)\"" (run-shell-command (format nil "~A ~A 2>/dev/null" *iwconfig-path* device) t)) (if match? (aref sub 0) (return-from fmt-wifi "no link"))))) (let* ((qual (read-wifi-info-int device "link"))) (format nil "~A ^[~A~D%^]" essid (bar-zone-color qual 40 30 15 t) qual))) ;; CLISP has annoying newlines in their error messages... Just ;; print a string showing our confusion. (t (c) (format nil "~A" c)))) ;;; Add mode-line formatter (add-screen-mode-line-formatter #\I #'fmt-wifi) ;;; EOF
4,712
Common Lisp
.lisp
108
34.194444
101
0.575817
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
97ee20bc95f3c3aa23c7b9b33c8f5950374e77d2f08c91f61f1c503dc55e38da
7,281
[ -1 ]
7,282
stumpwm.asd
blitz_stumpwm/stumpwm.asd
;;; -*- Mode: Lisp -*- (defpackage :stumpwm-system (:use :cl :asdf)) (in-package :stumpwm-system) ;; This is a hack for debian because it calls cmucl's clx ;; cmucl-clx. *very* annoying. I don't actually know if debian still ;; does this. #+cmu (progn (ignore-errors (require :cmucl-clx)) (ignore-errors (require :clx))) (defsystem :stumpwm :name "StumpWM" :author "Shawn Betts <[email protected]>" :version "CVS" :maintainer "Shawn Betts <[email protected]>" ;; :license "GNU General Public License" :description "A tiling, keyboard driven window manager" :serial t :depends-on (:cl-ppcre #-(or cmu clisp) :clx #+sbcl :sb-posix) :components ((:file "package") (:file "primitives") (:file "workarounds") (:file "wrappers") (:file "pathnames") (:file "keysyms") (:file "keytrans") (:file "kmap") (:file "input") (:file "core") (:file "command") (:file "menu") (:file "screen") (:file "head") (:file "group") (:file "window") (:file "floating-group") (:file "tile-group") (:file "tile-window") (:file "window-placement") (:file "message-window") (:file "selection") (:file "user") (:file "iresize") (:file "bindings") (:file "events") (:file "help") (:file "fdump") (:file "time") (:file "mode-line") (:file "color") (:file "module") (:file "stumpwm") ;; keep this last so it always gets recompiled if ;; anything changes (:file "version")))
1,791
Common Lisp
.asd
55
23.363636
68
0.512125
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
801ff6953bed902ffdd1107f5ca29a46ea6b792dc611575ab8ae991608595267
7,282
[ -1 ]
7,299
Makefile.in
blitz_stumpwm/Makefile.in
LISP=@LISP_PROGRAM@ clisp_BUILDOPTS=-K full -on-error exit ./make-image.lisp sbcl_BUILDOPTS=--load ./make-image.lisp ccl_BUILDOPTS=--load ./make-image.lisp ecl_BUILDOPTS=-norc -shell ./make-image.lisp clisp_INFOOPTS=-K full -on-error exit -x "(require 'asdf '(\"asdf.lisp\")) (load \"stumpwm.asd\") (load \"@PPCRE_PATH@/cl-ppcre.asd\") (asdf:operate 'asdf:load-op :stumpwm) (load (compile-file \"manual.lisp\")) (stumpwm::generate-manual) (ext:exit)" sbcl_INFOOPTS=--eval "(progn (require 'asdf) (require 'stumpwm) (load \"manual.lisp\"))" --eval "(progn (stumpwm::generate-manual) (sb-ext:quit))" ccl_INFOOPTS=--eval "(progn (require 'asdf) (require 'stumpwm))" --load manual.lisp --eval "(progn (stumpwm::generate-manual) (quit))" ecl_INFOOPTS=-eval "(progn (require 'asdf) (load \"@PPCRE_PATH@/cl-ppcre.asd\") (require 'stumpwm) (load \"manual.lisp\"))" -eval "(progn (stumpwm::generate-manual) (ext:quit))" datarootdir = @datarootdir@ prefix=@prefix@ exec_prefix= @exec_prefix@ bindir=@bindir@ infodir=@infodir@ # You shouldn't have to edit past this # This is copied from the .asd file. It'd be nice to have the list in # one place, but oh well. FILES=stumpwm.asd package.lisp primitives.lisp wrappers.lisp \ pathnames.lisp keysyms.lisp keytrans.lisp kmap.lisp input.lisp \ core.lisp command.lisp menu.lisp screen.lisp head.lisp group.lisp \ window.lisp floating-group.lisp tile-window.lisp window-placement.lisp \ message-window.lisp selection.lisp user.lisp iresize.lisp \ bindings.lisp events.lisp help.lisp fdump.lisp mode-line.lisp \ time.lisp color.lisp module.lisp stumpwm.lisp version.lisp all: stumpwm stumpwm.info stumpwm.info: stumpwm.texi makeinfo stumpwm.texi # FIXME: This rule is too hardcoded stumpwm.texi: stumpwm.texi.in $(LISP) $(@LISP@_INFOOPTS) stumpwm: $(FILES) $(LISP) $(@LISP@_BUILDOPTS) release: git tag -a -m "version @PACKAGE_VERSION@" @PACKAGE_VERSION@ git archive --format=tar --prefix=stumpwm-@PACKAGE_VERSION@/ HEAD > stumpwm-@[email protected] tar xf stumpwm-@[email protected] cd stumpwm-@PACKAGE_VERSION@ && tar zxf @PPCRE_PATH@/../cl-ppcre.tar.gz && mv cl-ppcre-* cl-ppcre git log > stumpwm-@PACKAGE_VERSION@/ChangeLog cp configure stumpwm-@PACKAGE_VERSION@/ tar zcf stumpwm-@[email protected] stumpwm-@PACKAGE_VERSION@ rm -fr stumpwm-@PACKAGE_VERSION@/ stumpwm-@[email protected] upload-release: gpg -b stumpwm-@[email protected] scp stumpwm-@[email protected] stumpwm-@[email protected] [email protected]:/releases/stumpwm/ ( echo rm stumpwm-latest.tgz.sig && echo rm stumpwm-latest.tgz && echo ln stumpwm-@[email protected] stumpwm-latest.tgz && echo ln stumpwm-@[email protected] stumpwm-latest.tgz.sig ) | sftp -b - [email protected]:/releases/stumpwm/ clean: rm -f *.fasl *.fas *.lib *.*fsl rm -f *.log *.fns *.fn *.aux *.cp *.ky *.log *.toc *.pg *.tp *.vr *.vrs rm -f stumpwm stumpwm.texi stumpwm.info install: stumpwm.info stumpwm test -z "$(destdir)$(bindir)" || mkdir -p "$(destdir)$(bindir)" install -m 755 stumpwm "$(destdir)$(bindir)" test -z "$(destdir)$(infodir)" || mkdir -p "$(destdir)$(infodir)" install -m 644 stumpwm.info "$(destdir)$(infodir)" install-info --info-dir="$(destdir)$(infodir)" "$(destdir)$(infodir)/stumpwm.info" uninstall: rm "$(destdir)$(bindir)/stumpwm" install-info --info-dir="$(destdir)$(infodir)" --remove "$(destdir)$(infodir)/stumpwm.info" rm "$(destdir)$(infodir)/stumpwm.info" # End of file
3,469
Common Lisp
.l
60
56.166667
249
0.728719
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
34fe3ebe6470eb019575726f44445344706ed9b6fe246b059c908e0834cae1b3
7,299
[ -1 ]
7,316
stumpwm-mode.el
blitz_stumpwm/contrib/stumpwm-mode.el
;;; stumpwm-mode.el --- special lisp mode for evaluating code into running stumpwm ;; Copyright (C) 2007 Shawn Betts ;; Maintainer: Shawn Betts ;; Keywords: comm, lisp, tools ;; 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., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; load this file, set stumpwm-shell-program to point to stumpish and ;; run M-x stumpwm-mode in your stumpwm lisp files. Now, you can ;; easily eval code into a running stumpwm using the regular bindings. ;;; Code: (defvar stumpwm-shell-program "stumpish" "program name, including path if needed, for the stumpish program.") (define-minor-mode stumpwm-mode "add some bindings to eval code into a running stumpwm using stumpish." :global nil :lighter " StumpWM" :keymap (let ((m (make-sparse-keymap))) (define-key m (kbd "C-M-x") 'stumpwm-eval-defun) (define-key m (kbd "C-x C-e") 'stumpwm-eval-last-sexp) m)) (defun stumpwm-eval-region (start end) (interactive "r") (let ((s (buffer-substring-no-properties start end))) (message "%s" (with-temp-buffer (call-process stumpwm-shell-program nil (current-buffer) nil "eval" s) (buffer-string))))) (defun stumpwm-eval-defun () (interactive) (save-excursion (end-of-defun) (skip-chars-backward " \t\n\r\f") (let ((end (point))) (beginning-of-defun) (stumpwm-eval-region (point) end)))) (defun stumpwm-eval-last-sexp () (interactive) (stumpwm-eval-region (save-excursion (backward-sexp) (point)) (point))) (provide 'stumpwm-mode) ;;; stumpwm-mode.el ends here
2,313
Common Lisp
.l
53
38.811321
82
0.689225
blitz/stumpwm
27
1
2
GPL-2.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
46a142858f54736bd98fcbb28847d01135cbf7feb93ceedcd7ec834651eee8fd
7,316
[ -1 ]
7,342
lisp-form-builder.lisp
mkoeppe_cl-bibtex/lisp-form-builder.lisp
;; A BibTeX re-implementation in Common Lisp - construct beautiful Lisp forms ;; Copyright 2001, 2002 Matthias Koeppe <[email protected]> ;; ;; This code is free software; you can redistribute it and/or ;; modify it under the terms of version 2.1 of the GNU Lesser ;; General Public License as published by the Free Software ;; Foundation or any later version, as clarified by the preamble ;; found in COPYING-preamble.txt. This preamble is in the style ;; of the Franz Inc. preamble at http://opensource.franz.com/preamble.html ;; with names and copyright holders altered accordingly. (in-package bibtex-compiler) (defun build-if-form (val-form then-form else-form) "Build a Lisp form equivalent to `(IF ,VAL-FORM ,THEN-FORM ,ELSE-FORM) but try to beautify the result by using COND, UNLESS, and WHEN, rather than IF in certain cases." (let ((then-operator (and (consp then-form) (car then-form))) (else-operator (and (consp else-form) (car else-form)))) (labels ((clauses (form) (let ((operator (and (consp form) (car form)))) (case operator (progn `((t ,@(cdr form)))) (if `((,(cadr form) ,(caddr form)) (t ,(cadddr form)))) (cond (cdr form)) (t `((t ,form)))))) (body (form) (let ((operator (and (consp form) (car form)))) (if (eql operator 'progn) (cdr form) (list form))))) (cond ((equal then-form '(values)) ; we have, in fact, an `unless' `(unless ,val-form ,@(body else-form))) ((equal else-form '(values)) ; we have, in fact, a `when' `(when ,val-form ,@(body then-form))) ((member else-operator '(if cond)) ; beautify using `cond' `(cond (,val-form ,@(body then-form)) ,@(clauses else-form))) ((member then-operator '(if cond)) ; beautify using reverse `cond' `(cond (,(build-not-form val-form) ,@(body else-form)) ,@(clauses then-form))) ((or (eql else-operator 'progn) (eql then-operator 'progn)) ; beautify using `cond' `(cond (,val-form ,@(body then-form)) ,@(clauses else-form))) (t ; normal if `(if ,val-form ,then-form ,else-form)))))) (defun build-associative-form (operators form1 form2) "Build the form `(,@OPERATORS FORM1 FORM2) but if FORM1 and FORM2 are of this form, use the associativity of the operation to build `(,@OPERATORS FORMS...) instead." (labels ((operation-p (form) (and (consp form) (let ((index (mismatch operators form :test 'equal))) (or (not index) (= index (length operators)))))) (args (form) (subseq form (length operators))) (arg-forms (form) (if (operation-p form) (args form) (list form)))) `(,@operators ,@(arg-forms form1) ,@(arg-forms form2)))) (defun build-not-form (form) "Build the form `(not ,@FORM) but simplify that if possible." (labels ((operator (f) (and (consp f) (car f)))) (let ((op (operator form))) (case op (not (cadr form)) ((> < >= <=) (if (= (length form) 3) (let ((negop (ecase op (> '<=) (< '>=) (<= '>) (>= '<)))) `(,negop ,@(cdr form))) `(not ,form))) (string= `(string/= ,@(cdr form))) (string/= `(string= ,@(cdr form))) ((and or) ;; de-Morgan-ize if at least one negated subform is found (if (find 'not (cdr form) :key #'operator) (let ((negop (ecase op (and 'or) (or 'and)))) `(,negop ,@(mapcar #'build-not-form (cdr form)))) `(not ,form))) (t `(not ,form)))))) (defun build-values-body (result-list) "Build a Lisp body containing one form, `(values ,@RESULT-LIST). For zero or one values, make simpler constructions." (case (length result-list) (0 ()) (1 (list (car result-list))) (t (list `(values ,@result-list))))) (defun build-progn-form (body) "Build a Lisp form equivalent to `(progn ,@BODY). For the special case of an empty body, use `(values)." (case (length body) (0 `(values)) (1 (car body)) (t `(progn ,@body))))
3,950
Common Lisp
.lisp
108
32.546296
77
0.62878
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
318faa142fac43b672ceea04a0d8649490bdaaacd9d30514176e1072b1886287
7,342
[ -1 ]
7,343
bst-builtins.lisp
mkoeppe_cl-bibtex/bst-builtins.lisp
;; A BibTeX re-implementation in Common Lisp - The built-in BST functions ;; Copyright 2001, 2002 Matthias Koeppe <[email protected]> ;; ;; This code is free software; you can redistribute it and/or ;; modify it under the terms of version 2.1 of the GNU Lesser ;; General Public License as published by the Free Software ;; Foundation or any later version, as clarified by the preamble ;; found in COPYING-preamble.txt. This preamble is in the style ;; of the Franz Inc. preamble at http://opensource.franz.com/preamble.html ;; with names and copyright holders altered accordingly. (in-package bibtex-compiler) (register-bst-primitive ">" '((integer) (integer)) '((boolean)) '>) (register-bst-primitive "<" '((integer) (integer)) '((boolean)) '<) (register-bst-primitive "=" '(t t) '((boolean)) 'equal) (define-bst-primitive "+" ((a (integer)) (b (integer))) ((integer)) :interpreted (+ a b) :compiled (build-associative-form `(+) a b)) (register-bst-primitive "-" '((integer) (integer)) '((integer)) '-) (define-bst-primitive "*" ((a (string)) (b (string))) ((string)) :interpreted (concatenate 'string a b) :compiled (build-associative-form `(concatenate 'string) a b)) (define-bst-primitive ":=" ((value t) (variable (symbol))) () :interpreted (let ((function (get-bst-function-of-type variable '(int-global-var str-global-var int-entry-var str-entry-var)))) (case (bst-function-type function) ((int-global-var int-entry-var) (unless (integerp value) (error "Assignment of non-integer value ~S to integer variable ~S" value variable))) ((str-global-var str-entry-var) (unless (stringp value) (error "Assignment of non-string value ~S to string variable ~S" value variable)))) (funcall (bst-function-setter function) value))) (register-bst-primitive "add.period$" '((string)) '((string)) 'add-period-unless-sentence-end) (define-bst-primitive "call.type$" () () :interpreted (let* ((type (bib-entry-type *bib-entry*)) (function (or (get-bst-function-of-type type '(wiz-defined compiled-wiz-defined)) (get-bst-function-of-type 'default.type '(wiz-defined compiled-wiz-defined))))) (when function (bst-execute function))) :compiled (let ((type/fun-sym (bst-intern "TYPE/FUN"))) `(let ((,type/fun-sym (assoc (bib-entry-type *bib-entry*) *bib-entry-type-functions* :test 'string-equal))) (if ,type/fun-sym (funcall (cdr ,type/fun-sym)) (,(bst-name-to-lisp-name "default.type" :function)))))) (define-bst-primitive "change.case$" ((string (string)) (spec (string) :need-variable t)) ((string)) :interpreted (cond ((string-equal spec "t") (bibtex-string-titledowncase string)) ((string-equal spec "l") (bibtex-string-downcase string)) ((string-equal spec "u") (bibtex-string-upcase string)) (t (bib-warn "~S is an illegal case-conversion string" spec) string)) :compiled (if (stringp spec) ; specifier known at compile time (cond ((string-equal spec "t") `(bibtex-string-titledowncase ,string)) ((string-equal spec "l") `(bibtex-string-downcase ,string)) ((string-equal spec "u") `(bibtex-string-upcase ,string)) (t (bib-warn "~S is an illegal case-conversion string" spec) string)) `(cond ((string-equal ,spec "t") (bibtex-string-titledowncase ,string)) ((string-equal ,spec "l") (bibtex-string-downcase ,string)) ((string-equal ,spec "u") (bibtex-string-upcase ,string)) (t (bib-warn "~S is an illegal case-conversion string" ,spec) ,string)))) (define-bst-primitive "chr.to.int$" ((s (string) :need-variable t)) ((integer)) :interpreted (cond ((= (length s) 1) (char-code (char s 0))) (t (bib-warn "String ~S is not a one-character string" s) 0)) :compiled (if (stringp s) (if (= (length s) 1) `(char-code ,(char s 0)) 0) `(if (= (length ,s) 1) (char-code (char ,s 0)) 0))) (define-bst-primitive "cite$" () ((string)) :interpreted (or (bib-entry-cite-key *bib-entry*) "") :compiled `(or (bib-entry-cite-key *bib-entry*) "")) (define-bst-primitive "duplicate$" ((object t)) (t t) :interpreted (values object object)) (register-bst-primitive "empty$" '((string missing)) '((boolean)) 'empty-field-p) (define-bst-primitive "format.name$" ((names (string)) (index (integer)) (format (string))) ((string)) :interpreted (format-nth-bibtex-name nil format names index) :compiled `(format-nth-bibtex-name nil ,format ,names ,index) ;; FIXME: This changes the arg order! ) (define-bst-primitive "if$" ((pred (boolean)) (then (symbol body)) (else (symbol body))) () :interpreted (bst-execute-stack-literal (if pred then else))) (define-bst-primitive "int.to.chr$" ((code (integer))) ((string)) :interpreted (let ((char (code-char code))) (cond (char (string char)) (t (bib-warn "~A isn't a valid character code" code) ""))) :compiled `(string (code-char ,code))) (define-bst-primitive "int.to.str$" ((n (integer))) ((string)) :interpreted (format nil "~A" n) :compiled `(format nil "~A" ,n)) (define-bst-primitive "missing$" ((object (string missing))) ((boolean)) :interpreted (null object) :compiled `(null ,object)) (define-bst-primitive "newline$" () () :interpreted (bbl-terpri) :compiled `(bbl-terpri) :side-effects-p t) (register-bst-primitive "num.names$" '((string)) '((integer)) 'num-bibtex-names) (define-bst-primitive "pop$" ((object t)) () :interpreted (declare (ignore object))) (define-bst-primitive "preamble$" () ((string)) :interpreted *bib-preamble* :compiled `*bib-preamble*) (register-bst-primitive "purify$" '((string)) '((string)) 'bibtex-string-purify) (define-bst-primitive "quote$" () ((string)) :interpreted "\"" :compiled "\"") (register-bst-primitive "skip$" '() '() 'values) (define-bst-primitive "stack$" () () :interpreted nil :compiled `(values)) (define-bst-primitive "substring$" ((s (string)) (start (integer)) (count (integer))) ((string)) :interpreted (bibtex-substring s start count) :compiled (if (eql count 'most-positive-fixnum) (if (eql start 1) ;; Program tried to cut the string down to a ;; length of `entry.max$'. Since CL-BibTeX does ;; not have such a limitations, we can just use ;; the string. s ;; We can't use subseq because it throws an error ;; if start >= length. At least get rid of the ;; `global.max$' equivalent. `(bibtex-substring ,s ,start)) ;; General form `(bibtex-substring ,s ,start ,count))) (define-bst-primitive "swap$" ((a t) (b t)) (t t) :interpreted (values b a)) (register-bst-primitive "text.length$" '((string)) '((integer)) 'length) ;; FIXME: TEXT.LENGTH$ counts all characters except for braces; if a ;; backslash occurs at bracelevel = 1, consume all characters until ;; bracelevel = 0, and count everything as one character. (register-bst-primitive "text.prefix$" '((string) (integer)) '((string)) 'bibtex-string-prefix) (define-bst-primitive "top$" ((object t)) () :interpreted (format *error-output* "~A~%" object) :compiled `(format *error-output* "~A~%" ,object) :side-effects-p t) (define-bst-primitive "type$" () ((string)) :interpreted (or (bib-entry-type *bib-entry*) "") :compiled `(or (bib-entry-type *bib-entry*) "")) (define-bst-primitive "warning$" ((warning (string))) () :interpreted (bib-warn warning) :compiled (if (and (consp warning) (not (mismatch warning '(concatenate (quote string)) :end1 2 :test 'equal))) `(bib-warn* ,@(cddr warning)) `(bib-warn* ,warning)) :side-effects-p t) #|(mismatch '(1 2 3) '(1 2) :end1 2)|# (define-bst-primitive "while$" ((predicate (symbol body)) (body (symbol body))) () :interpreted (do () ((not (bst-execute-stack-literal/pop predicate '(boolean)))) (bst-execute-stack-literal body))) (register-bst-primitive "width$" '((string)) '((integer)) 'bibtex-string-width) (define-bst-primitive "write$" ((s (string))) () :interpreted (bbl-print s) :compiled `(bbl-print ,s) :side-effects-p t) ;;; The following three functions are not defined in the original ;;; BibTeX but in all style files. We define them here because we ;;; can't infer that their result is `boolean' rather than `integer'. ;;; FIXME: BST's and, or functions don't shortcut. So introduce ;;; bindings when the subforms have side-effects... (define-bst-primitive "and" ((a (boolean)) (b (boolean))) ((boolean)) :interpreted (and a b) :compiled (build-associative-form `(and) a b) :ignore-redefinition-p t) (define-bst-primitive "or" ((a (boolean)) (b (boolean))) ((boolean)) :interpreted (or a b) :compiled (build-associative-form `(or) a b) :ignore-redefinition-p t) (define-bst-primitive "not" ((a (boolean))) ((boolean)) :interpreted (not a) :compiled (build-not-form a) :ignore-redefinition-p t) ;;; These two occur in amsxtra.bst. (define-bst-primitive "false" () ((boolean)) :interpreted (values nil) :compiled (values nil) :ignore-redefinition-p t) (define-bst-primitive "true" () ((boolean)) :interpreted t :compiled t :ignore-redefinition-p t) (register-bst-entry "SORT.KEY$" 'str-entry-var '(string) "" *builtin-bst-functions*) (register-bst-entry "CROSSREF" 'field '(string missing) nil *builtin-bst-functions*) (register-bst-global-var "ENTRY.MAX$" 'most-positive-fixnum 'int-global-var '(integer) most-positive-fixnum *builtin-bst-functions* :constant-p t) (register-bst-global-var "GLOBAL.MAX$" 'most-positive-fixnum 'int-global-var '(integer) most-positive-fixnum *builtin-bst-functions* :constant-p t)
9,708
Common Lisp
.lisp
226
39.384956
95
0.672463
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
23e4a7883b8d4e2c1796d9ba5811a1977548fb8516d7736343b584353eee6e8b
7,343
[ -1 ]
7,344
kpathsea.lisp
mkoeppe_cl-bibtex/kpathsea.lisp
;; An interface to Kpathsea (TeX's file search library) ;; Copyright 2001, 2002, 2007, 2018 Matthias Koeppe <[email protected]> ;; ;; This code is free software; you can redistribute it and/or ;; modify it under the terms of version 2.1 of the GNU Lesser ;; General Public License as published by the Free Software ;; Foundation or any later version, as clarified by the preamble ;; found in COPYING-preamble.txt. This preamble is in the style ;; of the Franz Inc. preamble at http://opensource.franz.com/preamble.html ;; with names and copyright holders altered accordingly. (in-package :kpathsea) ;; We use CLOCC PORT to run programs if we are not running in CMUCL or SBCL. ;;#+clisp ;;(eval-when (:compile-toplevel :load-toplevel :execute) ;; (cl:require :PORT)) ;; #-(or cmu sbcl clisp) ;; (cl:require :PORT) (defun find-file (name) #+cmu (let ((process (extensions:run-program "kpsewhich" (list (namestring name)) :output :stream))) (let ((line (read-line (extensions:process-output process) nil nil))) (prog1 (and line (parse-namestring line)) (extensions:process-close process)))) #+sbcl (let ((process (sb-ext:run-program "/usr/bin/env" (list "kpsewhich" (namestring name)) :output :stream))) (let ((line (read-line (sb-ext:process-output process) nil nil))) (prog1 (and line (parse-namestring line)) (sb-ext:process-close process)))) #+abcl (let ((process (sys:run-program "/usr/bin/env" (list "kpsewhich" (namestring name))))) (let ((line (read-line (sys:process-output process) nil nil))) (and line (parse-namestring line)))) #+allegro (let ((stream (excl:run-shell-command (vector "/bin/sh" "/bin/sh" "-c" (format nil "~A ~A" "kpsewhich" (namestring name))) :output :stream :wait nil) ;; Using run-shell-command with a vector is much faster ;; than with a list (tries to run $SHELL! -- this is what PORT does) )) (let ((line (read-line stream nil nil))) (prog1 (and line (parse-namestring line)) (port:close-pipe stream)))) #+ecl (let ((stream (ext:run-program "/usr/bin/env" (list "kpsewhich" (namestring name)) :output :stream))) (let ((line (read-line stream nil nil))) (and line (parse-namestring line)))) #-(or cmu sbcl abcl allegro ecl) (let ((stream (port:pipe-input "kpsewhich" (namestring name)))) (let ((line (read-line stream nil nil))) (prog1 (and line (parse-namestring line)) (port:close-pipe stream))))) #| (find-file "amsalpha.bst") |#
2,601
Common Lisp
.lisp
74
31.054054
78
0.666006
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
10959e0e20a63b2e90043c1ad0caa6fd1a47db48399367f9218879e5e880ddf3
7,344
[ -1 ]
7,345
run-lisp
mkoeppe_cl-bibtex/run-lisp
#! /bin/sh # ----------------------------------------------------------------------------- # Title: A script to invoke the various CL implementations in a uniform way # Created: 1999-01-16 16:41 # Author: Gilbert Baumann <[email protected]> # License: LGPL (See file GNU-LGPL for details) # ----------------------------------------------------------------------------- # (c) copyright 1999 by Gilbert Baumann, Sam Steingold, Bruno Haible # $CLOCC-Id: run-lisp,v 1.15 2001/12/14 19:06:01 sds Exp $ # $CLOCC-Source: /cvsroot/clocc/clocc/bin/run-lisp,v $ # Prior to invocation the LISPTYPE environment variable must been set to # one of these: # # clisp uses ${CLISP} if set, else "clisp" # cmucl uses ${CMUCL} if set, else "lisp" # acl43 uses ${ACL43} if set, else "cl" # acl5 uses ${ACL5} if set, else "cl" # gcl uses ${GCL} if set, else "gcl" # sbcl uses ${SBCL} if set, else "sbcl" usage(){ cat <<\EOF Usage: run-lisp [clause ...] [argument ...] clause ::= -i file ; load file `file' | -c file ; compile file `file' | -x form ; execute form `form' | -I image ; use image file `image' | -d image ; dump to image `image' | --safety n ; set safety level for compilation | --speed n ; set speed level for compilation Note: Lisp specific extensions (e.g. .dxl on ACL or .mem for CLISP) are not to be included into the image argument Anything else is stuffed into the Lisp variable 'argv', which is available in the lexical environment forms given to -x are evaluated in. run-lisp -run image interactively run `image' (user:run) will be called upon start up. Makefile support run-lisp -faslext echo the fasload file extension to stdout. This is useful for Makefile; you could then say e.g. FAS:=$(shell $(TOP)/bin/run-lisp -faslext) run-lisp -dumpext echo the memory image extension _with_ dot. usage: (like above) DUMP:=$(shell $(TOP)/bin/run-lisp -dumpext) run-lisp -cat [fasl-file ...] Cat all the given fasl files together. EXAMPLE $ run-lisp -x "(print argv)" foo bar baz "Hallo Welt" foo\"bar ("foo" "bar" "baz" "Hallo Welt" "foo\"bar") $ EOF exit 0; } fail(){ echo "$0: $*" 1>&2 exit 1 } case "$1" in "--help" | "-h" | "-?" ) usage ;; "-cat" ) shift case "$LISPTYPE" in clisp | cmucl | acl43 | acl5 | sbcl) cat "$@" ;; * ) fail "Sorry, option -cat not supported for LISPTYPE=${LISPTYPE}." ;; esac ;; "-faslext" ) # (pathname-type (compile-file-pathname "foo.lisp")) shift case "$LISPTYPE" in clisp ) # This is (pathname-type (car (system::*compiled-file-types*))). echo 'fas' ;; cmucl ) # This can be found via # (c:backend-fasl-file-type c:*target-backend*), # but for speed we look at the uname first. case `uname -m 2>/dev/null` in i[3-6]86 ) echo 'x86f' ;; * ) # Call . ${CMUCL-lisp} -noinit \ -eval "(progn \ (write-string (c:backend-fasl-file-type c:*target-backend*)) (terpri) (ext:quit 0))" ;; esac ;; acl43 | acl5 ) echo 'fasl' ;; gcl ) echo 'o' # but also 'data' on same platforms ;; sbcl ) echo 'fasl' ;; * ) # Since make does not stop when the exit status is 1, we simply # echo LISPTYPE_NOT_SET here. echo LISPTYPE_NOT_SET fail "Sorry, option -faslext not supported for LISPTYPE=${LISPTYPE}." ;; esac ;; "-dumpext" ) shift 1 case "$LISPTYPE" in clisp) echo .mem ;; acl43) echo "" ;; acl5) echo .dxl ;; cmucl) echo .core ;; sbcl) echo .core ;; *) # Since make does not stop when the exit status is 1, we simply # echo LISPTYPE_NOT_SET here. echo LISPTYPE_NOT_SET fail "Sorry, option -dumpext not supported for LISPTYPE=${LISPTYPE}." ;; esac ;; "-run" ) # we special case on '-run' for now shift 1 case "$LISPTYPE" in clisp) ${CLISP-clisp} -M "$1".mem ;; cmucl ) ${CMUCL-lisp} -core "$1".core ;; acl43 ) # Why "$1"? ACL4.3 dumps executables "$1" -e '(unwind-protect (run) (excl:exit))' ;; acl5 ) ${ACL5-cl} -I "$1".dxl -e '(unwind-protect (run) (excl:exit))' ;; gcl ) "$1" -eval '(run)' ;; sbcl ) ${SBCL:-sbcl} -core "$1".core ;; *) fail "Sorry, option -run not supported for LISPTYPE=${LISPTYPE}." ;; esac ;; * ) # Multiple arguments. unset image todo="" # list of forms to execute args="" # list of arguments (strings) to pass while [ $# != 0 ]; do case "$1" in -i) if [ $# = 1 ]; then fail "missing argument for $1" fi shift backslashify='s,\(["\\]\),\\\1,g' arg=`echo "$1" | sed -e "$backslashify"` todo=$todo" (load \"${arg}\")" shift ;; -x) if [ $# = 1 ]; then fail "missing argument for $1" fi shift todo=$todo" $1" shift ;; -c) if [ $# = 1 ]; then fail "missing argument for $1" fi shift backslashify='s,\(["\\]\),\\\1,g' arg=`echo "$1" | sed -e "$backslashify"` # todo=$todo" (compile-file \"${arg}\" :print nil)" # truename helps, when using Franz' emacs interface todo=$todo" (compile-file (truename \"${arg}\") :print nil)" shift ;; -I) if [ $# = 1 ]; then fail "missing argument for $1" fi shift image="$1" shift ;; -d) if [ $# = 1 ]; then fail "missing argument for $1" fi shift backslashify='s,\(["\\]\),\\\1,g' arg=`echo "$1" | sed -e "$backslashify"` case "$LISPTYPE" in clisp ) todo=$todo" (#+lisp=cl ext:saveinitmem #-lisp=cl lisp:saveinitmem \"${arg}.mem\")" ;; cmucl ) todo=$todo" (ext:save-lisp \"${arg}.core\")" ;; acl43 ) todo=$todo" (excl:dumplisp :name \"${arg}\")" ;; acl5 ) todo=$todo" (excl:dumplisp :name \"${arg}.dxl\")" ;; gcl ) todo=$todo" (si:save-system \"${arg}\")" ;; sbcl ) todo=$todo" (sb-ext:save-lisp-and-die \"${arg}.core\")" ;; * ) fail "Sorry, option -d not supported for LISPTYPE=${LISPTYPE}." ;; esac shift ;; --safety) if [ $# = 1 ]; then fail "missing argument for $1" fi shift 1 todo=$todo" (proclaim (quote (optimize (safety "$1"))))" shift 1 ;; --speed) if [ $# = 1 ]; then fail "missing argument for $1" fi shift 1 todo=$todo" (proclaim (quote (optimize (speed "$1"))))" shift 1 ;; *) backslashify='s,\(["\\]\),\\\1,g' arg=`echo "$1" | sed -e "$backslashify"` args=$args" \"${arg}\"" shift ;; esac done # done with collecting the arguments todo="(progn${todo})" args="(${args})" todo="(let ((argv '$args)) (declare (ignorable argv)) $todo (values))" case "$LISPTYPE" in clisp ) todo="(progn (setq #+lisp=cl ext:*load-paths* #-lisp=cl lisp:*load-paths* '(#P\"\")) ${todo})" test -z "$image" || image="-M ${image}.mem"; exec ${CLISP-clisp} -norc -q ${image} -x "$todo" ;; cmucl ) # we have to convince CMUCL to return a proper exit status. todo="(let (.res (.cond t)) (unwind-protect (multiple-value-setq (.res .cond) (ignore-errors (progn $todo (fresh-line) (finish-output)))) (unix:unix-exit (if .cond 1 0))))" test -z "$image" || image="-core ${image}.core"; exec ${CMUCL-lisp} -noinit ${image} -eval "$todo" ;; acl43 ) exec echo "$todo" | ${image-${ACL43-cl}} -batch ;; acl5 ) test -z "$image" || image="-I ${image}.dxl"; exec echo "$todo" | ${ACL5-cl} ${image+"-I ${image}.dxl"} -batch ;; gcl ) exec echo "$todo" | ${image-${GCL-gcl}} -batch ;; sbcl ) # see comment for CMUCL todo="(let (.res (.cond t)) (unwind-protect (multiple-value-setq (.res .cond) (ignore-errors (progn $todo (fresh-line) (finish-output)))) (sb-ext:quit :unix-status (if .cond 1 0))))" test -z "$image" || image="-core ${image}.core"; exec ${SBCL:-sbcl} --userinit /dev/null ${image} --eval "$todo" ;; * ) if [ -n "$LISPTYPE" ] ; then fail "Sorry, LISPTYPE=${LISPTYPE} is not supported" else fail "LISPTYPE environment variable is not set" fi ;; esac esac
10,421
Common Lisp
.lisp
324
21.570988
104
0.445933
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
133b60442ed5a94feec1e3014c0e41187a869808e7d89c38ff592d54ff9cc096
7,345
[ -1 ]
7,346
bst-functions.lisp
mkoeppe_cl-bibtex/bst-functions.lisp
;; A BibTeX re-implementation in Common Lisp - BST functions ;; Copyright 2001, 2002 Matthias Koeppe <[email protected]> ;; ;; This code is free software; you can redistribute it and/or ;; modify it under the terms of version 2.1 of the GNU Lesser ;; General Public License as published by the Free Software ;; Foundation or any later version, as clarified by the preamble ;; found in COPYING-preamble.txt. This preamble is in the style ;; of the Franz Inc. preamble at http://opensource.franz.com/preamble.html ;; with names and copyright holders altered accordingly. (in-package bibtex-compiler) ;;; BST functions (defclass side-effects () ((side-effects-p :accessor side-effects-side-effects-p :initarg :side-effects-p :initform nil) ;; strings designating BST functions, symbols designating Lisp ;; variables (including lexical BST variables) (used-variables :accessor side-effects-used-variables :initarg :used-variables :initform ()) (assigned-variables :accessor side-effects-assigned-variables :initarg :assigned-variables :initform ()) ;; unconditionally assigned variables are always assigned in the ;; form; in fact, they are assigned before they are referenced (unconditionally-assigned-variables :accessor side-effects-unconditionally-assigned-variables :initarg :unconditionally-assigned-variables :initform ()) (variables-used-before-assigned :accessor side-effects-variables-used-before-assigned :initarg :variables-used-before-assigned :initform ())) (:documentation "A description of the side-effects of a computation")) (defvar null-side-effects (make-instance 'side-effects)) (defstruct bst-function name type ignore-redefinition-p lisp-name argument-types result-types ;; For use in the BST compiler: pop-form-args lisp-form-maker (side-effects null-side-effects) setter-form-maker defun-form lexical-p constant-p (num-assignments 0) assigned-value-form ;; For use in the BST interpreter: value ; value as a variable body setter) (defvar *builtin-bst-functions* (make-hash-table :size 30 :test 'equalp)) (defun register-bst-primitive (bst-name argument-types result-types lisp-function &key (ignore-redefinition nil) (side-effects-p nil)) (setf (gethash (string bst-name) *builtin-bst-functions*) (make-bst-function :name (string bst-name) :type 'built-in :lisp-name lisp-function :argument-types argument-types :result-types result-types :side-effects (make-instance 'side-effects :side-effects-p side-effects-p) :ignore-redefinition-p ignore-redefinition))) (defmacro define-bst-primitive (bst-name arglist result-types &key interpreted compiled (side-effects-p nil) (ignore-redefinition-p nil)) `(setf (gethash ,(string bst-name) *builtin-bst-functions*) (make-bst-function :name ,(string bst-name) :type 'built-in :argument-types ',(mapcar #'cadr arglist) :pop-form-args ',(mapcar #'cddr arglist) :result-types ',result-types ,@(if interpreted `(:lisp-name #'(lambda ,(mapcar #'car arglist) ,@(if (symbolp bst-name) `((block ,bst-name ,interpreted)) (list interpreted)))) ()) ,@(if compiled `(:lisp-form-maker #'(lambda ,(mapcar #'car arglist) ,compiled)) ()) :side-effects (make-instance 'side-effects :side-effects-p ,side-effects-p) :ignore-redefinition-p ,ignore-redefinition-p))) (defun register-bst-entry (entry func-type type default-value hash-table) (setq entry (string entry)) (setf (gethash entry hash-table) (make-bst-function :name entry :lisp-name #'(lambda () (bib-entry-ref entry *bib-entry* default-value)) :lisp-form-maker #'(lambda () `(bib-entry-ref ,entry *bib-entry* ,default-value)) :setter #'(lambda (value) (setf (bib-entry-ref entry *bib-entry*) value)) :setter-form-maker #'(lambda (value-form) `(setf (bib-entry-ref ,entry *bib-entry*) ,value-form)) :side-effects (make-instance 'side-effects :used-variables (list entry) :variables-used-before-assigned (list entry)) :type func-type :argument-types '() :result-types (list type)))) (defun register-bst-global-var (variable lisp-name func-type type initial-value hash-table &key (constant-p nil)) (let ((variable (string variable))) (setf (gethash variable hash-table) (make-bst-function :name variable :lisp-name lisp-name :setter #'(lambda (value) (setf (bst-function-value (gethash variable hash-table)) value)) :lisp-form-maker #'(lambda () lisp-name) :setter-form-maker #'(lambda (value-form) `(setq ,lisp-name ,value-form)) :side-effects (make-instance 'side-effects :used-variables (list variable) :variables-used-before-assigned (list variable)) :assigned-value-form initial-value :constant-p constant-p :type func-type :argument-types '() :result-types (list type) :value initial-value)))) (defvar *bst-functions* nil) (defun builtin-bst-functions () (let ((table (make-hash-table :test 'equalp))) (loop for key being each hash-key of *builtin-bst-functions* do (setf (gethash key table) (gethash key *builtin-bst-functions*))) table)) (defvar *bst-package* nil "A temporary package where the BST compiler puts the symbols generated for the BibTeX style file") (defun bst-name-to-lisp-name (bst-name &optional (type :function)) (setq bst-name (substitute #\- #\. (string-upcase (string bst-name)))) (ecase type ((:function :lexical) (if (string-equal bst-name "T") (gentemp "TEMP" *bst-package*) (bst-intern bst-name))) ((:constant) (bst-intern (concatenate 'string "+" bst-name "+"))) ((:variable) (bst-intern (concatenate 'string "*" bst-name "*"))))) (defun bst-intern (name) "Intern NAME into *BST-PACKAGE*, shadowing imported symbols." (multiple-value-bind (symbol type) (find-symbol name *bst-package*) (case type ((nil :inherited) (shadow name *bst-package*)))) (intern name *bst-package*)) (defun check-for-already-defined-function (name) (unless (symbolp name) (error "~A is not a valid identifier" name)) (let ((function (gethash (string name) *bst-functions*))) (when function (unless (bst-function-ignore-redefinition-p function) (error "~A is already a ~A function name" name (bst-function-type function)))) function)) (defun get-bst-function-of-type (name &optional (type-list t)) "Check whether NAME is the name of a BST function, whose type is one contained in TYPE-LIST. If so, return that function. Otherwise, signal an error and don't return." (let ((function (gethash (string name) *bst-functions*))) (unless function (error "~A is an unknown function" name)) (when (and (not (eql type-list t)) (not (member (bst-function-type function) type-list))) (error "~A has bad function type" name)) function)) ;;; Local Variables: ;;; eval: (put 'define-bst-primitive 'lisp-indent-function 3) ;;; End:
7,276
Common Lisp
.lisp
182
34.983516
134
0.690773
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
f795a9ff3d348a71fcbfdec6614a143375de71dcb8c2b7b696876b1dd22cf32e
7,346
[ -1 ]
7,347
bst-reader.lisp
mkoeppe_cl-bibtex/bst-reader.lisp
;; A BibTeX re-implementation in Common Lisp - the BST file reader ;; Copyright 2001, 2002 Matthias Koeppe <[email protected]> ;; ;; This code is free software; you can redistribute it and/or ;; modify it under the terms of version 2.1 of the GNU Lesser ;; General Public License as published by the Free Software ;; Foundation or any later version, as clarified by the preamble ;; found in COPYING-preamble.txt. This preamble is in the style ;; of the Franz Inc. preamble at http://opensource.franz.com/preamble.html ;; with names and copyright holders altered accordingly. (in-package bibtex-compiler) (defvar *bst-readtable* (let ((*readtable* (copy-readtable nil))) ;; comment character (set-syntax-from-char #\% #\;) ;; CL's package marker : is an ordinary constituent in BST... ;; Here's just a quick fix to make := work (set-macro-character #\: #'(lambda (stream char) (declare (ignore char)) (let ((sym (read stream nil nil t))) (unless (symbolp sym) (error "Bad syntax")) (values (intern (string-upcase (concatenate 'string ":" (symbol-name sym)))))))) ;; function lists (set-macro-character #\{ #'(lambda (stream char) (declare (ignore char)) (read-delimited-list #\} stream t))) (set-syntax-from-char #\} #\)) ;; quote (set-macro-character #\' #'(lambda (stream char) (declare (ignore char)) (list 'quote (read stream nil nil t)))) ;; numbers (set-macro-character #\# #'(lambda (stream char) (declare (ignore char)) (read stream nil nil t))) ;; double-quote; BST strings have no escape (set-macro-character #\" #'(lambda (stream char) (declare (ignore char)) (coerce (loop as char = (read-char stream nil nil t) until (char= char #\") collect char) 'string))) *readtable*)) ;;; (defvar *bst-stream* nil) (defun bst-read (&key (eof-ok nil)) (let ((result (let ((*readtable* *bst-readtable*)) (read *bst-stream* nil '*EOF*)))) (when (and (not eof-ok) (eq result '*EOF*)) (error "Unexpected end of file")) result)) ;;; (defvar *read-seen-p* nil "Non-nil if the BST READ command has been seen.") (defvar *entry-seen-p* nil "Non-nil if the BST ENTRY command has been seen.") (defstruct bst-command function args) (defvar *bst-commands* (make-hash-table :test 'equalp)) (defmacro define-bst-command (name args &body body) `(setf (gethash ,(string name) *bst-commands*) (make-bst-command :function (lambda ,args ,@body) :args ',args))) (defun copy-comment (from-stream to-stream) (terpri to-stream) (loop while (char= (peek-char t from-stream nil #\x) #\%) do (princ ";" to-stream) (loop while (char= (peek-char nil from-stream nil #\x) #\%) do (read-char from-stream) (princ ";" to-stream)) (princ (read-line from-stream nil "") to-stream) (terpri to-stream))) (defun store-comment () "Copy top-level comments; replace N leading % signs with N+1 semicola" (let ((comment (with-output-to-string (s) (copy-comment *bst-stream* s)))) (push comment *bst-definition-sequence*))) (defun get-bst-commands-and-process (stream) (let* ((*bst-stream* stream) (*entry-seen-p* nil) (*read-seen-p* nil)) (loop (when (and *bst-compiling* (char= (peek-char t *bst-stream* nil #\x) #\%)) (store-comment)) (let ((command (bst-read :eof-ok t))) (when (eql command '*EOF*) (return)) (let ((bst-command (gethash (string command) *bst-commands*))) (unless bst-command (error "~A is an illegal style-file command" command)) (apply (bst-command-function bst-command) (mapcar (lambda (argname) (declare (ignore argname)) (bst-read :eof-ok nil)) (bst-command-args bst-command)))))))) (define-bst-command "ENTRY" (fields int-entry-vars str-entry-vars) (when *entry-seen-p* (error "Illegal, another entry command")) (setq *entry-seen-p* t) (dolist (field fields) (check-for-already-defined-function field) (register-bst-entry field 'field '(string missing) nil *bst-functions*)) (dolist (entry int-entry-vars) (check-for-already-defined-function entry) (register-bst-entry entry 'int-entry-var '(integer) 0 *bst-functions*)) (dolist (entry str-entry-vars) (check-for-already-defined-function entry) (register-bst-entry entry 'str-entry-var '(string) "" *bst-functions*))) (defun singleton-list-p (arg) "Non-nil if ARG is a list consisting of one symbol." (and (consp arg) (symbolp (car arg)) (null (cdr arg)))) (define-bst-command "EXECUTE" (function-list) (unless *read-seen-p* (error "Illegal, execute command before read command")) (unless (singleton-list-p function-list) (error "Illegal argument ~A to execute command" function-list)) (let* ((name (car function-list)) (function (get-bst-function-of-type name '(built-in wiz-defined compiled-wiz-defined)))) (if *bst-compiling* (progn (push (bst-compile-thunkcall name) *main-lisp-body*) (push function *bst-function-call-sequence*)) (bst-execute function)))) (define-bst-command "FUNCTION" (function-list function-definition) (unless (singleton-list-p function-list) (error "Illegal argument ~A to function command" function-list)) (let* ((bst-name (car function-list))) (unless (check-for-already-defined-function bst-name) (let ((bst-function (make-bst-function :name (string bst-name) :type 'wiz-defined :body function-definition))) (setf (gethash (string bst-name) *bst-functions*) bst-function) (when *bst-compiling* (compile-bst-function bst-function) (push bst-function *bst-definition-sequence*)))))) (define-bst-command "INTEGERS" (name-list) (unless (listp name-list) (error "Illegal argument ~A to integers command" name-list)) (dolist (bst-name name-list) (check-for-already-defined-function bst-name) (let* ((lexical (member bst-name *lexicals* :test 'string-equal)) (lisp-name (and *bst-compiling* (bst-name-to-lisp-name bst-name (if lexical :lexical :variable)))) (bst-function (register-bst-global-var bst-name lisp-name 'int-global-var '(integer) 0 *bst-functions*))) (when *bst-compiling* (push bst-function *bst-definition-sequence*))))) (define-bst-command "ITERATE" (function-list) (unless *read-seen-p* (error "Illegal, iterate command before read command")) (unless (singleton-list-p function-list) (error "Illegal argument ~A to iterate command" function-list)) (let* ((name (car function-list)) (function (get-bst-function-of-type name '(built-in wiz-defined compiled-wiz-defined)))) (if *bst-compiling* (progn (push `(dolist (*bib-entry* ,*bib-entries-symbol*) ,(bst-compile-thunkcall name)) *main-lisp-body*) (push function *bst-function-call-sequence*)) (dolist (*bib-entry* *bib-entries*) (bst-execute function))))) (define-bst-command "MACRO" (function-list function-definition) (when *read-seen-p* (error "Illegal, macro command after read command")) (unless (singleton-list-p function-list) (error "Illegal argument ~A to macro command" function-list)) (unless (and (consp function-definition) (stringp (car function-definition)) (null (cdr function-definition))) (error "Illegal argument ~A to macro command" function-definition)) (let ((name (car function-list)) (definition (car function-definition))) (check-for-already-defined-function name) (setq name (string name)) (make-bst-function :name name :lisp-name (lambda () (gethash name *bib-macros*)) :lisp-form-maker (lambda () `(gethash name *bib-macros*)) :type 'macro :argument-types '() :result-types '((string))) (setf (gethash name *bib-macros*) definition))) (define-bst-command "READ" () (when *read-seen-p* (error "Illegal, another read command")) (unless *entry-seen-p* (error "Illegal, read command before entry command")) (setq *read-seen-p* t) (if *bst-compiling* (push `(setq ,*bib-entries-symbol* (read-all-bib-files-and-compute-bib-entries)) *main-lisp-body*) (setq *bib-entries* (read-all-bib-files-and-compute-bib-entries)))) (define-bst-command "REVERSE" (function-list) (unless *read-seen-p* (error "Illegal, reverse command before read command")) (unless (singleton-list-p function-list) (error "Illegal argument ~A to execute command" function-list)) (let* ((name (car function-list)) (function (get-bst-function-of-type name '(built-in wiz-defined compiled-wiz-defined)))) (if *bst-compiling* (progn (push `(dolist (*bib-entry* (reverse ,*bib-entries-symbol*)) ,(bst-compile-thunkcall name)) *main-lisp-body*) (push function *bst-function-call-sequence*)) (dolist (*bib-entry* (reverse *bib-entries*)) (bst-execute function))))) (define-bst-command "SORT" () (unless *read-seen-p* (error "Illegal, sort command before read command")) (if *bst-compiling* (push `(setq ,*bib-entries-symbol* (stable-sort ,*bib-entries-symbol* #'cmp<)) *main-lisp-body*) (setq *bib-entries* (stable-sort *bib-entries* #'cmp<)))) (define-bst-command "STRINGS" (name-list) (unless (listp name-list) (error "Illegal argument ~A to strings command" name-list)) (dolist (bst-name name-list) (check-for-already-defined-function bst-name) (let* ((lexical (member bst-name *lexicals* :test 'string-equal)) (lisp-name (and *bst-compiling* (bst-name-to-lisp-name bst-name (if lexical :lexical :variable)))) (bst-function (register-bst-global-var bst-name lisp-name 'str-global-var '(string) "" *bst-functions*))) (when *bst-compiling* (push bst-function *bst-definition-sequence*)))))
9,991
Common Lisp
.lisp
257
34.07393
90
0.666563
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
6da69cde2f336eb19bebda86892c73213cbc6f160e29e3083d9f87b9bc6d1bf3
7,347
[ -1 ]
7,348
bibtex-program.lisp
mkoeppe_cl-bibtex/bibtex-program.lisp
;; Copyright 2001, 2002, 2007 Matthias Koeppe <[email protected]> ;; ;; This code is free software; you can redistribute it and/or ;; modify it under the terms of version 2.1 of the GNU Lesser ;; General Public License as published by the Free Software ;; Foundation or any later version, as clarified by the preamble ;; found in COPYING-preamble.txt. This preamble is in the style ;; of the Franz Inc. preamble at http://opensource.franz.com/preamble.html ;; with names and copyright holders altered accordingly. (in-package :bibtex-program) ;;; The emulation of the bibtex program (defun do-emulate-bibtex (command-line-args) (let ((*min-crossrefs* 2) (*bibtex-split-initials* t) (file-stem nil)) (dolist (arg command-line-args) (cond ((eql (mismatch "-min-crossrefs=" arg) (length "-min-crossrefs=")) (setq *min-crossrefs* (parse-integer arg :start (length "-min-crossrefs=")))) ((string= arg "-no-split-initials") (setq *bibtex-split-initials* nil)) ((string= arg "-split-initials") (setq *bibtex-split-initials* t)) ((string= arg "-terse") nil) ((and (not (string= arg "")) (char= (char arg 0) #\-)) (error "Unknown command-line switch: `~A'" arg)) (t (if file-stem (error "Need exactly one file argument; `~A' is extraneous" arg)) (setq file-stem arg)))) (unless file-stem (error "Need exactly one file argument")) (format *error-output* "This is CL-BibTeX, Version ~A~%" bibtex-compiler::+version+) (bibtex-compiler:bibtex file-stem))) (defun quit (&optional code) #+abcl (ext:quit code) #+allegro (excl:exit code) #+clisp (#+lisp=cl ext:quit #-lisp=cl lisp:quit code) #+cmu (ext:quit code) #+cormanlisp (win32:exitprocess code) #+gcl (lisp:bye code) #+lispworks (lw:quit :status code) #+lucid (lcl:quit code) #+sbcl (sb-ext:quit :unix-status (typecase code ((signed-byte 32) code) (null 0) (t 1))) #-(or allegro clisp cmu cormanlisp gcl lispworks lucid sbcl) (error 'not-implemented :proc (list 'quit code))) (defun emulate-bibtex (argv) ;;(princ "bar") (terpri) (let (#+cmu (ext:*gc-verbose* nil)) (multiple-value-bind (history err-count) (handler-case (do-emulate-bibtex argv) (error (condition) (format *error-output* "~&bibtex: ~A~%" condition) (format *error-output* "~&Try `bibtex --help' for more information.~%") (quit 4))) (unless (zerop history) (format *error-output* "~&(There ~[were~;was~:;were~] ~:*~D ~[~;warning~;error~;fatal~] message~:*~:P)~%" err-count history)) (quit history))))
2,640
Common Lisp
.lisp
67
35.19403
84
0.66251
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
1024c627bc66a7ac47f43df4de63739935ca31631ff9c74af873ea0bf2221eae
7,348
[ -1 ]
7,349
interpreter.lisp
mkoeppe_cl-bibtex/interpreter.lisp
;; A BibTeX re-implementation in Common Lisp - the BST interpreter ;; Copyright 2001, 2002 Matthias Koeppe <[email protected]> ;; ;; This code is free software; you can redistribute it and/or ;; modify it under the terms of version 2.1 of the GNU Lesser ;; General Public License as published by the Free Software ;; Foundation or any later version, as clarified by the preamble ;; found in COPYING-preamble.txt. This preamble is in the style ;; of the Franz Inc. preamble at http://opensource.franz.com/preamble.html ;; with names and copyright holders altered accordingly. (in-package bibtex-compiler) ;;; The BST interpreter (defvar *literal-stack* nil "The stack of BibTeX literals during interpretation of a BST program.") (defvar *show-stack* nil) (defun bst-execute-body (body) (dolist (form body) (when *show-stack* (format t "Stack: ~S Form: ~S~%" *literal-stack* form)) (cond ((or (numberp form) (stringp form)) (push form *literal-stack*)) ((and (consp form) (eql (car form) 'quote)) (push (cadr form) *literal-stack*)) ((listp form) (push form *literal-stack*)) ((symbolp form) (bst-execute (get-bst-function-of-type form))) (t (error "Illegal form in BST function body: ~S" form))))) (defun bst-execute-stack-literal (literal) (cond ((listp literal) (bst-execute-body literal)) ((symbolp literal) (bst-execute (get-bst-function-of-type literal))) (t (error "Stack literal ~S is not a function" literal)))) #|(defun stack-literal-type (literal) (typecase literal (integer '(integer boolean)) (string '(string)) (symbol (cond ((null literal) '(missing)) (t '(symbol)))) (cons '(body)) (otherwise (error "Bad stack literal: ~S" literal))))|# (defun bst-pop/coerce (type) (when (null *literal-stack*) (error "Literal stack empty")) (let ((literal (pop *literal-stack*))) (flet ((type-error () (error "Bad stack literal: ~S, expected type ~S" literal type))) (typecase literal (integer (cond ((equal type '(boolean)) (return-from bst-pop/coerce (> literal 0))) ((eql type t)) ((member 'integer type)) (t (type-error)))) (string (unless (or (eql type t) (member 'string type)) (type-error))) (null ;ambiguous: "missing" or an empty function body (unless (or (eql type t) (member 'missing type) (member 'body type)) (type-error))) (symbol (unless (or (eql type t) (member 'symbol type)) (type-error))) (cons (unless (or (eql type t) (member 'body type)) (type-error))) (otherwise (type-error)))) literal)) (defun bst-coerce/push (value type) (flet ((type-error () (error "Bad value to push: ~S, expected type ~S" value type))) (if (equal type '(boolean)) (setf value (if value 1 0)) (typecase value (integer (cond ((eql type t)) ((member 'integer type)) (t (type-error)))) (string (unless (or (eql type t) (member 'string type)) (type-error))) (null ; ambiguous; could be "missing" or an empty function body (unless (or (eql type t) (member 'missing type) (member 'body type)) (type-error))) (symbol (unless (or (eql type t) (member 'symbol type)) (type-error))) (cons (unless (or (eql type t) (member 'body type)) (type-error))) (otherwise (type-error)))) (push value *literal-stack*))) (defun bst-execute-stack-literal/pop (literal type) (bst-execute-stack-literal literal) (bst-pop/coerce type)) (defun bst-execute (bst-function) (cond ((bst-function-value bst-function) ; is a variable (push (bst-function-value bst-function) *literal-stack*)) ((bst-function-lisp-name bst-function) ; is a primitive, so call it (let* ((args (nreverse (mapcar #'bst-pop/coerce (reverse (bst-function-argument-types bst-function))))) (results (multiple-value-list (apply (bst-function-lisp-name bst-function) args)))) (dolist (type (bst-function-result-types bst-function)) (bst-coerce/push (pop results) type)))) (t ; is a wiz-defined function (bst-execute-body (bst-function-body bst-function)))))
4,260
Common Lisp
.lisp
121
30.53719
76
0.652132
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
73017a62f57d6bd893c15d394c368d9f508f9bbf5773dd8b14af6703f4a763a3
7,349
[ -1 ]
7,350
cmp.lisp
mkoeppe_cl-bibtex/cmp.lisp
;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Package: CMP -*- ;;; $Revision: 1.2 $ ;;; Copyright 2005 Paul Foley ([email protected]) ;;; All rights reserved. Use and verbatim redistribution permitted. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE ;;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ;;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT ;;; OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ;;; BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE ;;; USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH ;;; DAMAGE. #+CMU (ext:file-comment "$Header: /sources/cl-bibtex/cl-bibtex/cmp.lisp,v 1.2 2009/11/28 03:09:51 mkoeppe Exp $") (defpackage "CMP" (:use "COMMON-LISP") (:export "CMP" "HASH" "CMP<" "CMP>" "CMP=" "CMP<=" "CMP>=" "CMP/=")) (in-package "CMP") (declaim (ftype (function (t t) (member -1 0 +1 nil)) cmp) (ftype (function (t) (integer 0 #.most-positive-fixnum)) hash)) (defgeneric cmp (a b) (:documentation "Compare A and B; return -1 if A<B, 0 if A=B, +1 if A>B. May return NIL if A and B are not equal and have no meaningful order relation.") (:method ((a t) (b t)) (if (equal a b) 0 nil)) (:method ((a real) (b real)) (cond ((< a b) -1) ((> a b) +1) (t 0))) (:method ((a character) (b character)) (cond ((char< a b) -1) ((char> a b) +1) (t 0))) (:method ((a string) (b string)) (cond ((string< a b) -1) ((string> a b) +1) (t 0))) #| more "builtin" methods? |#) (defgeneric hash (thing) (:documentation "Hash such that (cmp= A B) => (= (hash A) (hash B))") (:method ((thing t)) (sxhash thing))) (declaim (inline two-arg-cmp< two-arg-cmp> two-arg-cmp= two-arg-cmp<= two-arg-cmp>= two-arg-cmp/=)) (defun two-arg-cmp< (a b) (and (not (eq a b)) (< (or (cmp a b) +1) 0))) (defun two-arg-cmp> (a b) (and (not (eq a b)) (> (or (cmp a b) -1) 0))) (defun two-arg-cmp= (a b) (or (eq a b) (= (or (cmp a b) 1) 0))) (defun two-arg-cmp<= (a b) (or (eq a b) (<= (or (cmp a b) +1) 0))) (defun two-arg-cmp>= (a b) (or (eq a b) (>= (or (cmp a b) -1) 0))) (defun two-arg-cmp/= (a b) (and (not (eq a b)) (/= (or (cmp a b) 1) 0))) (macrolet ((frob (name two-arg docstring) `(progn (declaim (ftype (function (t &rest t) boolean) ,name) (inline ,name)) (defun ,name (a &rest more) ,docstring (cond ((null more) t) ((,two-arg a (first more)) (apply (function ,name) more)) (t nil))) (define-compiler-macro ,name (&whole form a &rest more) (cond ((null more) t) ((not (cdr more)) `(let ((#1=#:a ,a) (#2=#:b ,(first more))) (,',two-arg #1# #2#))) ((not (cddr more)) `(let ((#1# ,a) (#2# ,(first more)) (#3=#:c ,(second more))) (and (,',two-arg #1# #2#) (,',two-arg #2# #3#)))) ((not (cdddr more)) `(let ((#1# ,a) (#2# ,(first more)) (#3# ,(second more)) (#4=#:d ,(third more))) (and (,',two-arg #1# #2#) (,',two-arg #2# #3#) (,',two-arg #3# #4#)))) (t form)))))) (frob cmp< two-arg-cmp< "Returns T if its arguments are in strictly increasing order according to CMP; NIL otherwise.") (frob cmp> two-arg-cmp> "Returns T if its arguments are in strictly decreasing order according to CMP; NIL otherwise.") (frob cmp= two-arg-cmp= "Returns T if all of its arguments are equal according to CMP; NIL otherwise.") (frob cmp<= two-arg-cmp<= "Returns T if its arguments are in strictly non-decreasing order according to CMP; NIL otherwise.") (frob cmp>= two-arg-cmp>= "Returns T if its arguments are in strictly non-increasing order according to CMP; NIL otherwise.")) (declaim (ftype (function (t &rest t) boolean) cmp/=) (inline cmp/=)) (defun cmp/= (a &rest more) "Returns T if no two of its arguments are equal according to CMP; NIL otherwise." (if more (and (every (lambda (x) (two-arg-cmp/= a x)) more) (apply #'cmp/= more)) t)) (define-compiler-macro cmp/= (&whole form a &rest more) (cond ((null more) t) ((not (cdr more)) `(let ((#1=#:a ,a) (#2=#:b ,(first more))) (two-arg-cmp/= #1# #2#))) ((not (cddr more)) `(let ((#1# ,a) (#2# ,(first more)) (#3=#:c ,(second more))) (and (two-arg-cmp/= #1# #2#) (two-arg-cmp/= #1# #3#) (two-arg-cmp/= #2# #3#)))) (t form))) #+CMU (ext:define-hash-table-test 'cmp= #'cmp= #'hash) #+SBCL (sb-ext:define-hash-table-test cmp= hash) #+CLISP (ext:define-hash-table-test cmp= cmp= hash)
4,803
Common Lisp
.lisp
105
42.542857
128
0.614103
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0ca12b7f2f6d4e2065a5ebebe0efe6c29776600312fe119e79aaaba52dbb70b7
7,350
[ -1 ]
7,351
packages.lisp
mkoeppe_cl-bibtex/packages.lisp
;; A BibTeX re-implementation in Common Lisp ;; Copyright 2001, 2002 Matthias Koeppe <[email protected]> ;; ;; This code is free software; you can redistribute it and/or ;; modify it under the terms of version 2.1 of the GNU Lesser ;; General Public License as published by the Free Software ;; Foundation or any later version, as clarified by the preamble ;; found in COPYING-preamble.txt. This preamble is in the style ;; of the Franz Inc. preamble at http://opensource.franz.com/preamble.html ;; with names and copyright holders altered accordingly. (defpackage :kpathsea (:use :common-lisp) (:export #:find-file)) (defpackage :bibtex-runtime (:use :common-lisp :cmp) (:shadow #:variable) (:export #:*bib-macros* #:*bib-database* #:*bib-entries* #:*bib-entry* #:*bib-preamble* #:*bib-style* #:*bib-files* #:*cite-all-entries* #:*cite-keys* #:*bib-entry-type-functions* #:*min-crossrefs* #:bib-entry-ref #:bib-entry-cite-key #:bib-entry-type #:bib-entry-sort-key #:read-aux-file #:read-bib-database #:cited-bib-entries #:make-bib-entry #:write-bib-entry #:read-all-bib-files-and-compute-bib-entries #:bibtex-name #:make-bibtex-name #:bibtex-name-first #:bibtex-name-von #:bibtex-name-last #:bibtex-name-jr #:*bibtex-split-initials* #:*bibtex-split-initials-already-warned-hashtable* #:parse-bibtex-name #:parse-bibtex-name-list #:*bibtex-long-token-length* #:*bibtex-long-name-length* #:format-bibtex-name #:format-nth-bibtex-name #:num-bibtex-names #:bibtex-substring #:add-period-unless-sentence-end #:whitespace-p #:empty-field-p #:bibtex-string-purify #:bibtex-string-downcase #:bibtex-string-upcase #:bibtex-string-titledowncase #:bibtex-string-prefix #:bibtex-string-width #:bib-warn #:bib-warn* #:bib-error #:bib-fatal #:*err-count* #:*history* #:+spotless-history+ #:+warning-message+ #:+error-message+ #:+fatal-message+ #:*bbl-output* #:*bbl-min-print-line* #:*bbl-max-print-line* #:bbl-print #:bbl-terpri #:with-bbl-output)) (defpackage :bibtex-compiler (:use :common-lisp :cmp :bibtex-runtime) (:shadow #:variable) (:export #:compile-bst-file #:bibtex #:*bibtex-styles* #:*allow-load-lisp-bibtex-style* #:register-bibtex-style #:define-bibtex-style #:find-bibtex-style #:lisp-bibtex-style #:interpreted-bibtex-style)) (defpackage :bibtex-program (:use :common-lisp :bibtex-runtime :bibtex-compiler) (:export #:do-emulate-bibtex #:emulate-bibtex))
2,527
Common Lisp
.lisp
53
43.849057
81
0.704049
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
3c15884fa8b2f77e561fa023a935be4366be278a80f3adea069f63952daf5069
7,351
[ -1 ]
7,352
icu.lisp
mkoeppe_cl-bibtex/icu.lisp
;; A BibTeX re-implementation in Common Lisp ;; File contributed by Paul Foley ;; Adds Unicode support in CMUCL (in-package "CL-USER") (defpackage "ICU") (in-package "ICU") (export '(ucol-open ucol-close ucol-get-sort-key with-open-collator)) (eval-when (:compile-toplevel :execute) (alien:load-foreign "/usr/lib/libicui18n.so.38" :libraries nil) (defconstant +ucol-open+ "ucol_open_3_8") (defconstant +ucol-close+ "ucol_close_3_8") (defconstant +ucol-get-sort-key+ "ucol_getSortKey_3_8")) (alien:def-alien-routine (#.+ucol-open+ %ucol-open) sys:system-area-pointer (locale c-call:c-string) (status c-call:int :out)) (alien:def-alien-routine (#.+ucol-close+ ucol-close) c-call:void (collator sys:system-area-pointer)) (alien:def-alien-routine (#.+ucol-get-sort-key+ %ucol-get-sort-key) c-call:int (collator sys:system-area-pointer) (source sys:system-area-pointer) (slength c-call:int) (keyarr sys:system-area-pointer) (klength c-call:int)) (defstruct icu-sort-key (vector (ext:required-argument) :type (simple-array (unsigned-byte 8) (*)) :read-only t)) (defun ucol-open (locale) (multiple-value-bind (collator status) (%ucol-open locale) ;; status < 0 : warning (see /usr/include/unicode/utypes.h) ;; status = 0 : no problem ;; status > 0 : error (cond ((minusp status) ; warning #| ignore |#) ((plusp status) ; error (error "Failed to create the collator (err=~D)" status))) collator)) (defun ucol-get-sort-key (collator string) (let* ((buffer (make-array (* 8 (length string)) ; should be enough :element-type '(unsigned-byte 8))) (size (%ucol-get-sort-key collator (lisp:buffer-sap string) -1 (lisp:buffer-sap buffer) (length buffer)))) (make-icu-sort-key :vector (lisp::shrink-vector buffer size)))) (defmacro with-open-collator ((var locale) &body body) (let ((xvar (gensym))) `(let ((,xvar (ucol-open ,locale))) (unwind-protect (let ((,var ,xvar)) ,@body) (ucol-close ,xvar))))) (defmethod cmp:cmp ((a icu-sort-key) (b icu-sort-key)) (do ((a (icu-sort-key-vector a)) (b (icu-sort-key-vector b)) (i 0 (1+ i))) (nil) (declare (optimize (speed 3) (space 1) (safety 0) (debug 0)) (type (integer 0 #.array-dimension-limit) i)) (cond ((= i (length a)) ; a <= b (return (if (< i (length b)) -1 0))) ((= i (length b)) ; a > b (return +1)) ((< (aref a i) (aref b i)) ; a < b (return -1)) ((> (aref a i) (aref b i)) ; a > b (return +1))))) (defmethod cmp:hash ((thing icu-sort-key)) (let ((thing (icu-sort-key-vector thing)) (x #.(sxhash pi))) (declare (type (integer 0 #.most-positive-fixnum) x)) (dotimes (i (length thing) x) (declare (type (integer 0 #.array-dimension-limit) i)) (setq x (logxor x (mod (* i (aref thing i)) most-positive-fixnum))))))
2,887
Common Lisp
.lisp
73
35.452055
78
0.64
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
fb80f304207c4b352d8980ae365ce8531fbe407245dca62e5fd5fab73b077635
7,352
[ -1 ]
7,353
bibtex.asd
mkoeppe_cl-bibtex/bibtex.asd
;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;; A BibTeX re-implementation in Common Lisp ;; Author: Matthias Koeppe ;; this bibtex asd file by Hans Halvorson <[email protected]> ;; ;; This code is free software; you can redistribute it and/or ;; modify it under the terms of version 2.1 of the GNU Lesser ;; General Public License as published by the Free Software ;; Foundation or any later version, as clarified by the preamble ;; found in COPYING-preamble.txt. This preamble is in the style ;; of the Franz Inc. preamble at http://opensource.franz.com/preamble.html ;; with names and copyright holders altered accordingly. (defpackage :bibtex-system (:use :cl :asdf)) (in-package :bibtex-system) (defsystem bibtex :version "1.1" :description "Compatible re-implementation of the BibTeX program, with a BST-to-CL compiler." :author "Matthias Koeppe <[email protected]>" :licence "LGPL 2.1+" :depends-on (#-(or cmu abcl sbcl clisp ecl) :port :split-sequence) :components ((:file "cmp") (:file "packages" :depends-on ("cmp")) (:file "kpathsea" :depends-on ("packages")) (:file "bibtex-runtime" :depends-on ("packages")) (:file "lisp-form-builder" :depends-on ("packages")) (:file "bst-functions" :depends-on ("packages" "lisp-form-builder" "bibtex-runtime")) (:file "interpreter" :depends-on ("bst-functions")) (:file "bibtex-compiler" :depends-on ("lisp-form-builder" "bst-functions" "bibtex-runtime")) (:file "bst-reader" :depends-on ("interpreter" "bst-functions" "bibtex-compiler" "bibtex-runtime")) (:file "bst-builtins" :depends-on ("bst-functions" "interpreter" "bibtex-runtime")) (:file "bibtex" :depends-on ("bibtex-compiler" "bst-reader")) (:file "bibtex-program" :depends-on ("bibtex"))))
1,874
Common Lisp
.asd
37
45.702703
95
0.679564
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
87f17497b3ff171dfd33bc283b6c74ba501620e1c88b3f77cbd4caefe1266446
7,353
[ -1 ]
7,357
COPYING-preamble.txt
mkoeppe_cl-bibtex/COPYING-preamble.txt
Prequel to the Gnu Lesser General Public License Copyright (c) 2000 Franz Inc., Berkeley, CA 94704 Matthias Koeppe has adopted the concept of the GNU Lesser General Public License version 2.1 ("LGPL") or any later version to govern the use and distribution of cl-bibtex. However, LGPL uses terminology that is more appropriate for a program written in C than one written in Lisp. Nevertheless, LGPL can still be applied to a Lisp program if certain clarifications are made. This document details those clarifications. Accordingly, the license for cl-bibtex consists of this document plus LGPL. Wherever there is a conflict between this document and LGPL, this document takes precedence over LGPL. A "Library" in Lisp is a collection of Lisp functions, data and foreign modules. The form of the Library can be Lisp source code (for processing by an interpreter) or object code (usually the result of compilation of source code or built with some other mechanisms). Foreign modules are object code in a form that can be linked into a Lisp executable. When we speak of functions we do so in the most general way to include, in addition, methods and unnamed functions. Lisp "data" is also a general term that includes the data structures resulting from defining Lisp classes. A Lisp application may include the same set of Lisp objects as does a Library, but this does not mean that the application is necessarily a "work based on the Library" it contains. The cl-bibtex Library consists of everything in the cl-bibtex distribution file set before any modifications are made to the files. If any of the functions or classes in the cl-bibtex Library are redefined in other files, then those redefinitions ARE considered a work based on the cl-bibtex Library. If additional methods are added to generic functions in the cl-bibtex Library, those additional methods are NOT considered a work based on the cl-bibtex Library. If cl-bibtex classes are subclassed, these subclasses are NOT considered a work based on the cl-bibtex Library. If the cl-bibtex Library is modified to explicitly call other functions that are neither part of Lisp itself nor an available add-on module to Lisp, then the functions called by the modified cl-bibtex Library ARE considered a work based on the cl-bibtex Library. The goal is to ensure that the cl-bibtex Library will compile and run without getting undefined function errors. It is permitted to add proprietary source code to the cl-bibtex Library, but it must be done in a way such that the cl-bibtex Library will still run without that proprietary code present. Section 5 of the LGPL distinguishes between the case of a library being dynamically linked at runtime and one being statically linked at build time. Section 5 of the LGPL states that the former results in an executable that is a "work that uses the Library." Section 5 of the LGPL states that the latter results in one that is a "derivative of the Library", which is therefore covered by LGPL. Since Lisp only offers one choice, which is to link the Library into an executable at build time, we declare that, for the purpose applying LGPL to the cl-bibtex Library, an executable that results from linking a "work that uses the cl-bibtex Library" with the Library is considered a "work that uses the Library" and is therefore NOT covered by LGPL. Because of this declaration, section 6 of LGPL is not applicable to the cl-bibtex Library. However, in connection with each distribution of this executable, you must also deliver, in accordance with the terms and conditions of the LGPL, the source code of cl-bibtex Library (or your derivative thereof) that is incorporated into this executable.
3,705
Common Lisp
.l
58
62.689655
72
0.816708
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
12d1069bfa1786d18ded016f780fb8dd4527a41690d06d7ddae3d3d9626283de
7,357
[ -1 ]
7,358
Makefile
mkoeppe_cl-bibtex/Makefile
VERSION=1.0.1 SOURCES=Makefile AUTHORS COPYING COPYING-preamble.txt \ ChangeLog README TODO NEWS \ bibtex.asd bibtex.system \ bibtex-compiler.lisp bibtex-runtime.lisp bibtex.lisp \ bst-builtins.lisp bst-functions.lisp bst-reader.lisp \ interpreter.lisp kpathsea.lisp lisp-form-builder.lisp \ packages.lisp \ test.lisp \ bibtex run-lisp bibtex-program.lisp tar: -rm -rf cl-bibtex-$(VERSION) mkdir cl-bibtex-$(VERSION) ln $(SOURCES) cl-bibtex-$(VERSION) tar cf cl-bibtex-$(VERSION).tar cl-bibtex-$(VERSION) gzip cl-bibtex-$(VERSION).tar -rm -rf cl-bibtex-$(VERSION)
580
Common Lisp
.l
17
32.176471
56
0.768271
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
a8c8020e5e071315333382f3c637c20f0e37e5fe55bc63b33129b3c204c4427f
7,358
[ -1 ]
7,368
changelog
mkoeppe_cl-bibtex/debian/changelog
cl-bibtex (0.4-1) unstable; urgency=low * New upstream version -- Matthias Koeppe <[email protected]> Tue, 1 Apr 2003 22:06:24 +0200 cl-bibtex (0.3.1-1) unstable; urgency=low * Initial Release -- Matthias Koeppe <[email protected]> Sun, 15 Dec 2002 15:25:37 +0100
313
Common Lisp
.l
6
49.166667
89
0.730897
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
d30047f9dd30ffdd8593718d5ab0e1ebec05a52a512ccc42e045f11576b68309
7,368
[ -1 ]
7,369
rules
mkoeppe_cl-bibtex/debian/rules
#!/usr/bin/make -f export DH_COMPAT=4 pkg := bibtex debpkg := cl-bibtex clc-source := usr/share/common-lisp/source clc-systems := usr/share/common-lisp/systems clc-src := $(clc-source)/$(pkg) doc-dir := usr/share/doc/$(debpkg) configure: configure-stamp configure-stamp: dh_testdir # Add here commands to configure the package. touch configure-stamp build: build-stamp build-stamp: configure-stamp dh_testdir # Add here commands to compile the package. touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp configure-stamp # Add here commands to clean up after the build process. rm -f debian/$(debpkg).postinst.* debian/$(debpkg).prerm.* dh_clean install: build dh_testdir dh_testroot dh_clean -k # Add here commands to install the package into debian/cl-bibtex. dh_installdirs $(clc-systems) $(clc-src) $(doc-dir) usr/bin \ usr/share/cl-bibtex dh_install run-lisp usr/share/cl-bibtex dh_install bibtex.system \ bibtex-compiler.lisp bibtex-runtime.lisp bibtex.lisp \ bst-builtins.lisp bst-functions.lisp bst-reader.lisp \ interpreter.lisp kpathsea.lisp lisp-form-builder.lisp \ packages.lisp bibtex-program.lisp \ $(clc-src) install -g root -o root -m 755 debian/cl-bibtex.sh debian/cl-bibtex/usr/bin/cl-bibtex dh_link $(clc-src)/bibtex.system $(clc-systems)/bibtex.system # mv change-log.txt changelog # Build architecture-independent files here. binary-indep: build install dh_testdir dh_testroot dh_installdocs NEWS README TODO AUTHORS dh_installchangelogs ChangeLog # dh_installexamples examples.lisp # dh_strip dh_compress dh_fixperms dh_installdeb # dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep .PHONY: build clean binary-indep binary-arch binary install configure
1,771
Common Lisp
.l
59
28.016949
86
0.783147
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
93aabffc92201ac3d3a25e81b114213c71f25f86e80b00bf479bfbe17600152b
7,369
[ -1 ]
7,370
cl-bibtex.sh
mkoeppe_cl-bibtex/debian/cl-bibtex.sh
#! /bin/sh export LISPTYPE=cmucl /usr/share/cl-bibtex/run-lisp -i "/usr/share/common-lisp/source/bibtex/bibtex-program.lisp" -x "(emulate-bibtex ARGV)" $@
156
Common Lisp
.l
3
51
122
0.738562
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
17eadaf971d3a35d03d34b74917fb894aedb94acb5877000943bee6c92b35b3b
7,370
[ -1 ]
7,371
control
mkoeppe_cl-bibtex/debian/control
Source: cl-bibtex Section: devel Priority: optional Maintainer: Matthias Koeppe <[email protected]> Build-Depends-Indep: debhelper (>> 4.0.0) Standards-Version: 3.5.8.0 Package: cl-bibtex Architecture: all Depends: common-lisp-controller (>= 3.37), cmucl Description: Replacement for BibTeX, written in Common Lisp This is a compatible replacement for the BibTeX program, written in Common Lisp. The aim is to enable the user to format bibliographic entries using Common Lisp programs, rather than using the stack language of BibTeX style files. . It contains an interpreter for BibTeX style files, so that old BibTeX styles can also be used with CL-BibTeX. It also contains a compiler that translates BibTeX style-files into comprehensible Common Lisp programs. The resulting programs can serve as a starting point for newly developed styles.
875
Common Lisp
.l
20
42.2
70
0.810304
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
ae3f1c8bb56cfaef42e8e3bc82fb4ecc2733131eeb4a6e37dbe23afce6dddaad
7,371
[ -1 ]
7,372
example.bib
mkoeppe_cl-bibtex/examples/example.bib
%%% Test bibliography of CL-BibTeX %%% @article {Gom58, AUTHOR = {Gomory, Ralph E.}, TITLE = {Outline of an algorithm for integer solutions to linear programs}, JOURNAL = {Bulletin of the American Mathematical Society}, VOLUME = 64, YEAR = 1958, PAGES = {275--278}, MRCLASS = {90.00 (06.60)}, MRNUMBER = {21 \#1230}, MRREVIEWER = {A. Charnes}, annote = {dual fractional, IP} } @article{deyRichard, Author = {Dey, Santanu S. and Richard, Jean-Philippe P.}, Doi = {10.1287/moor.1070.0283}, Eprint = {http://mor.journal.informs.org/cgi/reprint/33/1/140.pdf}, Journal = {Mathematics of Operations Research}, Number = {1}, Pages = {140--166}, Title = {Facets of Two-Dimensional Infinite Group Problems}, Url = {http://mor.journal.informs.org/cgi/content/abstract/33/1/140}, Volume = {33}, Year = {2008}, Equivalent-Entries = {dey3}, } @article{dey3, Author = {Dey, Santanu S. and Richard, Jean-Philippe P.}, Date-Added = {2015-04-29 15:08:03 +0000}, Date-Modified = {2015-04-29 15:08:03 +0000}, Doi = {10.1287/moor.1070.0283}, Eprint = {http://mor.journal.informs.org/cgi/reprint/33/1/140.pdf}, Equivalent-Entries = {dey3,deyRichard}, Issn = {0025-5610}, Journal = {Mathematics of Operations Research}, Number = {1}, Pages = {140--166}, Title = {Facets of Two-Dimensional Infinite Group Problems}, Url = {http://mor.journal.informs.org/cgi/content/abstract/33/1/140}, Volume = {33}, Year = {2008} } @article{Lenstra1982, Author = {Lenstra, A. K. and Lenstra, H.W. and Lov{\'a}sz, L.}, Journal = {Math. Ann.}, Owner = {Robert}, Pages = {515-534}, Timestamp = {2010.04.02}, Title = {Factoring Polynomials with rational coefficients}, Volume = {261}, Year = {1982}, Annote = {This bib entry is slightly incorrect because Lenstra's initials are not separated by a space. In plain BibTeX, all abbrv bibtex styles will abbreviate this name incorrectly. CL-BibTeX fixes this and also outputs a warning.} } % % Local Variables: % auto-fill-mode: t % End:
2,111
Common Lisp
.l
63
30.015873
70
0.666993
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
51537e63b1062ea7f63d1b212bce919ecfb13e76176575e5974072fb9e44e9a6
7,372
[ -1 ]
7,373
example.tex
mkoeppe_cl-bibtex/examples/example.tex
\documentclass{article} \title{CL-BibTeX example file} \begin{document} \maketitle In this document, we cite three papers with keys \verb|Gom58| \cite{Gom58}, \verb|deyRichard| \cite{deyRichard}, and \verb|Lenstra1983| \cite{Lenstra1982}. \medbreak We illustrate two additional features of CL-BibTeX. \begin{enumerate} \item There are actually two entries \verb|deyRichard| \cite{deyRichard} and \verb|dey3| \cite{dey3} for the same article, and both are cited. This often happens in collaborations. BibTeX cannot recognize that both are the same citation. Neither can CL-BibTeX. However, it provides a helpful facility for this situation. Bib entries can be marked using the field \verb|Equivalent-Entries|. CL-BibTeX computes the equivalence classes generated by these lists of equivalent entries. If equivalent entries are cited in one document (like in this example document), CL-BibTeX will emit a warning. The user can now fix the citations in the document. \item The bib entry for \verb|Lenstra1982| is slightly incorrect because Lenstra's initials are not separated by a space. In plain BibTeX, all abbrv bibtex styles will abbreviate ``Lenstra, H.W.'' as ``Lenstra, H.''. CL-BibTeX corrects this and also outputs a warning, so that the user can fix this entry. \end{enumerate} \bibliography{example} \bibliographystyle{amsabbrv} \end{document} %%% Local Variables: %%% mode: latex %%% TeX-master: t %%% End:
1,430
Common Lisp
.l
32
43.53125
79
0.791816
mkoeppe/cl-bibtex
26
2
1
LGPL-2.1
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
53d32a94999afa6aaf03e2462affd40f9f5376e6e2cd998bf754eac519f05f96
7,373
[ -1 ]
7,388
package.lisp
charJe_cl-yxorp/package.lisp
(defpackage yxorp (:use #:cl) (:import-from #:usocket #:address-in-use-error #:socket-stream #:socket-server #:socket-connect) (:import-from #:binding-arrows #:some->> #:some-<>> #:some-> #:-<> #:-> #:as-> #:->>) (:import-from #:flexi-streams #:string-to-octets #:octets-to-string) (:import-from #:rutils #:alist->ht #:ht->alist) (:import-from #:smart-buffer #:make-smart-buffer) (:import-from #:alexandria #:compose) (:export #:*suppress-errors* #:header #:*headers* #:*request-headers* #:*response-headers* #:config #:ssl-config #:*integer-headers* #:stop #:start #:read-config #:valid-destination-p #:destination-parts #:port #:destination #:websocket-p #:read-headers #:write-headers #:write-body-and-headers #:track-thread #:map-threads #:extract-charset #:extract-encodings)) (defpackage yxorp-config (:use #:cl #:yxorp #:binding-arrows))
1,221
Common Lisp
.lisp
53
14.943396
38
0.493573
charJe/cl-yxorp
24
1
4
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
1f8c012a2a843dc346d3be8c322782cfbfeae7d84db500aeb058a0deb1d6036b
7,388
[ -1 ]
7,389
utils.lisp
charJe_cl-yxorp/utils.lisp
(in-package #:yxorp) (defvar +crlf+ (coerce (list (code-char 13) (code-char 10)) 'string)) (declaim (hash-table *request-headers*)) (defvar *request-headers*) (declaim (hash-table *response-headers*)) (defvar *response-headers*) (declaim (hash-table *headers*)) (defvar *headers*) (defvar *integer-headers* (list :content-length)) (defun make-keyword (name) (intern (str:upcase name) '#:keyword)) (defun read-sequence* (stream) (let ((content-length (header :content-length))) (cond ((or (not (or content-length (header :transfer-encoding))) (member (header :method) (list "get" "head") :test 'equalp)) #()) ((header :content-length) (let ((seq (make-array content-length :element-type '(unsigned-byte 8)))) (read-sequence seq stream :end content-length) seq)) (t (loop with result = (list) for byte = (handler-case (read-byte stream nil nil) (end-of-file nil)) while byte do (push byte result) finally (return (coerce (reverse result) 'vector))))))) (defun header (name &optional (headers *headers*)) (declare (keyword name) (hash-table headers)) (gethash name headers)) (defun (setf header) (new-value name &aux (headers *headers*)) (declare (keyword name) (hash-table headers)) (if new-value (setf (gethash name headers) new-value) (remhash name headers))) (defun serialize-headers (headers) (declare (type list headers)) (let ((top (list :method :uri :http-version :status :message))) (str:join +crlf+ (append (list (str:join " " (->> top (map 'list (lambda (name) (cdr (assoc name headers)))) (remove nil) (map 'list 'princ-to-string)))) (as-> headers it (remove-if (lambda (name) (declare (type keyword name)) (member name top)) it :key 'car) (map 'list (lambda (pair) (str:join ": " (list (-> pair car symbol-name str:downcase) (princ-to-string (cdr pair))))) it)) (list +crlf+))))) (defun parse-header-line (line) (declare (type string line)) (let* ((pair (str:split ": " line :omit-nulls t)) (name (make-keyword (first pair)))) (cons name (if (member name *integer-headers*) (parse-integer (second pair)) (second pair))))) (defun %parse-request-headers (string) (let* ((lines (str:split +crlf+ string :omit-nulls t)) (first-line (str:split " " (first lines)))) (append (list (cons :method (first first-line)) (cons :uri (second first-line)) (cons :http-version (third first-line))) (map 'list 'parse-header-line (rest lines))))) (defun parse-request-headers (stream) (%parse-request-headers (read-headers stream))) (defun %parse-response-headers (string) (let* ((lines (str:split +crlf+ string :omit-nulls t)) (first-line (str:split " " (first lines)))) (append (list (cons :http-version (first first-line)) (cons :status (parse-integer (second first-line))) (cons :message (str:join " " (cddr first-line)))) (map 'list #'parse-header-line (rest lines))))) (defun parse-response-headers (stream) (let ((response-header-string (read-headers stream))) (when (str:blankp response-header-string) (abort)) (%parse-response-headers response-header-string))) (defun read-headers (stream) (loop with end = (the simple-string (reverse (str:concat +crlf+ +crlf+))) with chars = (list) until (and (nth 4 chars) (string= (coerce (subseq chars 0 4) 'simple-string) end)) for byte = (read-byte stream nil) while byte for char = (code-char byte) do (push char chars) finally (return (coerce (reverse chars) 'string)))) (defun forward-stream (origin destination) (loop for byte = (ignore-errors (read-byte origin nil)) while byte do (ignore-errors (write-byte byte destination) (force-output destination)))) (defun websocket-p () (string= "websocket" (let ((upgrade (str:downcase (header :upgrade)))) (the simple-string (if upgrade upgrade ""))))) (defun extract-encodings-from (header) (declare (keyword header)) (some->> header header (str:split ", ") (map 'list (compose #'make-keyword #'str:upcase #'str:trim)) (remove-if-not #'encodingp))) (defun extract-charset () (or (some-<>> :content-type header (str:split ";") (map 'list #'str:trim) (find "charset" <> :test #'str:starts-with-p) (str:split "=") second str:upcase make-keyword) (when (str:containsp "text" (header :content-type)) :iso-8859-1))) (defun copy-stream-to-stream (in out length) (let* ((left-to-read length) (buffer-size 8192) (buffer (make-array (list buffer-size) :element-type '(unsigned-byte 8)))) (loop for end = (read-sequence buffer in :end (min left-to-read buffer-size)) do (decf left-to-read end) (write-sequence buffer out :end end) (when (< end buffer-size) (return))))) (defun handle-headers-and-body (in out filter) "Read an http body from IN, run it through FILTER, and write headers and it to OUT." (let* ((str:*omit-nulls* t) (transfer-encodings (extract-encodings-from :transfer-encoding)) (content-encodings (extract-encodings-from :content-encoding)) (input (-> in (apply-decodings (reverse transfer-encodings)) (apply-decodings (reverse content-encodings)))) (read (lambda (input out) (let ((encoded-output (apply-encodings out content-encodings))) (if (null (header :transfer-encoding)) (progn (write-headers out) (finish-output out) (copy-stream-to-stream input encoded-output (or (header :content-length) 0))) (progn (setf (header :transfer-encoding) nil) (write-headers out) (finish-output out) (uiop:copy-stream-to-stream input encoded-output :element-type '(unsigned-byte 8)))) (finish-output encoded-output))))) (setf (header :content-encoding) (some->> content-encodings (str:join ", "))) (if (null filter) (funcall read input out) (let* ((buffer (make-smart-buffer)) (buffer-stream (make-instance 'smart-buffer-stream :buffer buffer))) (funcall read input buffer-stream) (setf (header :transfer-encoding) :chunked (header :content-length) nil) (let ((input (flex:make-flexi-stream (smart-buffer:finalize-buffer buffer) :external-format :utf8)) (encoded-output (flex:make-flexi-stream (apply-encodings out (append content-encodings (list :chunked))) :external-format :utf8))) (funcall filter input encoded-output) (finish-output encoded-output)))))) (defun write-headers (stream) (-> *headers* ht->alist serialize-headers string-to-octets (write-sequence stream)) (force-output stream)) (defun write-body-and-headers (body stream) (declare (type (or vector null) body)) (write-headers stream) (write-sequence body stream) (force-output stream)) (defun make-ssl-stream (stream config) (let ((ssl-config (config-ssl config))) (cl+ssl:make-ssl-server-stream stream :certificate (ssl-config-certificate ssl-config) :key (ssl-config-key ssl-config) :password (ssl-config-password ssl-config))))
8,541
Common Lisp
.lisp
216
29.018519
86
0.556733
charJe/cl-yxorp
24
1
4
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
e6719ac1c10d585ba4cc62d2d49998944dc043b9a97b23f87a23991c9f179a27
7,389
[ -1 ]
7,390
main.lisp
charJe_cl-yxorp/main.lisp
(in-package #:yxorp) (defvar *suppress-errors* t) (defmacro with-socket-handler-case (stream &body body) `(block nil (handler-bind ((cl+ssl::ssl-error-ssl (lambda (c) (declare (ignore c)) (format *error-output* "Non-ssl connection attempt; Consider configuring the ssl-redirect server.~%") (when *suppress-errors* (return)))) (stream-error (lambda (condition) (close ,stream :abort t) (format *error-output* "Client unexpectedly disconnected with ~A.~%" (type-of condition)) (when *suppress-errors* (return)))) (error (lambda (c) (format *error-output* "~A~%" c) (when *suppress-errors* (return))))) ,@body))) (defun websocket-handler (client server) (track-thread (bt:make-thread (lambda () (unwind-protect (forward-stream server client) (handler-case (close client) (stream-error nil)))) :name "YXORP Server->Client")) (write-headers server) (forward-stream client server)) (defun http-handler (client server config) (handle-headers-and-body client server (config-request-filter config)) (let* ((*headers* (alist->ht (parse-response-headers server))) (*response-headers* *headers*)) (handle-headers-and-body server client (config-response-filter config)))) (defun filter-encodings (headers) (let ((*headers* headers)) (setf (header :accept-encoding) nil) *headers*)) (defun save-ip (headers) (if (find "FORWARDED" headers :key (lambda (cons) (symbol-name (car cons))) :test #'str:containsp) headers (let ((ip (str:join "." (map 'list #'princ-to-string usocket:*remote-host*)))) (append (list (cons :x-forwarded-for ip)) (list (cons :forwarded (str:concat "for=" ip))) headers)))) (defun proxy-handler (client config) (track-thread (bt:current-thread)) (with-socket-handler-case client (let* ((client (if (ssl-config-p (config-ssl config)) (make-ssl-stream client config) client)) (*headers* (-> client parse-request-headers save-ip alist->ht filter-encodings)) (*request-headers* *headers*) (destination (make-destination (funcall (config-destinator config))))) (when destination (setf (header :host) (format nil "~A:~A" (host destination) (port destination))) (let ((host (host destination)) (port (port destination))) (handler-case (let ((stream (socket-stream (socket-connect host port :element-type '(unsigned-byte 8))))) (with-open-stream (server (if (destination-secure-p destination) (cl+ssl:make-ssl-client-stream stream) stream)) (if (websocket-p) (websocket-handler client server) (http-handler client server config)))) (usocket:connection-refused-error () (format *error-output* "Could not connect to ~A.~%" destination)))))))) (defun ssl-redirect (client config) (with-socket-handler-case client (let* ((*headers* (alist->ht (parse-request-headers client))) (redirect-to (-> config config-ssl ssl-config-redirect-to))) (setq *headers* (alist->ht (list (cons :http-version "HTTP/1.1") (cons :status 301) (cons :message "Moved Permanently") (cons :location (str:concat (format nil "~A" (make-instance 'destination :protocol 'https :host (first (str:split ":" (header :host) :omit-nulls t)) :port redirect-to)))) (header :uri)))) (write-headers client)))) (defun start (config &aux (config (cond ((stringp config) (read-config config)) ((config-p config) config) (:else (config))))) (flet ((server (port handler name) (handler-case (track-thread (socket-server usocket:*wildcard-host* port handler (list config) :element-type '(unsigned-byte 8) :multi-threading t :in-new-thread t :name name)) (address-in-use-error () (format *error-output* "Port ~A is already being used by another program. Edit your configuration to use a different port or stop the other program.~%" port))))) (some-> config config-ssl ssl-config-redirect-port (server 'ssl-redirect "YXORP SSL Redirect")) (server (config-port config) #'proxy-handler "YXORP Server"))) (defun stop () (map-threads #'bt:destroy-thread)) (defun main (&aux (args (uiop:command-line-arguments))) (start (nth 0 args)) ;; this is done in favor of :in-new-thread nil to properly catch interrupt (handler-case (let ((server (find "YXORP Server" (the list (bt:all-threads)) :key 'bt:thread-name :test 'string=))) (when server (bt:join-thread server))) (#+sbcl sb-sys:interactive-interrupt #+clozure ccl:interrupt-signal-condition #+ecl interrupt-signal-condition () (uiop:quit))))
5,858
Common Lisp
.lisp
141
29.049645
166
0.535226
charJe/cl-yxorp
24
1
4
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
df6a823290a0378ae8ac3ca30a8bcec258c0a2ce471decb20547266602ba182d
7,390
[ -1 ]
7,391
config.lisp
charJe_cl-yxorp/config.lisp
(in-package #:yxorp) (deftype port () 'integer) (deftype secure-protocol () '(member :https :wss)) (deftype protocol () '(or (member :http :ws) secure-protocol)) (deftype destination-specifier () '(or string port)) (defclass destination () ((protocol :reader protocol :initarg :protocol :initform :http :type protocol) (host :reader host :initarg :host :initform "127.0.0.1" :type string) (port :reader port :initarg :port :type (or null port)))) (defmethod print-object ((obj destination) out) (format out "~(~A~)://~A:~A" (protocol obj) (host obj) (port obj))) (defun default-protocol-port (protocol) (case protocol ((:https :wss) 443) (otherwise 80))) (defun make-destination (destination-specifier) (if (typep destination-specifier 'port) (make-instance 'destination :port destination-specifier) (flet ((make-destination-with-protocol (protocol specifier) (let ((destination-parts (str:split-omit-nulls ":" specifier))) (case (length destination-parts) (1 (make-instance 'destination :protocol protocol :host (first destination-parts) :port (default-protocol-port protocol))) (2 (let ((port (ignore-errors (parse-integer (second destination-parts))))) (when port (make-instance 'destination :protocol protocol :host (first destination-parts) :port port)))))))) (let ((protocol-parts (str:split-omit-nulls "://" destination-specifier))) (if (= 1 (length protocol-parts)) (make-destination-with-protocol :http (first protocol-parts)) (make-destination-with-protocol (make-keyword (first protocol-parts)) (second protocol-parts))))))) (defun destination-secure-p (destination) (typep (protocol destination) 'secure-protocol)) (defstruct (ssl-config (:constructor ssl-config)) (certificate "cert.pem" :type (or pathname string) :read-only t) (key "key.pem" :type (or pathname string) :read-only t) (password nil :type (or string null) :read-only t) (redirect-port nil :type (or port null) :read-only t) (redirect-to 443 :type port :read-only t)) (defstruct (config (:constructor config)) (port 8080 :type port :read-only t) (destinator (lambda () 8081) :type (or (function () destination-specifier) symbol) :read-only t) (request-filter nil :read-only t) (response-filter nil :read-only t) (ssl nil :type (or ssl-config null) :read-only t)) (defun read-config (file) (flet ((packageize (string) (str:concat "(progn #.(in-package #:yxorp-config) " string ")"))) (let ((package *package*)) (prog1 (handler-case (-> file uiop:read-file-string packageize read-from-string eval) (error (condition) (format *error-output* "There is a problem with your config file:~%~A~%" condition))) (setq *package* package)))))
3,484
Common Lisp
.lisp
109
22.93578
89
0.561106
charJe/cl-yxorp
24
1
4
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
37a5e9bf06b23de21b71ccf35f10c91da554a3382e93b304c16ca91ce442fd3e
7,391
[ -1 ]
7,392
threads.lisp
charJe_cl-yxorp/threads.lisp
(in-package #:yxorp) (defvar *threads*-lock (bt:make-lock)) (defvar *threads* '()) (defun track-thread (thread) (bt:with-lock-held (*threads*-lock) (push (tg:make-weak-pointer thread) *threads*))) (defun map-threads (function) (declare (type function function)) (bt:with-lock-held (*threads*-lock) (setq *threads* (delete-if-not 'tg:weak-pointer-value *threads*)) (setq *threads* (delete-if-not (lambda (pointer) (-> pointer tg:weak-pointer-value bt:thread-alive-p)) *threads*)) (map 'list (lambda (weak-pointer) (funcall function (tg:weak-pointer-value weak-pointer))) *threads*)))
797
Common Lisp
.lisp
22
25.5
67
0.534974
charJe/cl-yxorp
24
1
4
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0d0e14578bca6e5f56b4dcb1167fa689ad918de0c199bad08cc1d104c2236460
7,392
[ -1 ]
7,393
smart-buffer-stream.lisp
charJe_cl-yxorp/smart-buffer-stream.lisp
(in-package #:yxorp) (defclass smart-buffer-stream (trivial-gray-streams:fundamental-output-stream) ((smart-buffer :initarg :buffer :initform (error "SMART-BUFFER-STREAM must have a buffer.")) (size :initform 0 :accessor size))) (defmethod trivial-gray-streams:stream-write-byte ((stream smart-buffer-stream) byte) (incf (size stream)) (smart-buffer:write-to-buffer (slot-value stream 'smart-buffer) (make-array 1 :element-type '(unsigned-byte 8) :initial-element byte :adjustable nil :fill-pointer nil :displaced-to nil))) (defmethod trivial-gray-streams:stream-write-char ((stream smart-buffer-stream) char) (let ((octets (flex:string-to-octets (string char) :external-format :utf8))) (incf (size stream) (length octets)) (smart-buffer:write-to-buffer (slot-value stream 'smart-buffer) octets))) (defmethod trivial-gray-streams:stream-write-sequence ((stream smart-buffer-stream) sequence start end &key &allow-other-keys) (let ((start (or start 0)) (end (or end (length sequence)))) (incf (size stream) (- end start)) (smart-buffer:write-to-buffer (slot-value stream 'smart-buffer) sequence start end))) (defmethod trivial-gray-streams:stream-write-string ((stream smart-buffer-stream) string &optional (start 0) end) (let ((octets (flex:string-to-octets (subseq string start end) :external-format :utf8))) (incf (size stream) (length octets)) (smart-buffer:write-to-buffer (slot-value stream 'smart-buffer) octets)))
1,594
Common Lisp
.lisp
33
42.060606
126
0.688303
charJe/cl-yxorp
24
1
4
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b5cc3d0694ac73c485eb38faddb56415b0421d941be01bec3aa54c5cf92add4e
7,393
[ -1 ]
7,394
coding.lisp
charJe_cl-yxorp/coding.lisp
(in-package #:yxorp) (setq chunga:*accept-bogus-eols* t) (deftype encoding () '(member :chunked :gzip :deflate)) (defun encodingp (thing) (typep thing 'encoding)) (defun chunkify (stream) (let ((chunked (chunga:make-chunked-stream stream))) (setf (chunga:chunked-stream-input-chunking-p chunked) t) chunked)) (defun apply-decoding (stream encoding) (case encoding (:chunked (chunkify stream)) (:gzip (chipz:make-decompressing-stream 'chipz:gzip stream)) (:deflate (chipz:make-decompressing-stream 'chipz:deflate stream)) (otherwise stream))) (defun apply-decodings (stream decodings) (reduce #'apply-decoding decodings :initial-value stream)) (defun apply-encoding (stream encoding) (case encoding (:chunked (chunkify stream)) (:gzip (salza2:make-compressing-stream 'salza2:gzip-compressor stream)) (:deflate (salza2:make-compressing-stream 'salza2:deflate-compressor stream)) (otherwise stream))) (defun apply-encodings (stream encodings) (reduce #'apply-encoding encodings :initial-value stream))
1,088
Common Lisp
.lisp
28
34.678571
70
0.728137
charJe/cl-yxorp
24
1
4
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
2b29bd72aca609c7bdf4a35f3581283364c07f7a29c2cdb4009c3da786a2eb23
7,394
[ -1 ]
7,395
build.lisp
charJe_cl-yxorp/build.lisp
(declaim (optimize (compilation-speed 0) (debug 0) (safety 2) (space 3) (speed 3))) (require :asdf) (#+quicklisp ql:quickload #-quicklisp require 'yxorp) #+sbcl (sb-ext:save-lisp-and-die "cl-yxorp" :toplevel #'yxorp::main :executable t :compression t)
271
Common Lisp
.lisp
16
14.75
28
0.710317
charJe/cl-yxorp
24
1
4
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
e2d8c8938bcf1b6b17c1c21d0b6de145d2e3d71925ec6cbb785eead22780143d
7,395
[ -1 ]
7,396
yxorp.asd
charJe_cl-yxorp/yxorp.asd
(in-package #:asdf-user) (defsystem yxorp :description "A reverse proxy server that supports WebSocket, HTTP, HTTPS, HTTP to HTTPS redirecting, port and host forwarding configuration using a real programming language, HTTP header and body manipulation (also using a real programming language)." :version "1.1" :author "Charles Jackson <[email protected]>" :licence "AGPL3" :depends-on (#:binding-arrows #:chipz #:chunga #:cl+ssl #:flexi-streams #:rutils #:salza2 #:smart-buffer #:str #:trivial-garbage #:usocket #:usocket-server) :serial t :components ((:file "package") (:file "smart-buffer-stream") (:file "threads") (:file "coding") (:file "config") (:file "utils") (:file "main")))
771
Common Lisp
.asd
31
21.612903
78
0.695535
charJe/cl-yxorp
24
1
4
AGPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
426fe968965626f5712d5d23c894ff9bd68817ffd4ed7e5a1c0fb0cc505dca4d
7,396
[ -1 ]
7,420
report.lisp
willijar_cl-docutils/report.lisp
;;;; rstructuredtext implementation for Common Lisp ;;;; Copyright (C) 2002-2006 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; An attempt to parse the rstructuredtext syntax into markup ;;;; See ;;;; http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html ;;;; ;;;; Mechanisms for reporting parser errors (in-package :docutils) ;;; reporting levels ;; Debug report level: an internal reporting issue. Typically, there ;; is no effect on the processing. ;; Info report level: a minor issue that can be ignored. Typically there is ;; no effect on processing, and level-1 system messages are not reported. ;; Warning report level: an issue that should be addressed. If ;; ignored, there may be unpredictable problems with the output. ;; Error report level: an error that should be addressed. If ignored, ;; the output will contain errors ;; Severe report level: a severe error that must be addressed. If ignored, ;; the output will contain severe errors. Typically severe system ;; messages are turned into exceptions which halt processing. (defvar *current-line-number* -1 "Current line number - used for line in node creation") (defparameter +error-levels+ '(:debug 0 :info 2 :warning 4 :error 6 :severe 8 :terminal 10)) (define-condition docutils-condition(condition)()) (define-condition markup-condition(docutils-condition) ((node :initform nil :reader error-node :initarg :node) (line :initform nil :initarg :line :accessor error-line) (source :initform nil :initarg :source :reader error-source) (level :initform :warning :initarg :level :reader error-level) (data :initform nil :initarg :data :reader error-data) (backrefs :initform nil :initarg :backrefs :reader error-backrefs) (message :initform nil :initarg :message :reader error-message)) (:report (lambda(c os) (let ((msg (error-message c))) (format os "~A~@[ ~S~] ~@[for ~S node~] ~@[at line ~D~]" (error-level c) (if (and msg (listp msg)) (apply #'format (cons nil msg)) msg) (when (error-node c) (class-name (class-of (error-node c)))) (error-line c))))) (:documentation "An condition in the structured text markup. level can be used by handlers to determine whether to ignore, print, record or abort parsing")) (defgeneric error-severity(entity) (:documentation "Return the error-severity (0-10) for an entity")) (defmethod error-severity((c markup-condition)) (getf +error-levels+ (error-level c) 6)) (defmethod error-severity((c symbol)) (getf +error-levels+ c 6)) (defvar *system-message-destination* nil "Destination node for any system messages") (defun report(level message &key (node *system-message-destination*) (line (if node (line node) *current-line-number*)) source backrefs data) "Signals a report. Handlers will check settings to either halt processing or issue a report and return. If a system message has been added by handler, it is returned using the system-message restart" (restart-case (signal 'markup-condition :line line :data data :source source :backrefs backrefs :level level :message (if (listp message) (apply #'format (cons nil message)) message) :node node) (system-message(&optional system-message) (when system-message (add-child node system-message)) system-message))) (defmacro with-reports-to-node((node) &body body) `(let ((*system-message-destination* ,node)) ,@body))
3,860
Common Lisp
.lisp
81
41.246914
78
0.676752
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
fe9473cbec8def262574ec935503acd8d0d99602daef9158aec9c655181912bc
7,420
[ -1 ]
7,421
utilities.lisp
willijar_cl-docutils/utilities.lisp
;;;; Misc string and vector handling for docutils ;;;; Copyright (C) 2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; A document node has format ((tagname attributes) content) where ;;;; tagname is a keyword symbol, attributes a p-list ;;;; and content a list of nodes or content atoms ;;;; $Id: utilities.lisp,v 1.12 2007/07/26 08:56:35 willijar Exp willijar $ (in-package :docutils.utilities) (defvar *tab-size* 8 "The amount of space that a tab is equivalent to") (defparameter +wsp+ (mapcar #'code-char '(32 9 13 10 12 11)) "White space characters: Space, Tab, Return, Newline, Page, PageUp") (deftype wsp () `(member ,@(mapcar #'code-char '(32 9 13 10 12 11)))) (declaim (inline wsp-char-p line-blank-p)) (defun wsp-char-p(c) (typep c 'wsp)) (declaim (inline line-blank-p line-length)) (defun line-blank-p(line) (declare (string line)) (every #'wsp-char-p line)) (defun line-length(line) "Return length of line excluding trailing whitespace" (1+ (position-if-not #'wsp-char-p line :from-end t))) (defun indent-level(line &key (tab-size *tab-size*)) "Returns the indentation level of the line, including tabs as expanded" (declare (type simple-string line) (fixnum tab-size)) (let((l 0)) (declare (fixnum l)) (loop for c across (the simple-string line) while (wsp-char-p c) do (incf l (if (char= c #\tab) tab-size 1))) l)) (defun nsubvector(array start &optional (end (length array))) "Returns a displaced array on array of element from start to end (default length array)" (if (and (= 0 start) (= end (length array))) array (multiple-value-bind(displaced-to index-offset) (array-displacement array) (if displaced-to (make-array (- (or end (length array)) start) :element-type (array-element-type array) :displaced-to displaced-to :displaced-index-offset (+ start index-offset)) (make-array (- (or end (length array)) start) :element-type (array-element-type array) :displaced-to array :displaced-index-offset start))))) (defmacro do-vector((element vector &key (counter (gensym)) (start 0) end) &body body) "Iterate over the elements of a vector. Aon each iteration element is bound to the current element and counter to the index of this element. start and end may be used to specify the range of indexes to be iterated over." (let ((gvector (gensym)) (gend (gensym))) `(let* ((,gvector ,vector) (,gend ,(or end `(length ,gvector)))) (do*((,counter ,start (1+ ,counter))) ((>= ,counter ,gend)) (let ((,element (aref ,gvector ,counter))) ,@body))))) (declaim (inline rstrip strip)) (defun rstrip(string) "Remove trailing white space from string" (string-right-trim +wsp+ string)) (defun strip(string) "Remove prefixing and trailing white space from string" (string-trim +wsp+ string)) (defun lstrip(string) (string-left-trim +wsp+ string)) (defun lines-left-trim(lines length &key (start 0) (end (length lines))) "Trim `length` characters off the beginning of each line, from index `start` to `end`. No whitespace-checking is done on the trimmed text." (map 'vector #'(lambda(s) (subseq s (min length (length s)))) (nsubvector lines start end))) (defun escape2null(string &key (start 0) (end (length string))) "Return a string with escape-backslashes converted to nulls." (with-output-to-string(os) (with-input-from-string(is string :start start :end end) (do((c (read-char is nil) (read-char is nil))) ((not c)) (cond((and (eq c #\\) (eq (peek-char nil is nil) #\\)) (read-char is nil) (write-char #\null os)) (t (write-char c os))))))) (defun unescape(text &key restore-backslashes (start 0) end) "Return a string with nulls removed or restored to backslashes. Backslash-escaped spaces are also removed." (with-output-to-string(os) (with-input-from-string(is text :start start :end end) #+debug(when (< (or end (length text)) start) (break "start=~S end=~D length=~D" end (length text))) (do((c (read-char is nil) (read-char is nil))) ((not c)) (cond((eq c #\null) (if restore-backslashes (write-char #\\ os) (let ((next (peek-char nil is nil))) (when (wsp-char-p next) (read-char is nil))))) (t (write-char c os))))))) (defun split-lines(string) "Return a vector of lines split from string" (let ((lines (split-string string :delimiter #\newline))) (make-array (length lines) :element-type 'string :initial-contents lines))) (defun indented-block(lines &key (start 0) until-blank (strip-indent t) block-indent first-indent) "Extract and return a vector of indented lines of text. Collect all lines with indentation, determine the minimum indentation, remove the minimum indentation from all indented lines unless STRIP-INDENT is false, and return them. All lines up to but not including the first unindented line will be returned in a new vector. Keyword arguments: START: The index of the first line to examine. UNTIL-BLANK: Stop collecting at the first blank line if true. STRIP-INDENT: Strip common leading indent if true (default). BLOCK-INDENT: The indent of the entire block, if known. FIRST-INDENT: The indent of the first line, if known. Returns values: a new vector of the indented lines with minimum indent removed the amount of the indent a boolean: did the indented block finish with a blank line or EOF?" (let* ((indent block-indent) (first-indent (or first-indent block-indent)) (end (if first-indent (1+ start) start)) (last (length lines)) (blank-finish t)) (loop (unless (< end last) (setf blank-finish t) (return)) (let* ((line (aref lines end)) (line-indent (indent-level line))) (cond ((line-blank-p line) (when until-blank (setf blank-finish t) (return))) ((or (= line-indent 0) (and block-indent (< line-indent block-indent))) ;;Line not indented or insufficiently indented. ;;Block finished properly if the last indented line blank: (setf blank-finish (and (> end start) (line-blank-p (aref lines (1- end))))) (return)) ((not block-indent) (setf indent (if indent (min indent line-indent) line-indent))))) (incf end)) (let ((block (subseq lines start end))) (when (> (length block) 0) (when first-indent (setf (aref block 0) (subseq (aref block 0) (min first-indent (length (aref block 0)))))) (when (and indent strip-indent) (dotimes(idx (length block)) (unless (and (= idx 0) first-indent) (let ((s (aref block idx))) (setf (aref block idx) (subseq s (min indent (length s))))))))) (values block (or indent 0) blank-finish)))) (defvar *namespace* nil "Prefix namespace for ids") (defvar *namespace-delimiter* "::" "Characters used as a delimiter for id namespace component") (defgeneric namespace(id) (:method((id string)) "Return the namespace component of an id or nil if none. Returns other id component as second value" (let ((p (search *namespace-delimiter* id))) (if p (values (subseq id 0 p) (subseq id (+ p (length *namespace-delimiter*)))) (values nil id))))) (defun make-name(name &key (char-transform #'char-downcase) (namespace *namespace*)) (let ((last-wsp-p 0)) (with-output-to-string(os) (when (and namespace (not (namespace name))) (write-string namespace os) (write-string *namespace-delimiter* os)) (loop :for c :across name :do (cond ((wsp-char-p c) (unless (eql last-wsp-p 0) (setf last-wsp-p t))) (t (when (eql last-wsp-p t) (write-char #\space os)) (write-char (funcall char-transform c) os) (setf last-wsp-p nil))))))) (defun whitespace-normalise-name(name) "Return and whitespace-normalized name." (make-name name :char-transform #'identity :namespace nil)) (defun normalise-name(name) (make-name name :char-transform #'char-downcase :namespace *namespace*)) (defun make-id(string) "Make an ID from string that meets requirements of CSS and html 4.01" (with-output-to-string(os) (let ((start t) (last--p nil)) (loop :for c :across (normalise-name string) :do (cond (start (when (alpha-char-p c) (setf start nil) (write-char c os))) ((alphanumericp c) (when last--p (write-char #\- os)) (write-char c os) (setf last--p nil)) ((setf last--p t))))))) (defgeneric read-lines(entity) (:documentation "Read and return a vector of lines from an entity for subsequent parsing")) (defmethod read-lines((is stream)) (let ((lines nil)) (do ((line (read-line is nil) (read-line is nil))) ((not line)) (push line lines)) (make-array (length lines) :element-type 'string :initial-contents (nreverse lines)))) (defmethod read-lines((source pathname)) (with-open-file(is source :direction :input) (read-lines is))) (defmethod read-lines((source string)) (split-lines source)) (defmethod read-lines((source vector)) source) (defparameter *length-units* '((:in . 1) (nil . 75) (:cm . 254/100) (:em . 72/10) (:ex . 10) (:px . 75) ;; assume 75 dpi (:% . 75/8) ;; 100% is 800 pixels (:pt . 72) (:pc . 12/72) (:mm . 254/10)) "Conversion from various units to inches") (defun length-unit(unit) (or (cdr (assoc unit *length-units*)) (error "Unacceptable unit ~S - acceptable units are ~S" unit (mapcar #'car *length-units*)))) (defun convert-length-unit(size unit) (unless (consp size) (setf size (cons size :px))) (cons (* (/ (car size) (length-unit (cdr size))) (length-unit unit)) unit)) (defmacro when-bind ((var expr) &body body) "Bind VAR to VALUE of expression, execute body if true" `(let ((,var ,expr)) (when ,var ,@body))) (defmacro while (test &body body) "Repeat body while test returns true" `(do () ((not ,test)) ,@body)) (declaim (inline is-prefix-p is-suffix-p)) (defun is-prefix-p(subseq seq &key (start 0) (test #'eql)) "Return true if subseq is a prefix in seq" (let ((m (mismatch seq subseq :start1 start :test test))) (or (not m) (= m (length subseq))))) (defun is-suffix-p(subseq seq &key (test #'eql)) "Return true if subseq is a suffix in seq" (let ((m (mismatch seq subseq :from-end t :test test))) (or (not m) (= m (- (length seq) (length subseq)))))) (defun join-strings(strings &optional (separator #\space)) "Return a new string by joining together the STRINGS, separating each string with a SEPARATOR character or string" (let ((first-p t)) (with-output-to-string(os) (map 'nil #'(lambda(s) (if first-p (setf first-p nil) (write separator :stream os :escape nil)) (write-string s os)) strings)))) (defmacro for ((var start stop) &body body) (let ((gstop (gensym))) `(do ((,var ,start (1+ ,var)) (,gstop ,stop)) ((> ,var ,gstop)) ,@body))) (defun copy-stream(from to &optional count) "Copy from input stream FROM into output stream TO upto COUNT bytes, or until end-of-file if COUNT is NIL" (let ((buf (make-array 8192 :element-type (stream-element-type from)))) (do*((pos (read-sequence buf from) (read-sequence buf from)) (n pos (+ n pos))) ((or (= 0 pos) (and count (> n count))) (when (> pos 0) (write-sequence buf to :end (- pos (- n count))))) (write-sequence buf to :end pos)) )) (defvar *search-path* nil "List of paths to search for dependencies in addition to those specified in settings") (defun find-file(pathname &key (search-path *search-path*)) "Return the first complete pathname for an existing file found by merging pathname with each item in a search path in turn. Returns nil if not found" (flet ((ff(directory) (some #'probe-file (directory (merge-pathnames pathname directory))))) (some #'(lambda(path) (etypecase path (list (some #'ff path)) (string (some #'ff (split-string path :delimiter #\:))) (pathname (ff path)))) search-path))) (defclass line-wrap-stream(fundamental-character-output-stream trivial-gray-stream-mixin) ((stream-line-column :initform 0 :reader stream-line-column) (indentation-level :initform 0 :reader indentation-level :initarg :indentation-level :documentation "Current indentation level") (indentation-character :initform #\space :reader indentation-character) (stream :initarg :stream :reader stream-of :documentation "Actual stream being written to - must be capable of writing characters using write-char") (line-break-test :initform #'wsp-char-p :reader line-break-test :documentation "Function returns true if character can be used as line break") (line-buffer :reader line-buffer-of)) (:documentation "A simple line-wrapping stream filter")) (defmethod initialize-instance :after((stream line-wrap-stream) &key (line-length 80) &allow-other-keys) (setf (slot-value stream 'line-buffer) (make-array (or line-length 4048) :element-type 'character :fill-pointer 0))) (defmethod close((stream line-wrap-stream) &key abort) (unless abort (finish-output stream))) (defmethod stream-finish-output((stream line-wrap-stream)) (write-string (line-buffer-of stream) (stream-of stream)) (setf (fill-pointer (line-buffer-of stream)) 0) (finish-output (stream-of stream))) (defmethod stream-force-output((stream line-wrap-stream)) (write-string (line-buffer-of stream) (stream-of stream)) (setf (fill-pointer (line-buffer-of stream)) 0) (force-output (stream-of stream))) (defmethod stream-clear-output((stream line-wrap-stream)) (setf (fill-pointer (line-buffer-of stream)) 0) (clear-output (stream-of stream))) (defun stream-line-length(stream) (array-total-size (line-buffer-of stream))) (defmethod stream-start-line-p((stream line-wrap-stream)) (zerop (stream-line-column stream))) (defmethod (setf indentation-level)((v integer) (stream line-wrap-stream)) (assert (< v (stream-line-length stream)) (v) "Indentation level must be less than ~D character line length." (stream-line-length stream)) (setf (slot-value stream 'indentation-level) v)) (defmethod stream-write-char((stream line-wrap-stream) (c character)) (let* ((buffer (line-buffer-of stream)) (indent (indentation-level stream)) (len (array-total-size buffer)) (os (stream-of stream))) (with-slots(stream-line-column) stream (flet ((indent() (let ((c (indentation-character stream))) (dotimes(x indent) (write-char c os)) (setf stream-line-column indent)))) (cond ((or (eql c #\newline) (and (>= stream-line-column len) (funcall (line-break-test stream) c))) (write-line buffer os) (setf (fill-pointer buffer) 0 stream-line-column 0)) (t (when (zerop stream-line-column) (indent)) (vector-push c buffer) (incf stream-line-column))) (when (= (fill-pointer buffer) len) ;; buffer full (let ((p (position-if (line-break-test stream) buffer :from-end t))) (cond (p ;; if there is a break character write up until it (write-line (subseq buffer 0 p) os) (setf stream-line-column 0) (do((i (1+ p) (1+ i)) (j 0 (1+ j))) ((>= i len) (setf (fill-pointer buffer) j)) (setf (aref buffer j) (aref buffer i)))) (t ;; no break character - just empty out buffer (write-string buffer os) (setf (fill-pointer buffer) 0))))))))) (defmacro with-block-indentation((n os) &body body) (let ((gn (gensym))) `(let ((,gn (indentation-level ,os))) (unwind-protect (progn (incf (indentation-level ,os) ,n) ,@body) (setf (indentation-level ,os) ,gn))))) (defun last-char(stream) "Return last character written to the stream" (let* ((buffer (line-buffer-of stream)) (l (fill-pointer buffer))) (when (> l 0) (aref buffer (1- l))))) (defun unwrite-char(stream) "Removes last character from buffer and returns it if possible. If buffer was empty returns nil." (let* ((buffer (line-buffer-of stream)) (l (fill-pointer buffer))) (when (> l 0) (vector-pop buffer))))
17,346
Common Lisp
.lisp
418
35
102
0.63389
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
dd770f9bb353680e87b0810349724782f30343d464d376f2da662fa3a2186f3b
7,421
[ -1 ]
7,422
publisher.lisp
willijar_cl-docutils/publisher.lisp
;;;; Front end handling for docutils ;;;; Copyright (C) 2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; $Id: publisher.lisp,v 1.16 2007/08/03 08:16:52 willijar Exp $ ;;;; The processing chain is as follows ;;;; source - a source of characters for the processor ;;;; reader - reads data from source to produce a complete document ;;;; transform - used by readers for pending actions ;;;; writer - formats a document and writes to output ;;;; destination - a destination stream for the formatted document characters (in-package :docutils) (defparameter *revision* '(0 1 1) "(major minor micro) version number. The micro number is bumped for API changes, for new functionality, and for interim project releases. The minor number is bumped whenever there is a significant project release. The major number will be bumped when the project is feature-complete, and perhaps if there is a major change in the design.") (defmethod settings(source) (make-hash-table)) (defgeneric new-document(source) (:documentation "Create and return a new empty document tree (root node).") (:method(source) (make-instance 'docutils.nodes:document :settings (settings nil))) (:method((source pathname)) (make-instance 'docutils.nodes:document :source-path source :settings (settings source)))) (defgeneric read-document(source reader) (:documentation "Create and read a new document using reader from source")) (defgeneric write-document(writer document destination) (:documentation "Write document out to destination using given writer")) (defgeneric write-part(writer part output-stream) (:documentation "Write a document part from writer to an output stream.")) (defgeneric transform(transform) (:documentation "Apply a given transform to its' document node")) (defgeneric (setf document)(document component) (:documentation "Set the document to be processed and reset the component")) (defgeneric do-transforms(transforms document) (:documentation "Apply the transformations to this document in order. Any system messages are added into a dedicated section at the end of the document")) (defgeneric transforms(reader) (:documentation "Return a list of the default transforms class names to be applied after parsing")) ;;; ------------------------------------------------- ;;; Transform api used by readers for pending actions ;;; ------------------------------------------------- (defvar *unknown-reference-resolvers* nil "List of functions to try to resolve unknown references. Unknown references have a 'refname' attribute which doesn't correspond to any target in the document. Called when FinalCheckVisitor is unable to find a correct target. The list should contain functions which will try to resolve unknown references, with the following signature:: (defun reference_resolver(node) \"Returns boolean: true if resolved, false if not.\" )") (defvar *transform-counter* 0 "Used to ensure transforms of the same priority maintain their order") (defclass transform() ((priority :initform 500 :initarg :priority :reader priority :documentation "Numerical priority of this transform, 0 through 999.") (order :initform (incf *transform-counter*) :reader order) (node :initarg :node :reader node :documentation "The node at which this transform is to start")) (:documentation "Docutils transform component abstract base class.")) (defmethod print-object((transform transform) stream) (print-unreadable-object (transform stream :type t :identity t) (format stream "~A:~A" (slot-value transform 'priority) (slot-value transform 'order)))) (defmethod priority((f function)) 950) (defmethod order((f function)) 0) (defmethod transform((f function)) (funcall f *document*)) (defun transform-cmp(a b) "Transforms compared by priority and order in which created" (let ((pa (priority a)) (pb (priority b))) (or (< pa pb) (and (= pa pb) (< (order a) (order b)))))) ;;; ------------------------------------------------- ;;; The standard reader implementation base ;;; ------------------------------------------------- (defclass reader() ((settings :initform nil :initarg :settings :documentation "a-list of overwriding reading and parsing settings")) (:documentation "Base classes to produce a document from input")) (defvar *pending-transforms* nil) (defun add-transform(transform) (push transform *pending-transforms*)) (defmethod read-document :around (source (reader reader)) (let ((*pending-transforms* (transforms reader)) (*document* (new-document source))) ;; we copy reader/parser options into document settings ;; so they provide a permanent record for a particular document (dolist(setting (slot-value reader 'settings)) (setf (setting (first setting) *document*) (rest setting))) (let ((*package* (let ((p (setting :reader-package *document*))) (or (and p (find-package p)) (find-package *default-reader-package*) (find-package :common-lisp-user))))) (call-next-method) (do-transforms *pending-transforms* *document*) *document*))) (defun handle-transform-condition(e document) "Deal with transform errors, adding system message to messages node" (let ((report-level (setting :report-level document)) (halt-level (setting :halt-level document)) (msg nil)) (when (>= (error-severity e) report-level) (format *error-output* "~A~@[ line ~A~] ~A~%" ;; and print (error-level e) (error-line e) (error-message e)) (setf msg (make-node 'system-message e)) (when (error-node e) (add-backref msg (set-id (error-node e) document)))) (if (>= (error-severity e) halt-level) (error e) (invoke-restart 'system-message msg)))) (defmethod do-transforms((transforms list) document) (unless (= 0 (number-children document)) (let ((messages (make-node 'section))) ;; note we don't actually add messages to document until transforms are ;; actually completed i.e. the transforms don't apply ;; to the system message section (setf (slot-value messages 'parent) document) (add-child messages (make-node 'title "Docutils System Messages")) (with-reports-to-node(messages) (handler-bind ((markup-condition #'(lambda(e) (handle-transform-condition e document)))) (dolist(transform (sort (mapcar #'(lambda(transform) (etypecase transform (transform transform) (symbol (make-instance transform :node document)) (function (make-instance 'docutils.transform:simple-transform :function transform :node document)))) transforms) #'transform-cmp)) (transform transform))) (when (> (number-children messages) 1) (setf (slot-value document 'children) (nconc (slot-value document 'children) (list messages)))))))) ;;; ------------------------------------------------- ;;; The standard writer implementation base ;;; ------------------------------------------------- (defclass writer() ((parts :reader parts :initarg :parts :documentation "List of slot names for component parts in the output. The writer should accumulate strings on each part using push.") (settings :initarg :settings :initform nil :reader settings :documentation "Overwritten setting affecting document writing")) (:documentation "Base Class for writing a document")) (defmethod write-document ((writer writer) document (os stream)) (visit-node writer document) (dolist(part (parts writer)) (write-part writer (if (symbolp part) part (car part)) os))) (defmethod write-document(writer document (os (eql 'string))) (with-output-to-string(os) (write-document writer document os))) (defmethod write-part((writer writer) (part symbol) (os stream)) (dolist(s (nreverse (slot-value writer part))) (etypecase s (string (write-string s os)) (character (write-char s os))))) (defgeneric supports-format(writer format) (:documentation "Returns true if given writer supports a specific format")) (defgeneric visit-node(writer entity) (:documentation "Process entity for writer where entity is any entity in the document.")) (defvar *current-writer* nil "Writer currently processing document") (defvar *current-writer-part* nil "current destination writer slot") (defmethod visit-node :around ((writer writer) (document document)) (let ((*document* document) (*current-writer* writer) (docutils.utilities:*language* (setting :language document)) (docutils.utilities::*language-directory* (setting :translations document))) (dolist(part (parts writer)) (if (symbolp part) (setf (slot-value writer part) nil) (setf (slot-value writer (car part)) (reverse (cdr part))))) (call-next-method))) (defmacro with-part((part-name) &body body) `(let ((*current-writer-part* ',part-name)) ,@body)) (defun part-append(&rest values) (assert (every #'(lambda(c) (or (stringp c) (characterp c))) values)) (setf (slot-value *current-writer* *current-writer-part*) (nconc (nreverse values) (slot-value *current-writer* *current-writer-part*)))) (defun part-prepend(&rest values) (setf (slot-value *current-writer* *current-writer-part*) (nconc (slot-value *current-writer* *current-writer-part*) (nreverse values)))) (defmethod visit-node :around (writer entity) (restart-case (call-next-method) (continue() :report (lambda(stream) (format stream "Continue processing after ~S" entity))))) (defmethod visit-node (writer (entity element)) "By default visit children of an element. throw to :skip-siblings to not process further children" (catch :skip-siblings (with-children(child entity) (visit-node writer child)))) (defmethod visit-node (writer (node evaluateable)) (let ((evaluation (evaluate node)) (format (output-format node))) (cond ((stringp format) (part-append (format nil format evaluation))) ((not format) (part-append (write-to-string evaluation)))))) ;;; ------------------------------------------------- ;;; Processing settings and configuration handling ;;; ------------------------------------------------- (defvar *standard-config-files* `(#p"/etc/cl-docutils.conf" ,(merge-pathnames ".cl-docutils.conf" (user-homedir-pathname))) "List of standard docutils configuration files") (defvar *config-files-read* nil "List of configuration files already read.") (defvar *settings-spec* (make-hash-table) "Hash of of configuration parameters") (defgeneric setting(name entity) (:documentation "Return the value of given setting for entity") (:method((name symbol) (hash hash-table)) (gethash name hash)) (:method((name symbol) (list list)) (if (consp (car list)) (let ((a (assoc name list))) (if a (values (cdr a) t) (values nil nil))) (getf list name))) (:method((name symbol) (document document)) (multiple-value-bind(v v-p) (setting name (settings document)) (values (if v-p v (second (gethash name *settings-spec*))) v-p))) (:method((name symbol) (entity null)) (second (gethash name *settings-spec*))) (:method((name symbol) (node node)) (setting name (document node))) (:method((name symbol) (writer writer)) (multiple-value-bind(v v-p) (setting name (settings writer)) (if v-p (values v v-p) (setting name *document*))))) (defgeneric (setf setting)(value key element) (:documentation "Set a setting value for an entity") (:method(value (name symbol) (hash hash-table)) (setf (gethash name hash) value)) (:method (value (name symbol) (document document)) (setf (setting name (settings document)) value))) (defun register-settings-spec(new-spec) (dolist(item new-spec) (setf (gethash (first item) *settings-spec*) (rest item)))) (defmethod settings((document-path pathname)) (let ((settings (make-hash-table)) (*config-files-read* nil)) (dolist(fname (cons (merge-pathnames #p"cl-docutils.conf" document-path) *standard-config-files*)) (read-settings fname settings)) settings)) (defun read-settings(fname &optional (settings (make-hash-table))) (when (and (not (member fname *config-files-read* :test #'equal)) (probe-file fname)) (push fname *config-files-read*) (with-open-file(is fname :direction :input) (do((line (read-line is nil) (read-line is nil))) ((not line)) (when (and (> (length line) 1) (not (line-blank-p line)) (not (char= (char line 0) #\#))) (let ((p (position #\: line))) (if p (let* ((name (intern (string-upcase (strip (subseq line 0 p))) :keyword)) (value (if (< p (1- (length line))) (lstrip (subseq line (1+ p))) "")) (spec (gethash name *settings-spec*))) (if (eql name :config) (read-settings (pathname (strip value)) settings) (setf (gethash name settings) (if spec (restart-case (parse-input (first spec) value) (use-value(&optional (value (third spec))) :report (lambda(s) (format s "Use value <~A> for ~S" value name)) value)) value)))) (warn "~S is not a valid specification line in <~A>" line fname))))))) settings) (register-settings-spec ;; base settings spec `((:generator boolean t "Include a 'Generated by Docutils' credit and link at the end of the document.") (:datestamp symbol :rfc2822 "Include the date/time at the end of the document (UTC) is specified format.") (:source-link boolean nil "Include a 'View document source' link (relative to destination).") (:source-url (string :nil-allowed t) nil "Use the supplied <URL> verbatim for a 'View document source' link; implies --source-link.") (:toc-backlinks (member :type (symbol :nil-allowed t) :set (:top :entry nil)) :entry "Enable backlinks from section headers to top of table of contents or entries (default.") (:footnote-backlinks boolean t "Enable backlinks from footnotes and citations to their references. This is the default.") (:section-numbering boolean t "Enable Docutils section numbering") (:report-level (integer :min 0 :max 10) 4 "Set verbosity threshold; report system messages at or higher than level") (:halt-level (integer :min 0 :max 10) 8 "Set the threshold (<level>) at or above which system messages cause a halt") (:warnings (pathname :nil-allowed t) ,*error-output* "Send the output of system messages (warnings) to <file>.") (:language string "en" "Specify the language of input text (ISO 639 2-letter identifier).") (:translations (pathname :nil-allowed t) ,docutils.utilities::*language-directory* "Path to directory where language translations are stored. Each language has a file, named using its 2-letter identifier containing an a-list mapping translated form to a cannonical form.") (:record-dependencies '(pathname :nil-allowed t) nil "Write dependencies (caused e.g. by file inclusions) to <file>.") (:search-path (pathnames :nil-allowed t :wild-allowed t) nil "Path to search for paths (after source path)") (:config '(pathname :nil-allowed t) nil "Read configuration settings from <file> if it exists.") (:version boolean nil "Show this program's version number and exit.") (:reader-package symbol nil "The package into which Lisp expressions are to be read.") (:default-evaluation-format symbol nil "The format of output from evaluation nodes") (:help boolean nil "Show help message and exit."))) (defgeneric resolve-dependancy(node uri) (:documentation "Return full path corresponding to uri in a node") (:method (node uri) (let ((document (document node))) (find-file uri :search-path `(,(setting :source-path document) ,(setting :search-path document) ,@docutils.utilities::*search-path*)))))
17,518
Common Lisp
.lisp
374
39.072193
80
0.632688
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
432988398d1523281c1f5e7084202515fac41529aadf40e76765b297a7d12570
7,422
[ -1 ]
7,423
nodes.lisp
willijar_cl-docutils/nodes.lisp
;;; Docutils document tree element classes and implementation ;;;; Copyright (C) 2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; $Id: nodes.lisp,v 1.28 2007/07/26 08:56:05 willijar Exp willijar $ (in-package :docutils) (defvar *document* nil "Document (root element) currently being operated on") ;;;; node interface (defgeneric document(node) (:documentation "Return the document root of the tree containing this node")) (defgeneric parent(node) (:documentation "Back-reference to the Node immediately containing this Node.")) (defgeneric language(node) (:documentation "Language for this node")) (defgeneric as-text(element) (:documentation "Return text representation of an element as a string")) (defgeneric (setf as-text)(value element) (:documentation "Set the text value of a node (if allowed)")) (defgeneric line(element) (:documentation "The line number (1-based) of the beginning of this Node in `source`.")) (defgeneric tagname(element) (:documentation "The element generic identifier.")) (defgeneric as-sexp(element) (:documentation "Return lisp s-exp representation of an element")) (defgeneric attribute(node label) (:documentation "Return an attribute of a node corresponding to label")) (defgeneric (setf attribute)(value node label) (:documentation "Set a named attribute of an element")) (defgeneric rem-attribute(node label) (:documentation "Remove an attribute from a node")) (defgeneric make-node(node-type &rest attributes) (:documentation "Make a node with given initialisers")) (defgeneric child(parent index) (:documentation "Return a child at position index")) (defgeneric index(parent child) (:documentation "Return the posiiton of child in element")) (defgeneric add-child(parent child &optional index) (:documentation "Add child as a child node of node, either inserting it at position index or appending it to the end if no index is specified (default)")) (defgeneric rem-child(parent child-ref) (:documentation "Remove a child element from parent")) (defgeneric remove-node(node &optional index) (:documentation "Remove a node")) (defgeneric number-children(node) (:documentation "Reutrn the number of children a node has")) (defgeneric allowed-child-p(parent node &optional index) (:documentation "Return true if node is allowed as a child of parent")) (defmethod make-node((node-type symbol) &rest contents) (let ((node (make-instance node-type))) (apply #'make-node (cons node contents)) node)) (defclass node() ((line :initarg :line :reader line :initform *current-line-number* :documentation "The line number (1-based) of the beginning of this Node in source.") (parent :reader parent :documentation "The parent of this node in the document tree")) (:documentation "Abstract base class of nodes in a document tree")) (defmethod print-object((node node) stream) (print-unreadable-object (node stream :type t :identity t) (format stream "~@[line ~D ~]" (line node)))) (defmethod document((node node)) (or *document* (document (parent node)))) (defmethod namespace((node node)) (or (attribute node :namespace) (namespace (parent node)))) (defmethod language((node node)) (language (parent node))) ;(defmethod attribute((node node) (label (eql :line))) (line node)) ;(defmethod (setf attribute)(value (node node) (label (eql :line))) ; (setf (slot-value node 'line) value)) (defmethod tagname((node node)) (string-downcase (class-name (class-of node)))) (defgeneric setup-child(node chld &optional index) (:documentation "Setup up a child after adding to (arent at index") (:method ((node node) (child node) &optional index) (declare (ignore index)) (when (slot-boundp child 'parent) (error "Unable to setup node ~A as it already has a parent." child)) (setf (slot-value child 'parent) node))) (defclass text(node) ((text :initform "" :initarg :text)) (:documentation "Instances are terminal nodes (leaves) containing text only; no child nodes or attributes.")) (defmethod make-node((node (eql 'text)) &rest attributes) (let ((text (first attributes))) (if (stringp text) (make-instance 'text :text text) (apply #'make-instance (cons 'text attributes))))) (defgeneric copy-of-node(node) (:documentation "Deep copy a node") (:method(node) (make-instance (type-of node)))) (defmethod copy-of-node((node node)) (let ((copy (call-next-method))) (setf (slot-value copy 'line) (slot-value node 'line)) copy)) (defmethod copy-of-node((node text)) (let ((copy (call-next-method))) (setf (slot-value copy 'text) (slot-value node 'text)) copy)) (defmethod copy-of-node((node string)) node) (defmethod as-text((node text)) (slot-value node 'text)) (defmethod as-sexp((node text)) (slot-value node 'text)) (defmethod (setf as-text)((value string) (node text)) (setf (slot-value node 'text) value)) (defclass element(node) ((children :initform nil :documentation "List of child nodes (elements and/or `Text`).") (attributes :initarg :attributes :initform nil :documentation "p-list of attributes associated with this node.")) (:documentation "Abstract base to all specific elements containing attributes and child nodes.")) (defmethod print-object((node element) stream) (print-unreadable-object (node stream :type t :identity t) (format stream "~@[~S ~]~@[line ~D ~]~:[~;~D children~]" (attribute node :name) (line node) (> (number-children node) 0) (number-children node)))) (defmethod make-node ((node element) &rest contents) (do((item (pop contents) (pop contents))) ((not contents)) (etypecase item (symbol (case item (:class (add-class node (pop contents))) (:line (setf (slot-value node 'line) (pop contents))) (t (setf (attribute node item) (pop contents))))) (node (add-child node item)) (list (setf contents (append item contents))))) node) (defmacro with-children((node parent &key (copy nil)) &body body) "Exevute body over the children of a node During execution of the body a catch tags is available for :skip-siblings which will terminate the iteration" `(catch :skip-siblings (map 'nil #'(lambda(,node) ,@body) ,(if copy `(copy-list (slot-value ,parent 'children)) `(slot-value ,parent 'children))))) (defgeneric child-text-separator(element) (:documentation "Return separator for child nodes in as-text") (:method ((element element)) " ")) (defmethod copy-of-node((node element)) (let ((copy (call-next-method))) (setf (slot-value copy 'attributes) (copy-list (slot-value node 'attributes))) (dolist(child (slot-value node 'children)) (add-child copy (copy-of-node child))) copy)) (defun move-children(from-element to-element) "Move the children from one node to another. Returns the list of children in to-element" (check-type from-element element) (check-type to-element element) (dolist(child (slot-value from-element 'children)) (slot-makunbound child 'parent) (add-child to-element child)) (setf (slot-value from-element 'children) nil) (slot-value to-element 'children)) (defmethod language((node element)) (or (attribute node :language) (call-next-method))) (defclass text-element(element) () (:documentation "An element which directly contains text. Its children are all `Text` or `TextElement` subclass nodes")) (defmethod make-node((node text-element) &rest contents) (do((item (pop contents) (pop contents))) ((not (or contents item))) (etypecase item (symbol (when (< (length contents) 1) (error "Invalid initialisation item ~S for ~S node" item node)) (case item (:class (add-class node (pop contents))) (:line (setf (slot-value node 'line) (pop contents))) (t (setf (attribute node item) (pop contents))))) (text (add-child node item)) (text-element (add-child node item)) (list (setf contents (append item contents))) (string (add-child node (make-node 'text item))) (array (add-child node (make-node 'text (join-strings item #\newline)))))) node) (defclass evaluateable(node) ((language :initarg :language :initform :lisp :reader evaluation-language) (output-format :initform nil :initarg :format :reader output-format :documentation "Specifies what format the output is in (for writers).") (expression :initarg :expression :reader expression :documentation "Read expression to be evaluated at some later time.") (result :documentation "Cached result obtained from evaluating expression")) (:documentation "Base for nodes which can be evaluated")) (defclass inline-evaluation(evaluateable text-element) () (:documentation "Inline evaluateable element")) (defclass block-evaluation(evaluateable element) () (:documentation "Block evaluateable element")) (defmethod as-sexp((node evaluateable)) `(eval ',(slot-value node 'expression) ,@(when (slot-boundp node 'result) `(" => " ,(slot-value node 'result))))) (defmethod as-text((node evaluateable)) (write-to-string (slot-value node (if (slot-boundp node 'result) 'result 'expression)) :readably nil :escape nil)) (defmethod copy-of-node((node evaluateable)) (let ((copy (call-next-method))) (dolist(slot '(expression result output-format language)) (when (slot-boundp node slot) (setf (slot-value copy slot) (slot-value node slot)))) copy)) (defvar *default-reader-package* (find-package :common-lisp-user) "The default package Lisp expressions in the document are to be read into") (defvar *evaluator* #'eval "Function to call when evaluating an evaluateable node") (defvar *evaluation-error-hook* nil "Hook to call when there is an error in the evaluator") (defgeneric evaluate(node) (:documentation "Evaluate the node in current dynamic context, returning the result.") (:method ((node evaluateable)) (if (slot-boundp node 'result) (slot-value node 'result) (handler-bind ((style-warning #'muffle-warning) (error #'(lambda(e) (if *evaluation-error-hook* (funcall *evaluation-error-hook* e)) (report :error (write-to-string e :escape nil :readably nil ) )))) (ecase (evaluation-language node) (:lisp (funcall *evaluator* (expression node))))))) (:method((node docutils.nodes:element)) (with-children(child node) (evaluate child)) node) (:method(node) (declare (ignore node)))) (defclass fixed-text-element(text-element) () (:documentation "An element which directly contains preformatted text.")) (defclass docutils.nodes:inline(text-element)()) (defmethod allowed-child-p((element element) child &optional index) (declare (ignore index)) t) (defmethod allowed-child-p((element element) (child docutils.nodes:inline) &optional index) (declare (ignore index)) nil) (defmethod allowed-child-p((element text-element) child &optional index) (declare (ignore index)) nil) (defmethod allowed-child-p((element text-element) (child text) &optional index) (declare (ignore index)) t) (defmethod allowed-child-p((element text-element) (child text-element) &optional index) (declare (ignore index)) t) (defmethod initialize-instance :after ((element element) &key children attributes &allow-other-keys) (dolist(child children) (add-child element child)) (loop for a on attributes by #'cddr do (setf (attribute element (car a)) (cadr a)))) (defmethod setup-child((node element) (child node) &optional index) (if (allowed-child-p node child index) (call-next-method) (let ((msg (format nil "Element type ~S is not allowed as a child of an ~S element" (tagname child) (tagname node)))) (report :error msg) (restart-case (error msg) (add() :report "Ignore error, add element and continue" (call-next-method)) (not-add() :report "Continue without adding element" ))))) ;;; attributes interface (defmethod attribute((node element) (label symbol)) "Return an attribute corresponding to label" (getf (slot-value node 'attributes) label)) (defmethod (setf attribute)(value (node element) (label symbol)) "Set an attribute of an element" (setf (getf (slot-value node 'attributes) label) value)) (defmethod rem-attribute((node element) (label symbol)) (remf (slot-value node 'attributes) label)) (defgeneric add-class(node name) (:documentation "Add class to given node") (:method ((node element) (name string)) (let ((name (strip (string-downcase name)))) (let ((class (attribute node :class))) (if class (unless (member name (split-string class :delimiter #\space) :test #'string=) (setf (attribute node :class) (concatenate 'string class " " name))) (setf (attribute node :class) name)))))) ;;; child interface (defmethod child((node element) (index integer)) "Return a child at position index" (elt (slot-value node 'children) index)) (defmethod index((node element) (child node)) (position child (slot-value node 'children))) (defmethod add-child((node element) (child node) &optional index) (check-type index (or null (integer 0))) (restart-case (setup-child node child index) (continue() :report "Add the child anyway and continue") (drop() :report "Do not add the child and continue" (return-from add-child))) (if (and index (< index (number-children node))) (restart-case (progn (when (> index (length (slot-value node 'children))) (error "Attempting to add ~A beyond the end of the children of ~A" child node)) (if (= 0 index) (push child (slot-value node 'children)) (let ((tail (nthcdr index (slot-value node 'children)))) (setf (cdr tail) (cons (car tail) (cdr tail)) (car tail) child)))) (drop() :report "Do not add the child and continue" (return-from add-child)) (append() :report "Add the child at the end and continue")) (setf (slot-value node 'children) (nconc (slot-value node 'children) (list child)))) child) (defmethod add-child((node element) (children sequence) &optional index) "Append a set of children into a node" (map 'nil (if index #'(lambda(c) (add-child node c index) (incf index)) #'(lambda(c) (add-child node c))) children)) (defmethod add-child((node text-element) (child string) &optional index) (add-child node (make-instance 'text :text child) index)) (defgeneric substitute-node(new old &optional parent) (:documentation "Substitute new node for and old node in document tree")) (defmethod substitute-node((new node) (old node) &optional (parent (parent old))) "Substitute new node for old node in document tree" (substitute-node new (index parent old) parent)) (defmethod substitute-node((new element) (index integer) &optional parent) "Substitute new element for old node at index of parent node" (setup-child parent new index) (slot-makunbound (elt (slot-value parent 'children) index) 'parent) (setf (elt (slot-value parent 'children) index) new)) (defmethod rem-child((node element) (index integer)) "Remove an child element at index" (let ((children (slot-value node 'children))) (if (= index 0) (progn (slot-makunbound (car children) 'parent) (setf (slot-value node 'children) (cdr children))) (let((tail (nthcdr (1- index) children))) (slot-makunbound (cadr tail) 'parent) (setf (cdr tail) (cddr tail)))))) (defmethod rem-child((node element) (item node)) (let ((p (position item (slot-value node 'children)))) (when p (rem-child node p)))) (defmethod remove-node((node node) &optional index) (if index (rem-child node index) (rem-child (parent node) node))) (defmethod as-text((node element)) (join-strings (mapcar #'as-text (slot-value node 'children)) (child-text-separator node))) (defmethod as-sexp((node element)) `((,(class-name (class-of node)) ,@(slot-value node 'attributes) :line ,(line node)) ,@(mapcar #'as-sexp (slot-value node 'children)))) (defmethod number-children((node element)) (length (slot-value node 'children))) (defmethod initialize-instance :after ((node text-element) &key text &allow-other-keys) (when text (let ((text-node (make-node 'text (if (stringp text) text (join-strings text #\newline))))) (setup-child node text-node) (push text-node (slot-value node 'children))))) ;;; mixins (defclass resolvable() ((resolved :initform nil :accessor resolved))) (defclass backlinkable() ((backrefs :initform nil :reader backrefs))) (defun add-backref(element id) (push id (slot-value element 'backrefs))) (defclass root()()) (defclass titular()()) (defclass predecorative()() (:documentation "Category of Node which may occur before Decorative Nodes.")) (defclass prebibliographic(predecorative)() (:documentation "Category of Node which may occur before Bibliographic Nodes.")) (defclass bibliographic(predecorative)()) (defclass decorative()()) (defclass body()()) (defclass general(body)()) (defclass sequential(body)()) (defclass abmonition(body)()) (defclass docutils.nodes:special(body)() (:documentation "Special internal body elements.")) (defclass invisible(prebibliographic)() (:documentation "Internal elements that don't appear in output.")) (defclass part()()) (defclass referential(resolvable)()) (defclass targetable(resolvable) ((referenced :initform nil :accessor referenced))) (defmethod add-child :after(node (child targetable) &optional index) (declare (ignore index)) (set-id child)) (defclass labeled()() (:documentation "Contains a `label` as its first element.")) ;; ================ ;; Title Elements ;; ================ (defclass title(titular prebibliographic text-element)()) (defclass subtitle(titular prebibliographic text-element)()) (defclass rubric(titular text-element)()) ;; ======================== ;; Bibliographic Elements ;; ======================== (defclass docinfo(bibliographic element)()) (defclass author(bibliographic text-element)()) (defclass authors(bibliographic element)()) (defclass organization(bibliographic text-element)()) (defclass address(bibliographic text-element)()) (defclass contact(bibliographic text-element)()) (defclass version(bibliographic text-element)()) (defclass revision(bibliographic text-element)()) (defclass status(bibliographic text-element)()) (defclass date(bibliographic text-element)()) (defclass copyright(bibliographic text-element)()) ;; ===================== ;; Decorative elements ;; ===================== (defclass decoration(decorative element)()) (defclass header(decorative element)()) (defclass footer(decorative element)()) ;; ===================== ;; Structural elements ;; ===================== (defclass structural()()) ;; ====================== ;; Root Document Element ;; ====================== (defgeneric cmp(a b) (:documentation "Comparison function for ordering sequences of entities")) (defclass document(root structural element) ((namespace :reader namespace :initarg :namespace :initform nil) (settings :reader settings :initform (make-hash-table) :initarg :settings :documentation "Runtime settings data record.") (current-id :initform 0 :initarg :id-start :accessor current-id :documentation "current id.")) (:default-initargs :line 0) (:documentation "The main document root element")) (defmethod (setf settings)((value list) (document document)) (if (consp (first value)) (map 'nil #'(lambda(v) (setf (gethash (car v) (settings document)) (cdr v))) value) (loop :for a :on value :by #'cddr :do (setf (gethash (first a) (settings document)) (second a))))) (defmethod initialize-instance :after ((document document) &key source-path &allow-other-keys) (when source-path (setf (setting :source-path document) source-path))) (defmethod parent((node document)) nil) (defmethod document((node document)) node) (defmethod language((node document)) (or (attribute node :language) (setting :language node) *language*)) (defclass section(structural element)()) (defclass topic(structural element) () (:documentation "Topics are terminal, 'leaf' mini-sections, like block quotes with titles, or textual figures. A topic is just like a section, except that it has no subsections, and it doesn't have to conform to section placement rules.")) (defmethod allowed-child-p((parent element) (child topic) &optional index) (declare (ignore index)) nil) (defmethod allowed-child-p((parent structural) (child topic) &optional index) (declare (ignore index)) t) (defmethod allowed-child-p((parent topic) (child structural) &optional index) (declare (ignore index)) nil) (defclass sidebar(structural element)() (:documentation " Sidebars are like miniature, parallel documents that occur inside other documents, providing related or reference material. A sidebar is typically offset by a border and 'floats' to the side of the page; the document's main text may flow around it. Sidebars can also be likened to super-footnotes; their content is outside of the flow of the document's main text.")) (defclass transition(structural element)()) (defmethod allowed-child-p((parent section) (child structural) &optional index) (declare (ignore index)) t) (defmethod allowed-child-p((parent document) (child structural) &optional index) (declare (ignore index)) t) (defmethod allowed-child-p(parent (child structural) &optional index) (declare (ignore index)) nil) ;; =============== ;; Body elements ;; =============== (defclass paragraph(general text-element)()) (defclass compound(general element)()) (defclass container(general element)()) (defclass bullet-list(sequential element)()) (defclass enumerated-list(sequential element)()) (defclass list-item(part element)()) (defclass definition-list(sequential element)()) (defclass definition-list-item(part element)()) (defclass term(part text-element)()) (defclass classifier(part text-element)()) (defclass definition(part element)()) (defclass field-list(sequential element)()) (defclass field(part element)()) (defclass field-name(part text-element)()) (defclass field-body(part element)()) (defmethod allowed-child-p((parent field-list) child &optional index) (declare (ignore index)) (typep child 'field)) (defmethod print-object((node field-name) stream) (print-unreadable-object (node stream :type t :identity t) (format stream "~S ~@[line ~D ~]" (as-text node) (line node)))) (defmethod print-object((node field) stream) (print-unreadable-object (node stream :type t :identity t) (format stream "~S ~@[line ~D ~]" (when (child node 0) (as-text (child node 0))) (line node)))) (defclass option(part element)()) (defmethod child-text-separator((element option)) "") (defclass option-argument(part text-element)()) (defmethod as-text((element option-argument)) (concatenate 'string (or (attribute element :delimiter) " ") (call-next-method))) (defclass option-group(part element)()) (defmethod child-text-separator((element option-group)) ", ") (defclass option-list(sequential element)()) (defclass option-list-item(part element)()) (defmethod child-text-separator((element option-list-item)) " ") (defclass option-string(part text-element)()) (defclass description(part element)()) (defclass literal-block(general fixed-text-element)()) (defclass doctest-block(general fixed-text-element)()) (defclass line-block(general element)()) (defclass line(general text-element) ((indent :initform nil))) (defclass admonition(element)()) (defclass block-quote(general element)()) (defclass attribution(part text-element)()) (defclass attention(admonition element)()) (defclass caution(admonition element)()) (defclass danger(admonition element)()) (defclass docutils.nodes:error(admonition element)()) (defclass important(admonition element)()) (defclass note(admonition element)()) (defclass tip(admonition element)()) (defclass hint(admonition element)()) (defclass docutils.nodes:warning(admonition element)()) (defclass comment(docutils.nodes:special invisible fixed-text-element)()) (defclass substitution-definition(docutils.nodes:special invisible text-element)()) (defclass target(docutils.nodes:special invisible docutils.nodes:inline text-element targetable)()) (defmethod allowed-child-p((element element) (child target) &optional index) (declare (ignore index)) t) (defclass footnote(general element targetable labeled backlinkable)()) (defclass citation(general element targetable labeled backlinkable)()) (defclass label(part text-element)()) (defmethod allowed-child-p((element element) (child label) &optional index) (and (typep element 'labeled) (= (or index (number-children element)) 0))) (defclass figure(general element)()) (defclass caption(part text-element)()) (defclass legend(part element)()) (defclass table(general element)()) (defclass tgroup(part element)()) (defclass colspec(part element)()) (defclass thead(part element)()) (defclass tbody(part element)()) (defclass row(part element)()) (defclass entry(part element)()) (defclass system-message(docutils.nodes:special prebibliographic element backlinkable)()) (defmethod allowed-child-p((parent field) child &optional index) (let ((index (or index (number-children parent)))) (typecase child (system-message t) (field-name (evenp index)) (field-body (oddp index))))) (defmethod add-child((node text-element) (child system-message) &optional index) "Add system message to part of a text element" (assert (not index)) (add-child (parent node) child)) (defmethod make-node((node system-message) &rest message-args) (let* ((message (if (and (= 1 (length message-args)) (typep (car message-args) 'markup-condition)) (let* ((e (car message-args)) (line (error-line e)) (level (error-level e)) (source (error-source e)) (data (error-data e))) (setf (attribute node :level) level) (when source (setf (attribute node :source) source)) (when line (setf (slot-value node 'line) line)) (when data (add-child node (make-node 'literal-block data))) (when-bind(backrefs (error-backrefs e)) (dolist(bref backrefs) (add-backref node bref))) (error-message e)) (apply #'format (cons nil message-args))))) (let ((p (make-node 'paragraph))) (add-child node p 0) (add-child p message)) node)) (defmethod as-text((node system-message)) (format nil "~A: ~A~@[, source line ~D~]" (attribute node :level) (call-next-method) (line node)) #| old definition (format nil "~s:~s: (~s/~s) ~s" (attribute node :source) (line node) (attribute node :type) (attribute node :level) (call-next-method))) |#) (defmethod error-severity((c system-message)) (getf +error-levels+ (attribute c :level) 6)) (defclass pending(docutils.nodes:special invisible element) () (:documentation "The 'pending' element is used to encapsulate a pending operation: the operation (transform), the point at which to apply it, and any data it requires.")) (defclass raw(docutils.nodes:special docutils.nodes:inline prebibliographic fixed-text-element)() (:documentation "Raw data that is to be passed untouched to the Writer.")) (defmethod allowed-child-p((parent element) (child raw) &optional index) (declare (ignore index)) t) ;; ================= ;; inline elements ;; ================= (defclass emphasis(docutils.nodes:inline)()) (defclass strong(docutils.nodes:inline)()) (defclass literal(docutils.nodes:inline)()) (defclass reference(general docutils.nodes:inline referential)()) (defclass footnote-reference(docutils.nodes:inline referential)()) (defclass citation-reference(docutils.nodes:inline referential)()) (defclass substitution-reference(docutils.nodes:inline)()) (defclass title-reference(docutils.nodes:inline)()) (defclass abbreviation(docutils.nodes:inline)()) (defclass acronym(docutils.nodes:inline)()) (defclass superscript(docutils.nodes:inline)()) (defclass subscript(docutils.nodes:inline)()) (defclass image(general docutils.nodes:inline)()) (defmethod as-text((node image)) (or (attribute node :alt) "")) (defclass equation(general text-element)()) (defclass math(general docutils.nodes:inline)()) (defclass problematic(docutils.nodes:inline)()) (defclass generated(docutils.nodes:inline)()) (defmethod allowed-child-p((element element) (child reference) &optional index) (declare (ignore index)) t) (defmethod allowed-child-p((element element) (child image) &optional index) (declare (ignore index)) t) #| (defmethod allowed-child-p((element element) (child equation) &optional index) (declare (ignore index)) t) |# ;; ======================== ;; output specific elements ;; ======================== ;; Element tree traversal (defmacro with-nodes((node root &key (copy nil)) &body body) "Traverse a node tree depth first executing body for side affects. The body is executed then children are traversed (if an element). During execution of the body catch tags are available for :skip-children and :skip-siblings to finish processing children of current node or children of parent node. Execution is inside a nil block. Returns nil" (let ((func (gensym))) `(block nil (labels((,func(,node) (catch :skip-children ,@body (when (typep ,node 'element) (catch :skip-siblings (map 'nil #',func ,(if copy `(copy-list (slot-value ,node 'children)) `(slot-value ,node 'children)))))))) (,func ,root))))) (defmacro with-attributes((key value node &key (copy nil)) &body body) "Interate body over the attributes of a node setting key and value in turn. If keyword copy is true, the iteration will be over a list of the attribute list may be modified during iteration, otherwise it may not." (let ((a (gensym))) `(loop :for ,a :on ,(if copy `(copy-list (slot-value ,node 'attributes)) `(slot-value ,node 'attributes)) :by #'cddr :do (let ((,key (car ,a)) (,value (cadr ,a))) ,@body)))) (defun next-sibling(element) (cadr (member element (slot-value (parent element) 'children)))) (defun prev-sibling(element) (loop :for a :on (slot-value (parent element) 'children) :when (eql (cadr a) element) :return (car a))) (defun set-id(node &optional (document (document node)) (ids (ids document))) "This will set and return the id for a node." (let ((namespace (namespace document)) (id (attribute node :id))) (flet((new-id() (format nil "~@[~A.~]id~D" namespace (incf (current-id document))))) (if id (progn (when namespace (let ((prefix (concatenate 'string namespace "."))) (unless (= 0 (search prefix id)) (setf id (concatenate 'string prefix id))))) (unless (eql node (gethash id ids node)) (report :severe (format nil "Duplicate ID: ~S." id)))) (let ((name (attribute node :name))) (when (and name (not namespace)) (setf id (make-id name))) (when (or (not id) (gethash id ids)) (setf id (do ((id (new-id) (new-id))) ((not (gethash id ids)) id)))))) (setf (gethash id ids) node (attribute node :id) id)))) ;;; Collated information (defmacro collate-nodes((node root) test) (let((targets (gensym))) `(let ((,targets nil)) (with-nodes(,node ,root) (when ,test (push ,node ,targets))) (nreverse ,targets)))) (defgeneric implicit-target-p(node) (:documentation "Return true if an implicit target") (:method (node) nil) (:method ((node section)) t)) (defun refnames(element) "Return mapping of names to lists of referencing nodes." (let ((refnames (make-hash-table :test 'equal))) (with-nodes(node element) (when (typep node 'element) (let ((refname (attribute node :refname))) (when refname (push node (gethash refname refnames)))))) refnames)) (defun refids(element) "Mapping of ids to lists of referencing nodes." (let ((refids (make-hash-table :test 'equal))) (with-nodes(node element) (when (typep node 'element) (let ((refid (attribute node :refid))) (when refid (push node (gethash refid refids)))))) refids)) (defun ids(element) "Return mapping of ids to nodes in element." (let ((ids (make-hash-table :test #'equal))) (with-nodes(node element) (when (typep node 'element) (when-bind(id (attribute node :id)) (setf (gethash id ids) node)))) ids)) (defun nameids(element &optional (ids (ids (document element)))) "Mapping of names to unique id's." (let ((nameids (make-hash-table :test #'equal)) (nametypes (make-hash-table :test #'equal))) (with-nodes(node element) (when (typep node 'element) (when-bind(name (attribute node :name)) (let ((id (or (attribute node :id) (set-id node (document node) ids)))) (if (gethash name nameids) ;; duplicate (set-duplicate-name-id ids nameids nametypes node) (progn (setf (gethash name nameids) id) (setf (gethash name nametypes) (not (implicit-target-p node))))))))) nameids)) (defun named-node(element name) (with-nodes(node element) (when (and (typep node 'element) (equalp (attribute node :name) name)) (return-from named-node node)))) (defun set-duplicate-name-id(ids nameids nametypes node) "The following state transition table shows how `self.nameids` wand `self.nametypes`change with new input and what actions are performed: ==== ===== ======== ======== ======= ==== ===== ===== Old State Input Action New State Notes ----------- -------- ----------------- ----------- ----- ids types new type sys.msg. dupname ids types ==== ===== ======== ======== ======= ==== ===== ===== -- -- explicit -- -- new True -- -- implicit -- -- new False None False explicit -- -- new True old False explicit implicit old new True None True explicit explicit new None True old True explicit explicit new,old None True [#]_ None False implicit implicit new None False old False implicit implicit new,old None False None True implicit implicit new None True old True implicit implicit new old True ==== ===== ======== ======== ======= ==== ===== ===== .. [#] Do not clear the name-to-id map or invalidate the old target if both old and new targets are external and refer to identical URIs. The new target is invalidated regardless." (let* ((name (attribute node :name)) (id (attribute node :id)) (explicit (not (implicit-target-p node))) (old-id (gethash name nameids)) (old-explicit (gethash name nametypes))) (setf (gethash name nametypes) (or old-explicit explicit)) (flet ((dupname(node) (setf (attribute node :dupname) (attribute node :name)) (rem-attribute node :name))) (if explicit (if old-explicit (let ((level :warn)) (when old-id (let ((old-node (gethash old-id ids))) (unless (when-bind(refuri (attribute node :refuri)) (and (attribute old-node :name) (equal (attribute old-node :refuri) refuri))) (setf level :info) (dupname old-node) (remhash name nameids)))) (report level `("Duplicate explicit target name: ~s." ,name) :node node :backrefs (list id)) (dupname node)) (progn (setf (gethash name nameids) id) (when old-id (dupname (gethash old-id ids))))) (progn (when (and old-id (not old-explicit)) (remhash name nameids) (dupname (gethash old-id ids))) (dupname node)))) (when (or (not explicit) (and (not old-explicit) old-id)) (report :info `("Duplicate explicit target name: ~s." ,name) :node node :backrefs (list id))))) ;;; Accessors for document components (defgeneric docinfo(document) (:documentation "Return the docinfo component of a document") (:method((document document)) (with-children(node document) (when (typep node 'docinfo) (throw :skip-siblings node))))) (defgeneric title(entity) (:documentation "Return the title for an entity") (:method((element element)) (docutils:with-children(node element) (when (typep node 'docutils.nodes:title) (return-from title (as-text node)))))) (defgeneric abstract(entity) (:documentation "Return the abstract of an entity") (:method ((document document)) (docutils:with-children(node document) (when (and (typep node 'docutils.nodes:topic) (string-equal (title node) "abstract")) (return-from abstract node))))) (defgeneric field-value(name field-list) (:documentation "Return the field text for a specific field name") (:method(name field-list) (let ((name (string-upcase name)) (results nil)) (with-children(item field-list) (etypecase item (field (when (string-equal name (as-text (child item 0))) (push (as-text (child item 1)) results))) (bibliographic (when (string-equal name (string (type-of item))) (push (as-text item) results))))) (nreverse results))) (:method(name (document document)) (field-value name (docinfo document))))
39,320
Common Lisp
.lisp
908
37.903084
91
0.66603
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
88005f4360d3d4c3a1b3108f9c9aec3ebf8fe396cbe77395649c8895227ec887
7,423
[ -1 ]
7,424
defpackage.lisp
willijar_cl-docutils/defpackage.lisp
;;;; rstructuredtext implementation for Common Lisp ;;;; Copyright (C) 2002-2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details (in-package :cl-user) ;; we put the node names in their own package so they can be imported ;; (or not) separately if need be however this is not recommended ;; note some symbols clash with common-lisp names and need to be ;; shadowed if this package is used. (defpackage :docutils.nodes (:documentation "Package containing standard docutils Node names") (:use) ;; do not import common lisp (:export #:node #:element #:text #:text-element #:document #:resolvable #:backlinkable #:root #:titular #:predecorative #:prebibliographic #:bibliographic #:decorative #:body #:general #:sequential #:abmonition #:special #:invisible #:part #:referential #:targetable #:title #:subtitle #:rubric #:docinfo #:author #:authors #:organization #:address #:contact #:version #:revision #:status #:date #:copyright #:decoration #:header #:footer #:structural #:section #:topic #:sidebar #:transition #:paragraph #:compound #:container #:bullet-list #:enumerated-list #:list-item #:definition-list #:definition-list-item #:term #:classifier #:definition #:field-list #:field #:field-name #:field-body #:option #:option-argument #:option-group #:option-list #:option-list-item #:option-string #:description #:literal-block #:doctest-block #:line #:line-block #:attribution #:attention #:caution #:error #:block-quote #:system-message #:danger #:admonition #:important #:note #:tip #:hint #:warning #:comment #:substitution-definition #:target #:footnote #:citation #:label #:figure #:caption #:legend #:table #:tgroup #:colspec #:thead #:tbody #:row #:entry #:system #:pending #:inline #:raw #:emphasis #:strong #:literal #:reference #:footnote-reference #:citation-reference #:substitution-reference #:title-reference #:abbreviation #:acronym #:superscript #:subscript #:image #:problematic #:generated #:meta #:equation #:math #:evaluateable #:inline-evaluation #:block-evaluation)) (defpackage docutils.utilities (:documentation "Common utilities used by several docutils components") (:use :cl :trivial-gray-streams) (:import-from :docutils.nodes #:document #:line) (:import-from :data-format-validation #:split-string) (:export #:+wsp+ #:line-blank-p #:escape2null #:unescape #:split-lines #:make-id #:normalise-name #:whitespace-normalise-name #:indented-block #:indent-level #:line-length #:rstrip #:strip #:lstrip #:wsp-char-p #:canonical-text #:translated-text #:*language* #:*language-directory* #:author-separators #:read-lines #:translate-text #:canonical-text #:babel #:latex-quotes #:latex-double-quote-replacement #:namespace #:make-name #:*namespace* #:length-unit #:convert-length-unit #:when-bind #:while #:for #:is-suffix-p #:is-prefix-p #:copy-stream #:find-file #:search-path* #:line-wrap-stream #:with-block-indentation #:last-char #:unwrite-char)) (defpackage :docutils (:documentation "Document handling and structured text parsing") (:use :cl :docutils.utilities :docutils.nodes :data-format-validation) (:shadowing-import-from :cl #:warning #:error #:inline #:special) (:shadowing-import-from :docutils.nodes #:date) (:export ;; source interface #:read-lines #:settings #:new-document ;; reader interface #:transforms #:reader #:*document* #:read-document #:*unknown-reference-resolvers* ;; transforming interface #:transform #:node #:field-value #:*field-types* ;; writer interface #:writer #:supports-format #:visit-node #:parts #:part-append #:part-prepend #:write-document #:with-part #:write-part ;; error reporting #:report #:record-system-message #:error-level #:error-message #:error-text-block #:error-line #:error-severity #:error-node #:markup-condition #:with-reports-to-node #:error-data ;; node interface #:document #:parent #:as-text #:line #:as-sexp #:add-class #:make-node #:attribute #:rem-attribute #:child #:rem-child #:index #:add-child #:allowed-child-p #:with-nodes #:with-children #:number-children #:with-attributes #:next-sibling #:prev-sibling #:set-id #:add-class #:copy-of-node #:language #:*current-line-number* #:collate-nodes #:targets #:refnames #:refids #:source #:nameids #:ids #:named-node #:backrefs #:referenced #:remove-node #:substitute-node #:resolved #:add-backref ;; settings interface #:register-settings-spec #:setting ;; evaluateable nodes interface #:evaluate #:*evaluation-error-hook* #:*evaluator* #:*default-reader-package* #:output-format #:evaluation-language ;;simple example usage #:read-rst #:write-html #:write-latex)) (defpackage :docutils.transform (:documentation "Package containing standard docutils Node names") (:use :cl :docutils :docutils.utilities) (:import-from :data-format-validation #:format-output #:date #:split-string) (:shadow #:docinfo) (:export #:decorations #:final-checks #:filter-messages #:filter #:contents #:sectnum #:class-attribute #:target-notes #:doctitle #:docinfo #:substitutions #:chained-targets #:simple-transform #:anonymous-hyperlinks #:indirect-hyperlinks #:footnotes #:external-targets #:internal-targets #:fignum #:evaluate #:evaluate-transform #:*evaluator* #:resolve-media))
5,540
Common Lisp
.lisp
107
47.934579
78
0.708495
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
67e72b73090beb038f934fd28c496eb8c5c4f604a6206015453692d925a390a6
7,424
[ -1 ]
7,425
markup.lisp
willijar_cl-docutils/extensions/markup.lisp
;;;; Misc string and vector handling for docutils ;;;; Copyright (C) 2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; $Id: markup.lisp,v 1.3 2006/08/08 08:15:34 willijar Exp willijar $ (in-package :asdf) (defpackage :docutils.writer.markup (:documentation "Latex writer for docutils") (:use :cl) (:import-from :docutils.parser.rst #:rst-reader) (:import-from :jarw.port #:make-mutex #:with-lock) (:import-from :docutils #:read-document #:document #:write-part) (:import-from :docutils.writer.html #:html-writer #:body) (:import-from :markup #:html)) (in-package :docutils.writer.markup) (export '(markup::rst) (find-package :markup)) (defvar *markup-rst-reader* 'docutils.parser.rst:rst-reader) (defvar *markup-rst-writer* 'docutils.writer.html:html-writer) (defmethod html((stream stream) (tag (eql 'markup::rst)) &optional attr content) (when (first content) (html stream (read-document (first content) (make-instance (getf attr :reader *markup-rst-reader*))) attr))) (defmethod html((stream stream) (document docutils.nodes:document) &optional attr content) (declare (ignore content)) (unless (getf attr :initial-header-level) (setf (getf attr :initial-header-level) (1+ markup:*section-level*))) (let ((writer (make-instance (getf attr :writer *markup-rst-writer*) :settings attr))) (docutils:visit-node writer document) (docutils:write-part writer 'body stream))) (defmethod html(stream (node docutils.nodes:node) &optional attr content) (declare (ignore attr content)) ;; we clone the document with settings - note parent of node will ;; be the original parent NOT the clone. (let ((document (make-instance 'docutils.nodes:document :settings (docutils::settings (document node))))) (setf (slot-value document 'docutils::children) (list node)) (html stream document))) (defun markup::parse-restructured-text(text) `(markup::rst ,text)) (in-package :docutils.writer.latex) (defmethod visit-node ((writer latex-writer) (node evaluateable)) (case (output-format node) (:markup (part-append (with-output-to-string(os) (markup:latex os (evaluate node))))) (:latex (part-append (evaluate node))) (t (call-next-method)))) (in-package :docutils.writer.html) (defmethod visit-node((writer html-writer) (node evaluateable)) (case (output-format node) (:markup (part-append (with-output-to-string(os) (markup:html os (evaluate node))))) (:latex (part-append (evaluate node))) (t (call-next-method)))) ;; make markup the default (register-settings-spec '((:default-evaluation-format symbol nil "The format of output from evaluation nodes")))
2,994
Common Lisp
.lisp
70
37.242857
74
0.674459
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0d13d9d36f08e400fd0e1bfbf16a8ebb1171d106454bffae450ba1374289015c
7,425
[ -1 ]
7,426
media.lisp
willijar_cl-docutils/extensions/media.lisp
;; Extend docutils to use the jarw media server ;; Copyright (C) 2009 Dr. John A.R. Williams ;; Author: Dr. John A.R. Williams <[email protected]> ;; Keywords: ;;; Copying: ;; This file is part of docutils.extensions ;; 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. ;; FOOBAR 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 <http://www.gnu.org/licenses/>. ;;; Commentary: ;; ;;; Code: (in-package :docutils.writer.html) (defclass html-writer-using-media-server(html-writer) ()) (export 'html-writer-using-media-server) (setq docutils.writer.markup::*markup-rst-writer* 'html-writer-using-media-server) (defmethod html-url((writer html-writer-using-media-server) (uri string) &rest args) (if (equalp (getf args :content-type) "text/x-eqn") (let ((media-server jarw.media:*media-server*)) (when media-server (jarw.media:media-variant-url (jarw.media:media-variant (jarw.media:register-media uri media-server :content-type "text/x-eqn") media-server (getf args :output-format "image/png")) media-server))) uri)) (defmethod html-url((writer html-writer-using-media-server) (uri pathname) &rest args) (let ((media-server jarw.media:*media-server*)) (if media-server (jarw.media:media-variant-url (jarw.media:media-variant (jarw.media:register-media uri media-server) media-server (getf args :output-format (or (find (jarw.media:file-suffix-content-type uri) '("image/png" "image/gif" "image/jpeg") :test #'string-equal) "image/png")) args) media-server) (namestring uri)))) (in-package :docutils) (defun publish(src) (write-html (merge-pathnames (make-pathname :type "html") src) (read-rst src))) ;;;; VIDEO handling (in-package :docutils) (defclass docutils.nodes::video(general element)()) (in-package :docutils.parser.rst) (def-directive video(parent uri &option (height length) (width length) (align align) (class class)) (let((node (make-node 'video))) (add-child parent node) (when (find #\space uri) (report :error "Image URI contains whitespace" :line *current-line-number*)) (map nil #'(lambda(k v) (when v (setf (attribute node k) v))) '(:height :width :align :uri :class) (list height width align uri class)) node)) (in-package :docutils.writer.html) (defmethod visit-node((writer html-writer) (node docutils.nodes::video)) (let* ((atts (list :controls 1)) (uri (attribute node :uri))) (with-attributes(k v node) (setf (getf atts k) v)) (setf (getf atts :src) uri) (remf atts :uri) (flet ((set-size(symb) (when (getf atts symb) (setf (getf atts symb) (format nil "~,f~:[%~;~:*~A~]" (car (getf atts symb)) (cdr (getf atts symb))))))) (set-size :width) (set-size :height)) (part-append (start-tag nil "div" (image-div-atts node))) (part-append (start-tag node "video" atts) #\newline) (part-append (format nil " <a href=~S>Play: ~A</a>~%" uri uri)) (part-append "</video>" #\newline) (part-append "</div>" #\newline))) (in-package :docutils.writer.latex) (defmethod visit-node((writer latex-writer) (node docutils.nodes::video)) (part-append (format nil (if (typep (parent node) 'text-element) " (Video: ~A) " "~%~%{\bf Video:} ~A~%~%") (attribute node :uri))))
4,382
Common Lisp
.lisp
101
34.356436
82
0.598636
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0a0ea11d1f4293c4956159782a7dee6e05c0f1e49d5956af7acc3e4a4f35cab3
7,426
[ -1 ]
7,427
attachments.lisp
willijar_cl-docutils/extensions/attachments.lisp
;; Attachments directive ;; Copyright (C) 2009 Dr. John A.R. Williams ;; Author: Dr. John A.R. Williams <[email protected]> ;; Keywords: ;;; Copying: ;; This file is part of CL-DOCUTILS ;; 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. ;; FOOBAR 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 <http://www.gnu.org/licenses/>. ;;; Commentary: ;; ;;; Code: (in-package :docutils) (defclass attachment(element invisible) () (:documentation "Base node type for attachments")) (defmethod write-node((node attachment) (os line-wrap-stream)) (format os ".. attachment:: ~a~%" (attribute node :name)) (with-block-indentation(3 os) (format os ":content-type: ~A~%~%" (attribute node :content-type)) (format os ":encoding: ~A~%~%" (attribute node :encoding)) (write (attribute node :content) :stream os))) (defmethod visit-node(writer (node attachment)) (declare (ignore writer))) (in-package :docutils.parser.rst) ;; note that docutils doesn not deal with attachment content at all. It is up ;; to applications to parse and decode the data. (def-directive attachment (parent name &allow-spaces &option content-type encoding &content content) (add-child parent (make-node 'docutils::attachment :name name :encoding encoding :content-type content-type :content content)))
1,981
Common Lisp
.lisp
47
36.531915
77
0.680251
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
4cc4beba239206fb9d97e3413a2104e290225ee9cb8b0bd07ebab0cd428e8219
7,427
[ -1 ]
7,428
latex.lisp
willijar_cl-docutils/writers/latex.lisp
;;;; Misc string and vector handling for docutils ;;;; Copyright (C) 2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; $Id: html.lisp,v 1.4 2006/07/07 18:43:20 willijar Exp $ (defpackage :docutils.writer.latex (:documentation "Latex writer for docutils") (:use :cl :docutils :docutils.utilities :docutils.nodes :cl-ppcre :trivial-gray-streams) (:shadowing-import-from :cl #:warning #:error #:inline #:special) (:import-from :data-format-validation #:join-strings #:+ws+ #:split-string) (:export #:latex-writer #:latex-output-stream)) (in-package :docutils.writer.latex) (docutils:register-settings-spec `((:latex-document-class string "article" "Specify documentclass.") (:latex-document-options string "10pt,a4paper" "Specify document options. Multiple options can be given, separated by commas.") (:use-latex-footnotes boolean nil "Use LaTeX footnotes. LaTeX supports only numbered footnotes (does it?). Default: no, uses figures.") (:footnote-references (member :type symbol :set (:superscript :brackets)) :brackets "Format for footnote references: one of :superscript or :brackets.") (:use-latex-citations boolean nil "Default: no, uses figures which might get mixed with images.") (:attribution (member :type (symbol :nil-allowed t) :set (:dash :parentheses nil)) :dash "Format for block quote attributions: one of 'dash', 'parentheses' or 'nil'") (:latex-stylesheet pathname nil "Specify a stylesheet file. The file will be \"input\" by latex in ' the document header. Default is no stylesheet") (:stylesheet-path pathname nil "Specify a stylesheet file, relative to the current working directory. Overrides --stylesheet.") (:use-latex-toc boolean nil "Table of contents by docutils or latex (default). Latex (writer) supports only one ToC per document, but docutils does not write pagenumbers.") (:use-latex-docinfo boolean nil "Let LaTeX print author and date, do not show it in docutils document info.") (:hyperlink-colour string "blue" "Color of any hyperlinks embedded in text") (:print-hyperlink-url boolean t "If true urls are printed after the the hyperlink (for printed documents)") (:compound-enumerators boolean nil "Enable compound enumerators for nested enumerated lists ") (:section-prefix-for-enumerators boolean nil "Enable section (\".\" subsection ...) prefixes for compound enumerators. This has no effect without :compound-enumerators.") (:section-enumerator-separator string "-" "Set the separator between section number and enumerator for compound enumerated lists.") (:use-verbatim-when-possible boolean nil "When possibile, use verbatim for literal-blocks. Default is to always use the mbox environment.") (:table-style (member :type symbol :set (:standard :booktabs :nolines)) :standard "Table style. \"standard\" with horizontal and vertical lines, \"booktabs\" (LaTeX booktabs style) only horizontal lines above and below the table and below the header or \"nolines\".") (:graphicx-option (member :type (symbol :nil-allowed t) :set (:dvips :pdftex :auto nil)) nil "LaTeX graphicx package option. Possible values are \"dvips\", \"pdftex\". \"auto\" includes LaTeX code to use \"pdftex\" if processing with pdf(la)tex and dvips otherwise.") (:latex-font-encoding string "" "Possible values are \"T1\", \"OT1\", \"\" or some other fontenc option. The font encoding influences available symbols, e.g. \"<<\" as one character. Default is "" which leads to package \"ae\" (a T1 emulation using CM fonts)."))) (defclass latex-table() ((latex-type :initform "longtable" :initarg :latex-type :reader latex-type) (table-style :initform "booktabs" :initarg :table-style :reader table-style) (open :initform nil :accessor open-p) (caption :initform nil :reader caption) (attributes :initform nil) (col-width :initform nil) (preamble-written :initform nil) col-specs in-head (cell-in-row :reader entry-number) (rowspan :initform nil)) (:documentation " Manage a table while traversing. Maybe change to a mixin defining the visit/departs, but then class Table internal variables are in the Translator.")) (flet ((set-slots(entity slots values) (map nil #'(lambda(s v) (setf (slot-value entity s) v)) slots values ))) (defun open-table(table) (set-slots table '(open col-specs caption in-head preamble-written) '(t nil nil nil nil))) (defun close-table(table) (set-slots table '(open col-specs caption) '(nil nil nil)))) (defun used-packages(table) (if (eql (table-style table) :booktabs) "\\usepackage{booktabs}" "")) (defun vertical-bar(table) (if (eql (table-style table) :standard) "|" "")) (defun opening(table) (format nil "\\begin{~A}[c]~%" (latex-type table))) (defun closing(table) (let ((style (table-style table))) (format nil "~A\\end{~A}" (cond ((equal style :booktabs) "\\bottomrule") ((equal style :standard) "\\hline") ("")) (latex-type table)))) (defmethod visit-node((table latex-table) (node colspec)) (setf (slot-value table 'col-specs) (nconc (slot-value table 'col-specs) (list (attribute node :colwidth))))) (defun col-specs(table) "Return col-specs for longtable" (with-slots(col-specs col-width rowspan) table (let* ((width 60) (total-width (/ (+ (reduce #'+ col-specs) (length col-specs)) width))) (let ((factor 0.93)) (when (> total-width 1) (setf factor (/ factor total-width))) (setf col-width (mapcar #'(lambda(w) (+ (/ (* factor (1+ w)) width) 0.005)) col-specs) rowspan (make-list (length col-specs) :initial-element 0)) (let ((bar (vertical-bar table))) (format nil "~{~Ap{~,2f\\locallinewidth}~}~A" (mapcan #'(lambda(w) (list bar w)) col-width) bar)))))) (defun column-width(table) (with-slots(col-width cell-in-row) table (format nil "~,2f\\locallinewidth" (elt col-width (1- cell-in-row))))) (defun visit-thead(table) (case (table-style table) (:booktabs (values "\\toprule" "\\midrule\\endhead")) (:standard (values "\\hline" "\\hline")) (t (values "" "")))) (defun visit-row(table) (setf (slot-value table 'cell-in-row) 0)) (defun depart-row(table) (setf (slot-value table 'cell-in-row) nil) (with-output-to-string(os) (format os " \\\\~%") (with-slots(rowspan) table (setf rowspan (mapcar #'(lambda(v) (if (> v 0) (1- v) v)) rowspan)) (when (eql (table-style table) :standard) (let ((rowspans nil)) (do ((i 0 (1+ i))) ((>= i (length rowspan))) (when (<= (nth i rowspan) 0) (push (1- i) rowspans))) (if (= (length rowspan) (length rowspans)) (format os "\\hline~%") (format os "~{\\cline{~D-~:*~D}~%~}" (nreverse rowspans)))))))) (defun rowspan(table cell) (nth cell (slot-value table 'rowspan))) (defun (setf rowspan)(value table cell) (when (nth cell (slot-value table 'rowspan)) (setf (nth cell (slot-value table 'rowspan)) value))) (defun visit-entry(table ) (incf (slot-value table 'cell-in-row))) (defun to-latex-encoding(encoding) "Translate docutils encoding name into latex's. Default fallback method is remove \"-\" and \"_\" chars from docutils_encoding." (let ((enc (cdr (assoc encoding '(("iso-8859-1" . "latin1") ;; west european ("iso-8859-2" . "latin2") ;; east european ("iso-8859-3" . "latin3") ;; esperanto) maltese ("iso-8859-4" . "latin4") ;; north european)scandinavian) baltic ("iso-8859-5" . "iso88595") ;; cyrillic (ISO) ("iso-8859-9" . "latin5") ;; turkish ("iso-8859-15" . "latin9") ;; latin9) update to latin1. ("mac_cyrillic" . "maccyr") ;; cyrillic (on Mac) ("windows-1251" . "cp1251") ;; cyrillic (on Windows) ("koi8-r" . "koi8-r") ;; cyrillic (Russian) ("koi8-u" . "koi8-u") ;; cyrillic (Ukrainian) ("windows-1250" . "cp1250") ;; ("windows-1252" . "cp1252") ;; ("us-ascii" . "ascii")) :test #'string-equal)))) (or enc (string-downcase (regex-replace-all "[-_]" encoding ""))))) (defclass latex-writer(writer) ((class-sections :reader class-sections :initform '(("book" "chapter" "section" "subsection" "subsubsection" "paragraph" "subparagraph") ("scrbook" "chapter" "section" "subsection" "subsubsection" "paragraph" "subparagraph") ("report" "chapter" "section" "subsection" "subsubsection" "paragraph" "subparagraph") ("scrreprt" "chapter" "section" "subsection" "subsubsection" "paragraph" "subparagraph") ("article" "section" "subsection" "subsubsection" "paragraph" "subparagraph") ("scrartcl" "section" "subsection" "subsubsection" "paragraph" "subparagraph") )) (active-table :reader active-table) (topic-class :initform nil) (title :initform "" :accessor title) (date :accessor date :documentation "Set date") (author-stack :initform nil :accessor author-stack :documentation "List of author information") (mode :initform nil :documentation "List of Modes currently active e.g. :literal :mathmode :literal-block") (literal-block-stack :initform nil :accessor literal-block-stack :documentation "Nested literal blocks") (dependencies :initform nil :accessor dependencies :documentation "List of dependencie uris") (section-numbers :initform nil :accessor section-numbers :documentation "Stack of nested section numbers") (enumeration-counters :initform nil :accessor enumeration-counters :documentation "Stack of enumeration counters") (max-enum-depth :initform 0 :accessor max-enum-depth :documentation "Maximum enumeration counter depth so far") (metadata :initform (make-hash-table) :reader metadata :documentation "docinfo metadata for Latex and pdfinfo") ;; parts of document filled in during translate head-prefix pdfinfo pdfauthor head body-prefix docinfo body body-suffix bibitems footer tmp-parts) (:default-initargs :parts '(head-prefix pdfinfo pdfauthor head body-prefix docinfo body footer body-suffix)) (:documentation "Docutils latex writer")) (defun docutils:write-latex(os document) (let ((writer (make-instance 'latex-writer))) (visit-node writer document) (write-document writer document os))) (defmacro collect-parts(&body body) `(progn (setf (slot-value docutils::*current-writer* 'tmp-parts) nil) (with-part(tmp-parts) ,@body) (slot-value docutils::*current-writer* 'tmp-parts))) (defmacro with-modes((writer &rest modes) &body body) (let ((tmp (gensym)) (gwriter (gensym))) `(let* ((,gwriter ,writer) (,tmp (slot-value ,gwriter 'mode))) (setf (slot-value ,gwriter 'mode) (nconc (list ,@modes) (slot-value ,gwriter 'mode))) ,@body (setf (slot-value ,gwriter 'mode) ,tmp)))) (defun mode(checklist writer) "Return true if writer is in any of the checklist modes" (if (listp checklist) (intersection checklist (slot-value writer 'mode)) (member checklist (slot-value writer 'mode)))) ;; these are dependant on *language* (defun quote-quotes(text) (let ((quotes (latex-quotes *language*)) (quote-index 0)) (flet ((next-quote() (prog1 (elt quotes quote-index) (setf quote-index (mod (1+ quote-index) 2))))) (with-output-to-string(os) (let ((parts (split-string text :delimiter #\"))) (write-string (car parts) os) (dolist(part (cdr parts)) (write-string (next-quote) os) (write-string part os))))))) (defun double-quotes-in-tt(text) (let ((dqr (latex-double-quote-replacement *language*))) (if dqr (regex-replace-all (load-time-value (create-scanner "\"") t) text dqr) text))) (defun section(writer &optional (level (1- (length (section-numbers writer))))) "Return the section name at the given level for the specific document class." (let ((sections (cdr (assoc (setting :latex-document-class writer) (class-sections writer) :test #'string-equal)))) (if (< level (length sections)) (elt sections level) (car (last sections))))) (defmethod visit-node ((writer latex-writer) (document document)) (with-slots(mode section-numbers active-table bibitems max-enum-depth) writer (setf section-numbers nil mode nil bibitems nil max-enum-depth 0 active-table (make-instance 'latex-table :latex-type (if (search "twocolumn" (setting :latex-document-options writer)) "tabular" "longtable") :table-style (setting :table-style writer))) (with-part(head-prefix) (part-prepend (format nil "\\documentclass[~A~@[,~A~]]{~A}~%" (setting :latex-document-options writer) (babel *language*) (setting :latex-document-class writer))) (part-append (used-packages (active-table writer)) #\newline) (part-append (let ((color (setting :hyperlink-color writer))) (if color (format nil "\\usepackage[colorlinks=true,linkcolor=~A,urlcolor=~:*~A]{hyperref}" color) "\\usepackage[colorlinks=false]{hyperref}")) #\newline) (let ((enc (setting :latex-font-encoding writer))) (part-append (cond ((equal enc "OT1") "") ((equal enc "") "\\usepackage{ae} \\usepackage{aeguill}") (t (format nil "\\usepackage[~A]{fontenc}" enc))) #\newline)) (part-append (case (setting :graphicx-option writer) ('nil "\\usepackage{graphicx}") (:auto "'%Check if we are compiling under latex or pdflatex \\ifx\\pdftexversion\\undefined \\usepackage{graphicx} \\else \\usepackage[pdftex]{graphicx} \\fi") (t (format nil "\\usepackage[~A]{graphicx}" (string-downcase (setting :graphicx-option writer))))) #\newline) (part-append "\\input{docutils.tex}" #\newline) (when-bind (stylesheet (setting :latex-stylesheet writer)) (part-append (format nil "\\input{~A}~%" stylesheet)))) (setq *document* document) (unless (setting :use-latex-docinfo writer) (with-part(head) (part-append "\\author{}\\title{}" #\newline))) (with-part(body-prefix) (part-append #\newline "\\begin{document}" #\newline) (when (setting :use-latex-docinfo writer) (part-append "\\maketitle" #\newline))) (with-part(body) (part-append "\\setlength{\\locallinewidth}{\\linewidth}" #\newline) (call-next-method) (when (and bibitems (setting :use-latex-citations writer)) (let ((widest-label "")) (dolist(item bibitems) (when (> (length (first item)) (length widest-label)) (setf widest-label (first item)))) (part-append (format nil "\\begin{thebibliography}{~A}~%" widest-label))) (dolist(item bibitems) (part-append (format nil "\\bibitem[~A]{~A}{~A}~%" (first item) (first item) (second item)))) (part-append "\\end{bibliography" #\Newline))) (with-part(body-suffix) (part-append "\\end{document}") #\newline))) (defun encode(writer string) "Encode special characters in `text` & return encoded string. # $ % & ~ _ ^ \ { } Escaping with a backslash does not help with backslashes, ~ and ^. < > are only available in math-mode or tt font. (really ?) $ starts math- mode.\\begin{thebibliography}{%s} AND quotes:" (when (mode :verbatim writer) (return-from encode string)) (macrolet((replace-all(regexp replacement) `(setf string (regex-replace-all (load-time-value (create-scanner ,regexp) t) string ,replacement)))) ;; first the braces (replace-all "([\\{\\}])" "{\\\\\\1}") ;; then backslash except in form '{\{}' or '{\}} (replace-all "(?<!{)(\\\\)(?![{}]})" "{\\textbackslash}") ;; do character replacements (setf string (with-output-to-string(os) (loop :for c :across string :do (flet ((char-replace(map prefix suffix) (let ((repl (cdr (assoc c map)))) (when repl (write-string prefix os) (write-string repl os) (write-string suffix os))))) (or (unless (mode '(:literal-block :literal :mathmode) writer) (char-replace '((#\| . "textbar") (#\< . "textless") (#\> . "textgreater")) "{\\" "}")) (char-replace '((#\$ ."$") (#\& . "&") (#.(code-char 8224) . "dag") ;; † (#.(code-char 8225) . "ddag") ;; #\‡ (#.(code-char 167) . "S") ;; § (#.(code-char 8233) . "P") ;; 
 paragraph (#.(code-char 182) ."P") ;; ¶ (#\^ ."textasciicircum") (#\% . "%") (#\# ."#") (#.(code-char 174) . "texttrademark") ;; ® (#.(code-char 169) . "copyright") ;; © (#.(code-char 9824) . "spadesuit") ;; ♠ (#.(code-char 9829) ."heartsuit") ;; ♥ (#.(code-char 9830) . "diamondsuit") ;; ♦ (#.(code-char 9827) . "clubsuit") ;; ♣ #+nil(#\~ ."textasciitilde")) "{\\" "}") (char-replace '((#.(code-char 8660) . "Leftrightarrow")) ;; ⇔ "{\\ensuremathmode{\\" "}}") (write-char c os)))))) ;; Separate compound characters, e.g. "--" to "-{}-".(The ;; actual separation is done later; see below.) (let ((separate-chars (load-time-value (create-scanner "(-)-")))) (if (mode '(:literal-block :literal) writer) (progn (setf separate-chars (load-time-value (create-scanner "(-,`\'\"<>)\\1") t)) (setf string (double-quotes-in-tt string)) (if (equal (setting :font-encoding writer) "OT1") (progn (replace-all "_" "{\\underline{ }}") (replace-all "\\textbackslash" "\\reflectbox{/}")) (replace-all "_" "{\\_}"))) (progn (setf string (quote-quotes string)) (replace-all "_" "{\\_}"))) (dotimes(x 2) (setf string (regex-replace-all separate-chars string "\\1{}\\1")))) (cond ((mode '(:insert-newline :literal-block) writer) (replace-all " " " \\\\\\\\ ")) ((mode :mbox-newline writer) (let ((openings (join-strings (literal-block-stack writer))) (closings (make-string (length (literal-block-stack writer)) :initial-element #\}))) (replace-all " " (format nil "~s}\\\\ \\mbox{~s" closings openings))))) (when (mode :insert-non-breaking-blanks writer) (replace-all " " "~")) string)) (defun attval(writer string) (encode writer (with-output-to-string(os) (loop for c across string do (if (wsp-char-p c) (write-char #\space os) (write-char c os)))))) (defmethod visit-node((writer latex-writer) (text text)) (part-append (encode writer (as-text text)))) (defmacro visit-docinfo-item(writer node name) "Helper macro for docinfo items" `(if (setting :use-latex-docinfo ,writer) ,(case name ((author organization contact address) ;; We attach these to the last author. If any of them `(let ((text ,(if (eql name 'address) `(with-modes(,writer :insert-newline) (encode ,writer (as-text ,node))) `(attval ,writer (as-text ,node))))) ,(if (eql name 'author) `(progn (push (list text) (author-stack ,writer)) (setf (slot-value ,writer 'pdfauthor) (if (slot-value ,writer 'pdfauthor) (concatenate 'string (slot-value ,writer 'pdfauthor) ", " text) text))) `(setf (first (author-stack ,writer)) (nconc (first (author-stack ,writer)) (list text)))))) (date `(setf (date ,writer) (attval ,writer (as-text ,node))))) (with-part(docinfo) (part-append (format nil "\\textbf{~S}: & " (translated-text ,(string-downcase name) *language*))) ,(case name (address `(with-modes(,writer :insert-newline) (part-append "{\\raggedright" #\newline) (call-next-method) (part-append "}"))) (t '(call-next-method))) (part-append " \\\\" #\newline)))) (defmethod visit-node((writer latex-writer) (node address)) (visit-docinfo-item writer node address)) (defmethod visit-node((writer latex-writer) (node admonition)) (part-append (format nil "~%\\begin{admonition}~:[{~A}~;~]~%" (eql (type-of node) 'admonition) (translated-text (string-downcase (type-of node)) *language*))) (call-next-method) (part-append "\\end{admonition}" #\newline)) ;; skip authors as author called for each one (defmethod visit-node((writer latex-writer) (node author)) (let ((authors (gethash 'author (metadata writer)))) (setf (gethash 'author (metadata writer)) (if authors (concatenate 'string authors (elt (author-separators *language*) 0) (attval writer (as-text node))) (attval writer (as-text node))))) (visit-docinfo-item writer node author)) (defmethod visit-node((writer latex-writer) (node block-quote)) (part-append "\\begin{quote}" #\newline) (call-next-method) (part-append "\\end{quote}" #\newline)) (defmethod visit-node((writer latex-writer) (node bullet-list)) (if (equal (slot-value writer 'topic-class) "contents") (unless (setting :use-latex-toc writer) (part-append "\\begin{list}{}{}" #\newline) (call-next-method) (part-append "\\end{list}" #\newline)) (progn (part-append "\\begin{itemize}" #\newline) (call-next-method) (part-append "\\end{itemize}" #\newline)))) (defmethod visit-node((writer latex-writer) (node superscript)) (part-append "$^{") (with-modes(writer :mathmode) (call-next-method)) (part-append "}")) (defmethod visit-node((writer latex-writer) (node subscript)) (part-append "$_{") (with-modes(writer :mathmode) (call-next-method)) (part-append "}")) (defmethod visit-node((writer latex-writer) (node math)) (part-append (as-text (child node 0)))) (defmethod visit-node((writer latex-writer) (node equation)) (let ((prev (prev-sibling node)) (text (as-text (child node 0)))) (when (and (typep prev 'target) (attribute prev :id)) (multiple-value-bind(match regs) (cl-ppcre::scan-to-strings "\\\\begin\\{(.+)\\}((?m)(\\n|.)+)\\\\end{\\1\}" text) (when match (part-append #\newline "\\begin{equation}" (elt regs 1) (format nil "\\label{~A}~%" (attribute prev :id)) "\\end{equation}" #\newline) (return-from visit-node)))) (part-append #\newline text #\newline))) (defmethod visit-node((writer latex-writer) (node caption)) (part-append "\\caption{") (call-next-method) (part-append "}" #\newline)) (defmethod visit-node((writer latex-writer) (node title-reference)) (part-append "\\titlereference{") (call-next-method) (part-append "}")) (defmethod visit-node((writer latex-writer) (node citation)) (if (setting :use-latex-citations writer) (push (nreverse (collect-parts (call-next-method))) (slot-value writer 'bibitems)) (progn (part-append #\newline (format nil "\\begin{figure}[b]~%\\hypertarget{~A}" (attribute node :id))) (call-next-method) ; (bookmark writer node) (part-append "\\end{figure}" #\newline)))) (defmethod visit-node((writer latex-writer) (node citation-reference)) (if (setting :use-latex-citations writer) (progn (part-append "\\cite{") (call-next-method) (part-append "}")) (let ((href (or (attribute node :refid) (gethash (attribute node :refname) (nameids (document node)))))) (part-append (format nil "[\\hyperlink{~A}{" href)) (call-next-method) (part-append "}]")))) (defmethod visit-node((writer latex-writer) (node classifier)) (part-append "(\\textbf{") (call-next-method) (part-append "})" #\newline)) (defmethod visit-node((writer latex-writer) (node colspec)) (visit-node (active-table writer) node)) (defmethod visit-node((writer latex-writer) (node comment)) (part-append "%% " (ppcre:regex-replace-all " " (as-text node) " %"))) (defmethod visit-node((writer latex-writer) (node contact)) (visit-docinfo-item writer node contact)) (defmethod visit-node((writer latex-writer) (node copyright)) (visit-docinfo-item writer node copyright)) (defmethod visit-node((writer latex-writer) (node date)) (visit-docinfo-item writer node date)) (defmethod visit-node((writer latex-writer) (node definition)) (part-append "%[Start Definition]" #\newline) (call-next-method) (part-append "%[End Definition]" #\newline)) (defmethod visit-node((writer latex-writer) (node definition-list)) (part-append "\\begin{description}" #\newline) (call-next-method) (part-append "\\end{description}" #\newline)) (defmethod visit-node((writer latex-writer) (node definition-list-item)) (part-append "%[Start Definition List Item]" #\newline) (call-next-method) (part-append "%[End Definition List Item]" #\newline)) (defmethod visit-node((writer latex-writer) (node description)) (part-append #\space) (call-next-method)) (defmethod visit-node((writer latex-writer) (node docinfo)) (with-part(docinfo) (part-append " \\begin{center} \\begin{tabularx}{\\docinfowidth}{lX} ") (call-next-method) (part-append " \\end{tabularx} \\end{center} ")) (with-part(pdfinfo) (when (slot-value writer 'pdfauthor) (part-append (format nil "\\hypersetup{pdfauthor={~A}" (slot-value writer 'pdfauthor))) (setf (slot-value writer 'pdfauthor) nil)) (when (slot-value writer 'pdfinfo) (setf (slot-value writer 'pdfinfo) (list (join-strings (nreverse (slot-value writer 'pdfinfo)) ", "))) (part-append "}" #\newline))) (when (setting :use-latex-docinfo writer) (with-part(head) (part-append (format nil "\\date{~A}~%" (slot-value writer 'date)) (format nil "\\author{~A}~%" (join-strings (mapcar #'(lambda(a) (join-strings a "\\\\")) (author-stack writer)) " \\and ")))))) (defmethod visit-node((writer latex-writer) (node doctest-block)) (part-append "\\begin{verbatim}" #\newline) (with-modes(writer :verbatim) (call-next-method)) (part-append "\\end{verbatim}" #\newline)) (defmethod visit-node((writer latex-writer) (node emphasis)) (let ((txt "\\emph{")) (part-append txt) (push txt (literal-block-stack writer)) (call-next-method) (pop (literal-block-stack writer)) (part-append "}"))) (defmethod visit-node((writer latex-writer) (node entry)) (let ((table (active-table writer)) (suffix nil)) (visit-entry table) (if (= 1 (entry-number table)) ;; if the firstrow is a multirow, this actually is the second row. ;; this gets hairy if rowspans follow each other. (unless (zerop (rowspan table 0)) (part-append " & ") (visit-entry table)) (part-append " & ")) (let ((morerows (attribute node :morerows)) (morecols (attribute node :morecols))) (cond ((and morerows morecols) (error "Cells that span multiple rows and columns are not supported in Latex")) (morerows (let ((count (1+ morerows))) (setf (rowspan table (1- (entry-number table))) count) (part-append (format nil "\\multirow{~D}{~S}{" count (column-width table))) (push "}" suffix))) ; BUG following rows must have empty cells. (morecols (let ((bar1 (if (= 1 (entry-number table)) (vertical-bar table) "")) (count (1+ morecols))) ;; the vertical bar before column is missing if it is the first ;; column. the one after always. (part-append (format nil "\\multicolumn{~D}{~Al~A}{" count bar1 (vertical-bar table))) (push "}" suffix))))) (when (typep (parent (parent node)) 'thead) (part-append "\\textbf{") (push "}" suffix)) (call-next-method) (dolist(item (nreverse suffix)) (part-append item)) ;; if following row is spanned from above. (unless (zerop (or (rowspan table (entry-number table)) 0)) (part-append " & ") (visit-entry table)))) (defmethod visit-node((writer latex-writer) (node row)) (visit-row (active-table writer)) (call-next-method) (part-append (depart-row (active-table writer)))) (defmethod visit-node((writer latex-writer) (node enumerated-list)) (let ((enum-suffix (or (attribute node :suffix) ".")) (enum-prefix (or (attribute node :prefix) "")) (enum-type (get (attribute node :type) '(:arabic "arabic" :loweralpha "alph" :upperalpha "Alph" :lowerroman "roman" :upperroman "Roman") "arabic"))) (when (setting :compound-enumerators writer) (when (and (setting :section-prefix-for-enumerators writer) (section-numbers writer)) (setf enum-prefix (concatenate 'string enum-prefix (format nil "~{~D.~}" (reverse (section-numbers writer)))))) (setf enum-prefix (concatenate 'string enum-prefix (format nil "~{~A.~}" (reverse (enumeration-counters writer)))))) (let* ((n (1+ (length (enumeration-counters writer)))) (counter-name (format nil "listcnt~D" n))) (push (format nil "\\~A{~A}" enum-type counter-name) (enumeration-counters writer)) (when (> n (max-enum-depth writer)) (setf (max-enum-depth writer) n) (part-append (format nil "\\newcounter{~A}~%" counter-name))) (part-append (format nil "\\begin{list}{~A\\~A{~A}~A}~%" enum-prefix enum-type counter-name enum-suffix) (format nil "{~%\\usecounter{~A}~%" counter-name)) (let ((start (attribute node :start))) (when start (part-append (format nil "\\setcounter{~A}{~D}~%" counter-name (1- start))))) (part-append "\\setlength{\\rightmargin}{\\leftmargin}}" #\newline))) (call-next-method) (part-append "\\end{list}" #\newline) (pop (enumeration-counters writer))) (defmethod visit-node((writer latex-writer) (node field)) (part-append #\newline) (call-next-method)) (defmethod visit-node((writer latex-writer) (node field-body)) (call-next-method)) ;; (if (slot-value writer 'docinfo) ;; (with-part(docinfo) ;; (call-next-method) ;; (part-append "\\\\" #\newline)) ;; (part-append ;; (format nil "~A \\\\" (as-text node)))) ;; (call-next-method)) ;; (part-append #\newline)) (defmethod visit-node((writer latex-writer) (node field-list)) (if (eql docutils::*current-writer-part* 'docinfo) (call-next-method) (progn (part-append "\\begin{description}" #\newline) (call-next-method) (part-append "\\end{description}" #\newline)))) (defmethod visit-node((writer latex-writer) (node field-name)) (if (eql docutils::*current-writer-part* 'docinfo) (part-append (format nil "\\textbf{~A}: & " (encode writer (as-text node)))) (progn (part-append "\\item[") (call-next-method) (part-append "]")))) (defmethod visit-node((writer latex-writer) (node figure)) (let* ((width (when-bind(width (attribute node :width)) (car (convert-length-unit width :%)))) (env (if (and width (> width 50)) "figure*" "figure"))) (part-append #\newline "\\begin{" env "}" #\newline "\\begin{center}") (call-next-method) (let ((prev (prev-sibling node))) (when (and (typep prev 'target) (attribute prev :id)) (part-append (format nil "\\label{~A}~%" (attribute prev :id))))) (part-append "\\end{center}" #\newline "\\end{" env "}" #\newline))) (defmethod visit-node((writer latex-writer) (node footer)) (with-part(footer) (part-append #\newline "\\begin{center}\\small" #\newline) (call-next-method) (part-append #\newline "\\end{center}" #\newline #\newline))) (defmethod visit-node((writer latex-writer) (node footnote)) (if (setting :use-latex-footnotes writer) (progn (part-append "\\footnotetext[" (first (split-string (as-text node) :delimiter #\space)) "]{") (call-next-method) (part-append "}" #\newline)) (progn (part-append #\newline (format nil "\\begin{figure}[b]~%\\hypertarget{~s}" (attribute node :id))) (call-next-method) (part-append "\\end{figure}" #\newline)))) (defmethod visit-node((writer latex-writer) (node footnote-reference)) (if (setting :use-latex-footnotes writer) (part-append "\\footnotemark[" (encode writer (as-text node)) "]") (let ((href (or (attribute node :refid) (gethash (attribute node :refname) (nameids (document node)))))) (multiple-value-bind(prefix suffix) (ecase (setting :footnote-references writer) (:brackets (values "[" "]")) (:superscript (values "\\raisebox{.5em}[0em]{\\scriptsize" "}"))) (part-append prefix (format nil "\\hyperlink{~A}{" href)) (call-next-method) (part-append suffix))))) (defmethod visit-node((writer latex-writer) (node label)) (etypecase (parent node) (footnote (unless (setting :use-latex-footnotes writer) (multiple-value-bind(prefix suffix) (ecase (setting :footnote-references writer) (:brackets (values "[" "]")) (:superscript (values "$^{" "}$"))) (part-append prefix) (call-next-method) (part-append suffix)))) (citation (unless (setting :use-latex-citations writer) (part-append "[") (call-next-method) (part-append "] "))))) (defmethod visit-node((writer latex-writer) (node header)) (with-part(prefix) (part-append #\newline "\\verb|begin_header|" #\newline) (call-next-method) (part-append #\newline "\\verb|end_header|" #\newline))) (defun latex-length(size) (case (cdr size) (:% (format nil "~A\\textwidth" (/ (car size) 100.0))) (t (format nil "~A~A" (car size) (cdr size))))) (defmethod visit-node((writer latex-writer) (node image)) (push (attribute node :uri) (dependencies writer)) (let ((pre nil) (post (list (format nil "\\includegraphics[clip=true~@[,angle=~A~]~@[,scale=~A%~]~@[,width=~A~]~@[,height=~A~]]{~A}" (when-bind(angle (attribute node :angle)) angle) (when-bind(scale (attribute node :scale)) (* 100 scale)) (when-bind(width (attribute node :width)) (latex-length width)) (when-bind(height (attribute node :height)) (latex-length height)) (attribute node :uri))))) (when-bind(align (attribute node :align)) (multiple-value-bind(a b) (case align (:middle (values "\\raisebox{-0.5\\height}{" "}")) (:bottom (values "\\raisebox{-\\height}{" "}")) (:center (values "{\\hfill" "\\hfill}")) (:left (values "{" "\\hfill}")) (:right (values"{\\hfill" "}")) (t (values "" ""))) (push a pre) (push b post))) (unless (typep (parent node) 'text-element) (push #\newline pre) (push #\newline post)) (map 'nil #'part-append pre) (map 'nil #'part-append (nreverse post)))) ;(defmethod visit-node((writer latex-writer) (node interpretated)) ; (part-append "\\texttt{") ; (with-modes(:literal) (call-next-method)) ; (part-append "}")) (defmethod visit-node((writer latex-writer) (node legend)) (part-append "{\\small ") (call-next-method) (part-append "}")) (defmethod visit-node((writer latex-writer) (node line)) (part-append "\\item[] ") (call-next-method) (part-append #\newline)) (defmethod visit-node((writer latex-writer) (node line-block)) (part-append (if (typep (parent node) 'line-block) "\\item[] \\begin{lineblock}{\\lineblockindentation}" " \\begin{lineblock}{0em}") #\newline) (call-next-method) (part-append "\\end{lineblock}" #\newline)) (defmethod visit-node((writer latex-writer) (node list-item)) (part-append "\\item {} ") (call-next-method) (part-append #\newline)) (defmethod visit-node((writer latex-writer) (node literal)) (part-append "\\texttt{") (with-modes(writer :literal) (call-next-method)) (part-append "}")) (defmethod visit-node((writer latex-writer) (node literal-block)) (if (and (setting :use-verbatim-when-possible writer) (= 1 (number-children node)) (typep (child node 0) 'text)) (progn (part-append "\\begin{quote}" #\newline "\\begin{verbatim}" #\newline) (with-modes(writer :verbatim) (call-next-method)) (part-append #\newline "\\end{verbatim}" #\newline "\\end{quote}" #\newline)) (with-modes(writer :literal-block :insert-non-breaking-blanks) (if (open-p (active-table writer)) (progn (part-append #\newline "{\\ttfamily \\raggedright \\noindent" #\newline) (call-next-method) (part-append #\newline "}" #\newline)) (progn (part-append "\\begin{quote}{\\ttfamily \\raggedright \\noindent" #\newline) (call-next-method) (part-append #\newline "}\\end{quote}" #\newline)))))) (defmethod visit-node((writer latex-writer) (node meta)) (part-append "%[visit meta]" #\newline) (call-next-method) (part-append "%[depart meta]" #\newline)) (defmethod visit-node((writer latex-writer) (node option)) (unless (eql node (child (parent node) 0)) (part-append ", ")) (call-next-method)) (defmethod visit-node((writer latex-writer) (node option-argument)) (part-append (or (attribute node :delimiter) " ")) (call-next-method)) (defmethod visit-node((writer latex-writer) (node option-group)) (part-append "\\item[") (call-next-method) (part-append "] ")) (defmethod visit-node((writer latex-writer) (node option-list)) (part-append "\\begin{optionlist}{3cm}" #\newline) (call-next-method) (part-append "\\end{optionlist}")) (defmethod visit-node((writer latex-writer) (node option-list-item)) (call-next-method) (part-append "\\\\" #\newline)) (defmethod visit-node((writer latex-writer) (node organization)) (visit-docinfo-item writer node organization)) (defmethod visit-node((writer latex-writer) (node paragraph)) (let ((index (index (parent node) node))) (unless (or (equal (slot-value writer 'topic-class) "contents") (and (> index 0) (let ((prev (child (parent node) (1- index)))) (and (not (typep prev 'paragraph)) (not (typep prev 'compound)))))) (part-append #\newline))) (call-next-method) (part-append #\newline)) (defmethod visit-node((writer latex-writer) (node problematic)) (part-append (format nil "~%~%\\color{red}{\\bfseries{\\hyperlink{~A}[\\#~:*~A]} \\href{~A}{" (attribute node :id) (attribute node :refid) )) (call-next-method) (part-append "}}")) (defmethod visit-node((writer latex-writer) (node system-message)) (part-append (format nil "~%~%\\color{red}{\\bfseries{~@[\\hyperlink{~A}{}\\#~:*~A}~]" (attribute node :id))) (call-next-method) (part-append (format nil "~@[ See:~{ \\href{~A}{\\#~:*~A}~}~]}" (backrefs node)))) (defmethod visit-node((writer latex-writer) (node raw)) (when (member :latex (attribute node :format)) (part-append (as-text node)))) (defmethod visit-node((writer latex-writer) (node reference)) (if (attribute node :refid) (if (typep (gethash (attribute node :refid) (docutils:ids (document node))) 'docutils.nodes:section) (progn (call-next-method) (part-append (format nil "~~(Section~~\\ref{~A})" (attribute node :refid)))) (part-append (format nil "~~\\ref{~A})" (attribute node :refid)))) (let* ((hash-char "\\#")) (part-append (format nil "\\href{~A" (cond ((attribute node :refuri) (regex-replace "#" (attribute node :refuri) hash-char)) ((attribute node :refname) (concatenate 'string hash-char (gethash (attribute node :refname) (nameids (document node))))) ((error "Unknown reference"))))) (part-append "}{") (call-next-method) (part-append "}")))) (defmethod visit-node((writer latex-writer) (node revision)) (visit-docinfo-item writer node revision)) (defmethod visit-node((writer latex-writer) (node section)) (push 1 (section-numbers writer)) (call-next-method) (pop (section-numbers writer))) (defmethod visit-node((writer latex-writer) (node sidebar)) (part-append " \\setlength{\\locallinewidth}{0.9\\admonitionwidth} \\begin{center}\\begin{sffamily} \\fbox{\\colorbox[gray]{0.80}{\\parbox{\\admonitionwidth}{ ") (call-next-method) (part-append "}}} \\end{sffamily}\\end{center} \\setlength{\\locallinewidth}{\\linewidth} ")) (let ((attribution-formats '(:dash ("---" "") :parentheses ("(" ")") :parens ("(" ")") :none ("" "")))) (defmethod visit-node((writer latex-writer) (node attribution)) (multiple-value-bind(prefix suffix) (values-list (getf attribution-formats (or (attribute node :attribution) :parens))) (part-append #\newline "\\begin{flushright}" #\newline prefix) (call-next-method) (part-append suffix #\newline "\\end{flushright}" #\newline)))) (defmethod visit-node((writer latex-writer) (node status)) (visit-docinfo-item writer node status)) (defmethod visit-node((writer latex-writer) (node strong)) (let ((txt "\\textbf{")) (part-append txt) (push txt (literal-block-stack writer)) (call-next-method) (pop (literal-block-stack writer)) (part-append "}"))) (defmethod visit-node((writer latex-writer) (node substitution-definition)) ) (defmethod visit-node((writer latex-writer) (node substitution-reference)) (error "Substitution reference unimplemented")) (defmethod visit-node((writer latex-writer) (node subtitle)) (cond ((typep (parent node) 'sidebar) (part-append "~\\\\" #\newline "\\textbf{") (call-next-method) (part-append "}" #\newline "\\smallskip" #\newline)) (t (setf (title writer) (format nil "~A\\\\~%\\large{~A}~%" (title writer) (encode writer (as-text node))))))) (defmethod visit-node((writer latex-writer) (node table)) (let* ((width (when-bind(width (attribute node :width)) (car (convert-length-unit width :%)))) (env (if (and width (> width 50)) "table*" "table"))) (part-append #\newline "\\begin{" env "}" #\newline "\\begin{center}" #\newline) (call-next-method) (let ((prev (prev-sibling node))) (when (and (typep prev 'target) (attribute prev :id)) (part-append (format nil "\\label{~A}~%" (attribute prev :id))))) (part-append "\\end{center}" #\newline "\\end{" env "}" #\newline))) (defmethod visit-node((writer latex-writer) (node tgroup)) (let ((table (active-table writer))) (when (open-p table) (error "Nested tables are not supported")) (open-table table) (part-append #\newline (opening table)) (call-next-method) (part-append (closing table) #\newline) (close-table table))) (defmethod visit-node((writer latex-writer) (node target)) (cond ((attribute node :refuri)) ((or (attribute node :refid) (attribute node :refname)) (call-next-method)) (t (typecase (next-sibling node) (figure) (equation) (table) (section) (t (progn (part-append (format nil "\\hypertarget{~A}{" (attribute node :id))) (call-next-method) (part-append "}"))))))) (defun ensure-table-preamble(writer) (let ((table (active-table writer))) (unless (slot-value table 'preamble-written) (part-append (format nil "{~A}~@[~A~]~%" (col-specs table) (caption table)) (visit-thead table)) (setf (slot-value table 'preamble-written) t)))) (defmethod visit-node((writer latex-writer) (node tbody)) (ensure-table-preamble writer) (call-next-method)) (defmethod visit-node((writer latex-writer) (node term)) (part-append "\\item[") (call-next-method) (part-append "]")) (defmethod visit-node((writer latex-writer) (node thead)) (ensure-table-preamble writer) (call-next-method) (part-append (second (multiple-value-list (visit-thead (active-table writer)))))) (defun bookmark(writer node) (when-bind(id (attribute (parent node) :id)) (part-append (format nil "\\label{~A}~%" id)) (unless (setting :use-latex-toc writer) (let ((l (length (section-numbers writer)))) (when (> l 0) (decf l)) (part-append (format nil "\\pdfbookmark[~d]{~A}{~A}~%" l (encode writer (as-text node)) id)))))) (defmethod visit-node((writer latex-writer) (node title)) (let ((parent (parent node))) (typecase parent (topic (part-append "\\subsubsection*{~\\hfill ") (bookmark writer node) (call-next-method) (part-append "\\hfill ~}" #\newline)) ((or sidebar admonition) (part-append "{") (call-next-method) (part-append "}" #\newline)) (table (setf (slot-value (active-table writer) 'caption) (encode writer (as-text node)))) (document ;; document title (let ((txt (encode writer (as-text node)))) (setf (slot-value writer 'title) txt) (when (setting :use-latex-docinfo writer) (with-part(head) (part-append (format nil "\\title{~A}~%" txt)))) (with-part(pdfinfo) (part-append (format nil "\\hypersetup{pdftitle={~A}}~%" txt))))) (otherwise (part-append " %--------------------------------------------------------------------------- ") (part-append (format nil "\\~A~:[*~;~]{" (section writer) (setting :use-latex-toc writer))) (call-next-method) (part-append "}" #\newline) (bookmark writer node))))) (defmethod visit-node((writer latex-writer) (node topic)) (if (setting :use-latex-toc writer) (progn (setf (slot-value writer 'topic-class) nil) (part-append "\\tableofcontents" #\newline #\newline "\\bigskip" #\newline)) (progn (setf (slot-value writer 'topic-class) (attribute node :class)) (call-next-method) (setf (slot-value writer 'topic-class) nil) (part-append #\newline)))) (defmethod visit-node((writer latex-writer) (node docutils.nodes:inline)) (if (attribute node :class) (progn (part-append (format nil "\\docutilsrole~A{" (string-downcase (attribute node :class)))) (call-next-method) (part-append "{")) (call-next-method))) (defmethod visit-node((writer latex-writer) (node rubric)) (part-append "\\rubric{") (call-next-method) (part-append "}")) (defmethod visit-node((writer latex-writer) (node transition)) (part-append " %___________________________________________________________________________ \\hspace*{\\fill}\\hrulefill\\hspace*{\\fill} ") (call-next-method)) (defmethod visit-node((writer latex-writer) (node version)) (visit-docinfo-item writer node version)) (defmethod visit-node((writer latex-writer) (node evaluateable)) (if (eql (output-format node) :latex) (part-append (evaluate node)) (call-next-method))) (defclass latex-output-stream(line-wrap-stream) () (:documentation "Stream to help format latex out correctly - uses line wrapping, removes multiple spaces (including ~)")) (defmethod stream-write-char((stream latex-output-stream) (c character)) (case c (#.(code-char 8220) (write-sequence "``" stream)) (#.(code-char 8221) (write-sequence "''" stream)) (#\" (write-sequence (if (alphanumericp (last-char stream)) "''" "``") stream)) (#\newline (do ((lc (last-char stream) (last-char stream))) ((not (and lc (wsp-char-p lc)))) (unwrite-char stream)) (call-next-method)) (#\~ (when (wsp-char-p (last-char stream)) (unwrite-char stream)) (if (let ((lc (last-char stream))) (and lc (digit-char-p lc))) (write-sequence "\\," stream) (call-next-method))) (t (unless (and (wsp-char-p c) (let ((lc (last-char stream))) (and lc (wsp-char-p lc)))) (call-next-method)))) c) (defmethod write-document ((writer latex-writer) document (os stream)) (let ((os (make-instance 'latex-output-stream :stream os))) (unwind-protect (call-next-method writer document os) (close os)))) (defmethod write-part((writer latex-writer) (part (eql 'fragment)) (os stream)) (write-part writer 'docinfo os) (write-part writer 'body os))
52,447
Common Lisp
.lisp
1,220
34.672131
114
0.586208
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
b63e8df892e33ea7a5b6115c74365e365f5236a3e0d2c4f9653ffd5cad4bd738
7,428
[ -1 ]
7,429
directives.lisp
willijar_cl-docutils/parsers/directives.lisp
;; $Id: directives.lisp,v 1.11 2007/07/26 13:26:51 willijar Exp $ ;; Directives API and base directive definitions ;; Copyright (C) 2006 Dr. John A.R. Williams ;; Author: Dr. John A.R. Williams <[email protected]> ;; Keywords: ;; This file is part of the Common Lisp Docutils package ;; This is free software released under the GNU General Public License (GPL) ;; See <http://www.gnu.org/copyleft/gpl.html> ;;; Commentary: ;; ;;; Code: (in-package :docutils.parser.rst) (defstruct directive "Directive Specification" (name "") (arguments nil) (allow-spaces-p t) (options nil) (content-p nil) (function)) (defmacro def-directive(name (nodevar &rest lambda-list) &body body) "Define a directive handler for directive named name. lambda-list is a directive lambda-list as follows lambda-list::= ({var | (var [specializer])}* [&allow-spaces] [&option {var | (var [specializer])}* ] [{{&content {var}}] [{&parsed-content {var} [{kwargs}]] )" (let ((allow-spaces-p nil) (options-spec nil) (args-spec nil) (options-var nil) (content-var nil) (content-parser nil) (state :args)) (flet ((is-vardef(item) (or (and (listp item) (symbolp (first item))) (and (symbolp item) (not (eql (char (string item) 0) #\&))))) (varname(s) (if (listp s) (car s) s))) (dolist(arg lambda-list) (unless (or (symbolp arg) (listp arg)) (error "Invalid definition argument ~S" arg)) (case arg (&content (setf state :content)) (&content-parser (setf state :parse-content)) (&all-options (setf state :options)) (t (ecase state (:args (case arg (&allow-spaces (setf allow-spaces-p t state :allow-spaces)) (&option (setf state :option)) (:allow-other-options (error ":allow-other-option must occur after :option")) (t (if (is-vardef arg) (push arg args-spec) (error "Invalid variable definition ~S" arg))))) (:allow-spaces (case arg (&option (setf state :option)) (t (error "Argument ~S out of place" arg)))) (:option (if (is-vardef arg) (push arg options-spec) (error "Argument ~S out of place" arg))) (:options (if (and (is-vardef arg) (not options-var)) (setf options-var arg) (error "Argument ~S out of place" arg)) (setf state nil)) (:parse-content (unless (symbolp arg) (error "Invalid content parser definition ~S" arg)) (when content-parser (error "Wrong number of content parser arguments")) (setf content-parser arg)) (:content (unless (symbolp arg) (error "Invalid content spec ~S" arg)) (when content-var (error "Wrong number of content arguments")) (setf content-var arg) ))))) (setf args-spec (nreverse args-spec) options-spec (nreverse options-spec)) (let ((nodevarname (or nodevar (gensym))) (gcontent (or content-var (gensym))) (gparser (or content-parser (gensym))) (options (gensym)) (goptions-var (or options-var (gensym))) (arguments (gensym))) `(setf (get-directive ,(string-downcase name) *directives*) (make-directive :name ,(string-downcase name) :arguments ',args-spec :allow-spaces-p ,allow-spaces-p :options ',options-spec :content-p ,(when (or content-var content-parser) t) :function #'(lambda(,nodevarname ,arguments ,options ,gcontent ,gparser ,goptions-var) ,@(unless nodevar `((declare (ignore ,nodevarname)))) ,@(unless content-parser `((declare (ignore ,gparser)))) ,@(unless options-var `((declare (ignore ,goptions-var)))) ,@(unless content-var `((declare (ignore ,gcontent)))) (multiple-value-bind(,@(mapcar #'varname args-spec)) (values-list (mapcar #'second ,arguments)) (multiple-value-bind(,@(mapcar #'varname options-spec)) (values-list (mapcar #'second ,options)) ,@body))))))))) (defmacro def-admonition(name &optional (node-class (intern (string-upcase name)))) (let ((classname (format nil "admonition-~A" (string-downcase name)))) `(def-directive ,name (parent &content content &content-parser parser) (if content (let ((admonition (make-node ',node-class :class ,classname))) (add-child parent admonition) (funcall parser admonition)) (report :error ,(format nil "The ~s admonition is empty; content required." name)))))) (def-admonition "danger") (def-admonition "attention") (def-admonition "caution") (def-admonition "error") (def-admonition "hint") (def-admonition "important") (def-admonition "note") (def-admonition "tip") (def-admonition "warning") (def-directive admonition(parent title &allow-spaces &option (classname class "admonition") &content content &content-parser parser) (if content (let ((admonition (make-node 'admonition :class classname))) (add-child parent admonition) (when title (let ((titlenode (make-node 'title))) (add-child admonition titlenode) (add-child titlenode (parse-inline rst-patterns title)))) (funcall parser admonition)) (report :error "The admonition is empty; content required."))) (defmethod parse-input((spec (eql 'align)) input &key &allow-other-keys) (if (member input '("top" "middle" "bottom" "left" "center" "right") :test #'string-equal) (intern input :keyword) (error 'invalid-format :type spec :value input :reason "Not a valid alignment argument"))) (defmethod parse-input((spec (eql 'class)) input &key &allow-other-keys) (when (is-nil-string input) (error 'invalid-format :type spec :value input :reason "Class argument required but none supplied")) (join-strings (mapcar #'(lambda(s) (let ((id (make-id s))) (if (is-nil-string s) (error 'invalid-format :type spec :value input :reason (format nil "cannot make ~S into a class name" s)) id))) (cl-ppcre:split "\\s+" input)))) ;; figure sizes are numbers ;; if 0<=x<=1 it is a fraction of the natural size (text width or height) ;; if >1 then it is number of pixels. This is deprecated (defmethod parse-input((spec (eql 'figwidth)) input &key &allow-other-keys) (if (string-equal input "image") :image (parse-input '(number :min 0) input))) ;; Lengths are either a number of pixels >1 or 0<=x<=1.0 for a fraction (defmethod parse-input((spec (eql 'length)) input &key &allow-other-keys) "Parser for entity sizes - returns a cons of a number and units" (multiple-value-bind(value pos) (parse-integer input :junk-allowed t) (unless (and value (> value 0)) (error 'invalid-format :type spec :value input :report "Size must be an non-negative integer")) (let ((unit (when (< pos (length input)) (let ((s (strip (subseq input pos)))) (when (find #\' input) (error 'invalid-format :type spec :value s :reason "Invalid length unit")) (intern (string-upcase s) :keyword))))) (cons value (if (length-unit unit) unit :px))))) (defmethod parse-input((spec (eql 'scale)) input &key &allow-other-keys) (let ((docutils.utilities::*length-units* '((:% . 75/8) (nil . 1)))) (let ((v (parse-input 'length input))) (if (eql (cdr v) :%) (/ (car v) 100.0) (car v))))) (defun make-image-nodes(uri alt height width scale align target class angle) (let ((image-node (make-node 'image))) (when (find #\space uri) (report :error "Image URI contains whitespace" :line *current-line-number*)) (if alt (setf (attribute image-node :alt) alt) (report :warning "Image should have an alt option" :line *current-line-number*)) (map nil #'(lambda(k v) (when v (setf (attribute image-node k) v))) '(:height :width :scale :align :class :angle) (list height width scale align class angle)) (setf (attribute image-node :uri) uri) (list (if target (let ((ref (multiple-value-bind(type data) (parse-target (split-lines (escape2null target))) (ecase type (:refuri (make-node 'reference :refuri data)) (:refname (make-node 'reference :refname (normalise-name data))))))) (add-child ref image-node) ref) image-node)))) (def-directive image(parent uri &option alt (height length) (width length) (scale scale) (align align) (angle (number :nil-allowed t)) target (class class)) (add-child parent (make-image-nodes uri alt height width scale align target class angle))) (def-directive figure(parent uri &option alt (height length) (width length) (scale scale) (align align) target (class class) (angle (number :nil-allowed t)) (figwidth length) (figclass length) &content content &content-parser parser) (let ((figure-node (make-node 'figure))) (unless figwidth (setf figwidth width)) (unless figclass (setf figclass class)) (when figwidth (setf (attribute figure-node :width) figwidth)) (when figclass (setf (attribute figure-node :class) figclass)) (when align (setf (attribute figure-node :align) align)) (add-child figure-node (make-image-nodes uri alt height width scale :top target class angle)) (when content (let ((node (make-node 'element)) (legend nil) (firstp t)) (funcall parser node) (with-children(child node :copy t) (rem-child node child) (if firstp (typecase child (docutils.nodes:paragraph (let ((caption (make-node 'caption))) (add-child figure-node caption) (with-children(grandchild child :copy t) (rem-child child grandchild) (add-child caption grandchild)) (setf firstp nil))) (docutils.nodes:comment ) (t (report :error "Figure caption must be a paragraph or empty comment."))) (progn (unless legend (setf legend (make-node 'legend))) (add-child legend child)))) (when legend (add-child figure-node legend)))) (add-child parent figure-node))) (def-directive equation(parent &content content) (let ((node (make-node 'equation))) (add-child node (join-strings content #\newline)) (add-child parent node))) (def-directive replace(parent &content content &content-parser parser) (cond ((not (typep parent 'docutils.nodes:substitution-definition)) (report :error "Invalid context: the \"replace\" directive can only be used with a substitution definition" :data content)) ((not content) (report :error "The \"replace\" directive is empty; content required")) (t (funcall parser parent) (cond ((and (= (number-children parent) 1) (typep (child parent 0) 'docutils.nodes:paragraph)) (let ((p (child parent 0))) (with-children(child p) (rem-child p child) (add-child parent child)) (rem-child parent 0))) ((with-children(node parent :copy t) (if (typep node 'docutils.nodes:system-message) (rem-attribute node :backrefs) (rem-child parent node))) (with-reports-to-node(parent) (report :error "Error in \"replace\" directive: may contain a single paragraph only"))))))) ;; ------------------------ ;; HTML specific directive ;; ------------------------ (defun extract-name-value(line) "Return a list of (:name value) from a line of the form name=value" (let ((attlist nil)) (loop (when (= 0 (length line)) (return attlist)) (let* ((equals (position #\= line))) (unless equals (error 'invalid-format :value line :reason "missing '=''")) (let ((attname (strip (subseq line 0 equals))) (data nil)) (when (= 0 (length attname)) (error 'invalid-format :value line :reason "missing attribute before '='")) (setf line (string-left-trim +wsp+ (subseq line (1+ equals)))) (when (= 0 (length line)) (error 'invalid-format :value line :reason (format nil "missing value after ~s" attname))) (let ((q (char line 0))) (if (find q "\"'") (let ((endquote (position q line :start 1))) (unless endquote (error 'invalid-format :value line :reason (format nil "attribute ~S missing end quote ~S" attname q))) (when (and (< (1+ endquote) (length line)) (not (member (char line (1+ endquote)) +wsp+))) (error 'invalid-format :value line :reason (format nil "attribute ~s end quote ~s not followed by whitespace" attname q))) (setf data (subseq line 1 endquote) line (subseq line (min (1+ endquote) (length line))))) (let ((space (position #\space line))) (if space (setf data (subseq line 0 space) line (string-left-trim +wsp+ (subseq line (1+ space)))) (setf data line line ""))))) (push (cons (intern (string-upcase attname) :keyword) data) attlist)))))) (defclass docutils.nodes::meta(docutils.nodes:special docutils.nodes:prebibliographic docutils.nodes:element)()) (defmethod allowed-child-p((parent docutils.nodes::meta) child &optional index) (declare (ignore child index)) nil) (defclass meta-body(specialized-body) ((initial-transitions :allocation :class :initform (select-rst-transitions 'field-marker)))) (defmethod field-marker((state meta-body) match) (let ((name (match-group match 0)) (indented (get-indented (state-machine state) :first-indent (match-end match)))) (if (not indented) (report :info `("No content for meta tag ~S" ,name) :data indented) (let ((node (make-node 'meta)) (tokens (split-string name :delimiter #\space :remove-empty-subseqs t))) (add-child (parent state) node) (setf (attribute node :content) (join-strings indented)) (handler-case (let ((attlist (extract-name-value (first tokens)))) (setf (attribute node (caar attlist)) (cdar attlist))) (invalid-format(c) (declare (ignore c)) (setf (attribute node :name) (first tokens)))) (dolist(token (rest tokens)) (handler-case (let ((attlist (extract-name-value token))) (setf (attribute node (caar attlist)) (cdar attlist))) (invalid-format(c) (report :error `("Error parsing meta tag attribute ~S: ~S" ,token ,c) :data indented) (return)))) )) nil)) ;;; Processing for meta changed from origianal docutils - meta elements ;;; are not conditional on output format as this isn't known during parsing (def-directive meta(parent &content content &content-parser parser) (if (not content) (report :error "Empty meta directive" :data content) (funcall parser parent :initial-state 'meta-body :states '(meta-body))) nil) ;;--------------- ;; Document Parts ;;--------------- (def-directive contents(parent title-text &allow-spaces &option (depth (integer :min 0)) (local boolean nil) (backlinks (member :type (symbol :nil-allowed t) :set '(:top :entry nil))) (class class)) (let* ((label (translated-text "contents" (language parent))) (title (cond (title-text (make-node 'title (parse-inline rst-patterns title-text ))) ((not local) (make-node 'title label)))) (topic (make-node 'topic :class "contents")) (name (normalise-name (if title (as-text title) label))) (pending (make-node 'pending :depth depth :backlinks backlinks :local local))) (add-child parent topic) (when class (add-class topic class)) (when title (add-child topic title)) (add-child topic pending) (add-transform (make-instance 'docutils.transform:contents :node pending)) (unless (named-node (document parent) name) (setf (attribute topic :name) name))) nil) (def-directive sectnum(parent &option (depth (integer :min 0)) (start (integer :min 0)) (prefix string) (suffix string)) (let ((pending (make-node 'pending))) (setf (attribute pending :depth) depth (attribute pending :start) start (attribute pending :prefix) prefix (attribute pending :suffix) suffix) (add-child parent pending) (add-transform (make-instance 'docutils.transform:sectnum :node pending))) nil) (def-directive class(parent (class class)) (let ((pending (make-node 'pending))) (add-child parent pending) (setf (attribute pending :class) class) (add-transform (make-instance 'docutils.transform:class-attribute :node pending))) nil) (def-directive target-notes(parent) (let ((pending (make-node 'pending))) (add-child parent pending) (add-transform (make-instance 'docutils.transform:target-notes :node pending))) nil) ;;--------------- ;; Body ;;--------------- (defun topic(name parent title subtitle class content parser &optional (nodeclass 'docutils.nodes:topic)) (unless content (report :warning `("Content block expected for the ~S directive; none found." ,name)) (return-from topic)) (let ((topic (make-instance nodeclass)) (titlenode (make-node 'title))) (add-child parent topic) (add-child topic titlenode) (add-child titlenode (parse-inline rst-patterns title)) (when subtitle (let ((titlenode (make-node 'subtitle))) (add-child topic titlenode) (add-child titlenode (parse-inline rst-patterns title)))) (when class (add-class topic class)) (when content (funcall parser topic)))) (def-directive topic(parent title &allow-spaces &option (class class) &content content &content-parser parser) (topic "topic" parent title nil class content parser)) (def-directive sidebar(parent title &allow-spaces &option subtitle (class class) &content content &content-parser parser) (topic "sidebar" parent title subtitle class content parser 'docutils.nodes:sidebar)) (def-directive rubric(parent title &allow-spaces &option (class class)) (let ((rubric (make-node 'rubric))) (add-child parent rubric) (when class (add-class rubric class)) (add-child rubric (parse-inline rst-patterns title)))) (def-directive epigraph(parent &content content) (let ((node (make-node 'block-quote :class "eipgraph"))) (add-child parent node) (add-child node content))) (def-directive highlights(parent &content content) (let ((node (make-node 'block-quote :class "highlights"))) (add-child parent node) (add-child node content))) (def-directive compound(parent &option (class class) &content content &content-parser parser) (if (find-if-not #'line-blank-p content) (let ((node (make-node 'compound))) (add-child parent node) (when class (add-class node class)) (funcall parser node)) (report :error "The 'compound' directive is empty; content required" :data content))) (def-directive parsed-literal(parent &option (class class) &content content) (let ((node (make-node 'literal-block (parse-inline rst-patterns (join-strings content #\newline)) ))) (add-child parent node) (when class (add-class node class)))) ;;;; misc (defmethod (setf attribute) (format (element docutils.nodes:raw) (label (eql ':format))) (call-next-method (mapcar #'(lambda(s) (intern (string-upcase s) :keyword)) (cl-ppcre:split "\\s+" format)) element label)) (def-directive raw(parent format &allow-spaces &option (file (pathname :must-exist)) url &content content) (let ((node (make-node 'raw)) (blocktext (join-strings content #\newline)) (text nil)) (setf (attribute node :format) format) (cond (content (if (or file url) (report :error "'raw' directive must not both specify an external file and have content" :data blocktext) (setf text blocktext))) (file (if url (report :error "'raw' directive must not both url and file options" :data blocktext) (with-open-file(is file :direction :input) (setf (attribute node :source) file) (setf text (with-output-to-string(os) (copy-stream is os)))))) (url (setf (attribute node :source) url) ;;(setf text (inet.http::url-retrieve :http (inet.uri:url url))) (report :severe "URL reading not implemented")) (t (report :error "The 'raw' directive requires content; non supplied"))) (when text (add-child node text) (add-child parent node)))) (def-directive include(parent (pathname pathname) &option (literal boolean)) (when-bind(docpath (setting :source-path *document*)) (setf pathname (merge-pathnames pathname docpath))) (if (probe-file pathname) (with-open-file(is pathname :direction :input) (let ((lines nil)) (do ((line (read-line is nil) (read-line is nil))) ((not line)) (push line lines)) (let((textblock (make-array (length lines) :element-type 'string :initial-contents (nreverse lines)))) (if literal (add-child parent (make-node 'literal-block textblock)) (signal 'insert-lines :text-block textblock) )))) (report :severe `("Included file ~S not found" ,pathname)))) (def-directive role(nil argument &allow-spaces &all-options options &content content) ;;;; Dynamically create and register a custom interpreted text role. (block role (flet((report(msg) (report :error msg :data argument) (return-from role))) (unless argument (report "'role' directive requires arguments on the first line")) (let ((match (match '(:sequence (:greedy-repetition 0 nil wsp) (:register simplename) (:greedy-repetition 0 nil wsp) #\( (:greedy-repetition 0 nil wsp) (:register simplename) (:greedy-repetition 0 nil wsp) #\) (:greedy-repetition 0 nil wsp) :end-anchor) argument))) (unless match (report "'role' directive requires arguments not valid role names")) (let* ((new-role-name (match-group match 0)) (base-role-name (match-group match 1)) (base-role (if (> (length base-role-name) 0) (or (gethash base-role-name *interpreted-roles*) (report `("Unknown interpreted text role ~s" ,base-role-name))) (make-instance 'generic-custom-role)))) (unless (slot-value base-role 'options) (report `("Supplemental directive arguments for raw directive not supported (specified by ~s role) " base-role-name))) (setf (gethash new-role-name *interpreted-roles*) (make-instance 'custom-role :base-role base-role :name new-role-name :option-values (parse-options (slot-value base-role 'options) options) :content content))))))) (def-directive container(parent argument &allow-spaces &content-parser parser) (let ((node (make-node 'container))) (add-child parent node) (add-class node argument) (funcall parser node))) ; tables (def-directive table(parent title &allow-spaces &option (class class) (width length) (align align) &content content &content-parser parser) (if content (let ((table (let ((dummy (make-node 'element))) (funcall parser dummy) (child dummy 0)))) (when class (setf (attribute table :class) class)) (when width (setf (attribute table :width) width)) (when align (setf (attribute table :align) align)) (when title (let ((titlenode (make-node 'caption))) (add-child table titlenode 0) (add-child titlenode (parse-inline rst-patterns title)))) (remove-node table) (add-child parent table)) (report :error "Content block expected for the table directive; none found."))) (def-directive evaluation (parent language &option (format symbol nil) (package symbol nil) &content content) (let ((language (intern (string-upcase language) :keyword))) (if content (let ((content (with-output-to-string(os) (loop :for line :across content :do (write-line line os))))) (add-child parent (make-instance 'docutils.nodes:block-evaluation :format (or format (setting :default-evaluation-format parent)) :expression (ecase language (:lisp (let ((*package* (or (and package (find-package package)) *package*))) (read-from-string content))))))) (report :error "Evaluation directive is empty; content required."))))
29,169
Common Lisp
.lisp
653
32.084227
139
0.546387
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
62e49a71b986ba9f4a775d7d810950e781bcb84194d0c783f6a50819ec0afee4
7,429
[ -1 ]
7,430
roles.lisp
willijar_cl-docutils/parsers/roles.lisp
;;;; rstructuredtext implementation for Common Lisp ;;;; Copyright (C) 2002-2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; An attempt to parse the rstructuredtext syntax into markup ;;;; See ;;;; http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html (in-package :docutils.parser.rst) (defvar *interpreted-roles* (make-hash-table :test #'equalp) "Mapping of roles to role functions which take the interpretate text content and an alist of directive options to be interprated by the role function") (defvar *default-interpreted-role* "title-reference" "The canonical name of the default interpreted role. This role is used when no role is specified for a piece of interpreted text.") (defmethod parse-role((rolename string) text &optional option-values content) (let ((role (gethash (if (= 0 (length rolename)) *default-interpreted-role* (string-downcase rolename)) *interpreted-roles*))) (if role (parse-role role text option-values content) (report :info (format nil "No role entry for ~S" rolename))))) (defmethod parse-role((role (eql nil)) text &optional option-values content) (parse-role *default-interpreted-role* text option-values content)) (defclass role() ((name :initarg :name))) (defclass standard-role(role) ((options :initform nil :initarg :options) (content :initform nil :initarg :content ) (function :initarg :function))) (defmethod parse-role((role standard-role) text &optional (option-values (mapcar #'third (slot-value role 'options))) (content (slot-value role 'content))) (funcall (slot-value role 'function) text option-values content)) (defclass custom-role(role) ((base-role :initarg :base-role) (option-values :initarg :option-values :initform nil) (supplied-content :initarg :content :initform nil))) (defmethod parse-role((role custom-role) text &optional option-values content) (parse-role (slot-value role 'base-role) text (or option-values (mapcar #'second (slot-value role 'option-values))) (or content (slot-value role 'supplied-content)))) (defclass generic-custom-role(standard-role) ((options :initform '((:class class)) :initarg :options))) (defmethod parse-role((role generic-custom-role) text &optional option-values content) (declare (ignore content)) (let ((node (make-node 'inline (parse-inline rst-patterns text)))) (when option-values (add-class node (first option-values))) node)) (defmacro def-role(name (textvar &rest lambda-list) &body body) "Define a role handler for role with cannonical name name. content and options will come from the role directive. lambda list is as follows lambda-list::= ({var | (var [[specializer] [default]])}* [{{&content {var [[specializer] [default]]}}] )" (let ((options-spec nil) (content-spec nil) (state :option)) (flet ((is-vardef(item) (or (and (listp item) (symbolp (first item))) (and (symbolp item) (not (eql (char (string item) 0) #\&))))) (varname(s) (if (listp s) (car s) s))) (dolist(arg lambda-list) (unless (or (symbolp arg) (listp arg)) (error "Invalid definition argument ~S" arg)) (case arg (&content (setf state :content)) (t (ecase state (:option (if (is-vardef arg) (push arg options-spec) (error "Argument ~S out of place" arg))) (:content (unless (is-vardef arg) (error "Invalid content spec ~S" arg)) (when content-spec (error "Wrong number of content arguments")) (setf content-spec arg)))))) (setf options-spec (nreverse options-spec)) (let ((gcontent (or content-spec (gensym))) (options (gensym))) `(eval-when(:load-toplevel :execute) (setf (gethash ,(string-downcase name) *interpreted-roles*) (make-instance 'standard-role :name ,(string-downcase name) :options ',options-spec :content ,content-spec :function #'(lambda(,textvar ,options ,gcontent) ,@(unless content-spec `((declare (ignore ,gcontent)))) (multiple-value-bind(,@(mapcar #'varname options-spec)) (values-list ,options) ,@body))))))))) (defmacro def-generic-role(name) (let ((text (gensym)) (class (gensym)) (node (gensym))) `(def-role ,name (,text (,class class)) (let ((,node (make-instance ',(intern (string-upcase name) :docutils.nodes)))) (add-child ,node ,text) (when ,class (add-class ,node ,class)) ,node)))) (def-generic-role "abbreviation") (def-generic-role "acronym") (def-generic-role "emphasis") (def-generic-role "literal") (def-generic-role "strong") (def-generic-role "subscript") (def-generic-role "superscript") (def-generic-role "title-reference") (defvar *rfc-url* "ftp://ftp.rfc-editor.org/in-notes/rfc4~D.txt") (def-role rfc-reference(text) (let ((rfcnum (parse-integer text :junk-allowed t))) (if (and rfcnum (> rfcnum 0)) (let ((node (make-node 'reference :refuri (format nil *rfc-url* rfcnum)))) (add-child node (format nil "RFC~A" (unescape text))) node) (report :error `("RFC must be a number greater than 1; ~A is invalid." ,text))))) (defvar *pep-url* "http://www.python.org/dev/peps/pep-~4,'0d/") (def-role pep-reference(text) (let ((pepnum (parse-integer text :junk-allowed t))) (if (and pepnum (>= pepnum 0) (<= pepnum 9999)) (let ((node (make-node 'reference :refuri (format nil *pep-url* pepnum)))) (add-child node (format nil "PEP~A" (unescape text))) node) (report :error `("PEP must be a number from 0 to 9999; ~A is invalid." ,text))))) (def-role raw(text format (class class)) (if format (let ((node (make-node 'raw :format format (unescape text :restore-backslashes t)))) (when class (add-class node class)) node) (progn (report :error "No format (Writer name) is associated with this raw role: use the \'role\' directive to create a new role with an associated format") (make-node 'problematic text)))) (def-role math(text) (make-node 'math (concatenate 'string "$" text "$"))) (def-role eval(text) (handler-case (with-input-from-string(is text) (let ((*package* (find-package :common-lisp-user))) (let ((arg1 (read is t nil)) (arg2 (read is nil nil))) (make-instance 'docutils.nodes:inline-evaluation :expression (or arg2 arg1) :format (when arg2 arg1))))) (error(e) (make-node 'problematic (write-to-string e :escape nil :readably nil ))))) #| (def-unimplemented-role index) (def-unimplemented-role named-reference) (def-unimplemented-role anonymous-reference) (def-unimplemented-role uri-reference) (def-unimplemented-role footnote-reference) (def-unimplemented-role citation-reference) (def-unimplemented-role substitution-reference) (def-unimplemented-role target) ;;# This should remain unimplemented, for testing purposes: (def-unimplemented-role restructuredtext-unimplemented-role) |#
7,855
Common Lisp
.lisp
180
35.477778
81
0.622155
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
effac3b87c9dc81a60ba8bf72300f632fd258a533adf377a072ed7473c778e92
7,430
[ -1 ]
7,431
tables.lisp
willijar_cl-docutils/parsers/tables.lisp
;; $Id: tables.lisp,v 1.4 2007/07/26 08:30:50 willijar Exp willijar $ ;; Parse Restructured text Tables ;; Copyright (C) 2006 Dr. John A.R. Williams ;; Author: Dr. John A.R. Williams <[email protected]> ;; Keywords: ;; This file is part of CL-docutils ;; This is free software released under the GNU General Public License (GPL) ;; See <http://www.gnu.org/copyleft/gpl.html> ;;; Commentary: ;; This module defines table parser classes,which parse plaintext-graphic ;; tables and produce a well-formed data structure suitable for building a ;; CALS table. ;;; Code: (in-package :docutils.parser.tables) (define-condition table-condition(markup-condition)()) (defun parse-table(parser-class-name block) (let ((parser (make-instance parser-class-name :block (copy-seq block)))) (do-parse-table parser) (structure-from-cells parser))) (defclass table-parser() ((text-block :initarg :block :reader text-block :documentation "Block of text to be parser") (separator-pattern :initarg :separator-pattern) (head-body-sep :reader head-body-sep :initform nil :documentation "Index of head body separator") (done :reader done)) (:documentation "Abstract superclass for the common parts of the syntax-specific parsers.")) (defun bottom(text-block) (1- (length text-block))) (defun right(text-block) (1- (length (aref text-block 0)))) (defmethod initialize-instance :after ((parser table-parser) &key &allow-other-keys) (setf (slot-value parser 'done) (make-array (length (aref (text-block parser) 0)) :element-type 'fixnum :initial-element -1)) (with-slots(text-block separator-pattern head-body-sep) parser (dotimes(i (length text-block)) (let((line (aref text-block i))) (when (scan separator-pattern line) (if head-body-sep (error 'table-condition :source text-block :level :error :message (format nil "Multiple head/body row separators in table (at line offset ~d and ~d); only one allowed." head-body-sep i)) (progn (setf head-body-sep i) (setf (aref text-block i) (substitute #\- #\= line))))))) (when (and head-body-sep (or (= head-body-sep 0) (= head-body-sep (1- (length text-block))))) (error 'table-condition :source text-block :level :error :message "The head/body row separator may not be the first or last line of the table.")))) (defclass grid-table-parser(table-parser) ((cells :initform nil :accessor cells) (colseps :accessor colseps :initform '(0)) (rowseps :accessor rowseps :initform '(0))) (:default-initargs :separator-pattern "^\\+=[=+]+=\\+$") (:documentation "Parse a grid table using `parse()`. Here's an example of a grid table:: +------------------------+------------+----------+----------+ | Header row, column 1 | Header 2 | Header 3 | Header 4 | +========================+============+==========+==========+ | body row 1, column 1 | column 2 | column 3 | column 4 | +------------------------+------------+----------+----------+ | body row 2 | Cells may span columns. | +------------------------+------------+---------------------+ | body row 3 | Cells may | - Table cells | +------------------------+ span rows. | - contain | | body row 4 | | - body elements. | +------------------------+------------+---------------------+ Intersections use '+', row separators use '-' (except for one optional head/body row separator, which uses '='), and column separators use '|'. Passing the above table to the `parse()` method will result in the following data structure:: ([24, 12, 10, 10], [[(0, 0, 1, ['Header row, column 1']), (0, 0, 1, ['Header 2']), (0, 0, 1, ['Header 3']), (0, 0, 1, ['Header 4'])]], [[(0, 0, 3, ['body row 1, column 1']), (0, 0, 3, ['column 2']), (0, 0, 3, ['column 3']), (0, 0, 3, ['column 4'])], [(0, 0, 5, ['body row 2']), (0, 2, 5, ['Cells may span columns.']), None, None], [(0, 0, 7, ['body row 3']), (1, 0, 7, ['Cells may', 'span rows.', '']), (1, 1, 7, ['- Table cells', '- contain', '- body elements.']), None], [(0, 0, 9, ['body row 4']), None, None, None]]) The first item is a list containing column widths (colspecs). The second item is a list of head rows, and the third is a list of body rows. Each row contains a list of cells. Each cell is either None (for a cell unused because of another cell's span), or a tuple. A cell tuple contains four items: the number of extra rows used by the cell in a vertical span (morerows); the number of extra columns used by the cell in a horizontal span (morecols); the line offset of the first line of the cell contents; and the cell contents, a list of lines of text.")) (defun get-2d-block(text top left bottom right &key (strip-indent t)) (let((result (make-array (- bottom top)))) (when (> bottom top) (dotimes(i (length result)) (setf (aref result i) (subseq (aref text (+ i top)) left right))) (when strip-indent (let ((indent (reduce #'min (map 'list #'indent-level result)))) (when (< 0 indent right) (dotimes(i (length result)) (setf (aref result i) (subseq (aref result i) indent)))))) (dotimes(i (length result)) (setf (aref result i) (rstrip (aref result i))))) result)) (defun do-parse-table(parser) (let ((bottom (bottom (text-block parser))) (right (right (text-block parser)))) (let ((corners (list (list 0 0)))) (while corners (let* ((corner (pop corners)) (top (first corner)) (left (second corner))) (unless (or (= top bottom) (= left right) (<= top (aref (done parser) left))) (multiple-value-bind(bottom right rowseps colseps ok-p) (scan-cell parser top left) (when ok-p (setf (rowseps parser) (union rowseps (rowseps parser))) (setf (colseps parser) (union colseps (colseps parser))) (mark-done (done parser) top left bottom right) (push (list top left bottom right (get-2d-block (text-block parser) (1+ top) (1+ left) bottom right)) (cells parser)) (push (list top right) corners) (push (list bottom left) corners) (setf corners (sort corners #'(lambda(a b) (or (< (first a) (first b)) (and (= (first a) (first b)) (< (second a) (second b))))))))))))) (unless (check-parse-complete parser) (error 'table-condition :source (text-block parser) :level :error :message "parse incomplete")))) (defun mark-done(done top left bottom right) (let ((before (1- top)) (after (1- bottom))) (do((col left (1+ col))) ((>= col right)) (assert (= (aref done col) before)) (setf (aref done col) after)))) (defun check-parse-complete(parser) (let ((last (1- (bottom (text-block parser)))) (done (done parser))) (dotimes(col (right (text-block parser))) (unless (= (aref done col) last) (return-from check-parse-complete nil)))) t) (defun scan-cell(parser top left) (assert (eql (aref (aref (text-block parser) top) left) #\+)) (scan-right (text-block parser) top left)) (defun scan-right(text-block top left) "Look for the top-right corner of the cell, and make note of all column boundaries ('+')." (let ((colseps nil) (line (aref text-block top)) (right (right text-block))) (do((i (1+ left) (1+ i))) ((> i right)) (case (aref line i) (#\+ (push i colseps) (multiple-value-bind(bottom rowseps newcolseps ok-p) (scan-down text-block top left i) (when ok-p (setf colseps (nunion newcolseps colseps)) (return-from scan-right (values bottom i rowseps colseps t))))) (#\-) (t (return-from scan-right)))))) (defun scan-down(text-block top left right) "Look for the bottom-right corner of the cell, making note of all row boundaries." (let ((rowseps nil) (bottom (bottom text-block))) (do((i (1+ top) (1+ i))) ((> i bottom)) (case (aref (aref text-block i) right) (#\+ (push i rowseps) (multiple-value-bind(newrowseps colseps ok-p) (scan-left text-block top left i right) (when ok-p (setf rowseps (nunion newrowseps rowseps)) (return-from scan-down (values i rowseps colseps t))))) (#\|) (t (return-from scan-down)))))) (defun scan-left(text-block top left bottom right) "Noting column boundaries, look for the bottom-left corner of the cell. It must line up with the starting point." (let ((colseps nil) (line (aref text-block bottom))) (when (char= (aref line left) #\+) (do((i (1- right) (1- i))) ((<= i left)) (case (aref line i) (#\+ (pushnew i colseps)) (#\-) (t (return-from scan-left)))) (multiple-value-bind(rowseps ok-p) (scan-up text-block top left bottom) (when ok-p (return-from scan-left (values rowseps colseps t))))))) (defun scan-up(text-block top left bottom) "Noting row boundaries, see if we can return to the starting point." (let ((rowseps nil)) (do((i (1- bottom) (1- i))) ((<= i top)) (case (aref (aref text-block i) left) (#\+ (pushnew i rowseps)) (#\|) (t (return-from scan-up)))) (values rowseps t))) (defun structure-from-cells(parser) (let* ((rowseps (sort (copy-list (rowseps parser)) #'<)) (colseps (sort (copy-list (colseps parser)) #'<)) (colspecs (map 'list #'(lambda(a b) (- a b 1)) (rest colseps) colseps)) (rmax (1- (length rowseps))) (cmax (1- (length colseps))) (rows (make-array (list rmax cmax) :initial-element nil)) (remaining (* rmax cmax))) (flet((rowindex(row) (position row rowseps)) ;; row boundary -> index (colindex(col) (position col colseps))) ;; col boundary -> index (dolist(cell (cells parser)) (destructuring-bind (top left bottom right block) cell (let ((rownum (rowindex top)) (colnum (colindex left))) (when (aref rows rownum colnum) (report :error `("Cell (row ~D, column ~D) is already used" ,(1+ rownum) ,(1+ colnum)))) (let ((morerows (- (rowindex bottom) rownum 1)) (morecols (- (colindex right) colnum 1))) (decf remaining (* (1+ morerows) (1+ morecols))) (setf (aref rows rownum colnum) (list morerows morecols (1+ top) block)))))) (when (> remaining 0) (report :error "Unused cells remaining")) (if (head-body-sep parser) (let((h (rowindex (head-body-sep parser)))) (list colspecs (make-array (list h cmax) :displaced-to rows :displaced-index-offset 0) (make-array (list (- rmax h) cmax) :displaced-to rows :displaced-index-offset (* h cmax)))) (list colspecs nil rows)))))
12,280
Common Lisp
.lisp
269
35.520446
141
0.536439
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
46972e647eba1b45bc6f89427fe391cabb308b56656cd5af6230c55c67a3f937
7,431
[ -1 ]
7,432
regexp.lisp
willijar_cl-docutils/parsers/regexp.lisp
;;;; Regular expression parse trees for Common Lisp restructured text ;;;;;implementation ;;;; Copyright (C) 2002-2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; See ;;;; http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html (in-package :docutils.parser.rst) ;;;Fragments of patterns used by transitions. (define-parse-tree-synonym wsp (:char-class #\space #\newline #\Return #\tab #\Page #\rubout #.(code-char 11))) (define-parse-tree-synonym alpha (:char-class (:range #\a #\z) (:range #\A #\Z))) (define-parse-tree-synonym alphanum (:char-class (:range #\a #\z) (:range #\A #\Z) (:range #\0 #\9))) (define-parse-tree-synonym digit (:char-class (:range #\0 #\9))) (define-parse-tree-synonym alphanum+ (:char-class (:range #\a #\z) (:range #\A #\Z) (:range #\0 #\9) #\_ #\-)) (define-parse-tree-synonym nonalphanum7bit (:char-class (:range #\! #\/) (:range #\: #\@) (:range #\[ #\`) (:range #\{ #\~))) (define-parse-tree-synonym optname (:sequence alphanum (:greedy-repetition 0 NIL alphanum+))) (define-parse-tree-synonym optarg (:alternation optname (:sequence #\< alphanum (:greedy-repetition 1 nil (:inverted-char-class #\< #\>)) #\>))) ;;; options use 3 registers (define-parse-tree-synonym shortopt (:sequence (:NEGATIVE-LOOKBEHIND (:alternation #\+ #\-)) (:register (:sequence (:alternation #\+ #\-) alpha)) (:greedy-repetition 0 1 (:sequence (:register #\space) (:register optarg))))) (define-parse-tree-synonym longopt (:sequence (:register (:sequence (:alternation "--" #\/) optname)) (:greedy-repetition 0 1 (:sequence (:register (:char-class #\space #\=)) (:register optarg))))) (define-parse-tree-synonym option (:alternation longopt shortopt)) (define-parse-tree-synonym option-marker (:sequence :start-anchor option (:greedy-repetition 0 nil (:sequence ", " option)) (:alternation (:greedy-repetition 2 2 #\space) :end-anchor))) (define-parse-tree-synonym line (:sequence :start-anchor (:register nonalphanum7bit) (:greedy-repetition 0 nil (:back-reference 1)) (:greedy-repetition 0 nil #\space) :end-anchor)) (define-parse-tree-synonym non-whitespace-before (:NEGATIVE-LOOKBEHIND wsp)) (define-parse-tree-synonym non-whitespace-escape-before (:NEGATIVE-LOOKBEHIND (:alternation wsp #\null))) (define-parse-tree-synonym whitespace-after (:POSITIVE-LOOKAHEAD wsp)) (define-parse-tree-synonym non-whitespace-after (:NEGATIVE-LOOKAHEAD wsp)) ;; Alphanumerics with isolated internal [-._] chars (i.e. not 2 together): (define-parse-tree-synonym simplename (:SEQUENCE (:GREEDY-REPETITION 1 NIL (:GROUP (:SEQUENCE (:NEGATIVE-LOOKAHEAD #\_) alphanum))) (:GREEDY-REPETITION 0 NIL (:GROUP (:SEQUENCE (:CHAR-CLASS #\- #\. #\_) (:GREEDY-REPETITION 1 NIL (:GROUP (:SEQUENCE (:NEGATIVE-LOOKAHEAD #\_) alphanum)))))))) (define-parse-tree-synonym whitespace-after (:POSITIVE-LOOKAHEAD (:CHAR-CLASS #\space #\newline))) (define-parse-tree-synonym whitespace-before (:POSITIVE-LOOKBEHIND (:CHAR-CLASS #\space #\newline))) (define-parse-tree-synonym not-escaped (:NEGATIVE-LOOKBEHIND #\Null)) (define-parse-tree-synonym start-phrase-prefix (:ALTERNATION (:POSITIVE-LOOKBEHIND :START-ANCHOR) (:POSITIVE-LOOKBEHIND (:CHAR-CLASS #\- #\/ #\: #\space #\Newline #\' #\" #\( #\[ #\{ #\<)))) (define-parse-tree-synonym end-phrase-suffix (:ALTERNATION (:POSITIVE-LOOKAHEAD :END-ANCHOR) (:POSITIVE-LOOKAHEAD (:CHAR-CLASS #\- #\/ #\: #\. #\, #\; #\! #\? #\Space #\Newline #\Null #\' #\" #\) #\] #\} #\>)))) (defmacro define-recursive-element-parse-tree(name start &optional (end start)) "Matches an element that is recursive i.e. uses a greedy match" `(define-parse-tree-synonym ,name (:sequence start-phrase-prefix ,start non-whitespace-before (:register (:GREEDY-REPETITION 0 NIL :everything)) non-whitespace-before ,end end-phrase-suffix))) (define-parse-tree-synonym uric ;; Valid URI characters (see RFC 2396 & RFC 2732); ;; final \x00 allows backslash escapes in URIs: (:CHAR-CLASS #\- #\_ #\. #\! #\~ #\* #\' #\( #\) #\[ #\] #\; #\/ #\: #\@ #\& #\= #\+ #\$ #\, #\% (:RANGE #\a #\z) (:RANGE #\A #\Z) (:RANGE #\0 #\9) #\Null)) (define-parse-tree-synonym uri-end-delim ;; Delimiter indicating the end of a URI (not part of the URI): (:CHAR-CLASS #\>)) (define-parse-tree-synonym urilast ;; Last URI character; same as uric but no punctuation: (:CHAR-CLASS #\_ #\~ #\* #\/ #\= #\+ (:RANGE #\a #\z) (:RANGE #\A #\Z) (:RANGE #\0 #\9))) (define-parse-tree-synonym uri-end ;; End of a URI (either 'urilast' or 'uric followed by a ;; uri_end_delim') (:ALTERNATION urilast (:sequence uric uri-end-delim))) (define-parse-tree-synonym emailc (:CHAR-CLASS #\- #\_ #\! #\~ #\* #\' #\{ #\| #\} #\/ #\# #\? #\^ #\` #\& #\= #\+ #\$ #\% (:RANGE #\a #\z) (:RANGE #\A #\Z) (:RANGE #\0 #\9) #\Null)) (define-parse-tree-synonym email-pattern (:SEQUENCE (:GREEDY-REPETITION 1 NIL emailc) ; name (:GREEDY-REPETITION 0 NIL (:SEQUENCE #\. (:GREEDY-REPETITION 1 NIL emailc))) not-escaped #\@ ; unescaped @ (:GREEDY-REPETITION 1 NIL emailc) ; host (:GREEDY-REPETITION 0 NIL (:SEQUENCE #\. (:GREEDY-REPETITION 1 NIL emailc))) uri-end)) ; final URI char (define-parse-tree-synonym uri (:SEQUENCE start-phrase-prefix (:alternation (:register (:sequence (:register (:sequence alpha (:GREEDY-REPETITION 0 NIL (:alternation alphanum (:char-class #\. #\+ #\-))))) ; scheme #\: (:sequence #\/ (:greedy-repetition 0 1 #\/)) (:greedy-repetition 0 nil uric) uri-end (:GREEDY-REPETITION 0 1 ; query (:sequence #\? (:greedy-repetition 0 nil uric) uri-end)) (:GREEDY-REPETITION 0 1 ; fragment (:sequence #\# (:greedy-repetition 0 nil uric) uri-end)))) (:register email-pattern)) end-phrase-suffix)) (define-parse-tree-synonym embedded-uri (:sequence (:alternation (:positive-lookbehind (:alternation #\space #\newline)) (:positive-lookbehind :start-anchor)) #\< non-whitespace-after (:register (:greedy-repetition 1 nil (:inverted-char-class #\< #\> #\null))) non-whitespace-before #\> :end-anchor)) ;; from RFC 3986 (([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))")) ;; registers are ;; scheme = $2 ;; authority = $4 ;; path = $5 ;; query = $7 ;; fragment = $9
7,003
Common Lisp
.lisp
184
32.788043
81
0.604336
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
e6ac17bc1ff02beabfc5e2ba7a19b87a88a6d0eb5ebe81abb2a7d9cc2b56972b
7,432
[ -1 ]
7,433
inline.lisp
willijar_cl-docutils/parsers/inline.lisp
;;;; rstructuredtext implementation for Common Lisp ;;;; Copyright (C) 2002-2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; An attempt to parse the rstructuredtext syntax into markup ;;;; See ;;;; http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html (in-package :docutils.parser.rst) (defgeneric parse-role(role text &optional option-values supplied-content) (:documentation "Apply given role to text, returning a list of markup elements to be inserted in place")) (defparameter openers "'\"([{<") (defparameter closers "'\")]}>") (eval-when(:compile-toplevel :load-toplevel :execute) (defun not-quoted(&rest expr) "Return a parse tree expression for expr not quoted" `(:alternation (:sequence (:negative-lookbehind (:alternation #\' #\" #\( #\[ #\{ #\<)) ,@expr) (:sequence (:positive-lookbehind #\') ,@expr (:negative-lookahead #\')) (:sequence (:positive-lookbehind #\") ,@expr (:negative-lookahead #\")) (:sequence (:positive-lookbehind #\() ,@expr (:negative-lookahead #\))) (:sequence (:positive-lookbehind #\[) ,@expr (:negative-lookahead #\])) (:sequence (:positive-lookbehind #\{) ,@expr (:negative-lookahead #\})) (:sequence (:positive-lookbehind #\<) ,@expr (:negative-lookahead #\>)))) (defun quoted-pattern(&rest expr) "Return a parse tree expression for a quoted expression quoted" `(:alternation (:sequence (:positive-lookbehind (:alternation #\' #\" #\( #\[ #\{ #\<)) ,@expr) (:sequence (:negative-lookbehind #\') ,@expr (:positive-lookahead #\')) (:sequence (:negative-lookbehind #\") ,@expr (:positive-lookahead #\")) (:sequence (:negative-lookbehind #\() ,@expr (:positive-lookahead #\))) (:sequence (:negative-lookbehind #\[) ,@expr (:positive-lookahead #\])) (:sequence (:negative-lookbehind #\{) ,@expr (:positive-lookahead #\})) (:sequence (:negative-lookbehind #\<) ,@expr (:positive-lookahead #\>)))) ) (defmacro define-inline-element-parse-tree (name start &optional (end start) (middle '(:register (:NON-GREEDY-REPETITION 0 NIL :everything)))) `(define-parse-tree-synonym ,name (:sequence :single-line-mode-p start-phrase-prefix ,(not-quoted start) non-whitespace-after ,middle non-whitespace-before ,end end-phrase-suffix))) (define-inline-element-parse-tree strong "**") (define-inline-element-parse-tree math "$$") (define-inline-element-parse-tree emphasis (:sequence #\* (:negative-lookahead #\* ) ) (:sequence (:negative-lookbehind #\*) #\*)) (define-parse-tree-synonym role (:GREEDY-REPETITION 1 1 (:sequence #\: (:register simplename) #\:))) (eval-when(:compile-toplevel :load-toplevel :execute) (setf (cl-ppcre:parse-tree-synonym 'single-quoted) `(:sequence ,(not-quoted #\` '(:negative-lookahead #\`)) non-whitespace-before (:register (:non-greedy-repetition 1 NIL (:alternation (:inverted-char-class #\`) ,(quoted-pattern #\`)))) non-whitespace-before ,(not-quoted '(:negative-lookbehind #\`) #\`)))) (define-parse-tree-synonym interpreted (:sequence start-phrase-prefix (:alternation (:sequence role single-quoted) (:sequence single-quoted role) single-quoted) end-phrase-suffix)) (define-inline-element-parse-tree literal "``") (define-inline-element-parse-tree internal-target "_`" (:sequence (:negative-lookbehind #\`) #\`)) (define-inline-element-parse-tree substitution-reference #\| (:sequence #\| (:register (:greedy-repetition 0 2 #\_) ))) (define-inline-element-parse-tree footnote-reference "[" "]_") (define-parse-tree-synonym reference (:sequence start-phrase-prefix (:alternation single-quoted (:register simplename)) non-whitespace-before (:register (:greedy-repetition 1 2 #\_)) end-phrase-suffix)) (defparameter rst-patterns (mapcar #'(lambda(pattern) (cons pattern pattern)) `(strong emphasis math interpreted literal internal-target substitution-reference footnote-reference reference uri))) ;;; algorithm is for each pattern, scan through string collecting all matches ;;; order matches by start, and group by recursion. Remove overlapping patterns ;;; call handler function for outside element of each group ;;; handler function decides whether to recurse or not. (defun parse-inline(patterns string &key line (start 0) (end (length string)) (language *language*)) "Parse a string for inline patterns. Return a list of inline markup elements and system messages. Patterns is a list of patterns to be applied in turn. Each pattern can either be a symbol naming both the parse-tree synonym and a function or a cons of a regular expression pattern and a function. The pattern functions are called with two arguments, the match corresponding to the regexp match and a list of remaining patterns to be applied recursively. They should return a list of inline elements to be inserted. The :start and :end keyword arguments have their usual meanings." (let ((*language* language)) (cond ((= start end) nil) ((null patterns) (list (unescape string :restore-backslashes t :start start :end end))) ((let ((matches nil)) ;; get all matches of all patterns in ascending order but ignore ;; those which have a quoted start (dolist(pattern patterns) (multiple-value-bind(pattern function) (etypecase pattern (symbol (values pattern pattern)) (cons (values (car pattern) (cdr pattern)))) (setf matches (merge 'list matches (mapcar #'(lambda(m) (cons m function)) (matches pattern string :start start :end end)) #'< :key #'(lambda(r) (match-start (car r))))))) ;; remove nested and overlapping elements (let ((cursor matches)) (loop (unless (cdr cursor) (return)) (let ((end (match-end (caar cursor))) (next-start (match-start (caadr cursor))) (next-end (match-end (caadr cursor)))) (cond ((> next-start end)) ; outside - move to next ((> next-end end) ; overlapping - report and remove (report :warning (format nil "Inline markup for ~S not nested" (cdar matches)) :line line :source (unescape (match-string (caadr matches)))) (setf (cdr cursor) (cddr cursor))) (t (setf (cdr cursor) (cddr cursor)))) (setf cursor (cdr cursor))))) ;; build up result (let ((cursor start)) (flet((make-txt(end) (when (> end cursor) ; only if not zero length (list (make-instance ; add a text element 'docutils.nodes:text :text (unescape string :restore-backslashes t :start cursor :end end)))))) (nconc (mapcan #'(lambda(m) (let ((match (car m)) (func (cdr m))) (nconc (make-txt (match-start match)) (prog1 (funcall func match :line line) (setf cursor (match-end match)))))) matches) (make-txt end))))))))) (defmacro make-inline-nodes(type attributes &optional children) (let ((node (gensym))) `(list (let ((,node (apply #'docutils:make-node (cons ',(intern (string-upcase (eval type)) :docutils.nodes) ,attributes)))) (add-child ,node ,children) ,node)))) (defun emphasis(match &rest attributes) (make-inline-nodes 'emphasis attributes (parse-inline rst-patterns (match-string match) :start (elt (match-reg-starts match) 0) :end (elt (match-reg-ends match) 0)))) (defun strong(match &rest attributes) (make-inline-nodes 'strong attributes (parse-inline rst-patterns (match-string match) :start (elt (match-reg-starts match) 0) :end (elt (match-reg-ends match) 0)))) (defun math(match &rest attributes) (make-inline-nodes 'math attributes (list (concatenate 'string "$" (unescape (match-group match 0) :restore-backslashes t) "$")))) (defun literal(match &rest attributes) (make-inline-nodes 'literal attributes (list (unescape (match-group match 0) :restore-backslashes t)))) (defun interpreted(match &rest attributes) (declare (ignore attributes)) (let ((role (or (match-group match 0) (match-group match 3))) (phrase (or (match-group match 1) (match-group match 2) (match-group match 4)))) (let ((result (parse-role (or (canonical-text role) role) phrase))) (if (listp result) result (list result))))) (defun internal-target(match &rest attributes ) (make-inline-nodes 'target `(,@attributes :name ,(normalise-name (unescape (match-group match 0)))) (parse-inline rst-patterns (match-string match) :start (elt (match-reg-starts match) 0) :end (elt (match-reg-ends match) 0)))) (defun substitution-reference(match &rest attributes) (let ((end (match-group-length match 1)) (refname (normalise-name (match-group match 0)))) (let ((sub (make-inline-nodes 'substitution-reference attributes (list refname)))) (setf (attribute (first sub) :refname) refname) (if (> end 0) (make-inline-nodes 'reference `(:refname ,refname ,@(when (= 2 end) `(:anonymous t))) sub) sub)))) (defun footnote-reference(match &rest attributes) (let* ((label (match-group match 0)) (refname (normalise-name label))) (cond ((string= label "*") ;; auto symbol footnote (make-inline-nodes 'footnote-reference `(:auto #\* ,@attributes))) ((string= label "#") ;; auto number footnote (make-inline-nodes 'footnote-reference `(:auto 1 ,@attributes))) ((char= (char label 0) #\#) ;;labeled and autonumbered footnote (make-inline-nodes 'footnote-reference `(:auto 1 :refname ,(subseq refname 1) ,@attributes))) ((digit-char-p (char label 0)) ;; nanually labelled footnote (make-inline-nodes 'footnote-reference `(:refname ,refname ,@attributes) refname)) (t ;; citation reference (make-inline-nodes 'citation-reference `(:refname ,refname ,@attributes) label))))) (defun add-attributes(node attributes) (loop :for a :on attributes :by #'cddr :do (setf (attribute node (first a)) (second a)))) (defun reference(match &rest attributes) (let* ((rawtext (or (match-group match 0) (match-group match 1))) (uri-match (match 'embedded-uri rawtext)) (anon-p (> (match-group-length match 2) 1))) (flet((reference-node(text) (let ((node (docutils:make-node 'docutils.nodes:reference :anonymous anon-p text))) (add-attributes node attributes) node))) (if uri-match (let* ((uri (cl-ppcre::regex-replace "\\s+" (match-group uri-match 0) "")) (text (rstrip (unescape (subseq rawtext 0 (match-start uri-match))))) (refname (normalise-name text)) (reference (reference-node text))) (setf (attribute reference :refuri) uri) (setf (resolved reference) t) (if anon-p (list reference) (let ((target (docutils:make-node 'docutils.nodes:target :refuri uri :name refname (match-group uri-match 0)))) (add-attributes target attributes) (setf (referenced target) t) (list reference target) ))) (let* ((text (unescape rawtext)) (reference (reference-node text))) (setf (attribute reference :refname) (normalise-name text)) (list reference)))))) (defun uri(match &rest attributes) (declare (ignore attributes)) (let* ((unescaped (unescape (match-group match))) (uri (if (and (not (match-group match 1)) (match-group match 2)) (concatenate 'string "mailto:" unescaped) unescaped))) (list (docutils:make-node 'docutils.nodes:reference :refuri uri unescaped))))
13,373
Common Lisp
.lisp
293
35.525597
85
0.58815
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
47ee6e46d27d697e2f1336a69c66add39c10a782ea2376c0a142ec4bcd73ad22
7,433
[ -1 ]
7,434
defpackage.lisp
willijar_cl-docutils/parsers/defpackage.lisp
;;;; rstructuredtext implementation for Common Lisp ;;;; Copyright (C) 2002-2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details (in-package :cl-user) (defpackage :docutils.parser (:documentation "Library for docutils parsers") (:use :cl :docutils :docutils.utilities) (:import-from :cl-ppcre #:scan) (:export #:state-machine-eof #:unexpected-indentation #:state-machine #:state-machine-run #:state-correction #:transition-correction #:goto-line #:current-line #:next-line #:previous-line #:abs-line-offset #:abs-line-number #:add-states #:get-text-block #:input-lines #:line-offset #:next-line-blank-p #:state #:no-match #:bof #:eof #:nop #:initial-state #:wsp-state-machine #:wsp-state #:+wsp-transitions+ #:wsp-state-machine #:blank #:indent #:get-indented #:blank-finish #:known-indent #:known-first-indent #:initial-transitions #:add-transitions #:remove-transition #:match #:matches #:match-string #:match-start #:match-end #:match-group #:match-group-length #:+wsp-transitions+ #:match-reg-starts #:match-reg-ends #:matches #:transition-name #:transitions #:transition-match #:insert-lines #:apply-transition)) (defpackage :docutils.parser.tables (:documentation "CALS Table parser") (:use :cl :docutils :docutils.utilities) (:import-from :cl-ppcre #:create-scanner #:scan) (:export #:parse-table #:simple-table-parser #:grid-table-parser #:table-condition)) (defpackage :docutils.parser.rst (:documentation "Restructured text parser for docutils") (:use :cl :docutils :docutils.parser :docutils.utilities :docutils.parser.tables :data-format-validation) (:shadow #:make-node #:line) (:import-from :docutils #:add-transform) (:import-from :cl-ppcre #:create-scanner #:scan #:do-scans #:define-parse-tree-synonym #:split) (:import-from :data-format-validation #:is-nil-string) (:export #:rst-reader #:def-directive #:def-role #:&allow-spaces #:&option #:&content #:&content-parser))
2,138
Common Lisp
.lisp
42
46.97619
76
0.706501
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
f917b9ad9081dd66a56c3a9cc9500daf0f3f4f42abe3164e393d85fc6c2cf6cd
7,434
[ -1 ]
7,435
state-machine.lisp
willijar_cl-docutils/parsers/state-machine.lisp
;;;; rstructuredtext implementation for Common Lisp ;;;; Copyright (C) 2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; An attempt to parse the rstructuredtext syntax into markup ;;;; See ;;;; http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html ;;;; $Id: state-machine.lisp,v 1.11 2007/08/03 08:18:32 willijar Exp $ ;;;; Where the symantics differ from the document above it should be ;;;; considered an error EXCEPT that we will allow nested inline ;;;; markup. (in-package :docutils.parser) (defvar *goto-line-hooks* nil "A list of functions called when state machine moves to another line. Functions take two functions, the state machine and the absolute line offset") (defvar *state-change-hooks* nil "A list of functions called when state is changed. Called with state machine and the new state object") (define-condition unexpected-indentation(condition) ((line-number :initform nil :initarg :line :reader error-line) (text-block :initarg :text-block :initform nil :reader error-text-block)) (:report (lambda(c stream) (format stream "Unexpected indentation~@[ at line number ~D~]:~% ~S" (error-line c) (error-text-block c))))) (define-condition insert-lines(condition) ((text-block :initarg :text-block :initform nil :reader error-text-block))) (defclass state-machine() ((input-lines :initarg :input-lines :reader input-lines :documentation "vector of input lines (without newlines)") (states :initform nil :initarg :states :accessor states :documentation "a list of allowed state classe names.") (initial-state :initarg :initial-state :reader initial-state :documentation "the initial state name.") (current-state :reader current-state :documentation "the current state.") (input-offset :initform 0 :reader input-offset :initarg :input-offset :documentation "Offset of input-lines from the beginning of the file.") (line-offset :initform -1 :accessor line-offset :documentation "Current input line offset from beginning of input-lines.")) (:documentation "A finite state machine for text filters using matching functions The input is provided in the form of a list of one-line strings (no newlines) which may be modified. States are subclasses of the `State` class. Transitions consist of regular expression patterns and transition methods, and are defined in each state. The state machine is started with the `run()` method, which returns the results of processing in a list.")) (defun (setf current-state)(state state-machine) (dolist(hook *state-change-hooks*) (funcall hook state-machine state)) (setf (slot-value state-machine 'current-state) state)) (declaim (inline current-line)) (defun current-line(state-machine &optional (index (line-offset state-machine))) (aref (input-lines state-machine) index)) (defun insert-lines(state-machine lines &optional (offset (1+ (line-offset state-machine)))) (assert (> offset (line-offset state-machine)) (offset) "Offset must be greater than current line offset ~S" (line-offset state-machine)) (with-slots(input-lines) state-machine (setf input-lines (if (> offset (length input-lines)) (concatenate 'vector input-lines lines) (concatenate 'vector (subseq input-lines 0 offset) lines (subseq input-lines offset)))))) (defgeneric state-machine-run(state-machine input-lines &key input-offset initial-state &allow-other-keys) (:documentation "Run state machine over input lines filling in document")) (defmethod state-machine-run((state-machine state-machine) (input-lines vector) &key (input-offset 0) (initial-state (initial-state state-machine)) &allow-other-keys) "Run the state machine on INPUT-LINES. Return results (a list). INPUT-LINES: a list of strings without newlines. INPUT-OFFSET: the line offset of `input_lines` from the beginning of the data. INPUT-SOURCE: name or path of source of INPUT_LINES." (setf (slot-value state-machine 'input-lines) input-lines (slot-value state-machine 'input-offset) input-offset (line-offset state-machine) -1) (let* ((state (get-state state-machine initial-state)) (transitions (transitions state)) (results nil) (*current-line-number* (abs-line-number state-machine))) (handler-bind((insert-lines #'(lambda(e) (insert-lines state-machine (error-text-block e)) (continue e)))) (flet((extend-results(result) (when result (push result results)))) (extend-results (bof state)) (catch 'state-machine-eof (loop (next-line state-machine) (restart-case (multiple-value-bind(result next-state) (check-line state-machine state transitions) (when next-state (setf state (get-state state-machine next-state))) (setf transitions (transitions state)) (extend-results result)) (transition-correction(new-transition) (previous-line state-machine) (setf transitions (list (assoc new-transition transitions)))) (state-correction(next-state-name &key limit-transitions lines) (previous-line state-machine lines) (setf state (get-state state-machine next-state-name)) (setf transitions (if limit-transitions (mapcan #'(lambda(tr) (when (member (car tr) limit-transitions) (list tr))) (transitions state)) (transitions state)) ))))) (extend-results (eof state)))) (nreverse results))) (defun get-state(state-machine &optional next-state) "Return new state class object" (when next-state (unless (member (if (listp next-state) (first next-state) next-state) (states state-machine)) (error "Unknown state ~A for ~A" next-state state-machine)) (setf (current-state state-machine) (apply #'make-instance `(,@(if (listp next-state) next-state (list next-state)) :state-machine ,state-machine)))) (current-state state-machine)) (defun next-line(state-machine &optional (n 1)) (with-slots (line-offset input-lines) state-machine (incf line-offset n) (if (or (< line-offset 0) (>= line-offset (length input-lines))) (throw 'state-machine-eof nil) (current-line state-machine)))) (defun next-line-blank-p(state-machine) "TRUE if the next line is blank or non-existant." (let ((next (1+ (line-offset state-machine)))) (or (>= next (length (input-lines state-machine))) (line-blank-p (current-line state-machine next))))) (defun at-eof(state-machine) "True if the input is at or past end-of-file." (>= (line-offset state-machine) (1- (length (input-lines state-machine))))) (defun at-bof(state-machine) "True if the input is at or before beginning-of-file." (<= (line-offset state-machine) 0)) (defun previous-line(state-machine &optional (n 1)) (decf (line-offset state-machine) n) (when (>= (line-offset state-machine) 0) (current-line state-machine))) (defun goto-line(state abs-line-offset) "Jump to absolute line offset abs-line-offset, load and return it." (let* ((state-machine (state-machine state)) (line-offset (- abs-line-offset (input-offset state-machine)))) (setf (line-offset state-machine) line-offset) (unless (or (< line-offset 0) ;; unless eof (>= abs-line-offset (length (input-lines state-machine)))) (dolist(hook *goto-line-hooks*) (funcall hook state-machine abs-line-offset)) (current-line state-machine line-offset)))) (defun abs-line-offset(state-machine) "Return Return line offset of current line, from beginning of file." (+ (line-offset state-machine) (input-offset state-machine))) (defun abs-line-number(state-machine) (+ 1 (line-offset state-machine) (input-offset state-machine))) (defun get-text-block(state-machine &key flush-left (start (line-offset state-machine))) "Return a contiguous block of text. If `flush_left` is true, signal `UnexpectedIndentationError` if an indented line is encountered before the text block ends (with a blank line)." (let* ((input-lines (input-lines state-machine)) (last (length input-lines)) (text-block (subseq input-lines start (do((end start (1+ end))) ((>= end last) end) (let ((line (aref input-lines end))) (when (line-blank-p line) (return end)) (when (and flush-left (char= (char line 0) #\space)) (next-line state-machine (1- (- end start))) ; go to last line (signal 'unexpected-indentation :line (1+ end) :text-block (subseq input-lines start)) (return (1- end)))))))) (next-line state-machine (1- (length text-block))) text-block)) (defun check-line(state-machine state &optional (transitions (transitions state))) (let ((line (current-line state-machine)) (*current-line-number* (abs-line-number state-machine))) (dolist (transition transitions) (let ((match (transition-match transition line))) (when match (return-from check-line (apply-transition state transition match)))))) (no-match state transitions)) (defun add-states(state-machine state-classnames) "register state classes with this state engine" (dolist(state-classname state-classnames) (when (member state-classnames (states state-machine)) (error "Duplicate State ~A in ~A ~%" state-classname state-machine)) (push state-classname (states state-machine)))) (declaim (inline transition-name transition-pattern transition-function transition-next-state)) (defun transition-name(transition) (first transition)) (defun transition-pattern(transition) (second transition)) (defun transition-next-state(transition) (third transition)) (defun transition-function(transition) (first transition)) (defun transition-match(transition string) (match (transition-pattern transition) string)) (defgeneric apply-transition(state transition match) (:documentation "Execute transition from state with match") (:method(state transition match) (multiple-value-bind(result next-state) (funcall (transition-function transition) state match) (when result (break "Result not nil for state ~S transition ~S" state transition)) (values result (or next-state (transition-next-state transition)))))) (defclass state() ((state-machine :initarg :state-machine :reader state-machine :documentation "A reference to the controlling StateMachine object.") (initial-transitions :allocation :class :initform nil :reader initial-transitions :documentation "The initial set of transitions for this state") (transitions :accessor transitions :documentation "List of transitions in order.")) (:documentation "State superclass.")) (defgeneric make-nested-state-machine(state &optional initial-state) (:documentation "Created a nested state machine to parse nested document structures.") (:method ((state state) &optional (initial-state (class-name state))) (make-instance (class-of (state-machine state)) :initial-state initial-state :state-classes (list (class-name state))))) (defmethod initialize-instance :after ((state state) &key &allow-other-keys) (setf (transitions state) (slot-value state 'initial-transitions))) (defun add-transitions(state transitions) "Add a list of transitions to the start of the transition list." (dolist(transition transitions) (when (member transition (transitions state) :key #'transition-name) (error "Duplicate Transition ~A" transition)) (push transition (transitions state)))) (defun remove-transition(state name) "Remove a transition by `name`" (setf (transitions state) (remove name (transitions state) :key #'transition-name))) (defgeneric no-match(state transitions) (:documentation "Called when there is no match from `StateMachine.check_line()`.") (:method (state transitions) nil)) (defgeneric bof(state) (:documentation "Beginning of file transition") (:method(state) nil)) (defgeneric eof(state) (:documentation "End of file transition") (:method (state) nil)) (defgeneric nop(state match) (:documentation "A do nothing transition method.") (:method (state match) nil)) (defclass wsp-state-machine(state-machine) ((blank-finish :initform t :accessor blank-finish :documentation "Used to keep track of blank lines")) (:documentation "state-machine subclass specialized for whitespace recognition")) (defun get-indented(state-machine &key (until-blank nil) (strip-indent t) first-indent block-indent (strip-top first-indent)) "Return an indented block and info. Extract an indented block where the indent is known for all lines. Starting with the current line, extract the entire text block with at least `indent` indentation (which must be whitespace, except for the first line). :Parameters: - `block-indent`: The number of indent columns/characters if the indent is known for all lines. - first-indent: The indent where the indent is known for the first line and unknown for all other lines. - `until_blank`: Stop collecting at the first blank line if true (1). - `strip_indent`: Strip `indent` characters of indentation if true (1, default). - `strip_top`: Strip blank lines from the beginning of the block. :Return: - the indented block, - its first line offset from BOF, and - whether or not it finished with a blank line. - then indent, " (let ((offset (abs-line-offset state-machine))) (multiple-value-bind(indented indent blank-finish) (indented-block (input-lines state-machine) :start (line-offset state-machine) :until-blank until-blank :strip-indent strip-indent :first-indent first-indent :block-indent block-indent) ;; advance to last indented line (next-line state-machine (1- (length indented))) (setf (blank-finish state-machine) blank-finish) (when strip-top (let ((p (position-if-not #'line-blank-p indented))) (when p (setf indented (subseq indented p)) (incf offset p)))) (values (when (> (length indented) 0) indented) offset blank-finish indent)))) (defgeneric blank(state match) (:documentation "Handle blank lines.")) (defgeneric indent(state match) (:documentation "Handle an indented text block. Extend or override in subclasses. Recursively run the state machine for indented blocks")) (eval-when (:compile-toplevel :load-toplevel :execute) (defparameter +wsp-transitions+ '((blank "^\\s*$" ) (indent "^ +" )) "Transitons for a wsp state machine")) (defclass wsp-state(state) ((initial-transitions :allocation :class :initform +wsp-transitions+)) (:documentation "State superclass specialized for whitespace (blank lines & indents). Use this class with `StateMachineWS`. The transitions 'blank' (for blank lines) and 'indent' (for indented text blocks) are added automatically, before any other transitions. The transition method `blank()` handles blank lines and `indent()` handles nested indented blocks. Indented blocks trigger a new state machine to be created by `indent()` and run. The class of the state machine to be created is in `indent_sm`, and the constructor keyword arguments are in the dictionary `indent_sm_kwargs`.")) (defmethod blank-finish(state) (blank-finish (state-machine state))) (defun make-indent-state-machine(state) (make-nested-state-machine state)) (defun make-known-indent-state-machine(state) (make-indent-state-machine state)) (defmethod blank((state wsp-state) match) "Handle blank lines. Does nothing. Override in subclasses." (nop state match)) (defmethod indent((state wsp-state) match) "Handle an indented text block. Extend or override in subclasses. Recursively run the state machine for indented blocks" (multiple-value-bind(indented line-offset) (get-indented (state-machine state)) (state-machine-run (make-indent-state-machine state) indented :input-offset line-offset))) (defun known-indent(state match) "Handle a known-indent text block. Extend or override in subclasses. Recursively run the state machine for indented blocks" (multiple-value-bind(indented line-offset) (get-indented (state-machine state) :block-indent (match-end match)) (state-machine-run (make-known-indent-state-machine state) indented :input-offset line-offset))) (defun known-first-indent(state match) "Handle a known-indent text block (first line's indent known). Extend or override in subclasses. Recursively run the state machine for indented blocks" (multiple-value-bind(indented line-offset) (get-indented (state-machine state) :first-indent (match-end match)) (state-machine-run (make-known-indent-state-machine state) indented :input-offset line-offset))) (defstruct match "Results of a transition match" (start 0) ;; start index of match (end 0) ;; end index of match string ;; line being matched reg-starts ;; indices of register starts reg-ends) ;; other arguments to be passed from matcher to transition (defun match-group(match &optional (n nil)) "Return a new subsequence corresponding to match group n of match. If n is not specified returns entire match" (if n (let ((start (svref (match-reg-starts match) n))) (when start (subseq (match-string match) start (svref (match-reg-ends match) n)))) (subseq (match-string match) (match-start match) (match-end match)))) (defun match-group-length(match n) "Return length of the subsequence corresponding to match group n of match" (if (aref (match-reg-ends match) n) (- (aref (match-reg-ends match) n) (aref (match-reg-starts match) n)) 0)) (defparameter *scan-cache* (make-hash-table)) (defun match(pattern string &key (start 0) (end (length string))) (multiple-value-bind(start end reg-starts reg-ends) (typecase pattern (function (funcall pattern string :start start :end end)) (t (let ((scanner (or (gethash pattern *scan-cache*) (setf (gethash pattern *scan-cache*) (cl-ppcre::create-scanner pattern))))) (scan scanner string :start start :end end)))) (when start (make-match :string string :start start :end end :reg-starts reg-starts :reg-ends reg-ends)))) (defun matches(pattern string &key (start 0) (end (length string))) (let ((matches nil)) (do((match (match pattern string :start start :end end) (match pattern string :start start :end end))) ((not match)) (push match matches) (setf start (match-end match))) (nreverse matches)))
20,103
Common Lisp
.lisp
419
40.620525
79
0.672988
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
5903e743041e8a60878973093d1219d9da999ef36c1810f214ffaada270d5aa5
7,435
[ -1 ]
7,436
references.lisp
willijar_cl-docutils/transforms/references.lisp
;;;; Copyright (C) 2002-2006 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; $Id: references.lisp,v 1.7 2007/07/26 13:26:19 willijar Exp willijar $ (in-package :docutils.transform) (register-settings-spec '((:autofootnote-start integer 1 "Start number for automatically numbered footnotes") (:symbol-footnote-start integer 0 "Start symbol index for automatically symbolled footnotes"))) (defun internal-targets(element) (collate-nodes(node element) (and (typep node 'docutils.nodes:target) (attribute node :name)))) (defun external-targets(element) (collate-nodes(node element) (and (typep node 'docutils.nodes:target) (attribute node :refuri)))) (defun anonymous-targets(element) (collate-nodes(node element) (and (typep node 'docutils.nodes:element) (not (typep node 'docutils.nodes:reference)) (attribute node :anonymous)))) (defun anonymous-references(element) "Return a list of external targets in a document in order of occurance" (collate-nodes(node element) (and (typep node 'docutils.nodes:reference) (attribute node :anonymous)))) (defclass target-notes(transform) () (:default-initargs :priority 540) (:documentation "Creates a footnote for each external target in the text, and corresponding footnote references after each reference.")) (defmethod transform((transform target-notes)) (let* ((notes (make-hash-table :test #'equal)) (node (node transform)) (document (document (node transform))) (refnames (refnames document)) (nodelist)) (dolist(target (external-targets document )) (let ((name (attribute target :name))) (if name (let ((refs (gethash name refnames))) (when refs (let ((footnote (make-target-footnote document target refs notes))) (unless (gethash (attribute target :refuri) notes) (setf (gethash (attribute target :refuri) notes) footnote) (push footnote nodelist))))) (warn "No name on target: ~S" target)))) (let ((anonymous-targets (anonymous-targets document)) (anonymous-refs (anonymous-references document))) (when (= (length anonymous-targets) (length anonymous-refs)) (map 'nil #'(lambda(target ref) (let ((refuri (attribute target :refuri))) (when refuri (let ((footnote (make-target-footnote transform target (list ref) notes))) (unless (gethash refuri notes) (setf (gethash refuri notes) footnote) (push footnote nodelist)))))) anonymous-targets anonymous-refs))) (add-child (parent node) nodelist (index (parent node) node)) (rem-child (parent node) node))) (defun make-target-footnote(document target refs notes) (let ((refuri (attribute target :refuri))) (multiple-value-bind(footnote footnote-name) (let ((dup (gethash refuri notes))) (if dup (values dup (attribute dup :name)) (let* ((footnote (make-node 'docutils.nodes:footnote)) (footnote-name (format nil "target-note:~A" (set-id footnote document))) (paragraph (make-node 'docutils.nodes:paragraph)) (reference (make-node 'docutils.nodes:reference))) (setf (attribute footnote :auto) 1 (attribute footnote :name) footnote-name) (add-child footnote paragraph) (add-child paragraph reference) (add-child reference refuri) (setf (attribute reference :refuri) refuri) (values footnote footnote-name)))) (dolist(ref refs) (when (typep ref 'docutils.nodes:target) (let* ((refnode (make-node 'docutils.nodes:footnote-reference :auto 1 :refname footnote-name)) (index (1+ (index (parent ref) ref)))) (add-child (parent ref) refnode index) (when (setting :trim-footnote-reference-space document) (add-child (parent ref) (make-instance 'docutils.nodes:text :text " ") index))))) footnote))) (defclass chained-targets(transform) () (:default-initargs :priority 420) (:documentation "Attributes \"refuri\" and \"refname\" are migrated from the final direct target up the chain of contiguous adjacent internal targets")) (defmethod transform((transform chained-targets)) (let ((atts '(:refuri :refname :refid))) (with-nodes(node (document (node transform))) (when (typep node 'docutils.nodes:target) (multiple-value-bind(k v) (dolist(k atts) (let ((v (attribute node k))) (when v (return (values k v))))) (when k (let ((parent (parent node))) (do ((index (1- (index parent node)) (1- index))) ((< index 0)) (let ((sibling (child parent index))) (when (or (not (typep sibling 'docutils.nodes:target)) (some #'(lambda(a) (attribute sibling a)) atts)) (return)) (setf (attribute sibling k) v)))))))))) (defclass anonymous-hyperlinks(transform) () (:default-initargs :priority 440) (:documentation "Link anonymous references to targets")) (defmethod transform((transform anonymous-hyperlinks)) (let* ((document (document (node transform))) (refs (anonymous-references document)) (targets (anonymous-targets document))) (if (/= (length refs) (length targets)) (let* ((msg (report :error `("Anonymous hyperlink mismatch: ~d references but ~d targets. See :backrefs attribute for IDs" ,(length refs) ,(length targets)))) (msgid (set-id msg document))) (dolist(ref refs) (let* ((prb (make-node 'docutils.nodes:problematic :refid msgid (attribute ref :refid))) (prbid (set-id prb document))) (add-backref msg prbid) (add-child (parent ref) prb (index (parent ref) ref)) (remove-node ref)))) (map 'nil #'(lambda(ref target) (setf (referenced target) t) (if (attribute target :refuri) (progn (setf (attribute ref :refuri) (attribute target :refuri)) (setf (resolved ref) t)) (setf (attribute ref :refname) (attribute target :refname)))) refs targets)))) (defclass indirect-hyperlinks(transform) () (:default-initargs :priority 460) (:documentation "process internal and external indirect hyperlinks")) (defun indirect-targets(document) (collate-nodes(node document) (and (typep node 'docutils.nodes:target) (not (attribute node :anonymous)) (attribute node :refname)))) (defmethod transform((transform indirect-hyperlinks)) (let* ((document (document (node transform))) (nameids (nameids document)) (ids (ids document))) (dolist(target (indirect-targets (document (node transform)))) (unless (resolved target) (resolve-indirect-target target nameids ids)) (resolve-indirect-references target)))) (defun resolve-indirect-target(target &optional (nameids (nameids (document target))) (ids (ids (document target))) (refnames (refnames (document target))) (refids (refids (document target)))) (let* ((refname (attribute target :refname)) (reftarget-id (gethash refname nameids))) (flet ((indirect-target-error(target explanation) (let* ((name (attribute target :name)) (id (attribute target :id)) (naming (format nil "~@[~A ~]~@[(id=~A)~]" name id)) (reflist (if name (gethash name refnames) (gethash id refids))) (msg (report :error `("Indirect hyperlink target ~s refers to target ~s, ~s." ,naming ,refname ,explanation))) (msgid (set-id msg))) (dolist(ref reflist) (let* ((prb (make-node 'docutils.nodes:problematic (as-text ref) :refid msgid))) (substitute-node prb ref) (add-backref msg (set-id prb)))) (setf (resolved target) t)) (return-from resolve-indirect-target)) (set-refid(target id) (setf (attribute target :refid) id) (push target (gethash id refids)))) (unless reftarget-id (dolist(f *unknown-reference-resolvers*) (when (funcall f target) (return-from resolve-indirect-target))) (indirect-target-error target "which does not exist")) (let ((reftarget (gethash reftarget-id ids))) (when (and (typep reftarget 'docutils.nodes:target) (not (resolved target)) (attribute target :refname)) (when (attribute target :multiply-indirect) (indirect-target-error target "forming a circular reference") (return-from resolve-indirect-target)) (setf (attribute target :multiply-indirect) t) (resolve-indirect-target reftarget nameids ids refnames refids) (rem-attribute target :multiply-indirect)) (cond ((attribute reftarget :refuri) (setf (attribute target :refuri) (attribute reftarget :refuri))) ((attribute reftarget :refid) (set-refid target (attribute reftarget :refid))) ((attribute reftarget :id) (set-refid target (attribute reftarget :id))) (t (indirect-target-error target "which is a duplicate, and cannot be used as a unique reference"))) (rem-attribute target :refname) (setf (resolved target) t) (when (typep reftarget 'docutils.nodes:targetable) (setf (referenced reftarget) t)))))) (defun resolve-indirect-references(target &optional (refnames (refnames (document target))) (refids (refids (document target)))) (let* ((attname (cond ((attribute target :refid) :refid) ((attribute target :refuri) :refuri) ((return-from resolve-indirect-references)))) (attval (attribute target attname))) (multiple-value-bind(refatt delatt reflist) (cond ((attribute target :name) (values :name :refname (or (gethash (attribute target :name) refnames) (error 'transform-condition)))) ((attribute target :id) (values :id :refid (or (gethash (attribute target :id) refids) (error 'transform-condition)))) (t (return-from resolve-indirect-references))) (unless reflist (unless (referenced target) (report :info `("Indirect hyperlink target ~S is not referenced." ,(attribute target refatt)) :node target) (setf (referenced target) t)) (return-from resolve-indirect-references)) (dolist(ref reflist) (unless (resolved ref) (rem-attribute ref delatt) (setf (attribute ref attname) attval (resolved ref) t) (when (typep ref 'docutils.nodes:target) (resolve-indirect-references ref)))))) (setf (referenced target) t)) (defclass external-targets(transform) () (:default-initargs :priority 640) (:documentation "replace :refname attribute with the direct :refuri attribute for external targets.")) (defmethod transform((transform external-targets)) (let* ((document (document (node transform))) (refnames (refnames document))) (dolist(target (external-targets document)) (let ((name (attribute target :name)) (refuri (attribute target :refuri))) (when (and name refuri) (let ((reflist (gethash name refnames))) (if reflist (progn (dolist(ref reflist) (unless (resolved ref) (rem-attribute ref :refname) (setf (attribute ref :refuri) refuri (resolved ref) t))) (setf (referenced target) t)) (unless (or (not (typep target 'docutils.nodes:target)) (referenced target)) (report :info `("External hyperlink target ~s is not referenced." ,name) :node target) (setf (referenced target) t))))))))) (defclass internal-targets(transform) () (:default-initargs :priority 660) (:documentation "replace :refname attribute with the direct :refid attribute for internal targets.")) (defmethod transform((transform internal-targets)) (let* ((document (document (node transform))) (refnames (refnames document))) (dolist(target (internal-targets document)) (let ((name (attribute target :name)) (refid (set-id target))) (when (and name (not (attribute target :refuri)) (not (attribute target :refid))) (let ((reflist (gethash name refnames))) (if reflist (progn (dolist(ref reflist) (unless (resolved ref) (rem-attribute ref :refname) (setf (attribute ref :refid) refid (resolved ref) t))) (setf (referenced target) t)) (unless (referenced target) (report :info `("Internal hyperlink target ~s is not referenced." ,name) :node target) (setf (referenced target) t))))))))) (defclass footnotes(transform) ((autofootnote-labels :initform nil :accessor autofootnote-labels) (symbols :initarg :symbols :reader symbols :initform "*†‡§¶#♤♡♢♧")) ; '(#\* :|dagger| :|Dagger| :|sect| :|para| :|pilcrow| #\# ; :|spades| :|hearts| :|diams| :|clubs|))) (:default-initargs :priority 620) (:documentation "Assign numbers to autonumbered footnotes, and resolve links to footnotes, citations, and their references.")) (defmethod transform((transform footnotes)) (let* ((document (document (node transform))) (startnum (or (setting :autofootnote-start document) 0))) (setf (setting :autofootnote-start document) (number-footnotes transform startnum )) (number-footnote-references transform) (symbolise-footnotes transform) (resolve-footnotes-and-citations document))) (defun number-footnotes(transform startnum) "Assign numbers to autonumbered footnotes. For labeled autonumbered footnotes, copy the number over to corresponding footnote references." (let* ((document (document (node transform))) (nameids (nameids document))) (dolist(footnote (autofootnotes document)) (let ((label (loop (let ((label (write-to-string startnum))) (incf startnum) (when (not (gethash label nameids)) (return label)))))) (add-child footnote (make-node 'docutils.nodes:label label) 0) (unless (attribute footnote :dupname) (let ((name (attribute footnote :name))) (if name (dolist(ref (gethash name (footnote-refs document))) (add-child ref (make-instance 'docutils.nodes:text :text label)) (rem-attribute ref :refname) (setf (attribute ref :refid) (attribute footnote :id)) (add-backref footnote (set-id ref)) (setf (resolved ref) t)) (progn (setf (attribute footnote :name) label) (push label (autofootnote-labels transform)))))))) startnum)) (defun autofootnote-refs(document) (collate-nodes(node document) (and (typep node 'docutils.nodes:footnote-reference) (typep (attribute node :auto) 'number)))) (defun autofootnotes(document) (collate-nodes(node document) (and (typep node 'docutils.nodes:footnote) (typep (attribute node :auto) 'number)))) (defun symbol-footnote-refs(document) (collate-nodes(node document) (and (typep node 'docutils.nodes:footnote-reference) (typep (attribute node :auto) 'character)))) (defun symbol-footnotes(document) (collate-nodes(node document) (and (typep node 'docutils.nodes:footnote) (typep (attribute node :auto) 'character)))) (defun citation-refs(document) (let ((h (make-hash-table :test #'equalp))) (with-nodes(node document) (when (typep node 'docutils.nodes:citation-reference) (let ((refname (attribute node :refname))) (when refname (setf (gethash refname h) (nconc (gethash refname h) (list node))))))) h)) (defun citations(document) (collate-nodes(node document) (typep node 'docutils.nodes:citation))) (defun footnote-refs(document) (let ((h (make-hash-table :test #'equalp))) (with-nodes(node document) (when (typep node 'docutils.nodes:footnote-reference) (let ((refname (attribute node :refname))) (when refname (setf (gethash refname h) (nconc (gethash refname h) (list node))))))) h)) (defun footnotes(document) (collate-nodes(node document) (typep node 'docutils.nodes:footnote))) (defun number-footnote-references(transform &optional (nameids (nameids (document (node transform)))) (ids (ids (document (node transform))))) "Assign numbers to autonumbered footnote references." (do* ((labels (reverse (autofootnote-labels transform)) (rest labels)) (refs (autofootnote-refs (document (node transform))) (rest refs)) (label (first labels) (first labels)) (ref (first refs) (first refs))) ((or (not ref) (not label)) (when labels (let* ((msg (report :error `("Too many autonumbered footnote references: only corresponding footnotes available." ,(length (autofootnote-labels transform))) :node (or ref (node transform)))) (msgid (set-id msg))) (dolist(ref refs) (unless (or (resolved ref) (attribute ref :refname)) (let ((prb (make-node 'docutils.nodes:problematic (as-text ref) :refid msgid))) (substitute-node prb ref) (add-backref msg (set-id prb)) )))))) (let* ((id (gethash label nameids)) (footnote (gethash id ids))) (add-child ref (make-instance 'docutils.nodes:text :text label)) (setf (attribute ref :refid) id) (add-backref footnote (set-id ref)) (setf (resolved ref) t)))) (defun symbolise-footnotes(transform) "Add symbols indexes to '[*]'-style footnotes and references." (let ((document (document (node transform)))) (do* ((footnotes (symbol-footnotes document) (rest footnotes)) (refs (symbol-footnote-refs document) (rest refs)) (footnote (first footnotes) (first footnotes)) (ref (first refs) (first refs))) ((or (not ref) (not footnote)) (when refs (let* ((msg (report :error `("Too many symbol footnote references: only ~s corresponding footnotes available." ,(length (symbol-footnotes transform))) :node ref)) (msgid (set-id msg))) (dolist(ref refs) ;; remaining refs (unless (or (resolved ref) (attribute ref :refid)) (let ((prb (make-node 'docutils.nodes:problematic (as-text ref) :refid msgid))) (substitute-node prb ref) (add-backref msg (set-id prb)) )))))) (multiple-value-bind(reps index) (floor (or (setting :symbol-footnote-start document) 0) (length (symbols transform))) (let ((label (make-array (1+ reps) :initial-element (elt (symbols transform) index)))) (add-child ref label) (add-child footnote (make-node 'docutils.nodes:label label) 0))) (setf (setting :symbol-footnote-start document) (1+ (or (setting :symbol-footnote-start document) 0))) (setf (attribute ref :refid) (set-id footnote)) (add-backref footnote (set-id ref))))) (defun resolve-footnotes-and-citations(document) (resolve-references (footnotes document) (footnote-refs document)) (resolve-references (citations document) (citation-refs document))) (defun resolve-references(notes refs) (dolist(note notes) (let ((refs (gethash (attribute note :name) refs))) (when refs (let ((id (attribute note :id))) (dolist(ref refs) (unless (resolved ref) (rem-attribute ref :refname) (setf (attribute ref :refid) id) (add-backref note (set-id ref)) (setf (resolved ref) t)))) (setf (resolved note) t))))) (defclass substitutions(transform) () (:default-initargs :priority 220) (:documentation "Replace substitution-references with the contents of the corresponding substitution-definitions.")) (defun substitution-defs(element) "Return hashtable of substitution definitions in a document" (let ((refs (make-hash-table :test #'equal))) (with-nodes(node element) (when (typep node 'docutils.nodes:substitution-definition) (let* ((name (attribute node :subname)) (oldnode (gethash name refs))) (when oldnode (report :error `("Duplicate substitution definition name: ~s" ,name) :node oldnode) (setf (attribute oldnode :dupname) (attribute oldnode :subname)) (rem-attribute oldnode :subname)) (setf (gethash name refs) node)))) refs)) (defun substitution-refs(element) "Return a hashtable of lists of substitution refs keyed by name" (let ((refs (make-hash-table :test #'equal))) (with-nodes(node element) (when (typep node 'docutils.nodes:substitution-reference) (let ((name (attribute node :refname))) (push node (gethash name refs))))) refs)) (defmethod transform((transform substitutions)) (let* ((document (document (node transform))) (defs (substitution-defs document))) (maphash #'(lambda(refname refs) (let ((subdef (gethash refname defs))) (dolist(ref refs) (if subdef (let* ((parent (parent ref)) (index (index parent ref))) (when (and (or (attribute subdef :ltrim) (attribute subdef :trim)) (> index 0)) (let ((prev (child parent (1- index)))) (when (typep prev 'docutils.nodes:text) (substitute-node (make-instance 'docutils.nodes:Text :text (rstrip (as-text prev))) prev)))) (when (and (or (attribute subdef :rtrim) (attribute subdef :trim)) (< index (1- (number-children parent)))) (let ((next (child parent (1+ index)))) (when (typep next 'docutils.nodes:text) (substitute-node (make-instance 'docutils.nodes:Text :text (lstrip (as-text next))) next)))) (remove-node ref) (add-child parent (mapcar #'copy-of-node (slot-value subdef 'docutils::children)) index)) (let* ((msg (report :error `("Undefined subsititution referenced: ~s" ,refname) :node ref)) (msgid (set-id msg document)) (prb (make-node 'docutils.nodes:problematic :refid msgid (as-text ref))) (prbid (set-id prb document))) (add-backref msg prbid) (substitute-node prb ref)))))) (substitution-refs document)))) (register-settings-spec '((:resolve-media booelan t "Reolve media references to files"))) (defclass resolve-media(transform) () (:default-initargs :priority 850) (:documentation "Resolve media dependancies")) (defmethod transform((transform resolve-media)) (let ((document (document (node transform)))) (when (setting :resolve-media document) (with-nodes(node document) (typecase node (docutils.nodes:image (let ((uri (attribute node :uri))) (let ((path (docutils::resolve-dependancy document uri))) (if path (setf (attribute node :uri) path) (report :warning (list "Media uri ~S is either relative or the media file was not found." uri) :node node))))))))))
26,669
Common Lisp
.lisp
554
35.218412
160
0.566861
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0e36e29f15643236ce9f68593a69c7ea865e60a430f2401db96550ff02b71feb
7,436
[ -1 ]
7,437
defpackage.lisp
willijar_cl-docutils/transforms/defpackage.lisp
;;;; ;;;; Copyright (C) 2002-2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;; This package contains modules for standard tree transforms available ;; to Docutils components. Tree transforms serve a variety of purposes: ;; - To tie up certain syntax-specific "loose ends" that remain after the ;; initial parsing of the input plaintext. These transforms are used to ;; supplement a limited syntax. ;; - To automate the internal linking of the document tree (hyperlink ;; references, footnote references, etc.). ;; - To extract useful information from the document tree. These ;; transforms may be used to construct (for example) indexes and tables ;; of contents. ;; Each transform is an optional step that a Docutils Reader may choose to ;; perform on the parsed document, depending on the input context. A Docutils ;; Reader may also perform Reader-specific transforms before or after performing ;; these standard transforms. (in-package :docutils.transform) (define-condition transform-condition(condition)())
1,160
Common Lisp
.lisp
20
56.7
80
0.770723
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
0d777c524eb0e672284f87bb6935d164a534872689b42ece2fa23f4cbaa64dc9
7,437
[ -1 ]
7,438
frontmatter.lisp
willijar_cl-docutils/transforms/frontmatter.lisp
;;;; ;;;; Copyright (C) 2002-2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details (in-package :docutils.transform) #| In reStructuredText_, there is no way to specify a document title and subtitle explicitly. Instead, we can supply the document title (and possibly the subtitle as well) implicitly, and use this two-step transform to "raise" or "promote" the title(s) (and their corresponding section contents) to the document level. 1. If the document contains a single top-level section as its first non-comment element, the top-level section's title becomes the document's title, and the top-level section's contents become the document's immediate contents. The lone top-level section header must be the first non-comment element in the document. For example, take this input text:: ================= Top-Level Title ================= A paragraph. Once parsed, it looks like this:: <document> <section name=\"top-level title\"> <title> Top-Level Title <paragraph> A paragraph. After running the DocTitle transform, we have:: <document name=\"top-level title\"> <title> Top-Level Title <paragraph> A paragraph. 2. If step 1 successfully determines the document title, we continue by checking for a subtitle. If the lone top-level section itself contains a single second-level section as its first non-comment element, that section's title is promoted to the document's subtitle, and that section's contents become the document's immediate contents. Given this input text:: ================= Top-Level Title ================= Second-Level Title ~~~~~~~~~~~~~~~~~~ A paragraph. After parsing and running the Section Promotion transform, the result is:: <document name=\"top-level title"> <title> Top-Level Title <subtitle name="second-level title"> Second-Level Title <paragraph> A paragraph. (Note that the implicit hyperlink target generated by the "Second-Level Title" is preserved on the "subtitle" element itself.) Any comment elements occurring before the document title or subtitle are accumulated and inserted as the first body elements after the title(s). |# (register-settings-spec '((:doctitle-xform boolean t "Apply transform promote document title and subtitle") (:docinfo-xform boolean t "Apply transform to create bibliographic fields"))) (defun first-child-not-type(node type) "Returns first child of node not of type type" (with-children(child node) (when (not (typep child type)) (throw :skip-siblings child)))) (defclass doctitle(transform) () (:default-initargs :priority 320) (:documentation "Transform to promote document title and subtitle.")) (defmethod transform((transform doctitle)) (let ((document (document (node transform)))) (when (setting :doctitle-xform document) (when (promote-document-title document) (promote-document-subtitle document))))) (defun rem-children(node) "Remove children from node and return them as a list" (nreverse (let ((children nil)) (with-children(child node) (remove-node child) (push child children)) children))) (defun promote-document-title(document) (let ((section (candidate-node document))) (when section ;; Transfer the section's attributes to the document element (at ;; root) (with-attributes(k v section) (setf (attribute document k) v)) ;; move title to top of document (let ((title (child section 0))) (rem-child section 0) (add-child document title 0)) ;; move section contents into document before section (add-child document (rem-children section) (index document section )) (remove-node section) t))) (defun promote-document-subtitle(document) (let((subsection (candidate-node document))) (when subsection (let ((subtitle (make-node 'docutils.nodes::subtitle))) (with-attributes(k v subsection) (setf (attribute subtitle k) v)) ;;Transfer the contents of the subsection's title to the subtitle (let((title (child subsection 0))) (remove-node title) (add-child subtitle (rem-children title))) ;; insert subtitle into document (add-child document subtitle 1) ;; add subsection content into document (add-child document (rem-children subsection) (index document subsection)) (remove-node subsection)) t))) (defun candidate-node(document) (let ((node (first-child-not-type document '(or docutils.nodes:prebibliographic docutils.nodes:comment )))) (when (typep node 'docutils.nodes:section) node))) #| This transform is specific to the reStructuredText_ markup syntax; see "Bibliographic Fields" in the `reStructuredText Markup Specification`_ for a high-level description. This transform should be run *after* the `DocTitle` transform. Given a field list as the first non-comment element after the document title and subtitle (if present), registered bibliographic field names are transformed to the corresponding DTD elements, becoming child elements of the "docinfo" element (except for a dedication and/or an abstract, which become "topic" elements after "docinfo"). For example, given this document fragment after parsing:: <document> <title> Document Title <field_list> <field> <field_name> Author <field_body> <paragraph> A. Name <field> <field_name> Status <field_body> <paragraph> $RCSfile: frontmatter.lisp,v $ ... After running the bibliographic field list transform, the resulting document tree would look like this:: <document> <title> Document Title <docinfo> <author> A. Name <status> frontmatter.py ... The "Status" field contained an expanded RCS keyword, which is normally (but optionally) cleaned up by the transform. The sole contents of the field body must be a paragraph containing an expanded RCS keyword of the form "$keyword: expansion text $". Any RCS keyword can be processed in any bibliographic field. The dollar signs and leading RCS keyword name are removed. Extra processing is done for the following RCS keywords: - "RCSfile" expands to the name of the file in the RCS or CVS repository, which is the name of the source file with a ",v" suffix appended. The transform will remove the ",v" suffix. - "Date" expands to the format "YYYY/MM/DD hh:mm:ss" (in the UTC time zone). The RCS Keywords transform will extract just the date itself and transform it to an ISO 8601 format date, as in "2000-12-31". (Since the source file for this text is itself stored under CVS, we can't show an example of the "Date" RCS keyword because we can't prevent any RCS keywords used in this explanation from being expanded. Only the "RCSfile" keyword is stable; its expansion text changes only if the file name changes.) |# (defvar *rcs-keyword-substitutions* '(("\\$Date: 2006/08/08 08:12:59 $" . "\\1-\\2-\\3") ("\\$RCSfile: frontmatter.lisp,v $" . "\\1") ("\\$[a-zA-z]+: (.+) \\$" . "\\1"))) (defclass docinfo(transform) ((biblio-nodes :initarg :biblio-nodes :reader biblio-nodes :initform '(("author" . docutils.nodes:author) ("authors" . docutils.nodes:authors) ("organization" . docutils.nodes:organization) ("address" . docutils.nodes:address) ("contact" . docutils.nodes:contact) ("version" . docutils.nodes:version) ("revision" . docutils.nodes:revision) ("status" . docutils.nodes:status) ("date" . docutils.nodes:date) ("copyright" . docutils.nodes:copyright) ("dedication" . docutils.nodes:topic) ("abstract" . docutils.nodes:topic)))) (:default-initargs :priority 340) (:documentation "Transform to create document bibliographic fields.")) (defmethod transform((transform docinfo)) (let ((document (document (node transform)))) (when (setting :docinfo-xform document) (let ((candidate (first-child-not-type document '(or docutils.nodes:prebibliographic docutils.nodes:comment)))) (when (typep candidate 'docutils.nodes:field-list) (let ((first-nontitular (first-child-not-type document 'docutils.nodes:titular)) (nodelist (extract-bibliographic candidate (biblio-nodes transform)))) (add-child document nodelist (index document first-nontitular)) (remove-node candidate))))))) ;; remove untransformed field list (defun clean-rcs-keywords(paragraph &optional (substitutions *rcs-keyword-substitutions*)) (when (= 1 (number-children paragraph)) (let ((textnode (child paragraph 0))) (when (typep textnode 'docutils.nodes:text) (let ((data (as-text textnode))) (dolist(substitution substitutions) (when (cl-ppcre:scan (car substitution) data) (add-child paragraph (make-instance 'docutils.nodes:text :text (cl-ppcre:regex-replace (car substitution) data (cdr substitution))) 0) (remove-node textnode) (return-from clean-rcs-keywords)))))))) (defun extract-bibliographic(field-list biblio-nodes) (let ((docinfo (make-node 'docutils.nodes:docinfo :line (line field-list))) (topics (list (list "dedication") (list "abstract")))) (with-children(field field-list) (let ((docutils:*current-line-number* (line field))) (handler-case (let* ((name (as-text (child (child field 0) 0))) (canonical (canonical-text (normalise-name name))) (biblioclass (cdr (assoc canonical biblio-nodes :test #'string-equal)))) (unless (and (= 2 (number-children field)) biblioclass (check-empty-biblio-field field name)) (error 'transform-condition)) (cond ((subtypep biblioclass 'docutils.nodes:text-element) (unless (check-compound-biblio-field field name) (error 'transform-condition)) (let ((p (child (child field 1) 0))) (clean-rcs-keywords p) (remove-node p) (add-child docinfo (make-node biblioclass p )))) ((subtypep biblioclass 'docutils.nodes:authors) (extract-authors field name docinfo)) ((subtypep biblioclass 'docutils.nodes:topic) (let ((topic (assoc canonical topics :test #'string-equal))) (when (cdr topic) (report :warning `("There can be only one ~S field." ,name) :node field) (error 'transform-error)) (let ((topicnode (make-node biblioclass :class canonical ))) (add-child topicnode (make-node 'docutils.nodes:title (translated-text canonical))) (add-child topicnode (rem-children (child field 1))) (setf (cdr topic) topicnode)))) (t (add-child docinfo (make-node biblioclass (rem-children (child field 1))))))) (transform-condition() (let ((last (child field (1- (number-children field))))) (when (and (= 1 (number-children last)) (typep (child last 0) 'docutils.nodes:paragraph)) (clean-rcs-keywords (child last 0)))) (remove-node field) (add-child docinfo field))))) (append (when (> (number-children docinfo) 0) (list docinfo)) (mapcar #'cdr topics)))) (defun check-empty-biblio-field(field name) (if (> (number-children (child field (1- (number-children field)))) 0) t (progn (report :warning `("Cannot extract empty bibliographic field ~s" ,name) :node field) nil))) (defun check-compound-biblio-field(field name) (let ((last (child field (1- (number-children field))))) (cond ((> (number-children last) 1) (report :warning `("Cannot extract compound bibliographic field ~s" ,name) :node field) nil) ((not (typep (child last 0) 'docutils.nodes:paragraph)) (report :warning `("Cannot extractbibliographic field ~s containing anything other than a single paragraph" ,name) :node field) nil) (t t)))) (defun extract-authors(field name docinfo) (let ((value (child field 1))) (handler-case (let ((authornodes (mapcar #'(lambda(a) (make-node 'docutils.nodes:author a)) (cond ((/= (number-children value) 1) (authors-from-paragraphs value)) ((let ((value (child value 0))) (typecase value (docutils.nodes:paragraph (authors-from-paragraph value)) (docutils.nodes:bullet-list (authors-from-bullet-list value))))) (t (error 'transform-condition)))))) (cond ((> (length authornodes) 1) (add-child docinfo (make-node 'docutils.nodes:authors authornodes))) ((= (length authornodes) 1) (add-child docinfo (first authornodes))) (t (error 'transform-condition)))) (transform-condition() (report :warning `("Bibliographic field ~s incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ~A), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item" ,name ,(author-separators)) :node field))))) (defun authors-from-paragraph(paragraph) (let ((text (strip (as-text (child paragraph 0))))) (when (= 0 (length text)) (error 'transform-condition)) (mapcar #'(lambda(a) (make-node 'docutils.nodes:text (strip a))) (or (dolist(authorsep (author-separators)) (let ((authornames (split-string text :delimiter authorsep))) (when (> (length authornames) 1) (return authornames)))) (list text))))) (defun authors-from-bullet-list(list) (let ((authors nil)) (with-children(item list) (when (or (not (= (number-children item) 1)) (not (typep (child item 0) 'docutils.nodes:paragraph))) (error 'transform-condition)) (push (rem-children (child item 0)) authors)) (unless authors (error 'transform-condition)) (nreverse authors))) (defun authors-from-paragraphs(value) (let ((authors nil)) (with-children(p value) (unless (typep p 'docutils.nodes:paragraph) (error 'transform-condition)) (push (mapcar #'rem-children p) authors)) (nreverse authors)))
16,262
Common Lisp
.lisp
362
34.455801
121
0.602852
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
7d03397a77b881eafbfd86b012039531c41f23d23c4515eb46aa55fd9f9857fa
7,438
[ -1 ]
7,439
misc.lisp
willijar_cl-docutils/transforms/misc.lisp
;; $Id: misc.lisp,v 1.9 2007/07/03 06:59:36 willijar Exp $ ;; Miscellaneous transforms for restructured text ;; Copyright (C) 2006 Dr. John A.R. Williams ;; Author: Dr. John A.R. Williams <[email protected]> ;; Keywords: ;; This file is part of Cl-docutils ;; This is free software released under the GNU General Public License (GPL) ;; See <http://www.gnu.org/copyleft/gpl.html> ;;; Commentary: ;; class-attribute form carries our class directive ;; simple-transform provides a way of applying a function as a transform ;; evaluate transform and function execute eval nodes ;;; Code: (in-package :docutils.transform) (defclass class-attribute(transform) () (:default-initargs :priority 210) (:documentation "Move class attribute of pending node to next non-comment element")) (defmethod transform((transform class-attribute)) (let* ((pending (node transform)) (class (attribute pending :class))) (do*((child pending parent) (parent (parent pending) (parent parent))) ((not parent)) (let((f nil)) (with-children(element parent) (if f (unless (or (typep element 'docutils.nodes:Invisible) (typep element 'docutils.nodes:system-message)) (add-class element class) (remove-node pending) (return-from transform t)) (when (eql element child) (setf f t)))))) (report :error "No suitable element following class directive"))) (defclass simple-transform(transform) ((function :initarg :function)) (:documentation "A simple transform which calls the closure with the node")) (defmethod transform((transform simple-transform)) (funcall (slot-value transform 'function) (node transform))) (defclass evaluate-transform(transform) () (:documentation "Evaluate nodes cahcing result")) (defmethod transform((transform evaluate-transform)) (dolist(node (collate-nodes(node (node transform)) (typep node 'docutils.nodes::evaluateable))) (setf (slot-value node 'docutils::result) (evaluate node))))
2,106
Common Lisp
.lisp
47
39.212766
78
0.693548
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
87e1ed712b38e17647f3dae1bb2000b1aae1a9f519a3f46b077bc4cd5d61262f
7,439
[ -1 ]
7,440
filter.lisp
willijar_cl-docutils/transforms/filter.lisp
;;;; ;;;; Copyright (C) 2002-2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details (in-package :docutils.transform) (defclass filter(transform) () (:default-initargs :priority 780) (:documentation "Include or exclude elements - for use with pending elements")) (defmethod transform((filter filter)) (let* ((pending (node filter)) (parent (parent pending))) (when (funcall (attribute pending :test) pending) (let ((index (index parent pending))) (rem-child parent index) (dolist(child (attribute pending :nodes)) (add-child parent child index))))))
728
Common Lisp
.lisp
18
36.333333
76
0.691761
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
5a08a4aabfddc9031f5c61f805a5da649ba7596f9d68153b2787961f19af2f36
7,440
[ -1 ]
7,441
en.lisp
willijar_cl-docutils/languages/en.lisp
;; -*- lisp -*- ;; translation from en lanugauge to cannonical form ;; where same cannonical form occurs more than once, last occurance provides ;; cannonical inverse translation (in-package :docutils.utilities) (setf (gethash "en" *translations*) (parse-translations '(("ab" . "abbreviation") ("abbreviation" . "abbreviation") ("Abstract" . "abstract") ("ac" . "acronym") ("acronym" . "acronym") ("Admonition" . "admonition") ("anonymous-reference" . "anonymous-reference") ("Attention" . "attention") ("Caution" . "caution") ("citation-reference" . "citation-reference") ("citations" . "citations") ("class" . "class") ("compound" . "compound") ("Table of Contents" . "contents") ("container" . "container") ("csv-table" . "csv-table") ("Danger" . "danger") ("Dedication" . "dedication") ("emphasis" . "emphasis") ("epigraph" . "epigraph") ("Error" . "error") ("questions" . "questions") ("faq" . "questions") ("figure" . "figure") ("Figure" . "Figure") ("footnote-reference" . "footnote-reference") ("footnotes" . "footnotes") ("highlights" . "highlights") ("Hint" . "hint") ("i" . "index") ("image" . "image") ("imagemap" . "imagemap") ("Important" . "important") ("include" . "include") ("index" . "index") ("line-block" . "line-block") ("literal" . "literal") ("meta" . "meta") ("named-reference" . "named-reference") ("Note" . "note") ("parsed-literal" . "parsed-literal") ("pep" . "pep-reference") ("pep-reference" . "pep-reference") ("pull-quote" . "pull-quote") ("qa" . "questions") ("raw" . "raw") ("replace" . "replace") ("restructuredtext-test-directive" . "restructuredtext-test-directive") ("rfc" . "rfc-reference") ("rfc-reference" . "rfc-reference") ("role" . "role") ("rubric" . "rubric") ("section-numbering" . "sectnum") ("sectnum" . "sectnum") ("sidebar" . "sidebar") ("strong" . "strong") ("sub" . "subscript") ("subscript" . "subscript") ("substitution-reference" . "substitution-reference") ("sup" . "superscript") ("superscript" . "superscript") ("t" . "title-reference") ("table" . "table") ("target" . "target") ("target-notes" . "target-notes") ("Tip" . "tip") ("title" . "title-reference") ("title-reference" . "title-reference") ("topic" . "topic") ("unicode" . "unicode") ("uri" . "uri-reference") ("url" . "uri-reference") ("uri-reference" . "uri-reference") (:author-separators #\; #\,) (:babel . "english") ;; latex babel language (:latex-quotes "``" "''") ;; latex quotes ("Warning" . "warning"))))
2,521
Common Lisp
.lisp
84
28.02381
76
0.630542
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
04ede980c4d085fe7ed44aba70ecf8d32a1ee28a27d26fc7bebb60fe766dd96b
7,441
[ -1 ]
7,442
translate.lisp
willijar_cl-docutils/languages/translate.lisp
;;;; Translations for the docutils utilities ;;;; Copyright (C) 2005 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; $Id: translate.lisp,v 1.2 2006/06/25 08:33:38 willijar Exp willijar $ (in-package :docutils.utilities) (defvar *language-directory* #p"" "Directory in which translation data is held. Each language has a file containing an a-list mapping translated form to a cannonical form") (defvar *language* "en" "Default language for processing") (declaim (special *language-directory*)) (eval-when(:compile-toplevel) (setq *language-directory* (merge-pathnames (make-pathname :name :wild #-clisp :type #-clisp :unspecific) *compile-file-truename*))) (defstruct translation (translated (make-hash-table :test #'equalp)) (canonical (make-hash-table :test #'equalp))) (defvar *translations* (make-hash-table :test #'equalp) "Hash table mapping language name to languages") (defun parse-translations(entries) (let ((translation (make-translation))) (dolist(entry entries) (setf (gethash (cdr entry) (translation-translated translation)) (car entry) (gethash (car entry) (translation-canonical translation)) (cdr entry))) translation)) (defun get-translation(language) (or (gethash language *translations*) (let ((fname (merge-pathnames (make-pathname :name language :type nil) *language-directory*))) (unless (probe-file fname) (error "No translation available for ~S language" language)) (setf (gethash language *translations*) (parse-translations (with-open-file(is fname :direction :input) (read is))))))) (defun canonical-text(text &optional (language *language*)) (gethash text (translation-canonical (get-translation language)) text)) (defun translated-text(text &optional (language *language*)) (gethash text (translation-translated (get-translation language)) text)) (defun author-separators( &optional (language *language*)) (gethash :author-separators (translation-canonical (get-translation language)) '('\, #\;))) (defun babel( &optional (language *language*)) (gethash :babel (translation-canonical (get-translation language)) "english")) (defun latex-quotes( &optional (language *language*)) (gethash :latex-quotes (translation-canonical (get-translation language)) '("``" "''"))) (defun latex-double-quote-replacement( &optional (language *language*)) (gethash :latex-double-quote-replacement (translation-canonical (get-translation language))))
2,854
Common Lisp
.lisp
56
43.535714
80
0.672414
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
f464f715a970437251b1078e0482618ecbcad9cf33f7c10a2012dc028e80a1de
7,442
[ -1 ]
7,443
docutils.asd
willijar_cl-docutils/docutils.asd
;;;; System definition for doc handling -*- Lisp -*- ;;;; Copyright (C) 2006-2008 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; $Id: docutils.asd,v 1.5 2007/07/14 08:13:26 willijar Exp $ (in-package :asdf) (defsystem docutils :name "Docutils" :description "Document utilities and Restructured text parser" :author "Dr. John A.R. Williams" :version "0.1.1" :maintainer "Dr. John A.R. Williams" :licence "GPL v3" :depends-on (:cl-ppcre :trivial-gray-streams :data-format-validation) :components ((:file "defpackage") (:file "nodes" :depends-on ("defpackage" "report" "utilities" "languages")) (:file "publisher" :depends-on ("defpackage" "nodes")) (:file "utilities" :depends-on ("defpackage")) (:file "report" :depends-on ("defpackage" "utilities")) (:module "languages" :depends-on ("defpackage") :components ((:file "translate") (:file "en" :depends-on ("translate")))) (:module "parsers" :depends-on ("publisher" "nodes" "utilities" "report" "transforms" "languages") :components ((:file "defpackage") (:file "state-machine" :depends-on ("defpackage")) (:file "inline" :depends-on ("defpackage")) (:file "regexp" :depends-on ("defpackage")) (:file "tables" :depends-on ("defpackage")) (:file "rst" :depends-on ("defpackage" "inline" "regexp" "state-machine" "tables")) (:file "directives" :depends-on ("rst" "inline" "roles")) (:file "roles" :depends-on ("rst" "inline")))) (:module "transforms" :depends-on ("nodes" "utilities" "publisher" "report" "languages") :components ((:file "defpackage") (:file "filter" :depends-on ("defpackage")) (:file "universal" :depends-on ("defpackage")) (:file "references" :depends-on ("defpackage")) (:file "frontmatter" :depends-on ("defpackage")) (:file "misc" :depends-on ("defpackage")) (:file "parts" :depends-on ("defpackage")))) (:module "writers" :depends-on ("parsers") :components ((:file "html") (:file "latex")))))
2,462
Common Lisp
.asd
53
36.773585
79
0.56585
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
d40bd90bdbc29b6125d90057f3e07a742ff66434ca7763acc72e06ccc3b43ec7
7,443
[ -1 ]
7,444
docutils.extensions.asd
willijar_cl-docutils/extensions/docutils.extensions.asd
;;;; System definition for doc handling -*- Lisp -*- ;;;; Copyright (C) 2006-2008 John A.R. Williams <[email protected]> ;;;; Released under the GNU General Public License (GPL) ;;;; See <http://www.gnu.org/copyleft/gpl.html> for license details ;;;; ;;;; $Id: docutils.asd,v 1.5 2007/07/14 08:13:26 willijar Exp $ (in-package :asdf) (defsystem "docutils.extensions" :name "Docutils Markup Extensions" :description "Adds docutils parsing to markup handline" :author "Dr. John A.R. Williams" :version "0.0.1" :maintainer "Dr. John A.R. Williams" :licence "GPL v3" :depends-on (:docutils :markup :media :inet :jarw) :components ((:file "markup") (:file "media" :depends-on ("markup"))))
717
Common Lisp
.asd
18
37.555556
76
0.6901
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
3151c73bbf1bfdb6d6ddbeade144f4c9aa86c76a68748f7f2933e21e4befc5d3
7,444
[ -1 ]
7,456
docutils.css
willijar_cl-docutils/writers/docutils.css
/* :Author: David Goodger ([email protected]) :Id: $Id: html4css1.css 5196 2007-06-03 20:25:28Z wiemann $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to customize this style sheet. */ /* used to remove borders from tables and images */ .borderless, table.borderless td, table.borderless th { border: 0 } table.borderless td, table.borderless th { /* Override padding for "table.docutils td" with "! important". The right padding separates the table cells. */ padding: 0 0.5em 0 0 ! important } .first { /* Override more specific margin styles with "! important". */ margin-top: 0 ! important } .last, .with-subtitle { margin-bottom: 0 ! important } .hidden { display: none } a.toc-backref { text-decoration: none ; color: black } blockquote.epigraph { margin: 2em 5em ; } dl.docutils dd { margin-bottom: 0.5em } dl.docutils dt { font-weight: bold } div.abstract { margin: 2em 5em } div.abstract p.topic-title { font-weight: bold ; text-align: center } div.admonition, div.attention, div.caution, div.danger, div.error, div.hint, div.important, div.note, div.tip, div.warning { margin: 2em ; border: medium outset ; padding: 1em } div.admonition p.admonition-title, div.hint p.admonition-title, div.important p.admonition-title, div.note p.admonition-title, div.tip p.admonition-title { font-weight: bold ; font-family: sans-serif } div.attention p.admonition-title, div.caution p.admonition-title, div.danger p.admonition-title, div.error p.admonition-title, div.warning p.admonition-title { color: red ; font-weight: bold ; font-family: sans-serif } /* Uncomment (and remove this text!) to get reduced vertical space in compound paragraphs. div.compound .compound-first, div.compound .compound-middle { margin-bottom: 0.5em } div.compound .compound-last, div.compound .compound-middle { margin-top: 0.5em } */ div.dedication { margin: 2em 5em ; text-align: center ; font-style: italic } div.dedication p.topic-title { font-weight: bold ; font-style: normal } div.figure { margin-left: 2em ; margin-right: 2em } div.footer, div.header { clear: both; font-size: smaller } div.line-block { display: block ; margin-top: 1em ; margin-bottom: 1em } div.line-block div.line-block { margin-top: 0 ; margin-bottom: 0 ; margin-left: 1.5em } div.sidebar { margin: 0 0 0.5em 1em ; border: medium outset ; padding: 1em ; background-color: #ffffee ; width: 40% ; float: right ; clear: right } div.sidebar p.rubric { font-family: sans-serif ; font-size: medium } div.system-messages { margin: 5em } div.system-messages h1 { color: red } div.system-message { border: medium outset ; padding: 1em } div.system-message p.system-message-title { color: red ; font-weight: bold } div.topic { margin: 2em } h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { margin-top: 0.4em } h1.title { text-align: center } h2.subtitle { text-align: center } hr.docutils { width: 75% } img.align-left { clear: left } img.align-right { clear: right } ol.simple, ul.simple { margin-bottom: 1em } ol.arabic { list-style: decimal } ol.loweralpha { list-style: lower-alpha } ol.upperalpha { list-style: upper-alpha } ol.lowerroman { list-style: lower-roman } ol.upperroman { list-style: upper-roman } p.attribution { text-align: right ; margin-left: 50% } p.caption { font-style: italic } p.credits { font-style: italic ; font-size: smaller } p.label { white-space: nowrap } p.rubric { font-weight: bold ; font-size: larger ; color: maroon ; text-align: center } p.sidebar-title { font-family: sans-serif ; font-weight: bold ; font-size: larger } p.sidebar-subtitle { font-family: sans-serif ; font-weight: bold } p.topic-title { font-weight: bold } pre.address { margin-bottom: 0 ; margin-top: 0 ; font-family: serif ; font-size: 100% } pre.literal-block, pre.doctest-block { margin-left: 2em ; margin-right: 2em } span.classifier { font-family: sans-serif ; font-style: oblique } span.classifier-delimiter { font-family: sans-serif ; font-weight: bold } span.interpreted { font-family: sans-serif } span.option { white-space: nowrap } span.pre { white-space: pre } span.problematic { color: red } span.section-subtitle { /* font-size relative to parent (h1..h6 element) */ font-size: 80% } table.citation { border-left: solid 1px gray; margin-left: 1px } table.docinfo { margin: 2em 4em } table.docutils { margin-top: 0.5em ; margin-bottom: 0.5em } table.footnote { border-left: solid 1px black; margin-left: 1px } table.docutils td, table.docutils th, table.docinfo td, table.docinfo th { padding-left: 0.5em ; padding-right: 0.5em ; vertical-align: top } table.docutils th.field-name, table.docinfo th.docinfo-name { font-weight: bold ; text-align: left ; white-space: nowrap ; padding-left: 0 } table caption { caption-side: bottom; font-weight: bold; font-style: italic; } p.caption { text-align:center; font-weight: bold; } table.docutils, table.docutils tr th, table.docutils tr td { outline-width: thin; outline-style: solid; } h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { font-size: 100% } ul.auto-toc { list-style-type: none }
5,593
Common Lisp
.l
206
24.635922
105
0.723989
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
ab206dc94f3e3813822921f8c0f4f85e061d353ccfc04ade7e5da51b0518051e
7,456
[ -1 ]
7,458
docutils.tex
willijar_cl-docutils/writers/docutils.tex
\usepackage{babel} \usepackage{shortvrb} \usepackage{tabularx} \usepackage{longtable} \usepackage{amsmath} \usepackage{color} \usepackage{multirow} \usepackage{ifthen} \usepackage{float} \usepackage{framed} %\setlength{\extrarowheight}{2pt} \newlength{\admonitionwidth} \setlength{\admonitionwidth}{0.9\linewidth} \newlength{\docinfowidth} \setlength{\docinfowidth}{0.9\linewidth} \newlength{\locallinewidth} \newcommand{\optionlistlabel}[1]{\bf #1 \hfill} \newenvironment{optionlist}[1] {\begin{list}{} {\setlength{\labelwidth}{#1} \setlength{\rightmargin}{1cm} \setlength{\leftmargin}{\rightmargin} \addtolength{\leftmargin}{\labelwidth} \addtolength{\leftmargin}{\labelsep} \renewcommand{\makelabel}{\optionlistlabel}} }{\end{list}} \newlength{\lineblockindentation} \setlength{\lineblockindentation}{2.5em} \newenvironment{lineblock}[1] {\begin{list}{} {\setlength{\partopsep}{\parskip} \addtolength{\partopsep}{\baselineskip} \topsep0pt\itemsep0.15\baselineskip\parsep0pt \leftmargin#1} \raggedright} {\end{list}} \floatstyle{ruled} %\newfloat{assessment}{pbth}{ass} %\floatname{assessment}{Assessment} \newenvironment{assessment} { \begin{framed} \noindent \textbf{Assessment} \begin{list}{}{\setlength{\itemsep}{0pt}\setlength{\topsep}{0pt}\setlength{\parsep}{0pt}} } { \end{list} \end{framed} } \newenvironment{admonition}[1] {\begin{minipage}{\admonitionwidth} \begin{framed} \noindent\textbf{#1} } {\end{framed} \end{minipage} } \newenvironment{sidebar}[1] {\noindent\textbf{#1} } {} % begin: floats for footnotes tweaking., %\setlength{\floatsep}{0.5em} %\setlength{\textfloatsep}{\fill} %\addtolength{\textfloatsep}{3em} %\renewcommand{\textfraction}{0.5} %\renewcommand{\topfraction}{0.5} %\renewcommand{\bottomfraction}{0.5} %\setcounter{totalnumber}{50} %\setcounter{topnumber}{50} %\setcounter{bottomnumber}{50} % end floats for footnotes % some commands, that could be overwritten in the style file. \newcommand{\rubric}[1]{\subsection*{~\hfill {\it #1} \hfill ~}} \newcommand{\titlereference}[1]{\textsl{#1}}
2,041
Common Lisp
.l
76
25.671053
89
0.783188
willijar/cl-docutils
24
6
3
GPL-3.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
2003cbdac24b4b077d5a45974f04d911261fb5b86d9cd31d91c94683a98af939
7,458
[ -1 ]
7,487
md-utilities.lisp
kennytilton_its-alive/lisp/md-utilities.lisp
;; -*- mode: Lisp; Syntax: Common-Lisp; Package: cells; -*- #| Cells -- Automatic Dataflow Managememnt |# (in-package :cells) (defun md-awake (self) (eql :awake (md-state self))) (defun fm-grandparent (md) (fm-parent (fm-parent md))) (defmethod md-release (other) (declare (ignorable other))) (export! mdead) ;___________________ birth / death__________________________________ (defgeneric mdead (self) (:method ((self model-object)) (unless *not-to-be* ;; weird - let's folks function for not-to-be cleanup (eq :eternal-rest (md-state self)))) (:method (self) (declare (ignore self)) nil)) (export! *ntb-dbg*) (defgeneric not-to-be (self) (:method (other) (declare (ignore other))) (:method ((self cons)) (not-to-be (car self)) (not-to-be (cdr self))) (:method ((self array)) (loop for s across self do (not-to-be s))) (:method ((self hash-table)) (maphash (lambda (k v) (declare (ignorable k)) (not-to-be v)) self)) (:method ((self model-object)) (when *ntb-dbg* (trcx not2be self) (when (and *md-awake* (not (gethash self *md-awake*))) (trcx not2be-not-awake!!!! self))) (setf (md-census-count self) -1) (md-quiesce self) (md-awake-remove self)) (:method :before ((self model-object)) (loop for slot-name in (md-owning-slots self) do (not-to-be (slot-value self slot-name)))) (:method :around ((self model-object)) (declare (ignorable self)) (let ((*not-to-be* t) (dbg nil)) (flet ((gok () (if (md-shuffling-off self) (trc nil "n2be bailing on already dead or doomed" self (md-state self)(md-doomed self)) (progn ;(trx not-to-be!!!!!!! self) (setf (md-doomed self) t) (call-next-method) (setf (fm-parent self) nil (md-state self) :eternal-rest) (md-awake-remove self) (md-map-cells self nil (lambda (c) (c-warn? (eq :quiesced (c-state c)) () "Cell ~a of dead model ~a not quiesced. Was not-to-be shadowed by a primary method? Use :before instead." c self))) ;; fails if user obstructs not.to-be with primary method (use :before etc) )))) (if (not dbg) (gok) (wtrc (0 100 "not.to-be nailing" self (when (typep self 'family) (mapcar 'type-of (slot-value self '.kids)))) (gok) (when dbg (trc "finished nailing" self)))))))) (defun md-shuffling-off (self) (or (eq (md-state self) :eternal-rest) (md-doomed self))) (export! md-shuffling-off) (defun md-quiesce (self) #+xxxx (unless (search "QX-" (string (md-name self))) (trc "md-quiescing" self (type-of self)(type-of (fm-parent self)))) (md-map-cells self nil (lambda (c) (trc nil "quiescing" c) (c-warn? (not (find c *call-stack*))) (c-quiesce c))) (when (register? self) (fm-check-out self))) (defun c-quiesce (c) (typecase c (cell (trc nil "c-quiesce unlinking" c) (c-unlink-from-used c) (dolist (caller (c-callers c)) (setf (c-value-state caller) :uncurrent) (trc nil "c-quiesce totlalaly unlinking caller and making uncurrent" .dpid :q c :caller caller) (c-unlink-caller c caller)) (setf (c-state c) :quiesced) ;; 20061024 for debugging for now, might break some code tho ))) (defparameter *to-be-dbg* nil) (defmacro make-kid (class &rest ia) (with-gensyms (c) `(let ((,c ,class)) (make-instance ,c ,@ia :fm-parent (progn (assert self () "make-kid: self nil making ~a" ,c) self))))) (defvar *c-d-d*) (defvar *max-d-d*) (defparameter *model-pop* nil) (export! md-census-start md-census-report md-census-count) (defun md-census-start () (setf *model-pop* (make-hash-table :test 'eq))) (defun (setf md-census-count) (delta self) (when *model-pop* (incf (gethash (type-of self) *model-pop* 0) delta) #-gogo (when (minusp (gethash (type-of self) *model-pop* 0)) (warn "minus pop ~a" self)))) (defun md-census-report () (when *model-pop* (loop for (ct . type) in (sort (let (raw) (maphash (lambda (k v) (push (cons v k) raw)) *model-pop*) raw) '< :key 'car) unless (zerop ct) do (trc "pop" ct type)))) #+test (md-census-report) #+test (md-census-count) (defun md-census-count (&optional type) (when *model-pop* (if type (gethash type *model-pop* 0) (loop for v being the hash-values of *model-pop* summing v)))) (defun count-model (self &key count-cells &aux (ccc 0)) (setf *c-d-d* (make-hash-table :test 'eq) *max-d-d* 0) (let ((*counted* (make-hash-table :test 'eq :size 5000))) (with-metrics (t nil "cells statistics for" self) (labels ((cc (self from) (unless (gethash self *counted*) (setf (gethash self *counted*) t) (typecase self (cons (cc (car self) from) (cc (cdr self) from)) (model (when (zerop (mod (incf ccc) 100)) (trc "cc" (md-name self) (type-of self))) (count-it! :thing) (count-it! :thing (type-of self)) (when count-cells (loop for (nil . c) in (cells self) do (count-it! :live-cell) ;(count-it! :live-cell id) (when (c-lazy c) (count-it! :lazy) (count-it! :lazy (c-value-state c))) (typecase c (c-dependent (count-it! :dependent-cell) #+chill (loop repeat (length (c-useds c)) do (count-it! :cell-useds) (count-it! :dep-depth (c-depend-depth c)))) (otherwise (if (c-inputp c) (progn (count-it! :c-input-altogether) ;(count-it! :c-input id) ) (count-it! :c-unknown)))) (loop repeat (length (c-callers c)) do (count-it! :cell-callers))) (loop repeat (length (cells-flushed self)) do (count-it! :flushed-cell #+toomuchinfo id))) (loop for slot in (md-owning-slots self) do (loop for k in (let ((sv (slot-value self slot))) (if (listp sv) sv (list sv))) do (cc k self)))) (otherwise (count-it (type-of self))))))) (cc self nil))))) (defun c-depend-depth (ctop) (if (null (c-useds ctop)) 0 (or (gethash ctop *c-d-d*) (labels ((cdd (c &optional (depth 1) chain) (when (and (not (c-useds c)) (> depth *max-d-d*)) (setf *max-d-d* depth) (trc "new dd champ from user" depth :down-to c) (when (= depth 41) (trc "end at" (c-slot-name c) :of (type-of (c-model c))) (loop for c in chain do (trc "called by" (c-slot-name c) :of (type-of (c-model c)))))) (setf (gethash c *c-d-d*) ;(brk "c-depend-depth ~a" c) (progn ;(trc "dd" c) (1+ (loop for u in (c-useds c) maximizing (cdd u (1+ depth) (cons c chain)))))))) (cdd ctop)))))
8,557
Common Lisp
.lisp
199
28.572864
125
0.473464
kennytilton/its-alive
21
1
0
EPL-1.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
753318c172e341351766d7b5738182c48b6e5b9fa7da2f0cb7c5ee0cb313e93b
7,487
[ -1 ]
7,488
model-object.lisp
kennytilton_its-alive/lisp/model-object.lisp
;; -*- mode: Lisp; Syntax: Common-Lisp; Package: cells; -*- #| Cells -- Automatic Dataflow Managememnt |# (in-package :cells) ;;; --- model-object ---------------------- (eval-when (:compile-toplevel :load-toplevel :execute) (export '(md-name fm-parent .parent ))) (defclass model-object () ((.md-state :initform :nascent :accessor md-state) ; [nil | :nascent | :alive | :eternal-rest] (.doomed :initform nil :accessor md-doomed) ; goes t at start of not-to-be (prolly could fold into state w/ work) (.fnz :initform nil ) (.awaken-on-init-p :initform nil :initarg :awaken-on-init-p :accessor awaken-on-init-p) (.cells :initform nil :accessor cells) (.cells-flushed :initform nil :accessor cells-flushed :documentation "cells supplied but un-whenned or optimized-away") (adopt-ct :initform 0 :accessor adopt-ct))) (defmethod md-finalize ((self model-object)) (print `(:wow-fnz-non-mod ,(type-of self)))) (defmethod register? ((self model-object))) (defmethod md-state ((self symbol)) :alive) (defun e-restp (self) (eq :eternal-rest (md-state self))) ;;; --- md obj initialization ------------------ (defmethod shared-initialize :after ((self model-object) slotnames &rest initargs &key fm-parent) (declare (ignorable initargs slotnames fm-parent)) ;(excl:schedule-finalization self 'md-finalize) (setf (md-census-count self) 1) ;; bad idea if we get into reinitializing (md-awake-record self) ; ; for convenience and transparency of mechanism we allow client code ; to intialize a slot to a cell, but we want the slot to hold the functional ; value, partly for ease of inspection, partly for performance, mostly ; because sometimes we are a slave to other libraries, such as a persistence ; library that does interesting things automatically based on the slot value. ; ; here we shuttle cells out of the slots and into a per-instance dictionary of cells, ; as well as tell the cells what slot and instance they are mediating. ; (when (slot-boundp self '.md-state) (loop for esd in (class-slots (class-of self)) for sn = (slot-definition-name esd) for sv = (when (slot-boundp self sn) (slot-value self sn)) ;; do (print (list (type-of self) sn sv (typep sv 'cell))) when (typep sv 'cell) do (if (md-slot-cell-type (type-of self) sn) (md-install-cell self sn sv) (when *c-debug* (brk "warning: cell ~a offered for non-cellular model/slot ~a/~a" sv sn (type-of self))))) ; ; queue up for awakening ; (if (awaken-on-init-p self) (progn (when (and (not *within-integrity*) (zerop *data-pulse-id*)) ;; this is a top-level make-instance outside integrity ;; and the initial zero data-pulse matches the default zero ;; pulse-observed, so awaken-on-init-p's will not get their initial ;; observations. Perhaps cells puls-observed should start at -1? ;; but I like also getting *dp-id* off zero since the game is indeed underway (data-pulse-next :toplvl-mki)) (md-awaken self)) (with-integrity (:awaken self) (md-awaken self))) )) (defun md-install-cell (self slot-name c &aux (c-isa-cell (typep c 'cell))) ; ; iff cell, init and move into dictionary ; (when c-isa-cell (count-it :md-install-cell) (setf (c-model c) self (c-slot-name c) slot-name (md-slot-cell self slot-name) c)) ; ; now have the slot really be the slot ; (if c-isa-cell (if (c-unboundp c) (bd-slot-makunbound self slot-name) (if self (setf (slot-value self slot-name) (when (c-inputp c) (c-value c))) (setf (symbol-value slot-name) (when (c-inputp c) (c-value c))))) ;; note that in this else branch "c" is a misnomer since ;; the value is not actually a cell (if self (setf (slot-value self slot-name) c) (setf (symbol-value slot-name) c)))) ;;; --- awaken -------- ; ; -- do initial evaluation of all ruled slots ; -- call observers of all slots (defmethod md-awaken :around ((self model-object)) (when (eql :nascent (md-state self)) (call-next-method)) self) #+test (md-slot-cell-type 'cgtk::label 'cgtk::container) (defmethod md-awaken ((self model-object)) ; ; --- debug stuff ; (when *stop* (princ #\.) (return-from md-awaken)) (trc nil "md-awaken entry" self (md-state self)) (c-assert (eql :nascent (md-state self))) (count-it :md-awaken) ;(count-it 'mdawaken (type-of self)) ; --- (setf (md-state self) :awakening) (dolist (esd (class-slots (class-of self))) (bwhen (sct (md-slot-cell-type (type-of self) (slot-definition-name esd))) (let* ((slot-name (slot-definition-name esd)) (c (md-slot-cell self slot-name))) (when *c-debug* (bwhen (sv (and (slot-boundp self slot-name) (slot-value self slot-name))) (when (typep sv 'cell) (c-break "md-awaken ~a found cell ~a in slot ~a" self sv esd)))) (cond ((not c) ;; all slots must hit any change handlers as instances come into existence to get ;; models fully connected to the outside world they are controlling. that ;; happens in awaken-cell for slots in fact mediated by cells, but as an ;; optimization we allow raw literal values to be specified for a slot, in ;; which case heroic measures are needed to get the slot to the change handler ;; ;; next is an indirect and brittle way to determine that a slot has already been output, ;; but I think anything better creates a run-time hit. ;; ;; until 2007-10 (unless (cdr (assoc slot-name (cells--flushed self))) ;; make sure not flushed ;; but first I worried about it being slow keeping the flushed list /and/ searching, then ;; I wondered why a flushed cell should not be observed, constant cells are. So Just Observe It (let ((flushed (md-slot-cell-flushed self slot-name))) (when (or (null flushed) ;; constant, ie, never any cell provided for this slot (> *data-pulse-id* (flushed-cell-pulse-observed flushed))) ;; unfrickinlikely #+bahhh (when (and (eq 'cells:.kids slot-name) (typep self 'qxl::qx-tab-view)) (trc "reobserving flushed" flushed)) (when flushed (setf (flushed-cell-pulse-observed flushed) *data-pulse-id*)) ;; probably unnecessary (let ((*observe-why* :flush)) (slot-value-observe slot-name self (bd-slot-value self slot-name) nil nil flushed))))) ((find (c-lazy c) '(:until-asked :always t)) (trc nil "md-awaken deferring c-awaken since lazy" self esd)) ((eq :nascent (c-state c)) (c-assert (c-model c) () "c-awaken sees uninstalled cell" c) (trc nil "c-awaken > awakening" c) (count-it :c-awaken) (setf (c-state c) :awake) (awaken-cell c)))))) (setf (md-state self) :awake) self) (defun hackc (c) (declare (ignorable c)) ) ;;; --- utilities, accessors, etc -------------------------------------- (defmethod c-slot-value ((self model-object) slot) (slot-value self slot)) (defmethod md-slot-cell (self slot-name) (if self (cdr (assoc slot-name (cells self))) (get slot-name 'cell))) (defun md-cell-flush (c) (push (cons (c-slot-name c) #+gogo (c-pulse-observed c) #-gogo c) (cells-flushed (c-model c)))) (defun md-slot-cell-flushed (self slot-name) (if self (assoc slot-name (cells-flushed self)) (get slot-name 'cell))) (defun flushed-cell-pulse-observed (c) (if (numberp (cdr c)) (cdr c) (c-pulse-observed (cdr c)))) (defun (setf flushed-cell-pulse-observed) (pulse c) (if (numberp (cdr c)) (rplacd c pulse) (progn ;; (trc "flush-pulsing" :new pulse :old (if (numberp (cdr c)) (cdr c) (c-pulse-observed (cdr c)))(c-slot-name c)) (setf (c-pulse-observed (cdr c)) pulse)))) #+test (get 'cgtk::label :cell-types) (defun md-slot-cell-type (class-name slot-name) (assert class-name) (if (eq class-name 'null) (get slot-name :cell-type) (bif (entry (assoc slot-name (get class-name :cell-types))) (cdr entry) (dolist (super (class-precedence-list (find-class class-name)) (setf (md-slot-cell-type class-name slot-name) nil)) (bwhen (entry (assoc slot-name (get (c-class-name super) :cell-types))) (return-from md-slot-cell-type (setf (md-slot-cell-type class-name slot-name) (cdr entry)))))))) (defun (setf md-slot-cell-type) (new-type class-name slot-name) (assert class-name) (if (eq class-name 'null) ;; not def-c-variable (setf (get slot-name :cell-type) new-type) (let ((entry (assoc slot-name (get class-name :cell-types)))) (if entry (prog1 (setf (cdr entry) new-type) (loop for c in (class-direct-subclasses (find-class class-name)) do (setf (md-slot-cell-type (class-name c) slot-name) new-type))) (cdar (push (cons slot-name new-type) (get class-name :cell-types))))))) #+test (md-slot-owning? 'm-index '.value) (defun md-slot-owning? (class-name slot-name) (assert class-name) (if (eq class-name 'null) (get slot-name :owning) ;; might be wrong -- support for specials is unfinished w.i.p. (bif (entry (assoc slot-name (get class-name :direct-ownings))) (cdr entry) (bif (entry (assoc slot-name (get class-name :indirect-ownings))) (cdr entry) (cdar (push (cons slot-name (cdr (loop for super in (cdr (class-precedence-list (find-class class-name))) thereis (assoc slot-name (get (c-class-name super) :direct-ownings))))) (get class-name :indirect-ownings))))))) (defun (setf md-slot-owning-direct?) (value class-name slot-name) (assert class-name) (if (eq class-name 'null) ;; global variables (setf (get slot-name :owning) value) (progn (bif (entry (assoc slot-name (get class-name :direct-ownings))) (setf (cdr entry) value) (push (cons slot-name value) (get class-name :direct-ownings))) ; -- propagate to derivatives ... (labels ((clear-subclass-ownings (c) (loop for sub-c in (class-direct-subclasses c) for sub-c-name = (c-class-name sub-c) do (setf (get sub-c-name :indirect-ownings) (delete slot-name (get sub-c-name :indirect-ownings) :key 'car)) ;; forces redecide (setf (get sub-c-name :model-ownings) nil) ;; too much forcing full recalc like this? (clear-subclass-ownings sub-c)))) (clear-subclass-ownings (find-class class-name)))))) (defun md-owning-slots (self &aux (st (type-of self))) (or (get st :model-ownings) (setf (get st :model-ownings) (loop for s in (class-slots (class-of self)) for sn = (slot-definition-name s) when (and (md-slot-cell-type st sn) (md-slot-owning? st sn)) collect sn)))) #+test (md-slot-owning? 'cells::family '.kids) (defun md-slot-value-store (self slot-name new-value) (trc nil "md-slot-value-store" self slot-name new-value) (if self (setf (slot-value self slot-name) new-value) (setf (symbol-value slot-name) new-value))) ;----------------- navigation: slot <> initarg <> esd <> cell ----------------- #+cmu (defmethod c-class-name ((class pcl::standard-class)) (pcl::class-name class)) (defmethod c-class-name (other) (declare (ignore other)) nil) ;; why not #-cmu? (defmethod c-class-name ((class standard-class)) (class-name class)) (defmethod cell-when (other) (declare (ignorable other)) nil) (defun (setf md-slot-cell) (new-cell self slot-name) (if self ;; not on def-c-variables (bif (entry (assoc slot-name (cells self))) ; this next branch guessed it would only occur during kid-slotting, ; before any dependency-ing could have happened, but a math-editor ; is silently switching between implied-multiplication and mixed numbers ; while they type and it (progn (trc nil "second cell same slot:" slot-name :old entry :new new-cell) (let ((old (cdr entry))) ;; s/b being supplanted by kid-slotter (declare (ignorable old)) (c-assert (null (c-callers old))) (when (typep entry 'c-dependent) (c-assert (null (cd-useds old)))) (trc nil "replacing in model .cells" old new-cell self) (rplacd entry new-cell))) (progn (trc nil "adding to model .cells" new-cell self) (push (cons slot-name new-cell) (cells self)))) (setf (get slot-name 'cell) new-cell))) (defun md-map-cells (self type celldo) (map type (lambda (cell-entry) (bwhen (cell (cdr cell-entry)) (unless (listp cell) (funcall celldo cell)))) (cells self)))
13,476
Common Lisp
.lisp
296
37.746622
119
0.614637
kennytilton/its-alive
21
1
0
EPL-1.0
9/19/2024, 11:26:28 AM (Europe/Amsterdam)
8a3c84c373a8da1ce4604972ae8decd02af8c2cb4c28535afa9c580624ae35b4
7,488
[ -1 ]