{"size":115625,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"; malyon.el --- mode to execute z code files version 3, 5, 8\n\n;; Maintainer: Peter Ilberg \n;; (I am unable to continue supporting malyon.el. Please send me an\n;; email if you are interested in taking over the project. Thanks.)\n\n;; Copyright (C) 1999-2011 Peter Ilberg\n\n;; Permission is hereby granted, free of charge, to any person obtaining a\n;; copy of this software and associated documentation files (the \"Software\"),\n;; to deal in the Software without restriction, including without limitation\n;; the rights to use, copy, modify, merge, publish, distribute, sublicense,\n;; and\/or sell copies of the Software, and to permit persons to whom the\n;; Software is furnished to do so, subject to the following conditions:\n\n;; The above copyright notice and this permission notice shall be included in\n;; all copies or substantial portions of the Software.\n\n;; THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\n;; DEALINGS IN THE SOFTWARE.\n\n;;; Credits:\n\n;; The author would like to thank the following people for reporting\n;; bugs, testing, suggesting and\/or contributing improvements:\n;; Bernhard Barde, Jonathan Craven, Alberto Petrofsky, Alan Shutko\n\n;;; Commentary:\n\n;; This package provides a basic interpreter for version 3, 5, 8 z code\n;; story files as generated by Inform (C) Graham Nelson and Infocom.\n\n;; If you encounter a bug please send a report to Peter Ilberg at \n;; peter.ilberg@gmail.com. Thank you!\n\n;; To play a story file simple type M-x malyon and enter the path to the\n;; story file. If anything goes wrong and you want to manually clean\n;; up type M-x malyon-quit. In addition, you can switch back to a game in\n;; progress by typing M-x malyon-restore.\n\n;; A note on the format of saved game states:\n\n;; As of version 1.0, Malyon supports the quetzal file format for saved \n;; games. Support for this format required changes to several internal\n;; data structures (stack frames and catch-throw) that are incompatible\n;; with the old implementation. Unfortunately, the old file format for\n;; saved games cannot be converted into quetzal.\n\n;; For backwards compatibility, however, Malyon still supports the old\n;; file format. And you can continue to play your old game states.\n\n;; Because of the incompatibility of the two file formats, Malyon now \n;; runs, as follows, in either of two modes: quetzal and compatibility.\n\n;; - in quetzal mode, game states are saved in quetzal format\n;; - in compatibility mode, games states are saved in the old format\n;; - loading a game state in quetzal format switches to quetzal mode\n;; - loading an old game state switches to compatibility mode\n;; - quetzal mode is the default setting\n\n;; In other words, Malyon will only use the old file format if you've\n;; restored a game state saved in the old file format.\n\n;; Enjoy!\n\n;;; Code:\n\n;; global variables - moved here to appease the byte-code compiler\n\n;; story file information\n\n(defvar malyon-story-file-name nil\n \"The name of the story file being executed.\")\n\n(defvar malyon-story-file nil\n \"The story file which is currently being run.\")\n\n(defvar malyon-story-version nil\n \"The story file version.\")\n\n(defvar malyon-supported-versions '(3 5 8)\n \"A list of supported story file versions.\")\n\n;; status and transcript buffers\n\n(defvar malyon-transcript-buffer nil\n \"The main transcript buffer of the story file execution.\")\n\n(defvar malyon-transcript-buffer-buffered nil\n \"Is output in the transcript buffer buffered?\")\n\n(defvar malyon-status-buffer nil\n \"The status bar buffer of the story file execution.\")\n\n(defvar malyon-status-buffer-lines nil\n \"The number of lines in the status bar buffer.\")\n\n(defvar malyon-status-buffer-delayed-split nil\n \"If the number of lines in the status buffer is reduced,\nthe window configuration is not changed immediately. It\nis changed after the next turn (read or read_char).\")\n\n(defvar malyon-status-buffer-point nil\n \"The point location in the status bar buffer.\")\n\n(defvar malyon-max-column 72\n \"Maximum column for text display.\")\n\n;; window management\n\n(defvar malyon-window-configuration nil\n \"The current window configuration of the malyon interpreter.\")\n\n(defvar malyon-current-window nil\n \"The currently active window for text output.\")\n\n;; z machine registers\n\n(defvar malyon-stack nil\n \"The stack of the z machine.\")\n\n(defvar malyon-stack-pointer nil\n \"The stack pointer of the z machine.\")\n\n(defvar malyon-frame-pointer nil\n \"The frame pointer of the z machine.\")\n\n(defvar malyon-instruction-pointer nil\n \"The instruction pointer of the z machine.\")\n\n;; game file related global variables\n\n(defvar malyon-score-game nil\n \"A flag indicating whether this story uses score or time.\")\n\n(defvar malyon-packed-multiplier nil\n \"The amount by which packed addresses are multiplied to get byte\naddresses.\")\n\n(defvar malyon-global-variables nil\n \"A pointer to the global variable section in the story file.\")\n\n(defvar malyon-abbreviations nil\n \"A pointer to the abbreviations in the story file.\")\n\n(defvar malyon-alphabet nil\n \"The z machine's text alphabet.\")\n\n(defvar malyon-whitespace nil\n \"A string of whitespace characters recognized by the interpreter.\")\n\n;; object tables\n\n(defvar malyon-object-table nil\n \"A pointer to the object table in the story file.\")\n\n(defvar malyon-object-table-entry-size nil\n \"The size of one entry in the object table.\")\n\n(defvar malyon-object-properties nil\n \"The number of properties per object minus one.\")\n\n(defvar malyon-object-property-offset nil\n \"The byte offset of the properties table in the object.\")\n\n;; dictionaries\n\n(defvar malyon-dictionary nil\n \"A pointer to the dictionary of the story file.\")\n\n(defvar malyon-dictionary-entry-length nil\n \"The length of a dictionary entry.\")\n\n(defvar malyon-dictionary-num-entries nil\n \"The number of dictionary entries.\")\n\n(defvar malyon-dictionary-entries nil\n \"A pointer to the first dictionary entry.\")\n\n(defvar malyon-dictionary-word-length nil\n \"The length of a dictionary word.\")\n\n;; game state information\n\n(defvar malyon-game-state-restart nil\n \"The machine state for implementing restart.\")\n\n(defvar malyon-game-state-undo nil\n \"The machine state for implementing undo.\")\n\n(defvar malyon-game-state-quetzal t\n \"Store game state information for quetzal.\")\n\n;; various\n\n(defvar malyon-current-face nil\n \"The current face in which to display text.\")\n\n(defvar malyon-last-cursor-position-after-input nil\n \"The last cursor position after reading input from the keyboard.\")\n\n;; interactive functions\n\n(defun malyon (file-name)\n \"Major mode for playing z3\/5\/8 story files.\nThis mode allows execution of version 3, 5, 8 z code story files.\"\n (interactive \"fStory file name: \")\n (if malyon-story-file\n (message \"You are already playing a game.\")\n (if (not (string-match \".*\\.z[358]$\" file-name))\n (message \"%s is not a version 3, 5, or 8 story file.\" file-name)\n (condition-case nil\n (malyon-load-story-file file-name)\n (error\n (malyon-fatal-error \"loading of story file failed.\")))\n (setq malyon-story-version (aref malyon-story-file 0))\n (cond ((memq malyon-story-version malyon-supported-versions)\n (condition-case nil\n (malyon-initialize)\n (error\n (malyon-fatal-error \"initialization of interpreter failed.\")))\n (malyon-interpreter))\n (t\n (message \"%s is not a version 3, 5, or 8 story file.\" file-name)\n (malyon-cleanup))))))\n\n(defun malyon-restore ()\n \"Restore the save window configuration for the interpreter.\"\n (interactive)\n (condition-case nil\n (progn\n (malyon-restore-window-configuration)\n (malyon-adjust-transcript))\n (error\n (malyon-fatal-error \"restoring window configuration failed.\"))))\n\n(defun malyon-quit ()\n \"Exit the malyon interpreter.\"\n (interactive)\n (if malyon-story-file\n (progn\n (malyon-restore)\n (if (malyon-yes-or-no-p-minibuf \"Do you really want to quit? \")\n (malyon-cleanup)))))\n\n(defun malyon-mode ()\n \"This mode provides a basic interpreter for version 3, 5, 8 z code\nstory files as generated by Inform (C) Graham Nelson and Infocom. \n\nNote that this package is by no means complete and bug free.\nIf you encounter a bug please send a report to Peter Ilberg at \npeter.ilberg@natinst.com. Thank you!\n\nTo play a story file simple type M-x malyon and enter the path to the\nstory file. If anything goes wrong and you want to manually clean\nup type M-x malyon-quit. In addition, you can switch back to a game in\nprogress by typing M-x malyon-restore.\n\nThe author would like to thank the following people for reporting\nbugs, testing, suggesting and\/or contributing improvements:\n Bernhard Barde, Jonathan Craven, Alberto Petrofsky, Alan Shutko\"\n (message \"Use M-x malyon if you want to play a zcode game.\"))\n\n;; compatibility functions for GNU emacs\n\n(if (fboundp 'cadr)\n (defalias 'malyon-cadr 'cadr)\n (defun malyon-cadr (list)\n \"Take the cadr of the list.\"\n (car (cdr list))))\n\n(if (fboundp 'caddr)\n (defalias 'malyon-caddr 'caddr)\n (defun malyon-caddr (list)\n \"Take the caddr of the list.\"\n (car (cdr (cdr list)))))\n\n(if (fboundp 'cdddr)\n (defalias 'malyon-cdddr 'cdddr)\n (defun malyon-cdddr (list)\n \"Take the cdddr of the list.\"\n (cdr (cdr (cdr list)))))\n\n(if (fboundp 'char-before)\n (defalias 'malyon-char-before 'char-before)\n (defun malyon-char-before ()\n \"Return the character before the point.\"\n (char-after (- (point) 1))))\n\n(if (fboundp 'char-to-int)\n (defalias 'malyon-char-to-int 'char-to-int)\n (defun malyon-char-to-int (c)\n \"Convert a character into an integer.\"\n c))\n\n(if (fboundp 'characterp)\n (defalias 'malyon-characterp 'characterp)\n (defun malyon-characterp (x)\n \"Test for a character.\"\n (and (numberp x) (<= 0 x) (< x 256))))\n\n(defun malyon-disable-multibyte ()\n \"Disable multibyte support in the current buffer.\"\n (condition-case nil (set-buffer-multibyte nil) (error)))\n\n(defun malyon-erase-buffer (&optional buffer)\n \"Erase the given buffer.\"\n (save-excursion\n (if buffer (set-buffer buffer))\n (if (and buffer (eq buffer malyon-transcript-buffer))\n (malyon-begin-section)\n (erase-buffer))))\n\n(if (fboundp 'int-to-char)\n (defalias 'malyon-int-to-char 'int-to-char)\n (defun malyon-int-to-char (i)\n \"Convert an integer into a character.\"\n i))\n\n(if (fboundp 'mapc)\n (defalias 'malyon-mapc 'mapc)\n (defun malyon-mapc (function list)\n \"Apply fun to every element of args ignoring the results.\"\n (if (null list)\n '()\n (funcall function (car list))\n (malyon-mapc function (cdr list)))))\n\n(if (fboundp 'mapcan)\n (defalias 'malyon-mapcan 'mapcan)\n (defun malyon-mapcan (function list)\n \"Apply fun to every element of args nconc'ing the result.\"\n (if (null list)\n '()\n (nconc (funcall function (car list))\n (malyon-mapcan function (cdr list))))))\n\n; Do not use the built-in conversion via 'multibyte-char-to-unibyte.\n(defun malyon-multibyte-char-to-unibyte (char)\n \"Convert a multibyte character to unibyte.\"\n char)\n\n(defun malyon-point-max (&optional buffer)\n \"Get the point-max of the given buffer.\"\n (save-excursion\n (if buffer (set-buffer buffer))\n (point-max)))\n\n(if (fboundp 'redisplay-frame)\n (defalias 'malyon-redisplay-frame 'redisplay-frame)\n (defun malyon-redisplay-frame (frame &rest ignore)\n \"Redisplay the given frame.\"))\n\n(if (fboundp 'remove)\n (defalias 'malyon-remove 'remove)\n (defun malyon-remove (element list)\n \"Remove the element from the list.\"\n (cond ((null list)\n '())\n ((eq element (car list))\n (malyon-remove element (cdr list)))\n ((equal element (car list))\n (malyon-remove element (cdr list)))\n (t\n (cons (car list)\n (malyon-remove element (cdr list)))))))\n\n(if (fboundp 'set-keymap-name)\n (defalias 'malyon-set-keymap-name 'set-keymap-name)\n (defun malyon-set-keymap-name (keymap name)\n \"Set the name of the keymap.\"))\n\n(if (fboundp 'string-to-list)\n (defalias 'malyon-string-to-list 'string-to-list)\n (defun malyon-string-to-list (s)\n \"Convert a string into a list of characters.\"\n (let ((i (- (length s) 1)) (l '()))\n (while (<= 0 i)\n (setq l (cons (aref s i) l)\n i (- i 1)))\n l)))\n\n(if (fboundp 'string-to-vector)\n (defalias 'malyon-string-to-vector 'string-to-vector)\n (defun malyon-string-to-vector (s)\n \"Convert a string into a vector of characters.\"\n (let* ((i 0) (l (length s)) (v (make-vector l 0)))\n (while (< i l)\n (aset v i (aref s i))\n (setq i (+ 1 i)))\n v)))\n\n; Do not use the built-in conversion via 'unibyte-char-to-multibyte.\n(defun malyon-unibyte-char-to-multibyte (char)\n \"Convert a unibyte character to multibyte.\"\n char)\n\n(defun malyon-vector-to-list (v begin end)\n \"Return a list of elements in v in the range [begin, end).\"\n (let ((result '()))\n (while (< begin end)\n (setq result (cons (aref v begin) result))\n (setq begin (+ 1 begin)))\n (reverse result)))\n\n(if (fboundp 'window-displayed-height)\n (defalias 'malyon-window-displayed-height 'window-displayed-height)\n (defun malyon-window-displayed-height (&optional window)\n \"Get the height of the window's displayed region.\"\n (- (window-height) 1)))\n\n(if (fboundp 'yes-or-no-p-minibuf)\n (defalias 'malyon-yes-or-no-p-minibuf 'yes-or-no-p-minibuf)\n (defun malyon-yes-or-no-p-minibuf (prompt)\n \"Ask a yes or no question.\"\n (yes-or-no-p prompt)))\n\n;; global variables for the malyon mode\n\n(defvar malyon-syntax-table nil\n \"Syntax table used while in malyon mode (same as in text-mode).\")\n\n(if malyon-syntax-table\n '()\n (setq malyon-syntax-table (make-syntax-table))\n (modify-syntax-entry ?\\\" \". \" malyon-syntax-table)\n (modify-syntax-entry ?\\\\ \". \" malyon-syntax-table)\n (modify-syntax-entry ?' \"w \" malyon-syntax-table))\n\n(defvar malyon-keymap-read nil\n \"Keymap for malyon mode for reading input into a buffer.\")\n\n(defvar malyon-history-saved-up nil\n \"The saved binding for the up arrow key.\")\n\n(defvar malyon-history-saved-down nil\n \"The saved binding for the down arrow key.\")\n\n(if malyon-keymap-read\n '()\n (setq malyon-keymap-read (make-sparse-keymap))\n (malyon-set-keymap-name malyon-keymap-read 'malyon-keymap-read)\n (setq malyon-history-saved-up (global-key-binding [up]))\n (setq malyon-history-saved-down (global-key-binding [down]))\n (define-key malyon-keymap-read \"\\r\" 'malyon-end-input)\n (define-key malyon-keymap-read [up] 'malyon-history-previous-char)\n (define-key malyon-keymap-read [down] 'malyon-history-next-char)\n (define-key malyon-keymap-read \"\\M-p\" 'malyon-history-previous-char)\n (define-key malyon-keymap-read \"\\M-n\" 'malyon-history-next-char)\n (define-key malyon-keymap-read \"\\C-a\" 'malyon-beginning-of-line)\n (define-key malyon-keymap-read \"\\C-w\" 'malyon-kill-region)\n (define-key malyon-keymap-read \"\\C-k\" 'malyon-kill-line)\n (define-key malyon-keymap-read \"\\M-d\" 'malyon-kill-word)\n (define-key malyon-keymap-read \"\\C-y\" 'malyon-yank)\n (define-key malyon-keymap-read \"\\M-y\" 'malyon-yank-pop)\n (define-key malyon-keymap-read \"\\C-d\" 'malyon-delete-char)\n (define-key malyon-keymap-read \"\\d\" 'malyon-backward-delete-char)\n (define-key malyon-keymap-read [del] 'malyon-delete-char)\n (define-key malyon-keymap-read [backspace] 'malyon-backward-delete-char)\n (substitute-key-definition (lookup-key (current-global-map) \"a\")\n 'malyon-self-insert-command\n malyon-keymap-read (current-global-map)))\n\n(defvar malyon-keymap-readchar nil\n \"Keymap for malyon mode for waiting for input.\")\n\n(if malyon-keymap-readchar\n '()\n (setq malyon-keymap-readchar (make-sparse-keymap))\n (malyon-set-keymap-name malyon-keymap-readchar 'malyon-keymap-readchar)\n (define-key malyon-keymap-readchar \"\\r\" 'malyon-wait-char)\n (substitute-key-definition (lookup-key (current-global-map) \"a\")\n 'malyon-wait-char\n malyon-keymap-readchar (current-global-map)))\n\n(defvar malyon-keymap-more nil\n \"Keymap for malyon mode for browsing through text.\")\n\n(if malyon-keymap-more\n '()\n (setq malyon-keymap-more (make-sparse-keymap))\n (malyon-set-keymap-name malyon-keymap-more 'malyon-keymap-more)\n (define-key malyon-keymap-more \"\\r\" 'malyon-more-char)\n (substitute-key-definition (lookup-key (current-global-map) \"a\")\n 'malyon-more-char\n malyon-keymap-more (current-global-map)))\n\n(defvar malyon-keymap-more-status nil\n \"Keymap for malyon mode for browsing through the status buffer.\")\n\n(if malyon-keymap-more-status\n '()\n (setq malyon-keymap-more-status (make-sparse-keymap))\n (malyon-set-keymap-name malyon-keymap-more-status 'malyon-keymap-more-status)\n (define-key malyon-keymap-more-status \"\\r\" 'malyon-more-char-status)\n (substitute-key-definition (lookup-key (current-global-map) \"a\")\n 'malyon-more-char-status\n malyon-keymap-more-status (current-global-map)))\n\n(defvar malyon-faces nil\n \"An association list of text faces used by the malyon mode.\")\n\n(defun malyon-initialize-faces ()\n (copy-face 'default 'malyon-face-plain)\n (copy-face 'bold 'malyon-face-reverse)\n (copy-face 'bold 'malyon-face-bold)\n (copy-face 'italic 'malyon-face-italic)\n (copy-face 'default 'malyon-face-error)\n (set-face-foreground 'malyon-face-error \"red\")\n (setq malyon-faces '((0 . malyon-face-plain)\n (1 . malyon-face-reverse)\n (2 . malyon-face-bold)\n (4 . malyon-face-italic)\n (8 . malyon-face-plain))))\n\n(defvar malyon-print-separator nil\n \"A flag indicating whether to print the * * * separator.\")\n\n(defun malyon-begin-section ()\n \"Print a section divider and begin a new section.\"\n (if malyon-print-separator\n (progn\n (malyon-mapc 'malyon-putchar-transcript '(?\\n ?\\n ?* ? ?* ? ?*))\n (center-line)\n (malyon-mapc 'malyon-putchar-transcript '(?\\n ?\\n))\n (setq malyon-print-separator nil)))\n (narrow-to-region (point-max) (point-max)))\n\n(if malyon-whitespace\n '()\n (setq malyon-whitespace (list (malyon-char-to-int ? )\n (malyon-char-to-int ?\\t)\n (malyon-char-to-int ?\\n)\n (malyon-char-to-int ?\\r))))\n\n;; memory utilities\n\n(defsubst malyon-read-byte (address)\n \"Read a byte at address in the story file.\"\n (if (<= 0 address)\n (aref malyon-story-file address)\n (aref malyon-story-file (+ 65536 address))))\n\n(defsubst malyon-store-byte (address value)\n \"Store a byte at address in the story file.\"\n (if (<= 0 address)\n (aset malyon-story-file address (logand 255 value))\n (aset malyon-story-file (+ 65536 address) (logand 255 value))))\n\n(defsubst malyon-read-word (address)\n \"Read a word at address in the story file.\"\n (if (<= 0 address)\n (logior (lsh (aref malyon-story-file address) 8)\n (aref malyon-story-file (+ 1 address)))\n (logior (lsh (aref malyon-story-file (+ 65536 address)) 8)\n (aref malyon-story-file (+ 65537 address)))))\n \n(defsubst malyon-store-word (address value)\n \"Store a word at address in the story file.\"\n (if (<= 0 address)\n (progn\n (aset malyon-story-file address (logand 255 (lsh value -8)))\n (aset malyon-story-file (+ 1 address) (logand 255 value)))\n (aset malyon-story-file (+ 65536 address) (logand 255 (lsh value -8)))\n (aset malyon-story-file (+ 65537 address) (logand 255 value))))\n\n(defsubst malyon-read-code-byte ()\n \"Read the next byte at the program counter location.\"\n (setq malyon-instruction-pointer (+ malyon-instruction-pointer 1))\n (malyon-read-byte (- malyon-instruction-pointer 1)))\n\n(defsubst malyon-read-code-word ()\n \"Read the next word at the program counter location.\"\n (setq malyon-instruction-pointer (+ malyon-instruction-pointer 2))\n (malyon-read-word (- malyon-instruction-pointer 2)))\n\n(defsubst malyon-pop-stack ()\n \"Pop a value off the stack.\"\n (if (> 0 malyon-stack-pointer)\n (malyon-fatal-error \"stack underflow.\"))\n (setq malyon-stack-pointer (- malyon-stack-pointer 1))\n (aref malyon-stack (+ malyon-stack-pointer 1)))\n\n(defsubst malyon-read-local-variable (variable)\n \"Read a local variable.\"\n (aref malyon-stack (+ variable malyon-frame-pointer)))\n\n(defsubst malyon-read-global-variable (variable)\n \"Read a global variable.\"\n (malyon-read-word (+ malyon-global-variables (* 2 variable))))\n\n(defsubst malyon-read-variable (variable)\n \"Read a variable.\"\n (cond ((= variable 0) (malyon-pop-stack))\n ((< variable 16) (malyon-read-local-variable variable))\n (t (malyon-read-global-variable (- variable 16)))))\n\n(defsubst malyon-push-stack (value)\n \"Push a value onto the stack.\"\n (setq malyon-stack-pointer (+ malyon-stack-pointer 1))\n (aset malyon-stack malyon-stack-pointer value))\n\n(defsubst malyon-store-local-variable (variable value)\n \"Store a value in a local variable.\"\n (aset malyon-stack (+ variable malyon-frame-pointer) value))\n\n(defsubst malyon-store-global-variable (variable value)\n \"Store a value in a global variable.\"\n (malyon-store-word (+ malyon-global-variables (* 2 variable)) value))\n\n(defsubst malyon-store-variable (var value)\n \"Store the value in a variable.\"\n (setq value (logand 65535 value))\n (cond ((= var 0) (malyon-push-stack value))\n ((< var 16) (malyon-store-local-variable var value))\n (t (malyon-store-global-variable (- var 16) value))))\n\n;; list of opcodes\n\n(defvar malyon-opcodes\n [malyon-opcode-nop\n malyon-opcode-je malyon-opcode-jl\n malyon-opcode-jg malyon-opcode-dec-chk\n malyon-opcode-inc-chk malyon-opcode-jin\n malyon-opcode-test malyon-opcode-or\n malyon-opcode-and malyon-opcode-test-attr\n malyon-opcode-set-attr malyon-opcode-clear-attr\n malyon-opcode-store malyon-opcode-insert-obj\n malyon-opcode-loadw malyon-opcode-loadb\n malyon-opcode-get-prop malyon-opcode-get-prop-addr\n malyon-opcode-get-next-prop malyon-opcode-add\n malyon-opcode-sub malyon-opcode-mul\n malyon-opcode-div malyon-opcode-mod\n malyon-opcode-calls malyon-opcode-calln\n malyon-opcode-set-color malyon-opcode-throw\n malyon-opcode-nop malyon-opcode-nop\n malyon-opcode-nop malyon-opcode-nop\n malyon-opcode-je malyon-opcode-jl\n malyon-opcode-jg malyon-opcode-dec-chk\n malyon-opcode-inc-chk malyon-opcode-jin\n malyon-opcode-test malyon-opcode-or\n malyon-opcode-and malyon-opcode-test-attr\n malyon-opcode-set-attr malyon-opcode-clear-attr\n malyon-opcode-store malyon-opcode-insert-obj\n malyon-opcode-loadw malyon-opcode-loadb\n malyon-opcode-get-prop malyon-opcode-get-prop-addr\n malyon-opcode-get-next-prop malyon-opcode-add\n malyon-opcode-sub malyon-opcode-mul\n malyon-opcode-div malyon-opcode-mod\n malyon-opcode-calls malyon-opcode-calln\n malyon-opcode-set-color malyon-opcode-throw\n malyon-opcode-nop malyon-opcode-nop\n malyon-opcode-nop malyon-opcode-nop\n malyon-opcode-je malyon-opcode-jl \n malyon-opcode-jg malyon-opcode-dec-chk\n malyon-opcode-inc-chk malyon-opcode-jin\n malyon-opcode-test malyon-opcode-or\n malyon-opcode-and malyon-opcode-test-attr\n malyon-opcode-set-attr malyon-opcode-clear-attr\n malyon-opcode-store malyon-opcode-insert-obj\n malyon-opcode-loadw malyon-opcode-loadb\n malyon-opcode-get-prop malyon-opcode-get-prop-addr\n malyon-opcode-get-next-prop malyon-opcode-add\n malyon-opcode-sub malyon-opcode-mul\n malyon-opcode-div malyon-opcode-mod\n malyon-opcode-calls malyon-opcode-calln\n malyon-opcode-set-color malyon-opcode-throw\n malyon-opcode-nop malyon-opcode-nop\n malyon-opcode-nop malyon-opcode-nop\n malyon-opcode-je malyon-opcode-jl\n malyon-opcode-jg malyon-opcode-dec-chk\n malyon-opcode-inc-chk malyon-opcode-jin\n malyon-opcode-test malyon-opcode-or\n malyon-opcode-and malyon-opcode-test-attr\n malyon-opcode-set-attr malyon-opcode-clear-attr\n malyon-opcode-store malyon-opcode-insert-obj\n malyon-opcode-loadw malyon-opcode-loadb\n malyon-opcode-get-prop malyon-opcode-get-prop-addr\n malyon-opcode-get-next-prop malyon-opcode-add\n malyon-opcode-sub malyon-opcode-mul\n malyon-opcode-div malyon-opcode-mod\n malyon-opcode-calls malyon-opcode-calln\n malyon-opcode-set-color malyon-opcode-throw\n malyon-opcode-nop malyon-opcode-nop\n malyon-opcode-nop malyon-opcode-jz\n malyon-opcode-get-sibling malyon-opcode-get-child\n malyon-opcode-get-parent malyon-opcode-get-prop-len\n malyon-opcode-inc malyon-opcode-dec\n malyon-opcode-print-addr malyon-opcode-calls\n malyon-opcode-remove-obj malyon-opcode-print-obj\n malyon-opcode-ret malyon-opcode-jump\n malyon-opcode-print-paddr malyon-opcode-load\n malyon-opcode-calln malyon-opcode-jz\n malyon-opcode-get-sibling malyon-opcode-get-child\n malyon-opcode-get-parent malyon-opcode-get-prop-len\n malyon-opcode-inc malyon-opcode-dec\n malyon-opcode-print-addr malyon-opcode-calls\n malyon-opcode-remove-obj malyon-opcode-print-obj\n malyon-opcode-ret malyon-opcode-jump\n malyon-opcode-print-paddr malyon-opcode-load\n malyon-opcode-calln malyon-opcode-jz\n malyon-opcode-get-sibling malyon-opcode-get-child\n malyon-opcode-get-parent malyon-opcode-get-prop-len\n malyon-opcode-inc malyon-opcode-dec\n malyon-opcode-print-addr malyon-opcode-calls\n malyon-opcode-remove-obj malyon-opcode-print-obj\n malyon-opcode-ret malyon-opcode-jump\n malyon-opcode-print-paddr malyon-opcode-load\n malyon-opcode-calln malyon-opcode-rtrue\n malyon-opcode-rfalse malyon-opcode-print\n malyon-opcode-print-ret malyon-opcode-nop\n malyon-opcode-illegal malyon-opcode-illegal\n malyon-opcode-restart malyon-opcode-ret-popped\n malyon-opcode-catch malyon-opcode-quit\n malyon-opcode-new-line malyon-opcode-illegal\n malyon-opcode-verify malyon-opcode-illegal\n malyon-opcode-piracy malyon-opcode-nop\n malyon-opcode-je malyon-opcode-jl\n malyon-opcode-jg malyon-opcode-dec-chk\n malyon-opcode-inc-chk malyon-opcode-jin\n malyon-opcode-test malyon-opcode-or\n malyon-opcode-and malyon-opcode-test-attr\n malyon-opcode-set-attr malyon-opcode-clear-attr\n malyon-opcode-store malyon-opcode-insert-obj\n malyon-opcode-loadw malyon-opcode-loadb\n malyon-opcode-get-prop malyon-opcode-get-prop-addr\n malyon-opcode-get-next-prop malyon-opcode-add\n malyon-opcode-sub malyon-opcode-mul\n malyon-opcode-div malyon-opcode-mod\n malyon-opcode-calls malyon-opcode-calln\n malyon-opcode-set-color malyon-opcode-throw\n malyon-opcode-nop malyon-opcode-nop\n malyon-opcode-nop malyon-opcode-calls\n malyon-opcode-storew malyon-opcode-storeb\n malyon-opcode-put-prop malyon-opcode-aread\n malyon-opcode-print-char malyon-opcode-print-num\n malyon-opcode-random malyon-opcode-push\n malyon-opcode-pull malyon-opcode-split-window\n malyon-opcode-set-window malyon-opcode-calls\n malyon-opcode-erase-window malyon-opcode-erase-line\n malyon-opcode-set-cursor malyon-opcode-get-cursor\n malyon-opcode-set-text-style malyon-opcode-buffer-mode\n malyon-opcode-output-stream malyon-opcode-input-stream\n malyon-opcode-nop malyon-opcode-read-char\n malyon-opcode-scan-table malyon-opcode-not\n malyon-opcode-calln malyon-opcode-calln\n malyon-opcode-tokenise malyon-opcode-encode-text\n malyon-opcode-copy-table malyon-opcode-print-table\n malyon-opcode-check-arg-count malyon-opcode-save\n malyon-opcode-restore malyon-opcode-log-shift\n malyon-opcode-art-shift malyon-opcode-set-font\n malyon-opcode-illegal malyon-opcode-illegal\n malyon-opcode-illegal malyon-opcode-illegal\n malyon-opcode-save-undo malyon-opcode-restore-undo\n malyon-opcode-print-unicode malyon-opcode-check-unicode\n malyon-opcode-nop malyon-opcode-nop\n malyon-opcode-nop]\n \"A vector of all known legal z code opcodes.\")\n\n;; initialization\n\n(defun malyon-load-story-file (file-name)\n \"Load a z code story file into an internal vector.\"\n (save-excursion\n (set-buffer (create-file-buffer file-name))\n (malyon-disable-multibyte)\n (malyon-erase-buffer)\n (let ((coding-system-for-read 'binary))\n (insert-file-contents file-name))\n (setq malyon-story-file-name file-name)\n (setq malyon-story-file (buffer-substring-no-properties (point-min)\n (point-max)))\n (setq malyon-story-file (malyon-string-to-vector malyon-story-file))\n (if (not (eq ?\\^A 1))\n (let ((i 0))\n (while (< i (length malyon-story-file))\n (aset malyon-story-file\n i\n (malyon-char-to-int (aref malyon-story-file i)))\n (setq i (+ 1 i)))))\n (kill-buffer nil)))\n\n(defun malyon-initialize ()\n \"Initialize the z code interpreter.\"\n; (malyon-trace-file)\n (setq malyon-game-state-quetzal t)\n (malyon-initialize-faces)\n (malyon-initialize-status)\n (malyon-initialize-transcript)\n (malyon-initialize-windows)\n (malyon-initialize-story-header)\n (malyon-initialize-registers)\n (malyon-initialize-opcodes)\n (malyon-history-clear)\n (setq malyon-game-state-restart (malyon-current-game-state))\n (malyon-print-header))\n\n(defun malyon-initialize-status ()\n \"Initialize the status buffer.\"\n (setq malyon-status-buffer (get-buffer-create \"Malyon Status\"))\n (switch-to-buffer malyon-status-buffer)\n (malyon-erase-buffer)\n (kill-all-local-variables)\n (setq malyon-status-buffer-point (point))\n (setq malyon-status-buffer-lines 0)\n (setq malyon-status-buffer-delayed-split nil)\n (use-local-map malyon-keymap-read)\n (set-syntax-table malyon-syntax-table)\n (setq mode-name \"Malyon\")\n (setq major-mode 'malyon-mode)\n (run-hooks 'malyon-mode-hook))\n\n(defun malyon-initialize-transcript ()\n \"Initialize the transcript buffer.\"\n (setq malyon-transcript-buffer (get-buffer-create \"Malyon Transcript\"))\n (switch-to-buffer malyon-transcript-buffer)\n (malyon-erase-buffer)\n (kill-all-local-variables)\n (setq malyon-last-cursor-position-after-input\n (malyon-point-max malyon-transcript-buffer))\n (use-local-map malyon-keymap-read)\n (set-syntax-table malyon-syntax-table)\n (setq fill-column malyon-max-column)\n (auto-fill-mode 1)\n (setq mode-name \"Malyon\")\n (setq major-mode 'malyon-mode)\n (run-hooks 'malyon-mode-hook))\n\n(defun malyon-initialize-windows ()\n \"Initialize the window configuration for the z machine.\"\n (setq window-min-height 3)\n (setq malyon-transcript-buffer-buffered t)\n (malyon-set-window-configuration 0)\n (malyon-opcode-set-window 0))\n\n(defun malyon-initialize-story-header ()\n \"Initializes the header section of the story file.\"\n (malyon-store-byte 1 \n (if (>= malyon-story-version 5)\n 28\n (logior 48 (malyon-read-byte 1))))\n (malyon-store-byte 16 (logand 440 (malyon-read-byte 16)))\n (malyon-store-byte 30 1)\n (malyon-store-byte 31 65)\n (malyon-store-byte 32 255)\n (malyon-store-byte 33 (- malyon-max-column 1))\n (malyon-store-word 34 (- malyon-max-column 1))\n (malyon-store-word 36 255)\n (malyon-store-word 38 1)\n (malyon-store-word 39 1)\n (malyon-store-byte 44 0)\n (malyon-store-byte 45 0)\n (malyon-store-byte 50 1)\n (malyon-store-byte 51 0))\n\n(defun malyon-initialize-registers ()\n \"Initialize the interpreter's internal registers.\"\n (setq malyon-stack (make-vector 1024 0))\n (setq malyon-stack-pointer -1)\n (malyon-push-initial-frame)\n (setq malyon-frame-pointer malyon-stack-pointer)\n (setq malyon-instruction-pointer (malyon-read-word 6))\n (setq malyon-global-variables (malyon-read-word 12))\n (setq malyon-object-table (malyon-read-word 10))\n (cond ((< malyon-story-version 5)\n (setq malyon-object-table-entry-size 9)\n (setq malyon-object-properties 31)\n (setq malyon-object-property-offset 7))\n (t\n (setq malyon-object-table-entry-size 14)\n (setq malyon-object-properties 63)\n (setq malyon-object-property-offset 12)))\n (setq malyon-abbreviations (malyon-read-word 24))\n (if (< malyon-story-version 5)\n (setq malyon-score-game (zerop (logand 2 (malyon-read-byte 1)))))\n (setq malyon-packed-multiplier\n (malyon-cadr (assq malyon-story-version '((3 2) (5 4) (8 8)))))\n (if (or (< malyon-story-version 5) (zerop (malyon-read-word 52)))\n (setq malyon-alphabet (concat \"abcdefghijklmnopqrstuvwxyz\"\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n \" \\n0123456789.,!?_#'\\\"\/\\\\-:()\"))\n (setq malyon-alphabet (make-string 78 ? ))\n (let ((i 0))\n (while (< i 78)\n (aset malyon-alphabet i\n (malyon-read-byte (+ i (malyon-read-word 52))))\n (setq i (+ 1 i)))))\n (malyon-initialize-unicode-table)\n (setq malyon-dictionary (malyon-read-word 8))\n (setq malyon-dictionary-entry-length\n (malyon-read-byte\n (+ 1 malyon-dictionary (malyon-read-byte malyon-dictionary))))\n (setq malyon-dictionary-num-entries\n (malyon-read-word\n (+ 2 malyon-dictionary (malyon-read-byte malyon-dictionary))))\n (setq malyon-dictionary-entries\n (+ 4 malyon-dictionary (malyon-read-byte malyon-dictionary)))\n (setq malyon-dictionary-word-length (if (< malyon-story-version 5) 3 5))\n (setq malyon-current-face 'malyon-face-plain)\n (setq malyon-print-separator nil)\n (malyon-initialize-output-streams))\n\n(defun malyon-initialize-opcodes ()\n \"Initialize the opcode table used by the story file.\"\n (cond ((< malyon-story-version 5)\n (aset malyon-opcodes 143 'malyon-opcode-not)\n (aset malyon-opcodes 181 'malyon-opcode-save)\n (aset malyon-opcodes 182 'malyon-opcode-restore)\n (aset malyon-opcodes 185 'malyon-opcode-pop)\n (aset malyon-opcodes 188 'malyon-opcode-show-status))\n (t\n (aset malyon-opcodes 143 'malyon-opcode-calln)\n (aset malyon-opcodes 181 'malyon-opcode-illegal)\n (aset malyon-opcodes 182 'malyon-opcode-illegal)\n (aset malyon-opcodes 185 'malyon-opcode-catch)\n (aset malyon-opcodes 188 'malyon-opcode-illegal))))\n\n(defun malyon-print-header ()\n \"Print malyon mode header information.\"\n (malyon-opcode-set-text-style 2)\n (malyon-print \"Malyon V 1.0.3\")\n (malyon-opcode-set-text-style 0)\n (malyon-newline)\n (malyon-print \"A z-code interpreter for version 3, 5, and 8 games.\")\n (malyon-newline)\n (malyon-print \"(c) 1999-2011 by Peter Ilberg \")\n (malyon-newline)\n (malyon-newline))\n\n;; cleanup\n\n(defun malyon-cleanup ()\n \"Clean up the z code interpreter.\"\n (condition-case nil\n (progn\n (setq malyon-story-file nil)\n (setq malyon-window-configuration nil)\n (setq malyon-game-state-restart nil)\n (setq malyon-game-state-undo nil)\n (if (get-buffer \"Malyon Status\")\n (kill-buffer (get-buffer \"Malyon Status\")))\n (if (get-buffer \"Malyon Transcript\")\n (progn\n (switch-to-buffer (get-buffer \"Malyon Transcript\"))\n (malyon-redisplay-frame (selected-frame) t)\n (delete-other-windows (get-buffer-window (current-buffer)))\n (widen)\n (text-mode)))\n (setq malyon-status-buffer nil)\n (setq malyon-transcript-buffer nil))\n (error\n (malyon-fatal-error \"cleanup failed.\"))))\n\n;; error handling\n\n(defun malyon-fatal-error (message)\n \"Print error message and abort.\"\n (setq message (concat \"Malyon fatal error: \" message))\n (unwind-protect\n (save-excursion\n (set-buffer malyon-transcript-buffer)\n (goto-char (point-max))\n (newline)\n (newline)\n (put-text-property 0\n (length message)\n 'face\n 'malyon-face-error\n message)\n (insert message)\n (newline))\n (malyon-cleanup)\n (malyon-redisplay-frame (selected-frame) t)\n (error message)))\n\n;; conversion of zscii to ascii\n\n(defvar malyon-unicode-table nil\n \"An array mapping zscii characters to latin-1 ones.\")\n\n(defvar malyon-default-unicode-table nil\n \"The default array mapping zscii characters to latin-1 ones.\")\n\n(if malyon-default-unicode-table\n '()\n (setq malyon-default-unicode-table\n [32 \n 0 0 0 0 0 0 0 ; 1 - 7\n 8 0 0 0 0 10 0 0 ; 8 - 15\n 0 0 0 0 0 0 0 0 ; 16 - 23\n 0 0 0 39 0 0 0 0 ; 24 - 31\n 32 33 34 35 36 37 38 39 ; 32 - 39\n 40 41 42 43 44 45 46 47 ; 40 - 47\n 48 49 50 51 52 53 54 55 ; 48 - 55\n 56 57 58 59 60 61 62 63 ; 56 - 63\n 64 65 66 67 68 69 70 71 ; 64 - 71\n 72 73 74 75 76 77 78 79 ; 72 - 79\n 80 81 82 83 84 85 86 87 ; 80 - 87\n 88 89 90 91 92 93 94 95 ; 88 - 95\n 96 97 98 99 100 101 102 103 ; 96 - 103\n 104 105 106 107 108 109 110 111 ; 104 - 111\n 112 113 114 115 116 117 118 119 ; 112 - 119\n 120 121 122 123 124 125 126 0 ; 120 - 127\n 0 0 0 0 0 0 0 0 ; 128 - 135\n 0 0 0 0 0 0 0 0 ; 136 - 143\n 0 48 49 50 51 52 53 54 ; 144 - 151\n 55 56 57 228 246 252 196 214 ; 152 - 159\n 220 223 187 171 235 239 255 203 ; 160 - 167\n 207 225 233 237 243 250 253 193 ; 168 - 175\n 201 205 211 218 221 224 232 236 ; 176 - 183\n 242 249 192 200 204 210 217 226 ; 184 - 191\n 234 238 244 251 194 202 206 212 ; 192 - 199\n 219 229 197 248 216 227 241 245 ; 200 - 207\n 195 209 213 230 198 231 199 254 ; 208 - 215\n 240 222 208 163 63 63 161 191 ; 216 - 223\n 0 0 0 0 0 0 0 0 ; 224 - 231\n 0 0 0 0 0 0 0 0 ; 232 - 239\n 0 0 0 0 0 0 0 0 ; 240 - 247\n 0 0 0 0 0 0 0 0 ; 248 - 255\n ]))\n\n(defun malyon-initialize-unicode-table ()\n \"Initializes the zscii-to-unicode conversion table.\"\n (setq malyon-unicode-table\n (copy-sequence malyon-default-unicode-table))\n (let* ((ext (malyon-read-word 54))\n (len (if (zerop ext) 0 (malyon-read-word ext)))\n (table (if (< len 3) 0 (malyon-read-word (+ ext 6)))))\n (if (or (< malyon-story-version 5) (zerop table))\n '()\n (let ((i 0))\n (while (< i 96)\n (aset malyon-unicode-table (+ 155 i) (malyon-char-to-int ??))\n (setq i (+ 1 i))))\n (setq len (malyon-read-byte table))\n (let ((i 0))\n (while (< i len)\n (aset malyon-unicode-table (+ 155 i)\n (malyon-read-word (+ table 1 i)))\n (setq i (+ 1 i)))))))\n\n(defsubst malyon-zscii-to-unicode (char)\n \"Converts a zscii character to unicode.\"\n (if (or (< char 0) (> char 255))\n ??\n (let ((uni (aref malyon-unicode-table char)))\n (if (zerop uni)\n ??\n (malyon-unibyte-char-to-multibyte (malyon-int-to-char uni))))))\n\n(defsubst malyon-unicode-to-zscii (char)\n \"Converts a unicode character to zscii.\"\n (setq char (malyon-multibyte-char-to-unibyte char))\n (setq char (if (malyon-characterp char) (malyon-char-to-int char) char))\n (if (= 13 char)\n ?\\r\n (let ((i 1) (found 0))\n (while (and (< i 255) (zerop found))\n (if (= char (aref malyon-unicode-table i))\n (setq found i))\n (setq i (+ i 1)))\n (malyon-int-to-char found))))\n\n;; output streams\n\n(defvar malyon-output-streams nil\n \"Valid output streams for the interpreter.\")\n\n(defvar malyon-output-streams-tables nil\n \"A list of active tables for stream 3.\")\n\n(defun malyon-initialize-output-streams ()\n \"Initializes the output streams.\"\n (setq malyon-output-streams '())\n (setq malyon-output-streams-tables '())\n (malyon-add-output-stream 1 0))\n\n(defun malyon-output-stream-function (stream)\n \"Returns the output function representing the given stream.\"\n (cond ((= 1 stream) (if (zerop malyon-current-window)\n 'malyon-putchar-transcript\n 'malyon-putchar-status))\n ((= 2 stream) 'malyon-putchar-printer)))\n\n(defun malyon-add-output-stream (stream table)\n \"Add a new output stream.\"\n (if (= stream 3)\n (progn\n (setq malyon-output-streams-tables\n (cons table malyon-output-streams-tables))\n (malyon-store-word table 0))\n (let ((function (malyon-output-stream-function stream)))\n (setq malyon-output-streams\n (if (member function malyon-output-streams)\n malyon-output-streams\n (cons function malyon-output-streams))))))\n\n(defun malyon-remove-output-stream (stream)\n \"Remove an output stream.\"\n (if (= stream 3)\n (setq malyon-output-streams-tables (cdr malyon-output-streams-tables))\n (setq malyon-output-streams\n (malyon-remove (malyon-output-stream-function stream)\n malyon-output-streams))))\n\n(defun malyon-update-output-streams ()\n \"Update output streams when the output window has changed.\"\n (let ((one (or (member 'malyon-putchar-transcript malyon-output-streams)\n (member 'malyon-putchar-status malyon-output-streams))))\n (setq malyon-output-streams\n (malyon-remove 'malyon-putchar-transcript\n (malyon-remove 'malyon-putchar-status\n malyon-output-streams)))\n (if one\n (malyon-add-output-stream 1 0))))\n\n(defsubst malyon-output-character (char)\n \"Output a single character on all active streams.\"\n (setq char (malyon-zscii-to-unicode char))\n (if malyon-output-streams-tables\n (malyon-putchar-table char (car malyon-output-streams-tables))\n (malyon-mapc (lambda (s) (funcall s char)) malyon-output-streams)))\n\n;; printing text\n\n(defsubst malyon-abbrev (abbrev x)\n \"Print an abbreviation.\"\n (malyon-print-ztext\n (* 2 (malyon-read-word (+ malyon-abbreviations\n (* 2 (+ x (* 32 (1- abbrev)))))))))\n\n(defun malyon-newline ()\n \"Print a newline.\"\n (if (eq malyon-status-buffer (current-buffer))\n (goto-char malyon-status-buffer-point)\n (goto-char (point-max)))\n (malyon-output-character ?\\r)\n (if (eq malyon-status-buffer (current-buffer))\n (setq malyon-status-buffer-point (point))\n (goto-char malyon-last-cursor-position-after-input))\n (malyon-redisplay-frame (selected-frame) nil))\n\n(defun malyon-print (object)\n \"Print text.\" \n (let ((text (if (malyon-characterp object) (char-to-string object) object))\n (start))\n (if (eq malyon-transcript-buffer (current-buffer))\n (goto-char (point-max))\n (goto-char malyon-status-buffer-point))\n (setq start (point))\n (malyon-print-characters (malyon-string-to-list text))\n (put-text-property start (point) 'face malyon-current-face)\n (if (eq malyon-status-buffer (current-buffer))\n (setq malyon-status-buffer-point (point))\n (goto-char malyon-last-cursor-position-after-input))))\n\n(defun malyon-print-characters (text)\n \"Print a list of characters.\"\n (malyon-mapc 'malyon-output-character text))\n\n(defsubst malyon-print-state-new (char shift abbr zscii zcode)\n \"Generate a new print state.\"\n (list char shift abbr zscii zcode))\n\n(defsubst malyon-print-state-initial ()\n \"Returns an initial state for the ztext decoder.\"\n (malyon-print-state-new nil -6 0 0 0))\n\n(defsubst malyon-print-state-next (x ignore shift abbr zscii z)\n \"Print state transition function.\"\n (cond ((= zscii 2)\n (malyon-print-state-new (+ z x) -6 0 0 0))\n ((= zscii 1)\n (malyon-print-state-new nil -6 0 2 (* 32 x)))\n ((> abbr 0)\n (malyon-abbrev abbr x)\n (malyon-print-state-initial))\n ((= x 0)\n (malyon-print-state-new ? -6 0 0 0))\n ((< x 4)\n (malyon-print-state-new nil -6 x 0 0))\n ((= x 4)\n (malyon-print-state-new nil 20 0 0 0))\n ((= x 5)\n (malyon-print-state-new nil 46 0 0 0))\n ((and (= shift 46) (= x 6))\n (malyon-print-state-new nil -6 0 1 0))\n ((and (= shift 46) (= x 7))\n (malyon-print-state-new ?\\r -6 0 0 0))\n (t\n (malyon-print-state-new\n (aref malyon-alphabet (+ shift x)) -6 0 0 0))))\n\n(defun malyon-print-text (address)\n \"Print text at address and return the address of the following byte.\"\n (let ((start))\n (if (eq malyon-transcript-buffer (current-buffer))\n (goto-char (point-max))\n (goto-char malyon-status-buffer-point))\n (setq start (point))\n (setq address (malyon-print-ztext address))\n (put-text-property start (point) 'face malyon-current-face)\n (if (eq malyon-status-buffer (current-buffer))\n (setq malyon-status-buffer-point (point))\n (goto-char malyon-last-cursor-position-after-input))\n (malyon-redisplay-frame (selected-frame) nil)\n address))\n\n(defun malyon-print-ztext (address)\n \"Print the ztext stored at the given address.\"\n (let ((high 0) (low) (a) (b) (c) (state (malyon-print-state-initial)))\n (while (zerop (logand 128 high))\n (setq high (malyon-read-byte address))\n (setq low (malyon-read-byte (+ 1 address)))\n (setq a (logand 31 (lsh high -2)))\n (setq b (logand 31 (logior (lsh high 3) (lsh low -5))))\n (setq c (logand 31 low))\n (setq state (apply 'malyon-print-state-next a state))\n (if (car state) (malyon-output-character (car state)))\n (setq state (apply 'malyon-print-state-next b state))\n (if (car state) (malyon-output-character (car state)))\n (setq state (apply 'malyon-print-state-next c state))\n (if (car state) (malyon-output-character (car state)))\n (setq address (+ 2 address)))\n address))\n\n(defun malyon-putchar-transcript (char)\n \"Print a single character in the transcript window.\"\n (if (char-equal char ?\\n)\n (newline 1)\n (insert char)\n (setq malyon-print-separator (null (member char malyon-whitespace))))\n (if (and malyon-transcript-buffer-buffered\n (> (current-column) (current-fill-column)))\n (progn\n (end-of-line)\n (forward-word -1)\n (if (< 0 (current-column))\n (newline 1))\n (end-of-line))))\n\n(defun malyon-putchar-status (char)\n \"Print a single character in the status window.\"\n (if malyon-status-buffer-delayed-split\n (progn\n (malyon-split-buffer-windows malyon-status-buffer-delayed-split)\n (other-window 1)))\n (if (char-equal char ?\\n)\n (progn\n (beginning-of-line)\n (forward-line 1)\n (if (= (point) (point-max))\n (forward-line -1)))\n (if (> (current-column) (current-fill-column))\n '()\n (insert char)\n (delete-char 1))))\n\n(defun malyon-putchar-table (char table)\n \"Print a single character into a table.\"\n (setq char (malyon-unicode-to-zscii char))\n (malyon-store-byte (+ 2 table (malyon-read-word table)) char)\n (malyon-store-word table (+ 1 (malyon-read-word table))))\n\n(defun malyon-putchar-printer (char)\n \"Print a single character onto a printer.\"); not yet implemented\n\n;; more\n\n(defvar malyon-more-continue-keymap nil\n \"The keymap with which to continue after More has finished.\")\n\n(defun malyon-more (keymap)\n \"Enter More mode.\"\n (if (eq malyon-status-buffer (current-buffer))\n (use-local-map keymap)\n (if (< malyon-story-version 5) (malyon-opcode-show-status))\n (if (< (count-lines malyon-last-cursor-position-after-input (point-max))\n (malyon-window-displayed-height))\n (progn\n (malyon-adjust-transcript)\n (use-local-map keymap))\n (goto-char malyon-last-cursor-position-after-input)\n (beginning-of-line)\n (recenter 1)\n (setq malyon-more-continue-keymap keymap)\n (use-local-map malyon-keymap-more)\n (message \"[More]\"))))\n\n(defun malyon-more-status-buffer ()\n \"Enter More mode for the status buffer.\"\n (setq malyon-more-continue-keymap (current-local-map))\n (use-local-map malyon-keymap-more-status)\n (message \"[More]\")\n (throw 'malyon-end-of-interpreter-loop 'malyon-waiting-for-input))\n\n;; input history\n\n(defvar malyon-history nil\n \"The input history.\")\n\n(defun malyon-history-previous ()\n \"Move one entry up in the input history.\"\n (let ((prev (aref malyon-history 0))\n (curr (aref malyon-history 1))\n (next (aref malyon-history 2)))\n (if (null prev)\n curr\n (aset malyon-history 2 (if curr (cons curr next) next))\n (aset malyon-history 0 (cdr prev))\n (aset malyon-history 1 (car prev)))))\n\n(defun malyon-history-next ()\n \"Move one entry down in the input history.\"\n (let ((prev (aref malyon-history 0))\n (curr (aref malyon-history 1))\n (next (aref malyon-history 2)))\n (if (null next)\n curr\n (aset malyon-history 0 (if curr (cons curr prev) prev))\n (aset malyon-history 2 (cdr next))\n (aset malyon-history 1 (car next)))))\n\n(defun malyon-history-clear ()\n \"Clear the input history.\"\n (setq malyon-history (vector '() nil '())))\n\n(defun malyon-history-insert (entry)\n \"Insert an entry into the input history.\"\n (let* ((prev (aref malyon-history 0))\n (curr (aref malyon-history 1))\n (next (aref malyon-history 2))\n (l (malyon-remove entry\n (append (nreverse prev)\n (if curr (cons curr next) next))))\n (cut (- (length l) 19)))\n (while (> cut 0)\n (setq l (cdr l)\n cut (- cut 1)))\n (aset malyon-history 0\n (malyon-remove nil (malyon-remove \"\" (cons entry (nreverse l)))))\n (aset malyon-history 1 nil)\n (aset malyon-history 2 '())))\n\n;; dictionary lookup\n\n(defun malyon-dictionary-word (chars)\n \"Convert a list of characters into a dictionary word.\"\n (list (car (car chars))\n (length chars)\n (malyon-encode-dictionary-word (append (malyon-mapcan 'cdr chars)\n '(5 5 5 5 5 5 5 5)))))\n\n(defsubst malyon-join-characters (stop list)\n \"Joins three ztext characters into two bytes.\"\n (let ((a (car list))\n (b (malyon-cadr list))\n (c (malyon-caddr list))\n (x (if (zerop stop) 0 128)))\n (list (logior x (logand 255 (logior (lsh a 2) (lsh b -3))))\n (logand 255 (logior (lsh b 5) c)))))\n\n(defun malyon-encode-dictionary-word (l)\n \"Converts a list of ztext characters into a dictionary word.\"\n (let* ((first l)\n (second (malyon-cdddr first))\n (third (malyon-cdddr second)))\n (apply 'vector\n (if (< malyon-story-version 5)\n (append (malyon-join-characters 0 first)\n (malyon-join-characters 1 second))\n (append (malyon-join-characters 0 first)\n (malyon-join-characters 0 second)\n (malyon-join-characters 1 third))))))\n\n(defun malyon-lookup (dict code)\n \"Look for the given code in the dictionary and return its address.\"\n (cond ((not code) 0)\n ((not dict) (malyon-binary-search code))\n ((= dict malyon-dictionary) (malyon-binary-search code))\n (t (malyon-linear-search dict code))))\n\n(defsubst malyon-compare-words (word address)\n \"Compares the given word to the word stored at address.\"\n (let* ((i 0)\n (j address)\n (x (aref word i))\n (y (malyon-read-byte j)))\n (while (not (or (\/= x y) (= i malyon-dictionary-word-length)))\n (setq i (+ 1 i)\n j (+ 1 j)\n x (aref word i)\n y (malyon-read-byte j)))\n (- x y)))\n\n;; search functions\n\n(defun malyon-binary-search (code)\n \"Binary search through the main dictionary.\"\n (let* ((lower 0)\n (upper (- malyon-dictionary-num-entries 1))\n (median (\/ (+ lower upper) 2))\n (entry (+ malyon-dictionary-entries\n (* malyon-dictionary-entry-length median)))\n (looking (malyon-compare-words code entry)))\n (while (not (or (> lower upper) (zerop looking)))\n (setq lower (if (< 0 looking) (+ median 1) lower)\n upper (if (> 0 looking) (- median 1) upper)\n median (\/ (+ lower upper) 2)\n entry (+ malyon-dictionary-entries\n (* malyon-dictionary-entry-length median))\n looking (malyon-compare-words code entry)))\n (if (zerop looking) entry 0)))\n\n(defun malyon-linear-search (dictionary code)\n \"Linear search through the given dictionary.\"\n (let* ((length (malyon-read-byte (+ dictionary 1\n (malyon-read-byte dictionary))))\n (number (malyon-read-word (+ dictionary 2\n (malyon-read-byte dictionary))))\n (entries (+ dictionary 4 (malyon-read-byte dictionary)))\n (i 0)\n (entry (+ entries (* length i)))\n (looking (malyon-compare-words code entry)))\n (while (not (or (>= i number) (zerop looking)))\n (setq i (+ 1 i)\n entry (+ entries (* length i))\n looking (malyon-compare-words code entry)))\n (if (zerop looking) entry 0)))\n\n;; encoding text and lexical analysis\n\n(defun malyon-split-list (sep list &optional x)\n \"Split a list into sublists as indicated by the separators.\"\n (cond ((null list)\n (list (nreverse x)))\n ((eq sep (car list))\n (cons (nreverse x) (malyon-split-list sep (cdr list) '())))\n (t\n (malyon-split-list sep (cdr list) (cons (car list) x)))))\n\n(defun malyon-characters-to-words (list)\n \"Turn the list of characters into a list of words.\"\n (mapcar 'malyon-dictionary-word\n (delete '() (malyon-split-list 'malyon-word-separator list))))\n\n(defsubst malyon-char-in-string (c s)\n \"Returns the index of c in s if found, or length of s.\"\n (let ((i 0))\n (while (not (or (= i (length s)) (= c (aref s i))))\n (setq i (+ 1 i)))\n i))\n\n(defsubst malyon-encode-into-ztext (c)\n \"Convert a character into ztext.\"\n (let* ((index (malyon-char-in-string c malyon-alphabet))\n (shift (floor index 26))\n (char (+ 6 (mod index 26))))\n (cond ((> shift 2) (list 5 6 (logand 31 (lsh c -5)) (logand 31 c)))\n ((= shift 2) (list 5 char))\n ((= shift 1) (list 4 char))\n (t (list char)))))\n\n(defun malyon-encode-single-character (terminating-characters char)\n \"Encode a character into ztext.\"\n (let ((pos (car char))\n (c (cdr char)))\n (cond ((member c malyon-whitespace)\n (list 'malyon-word-separator))\n ((member c terminating-characters)\n (list 'malyon-word-separator\n (cons pos (malyon-encode-into-ztext c))\n 'malyon-word-separator))\n (t (list (cons pos (malyon-encode-into-ztext c)))))))\n\n(defun malyon-encode-character-list (dict list)\n \"Encode the list of characters into ztext.\"\n (let ((l '())\n (i 0))\n (while (< i (malyon-read-byte dict))\n (setq l (cons (malyon-read-byte (+ dict 1 i)) l)\n i (+ 1 i)))\n (malyon-mapcan (lambda (x) (malyon-encode-single-character l x)) list)))\n\n(defun malyon-text-length (address)\n \"Return the length of the input text.\"\n (if (>= malyon-story-version 5)\n (malyon-read-byte (+ 1 address))\n (let ((i 0))\n (while (not (zerop (malyon-read-byte (+ i 1 address))))\n (setq i (+ i 1)))\n i)))\n\n(defun malyon-text-to-character-list (address)\n \"Convert the input text into a list of characters.\"\n (let ((i (malyon-text-length address))\n (text '()))\n (while (< 0 i)\n (setq text (cons\n (cons (if (< malyon-story-version 5) i (+ 1 i))\n (malyon-read-byte\n (+ i address (if (< malyon-story-version 5) 0 1))))\n text)\n i (- i 1)))\n text))\n\n(defun malyon-text-to-words (address dictionary)\n \"Turn ztext into a list of dictionary words.\"\n (malyon-characters-to-words\n (malyon-encode-character-list (if dictionary dictionary malyon-dictionary)\n (malyon-text-to-character-list address))))\n\n;; window management\n\n(defvar malyon-status-buffer-grew-this-turn nil\n \"A flag signalling if the status buffer grew this turn.\")\n\n(defun malyon-adjust-transcript ()\n \"Adjust the position of the transcript text.\"\n (save-excursion\n (setq malyon-status-buffer-grew-this-turn nil)\n (set-buffer malyon-transcript-buffer)\n (goto-char (point-max))\n (recenter (- (malyon-window-displayed-height) 2))))\n\n(defun malyon-prepare-status-buffer (status)\n \"Fill the status buffer with empty lines.\"\n (save-excursion\n (set-buffer malyon-status-buffer)\n (let ((lines (count-lines (point-min) (point-max)))\n (new status))\n (if (zerop lines)\n (newline 1))\n (goto-char (point-max))\n (setq status (- status lines -1))\n (while (> status 0)\n (insert (make-string (+ 3 malyon-max-column) ? ))\n (newline 1)\n (setq status (- status 1)))\n (goto-char (point-min))\n (forward-line (+ 1 new))\n (kill-region (point) (point-max))\n (insert (make-string (+ 3 malyon-max-column) ? ))\n (newline 1))))\n\n(defun malyon-restore-window-configuration ()\n \"Restore the saved window configuration.\"\n (let ((buffer (window-buffer (selected-window))))\n (if malyon-window-configuration\n (set-window-configuration malyon-window-configuration))\n (cond ((eq malyon-status-buffer buffer) (other-window 1))\n ((eq malyon-transcript-buffer buffer) (goto-char (point-max))))))\n\n(defun malyon-set-window-configuration (status)\n \"Set up the new window configuration.\"\n (cond ((< status malyon-status-buffer-lines)\n (setq malyon-status-buffer-delayed-split status)\n (if malyon-status-buffer-grew-this-turn\n (malyon-more-status-buffer)))\n ((> status malyon-status-buffer-lines)\n (malyon-split-buffer-windows status)\n (setq malyon-status-buffer-grew-this-turn t))\n ((not malyon-window-configuration)\n (malyon-split-buffer-windows status))))\n\n(defun malyon-split-buffer-windows (status)\n \"Split the buffer windows.\nThe status buffer gets 'status' lines while the transcript buffer\ngets the remaining lines.\"\n (delete-other-windows (get-buffer-window (current-buffer)))\n (setq malyon-status-buffer-lines status)\n (setq malyon-status-buffer-delayed-split nil)\n (if (zerop status)\n '()\n (split-window (get-buffer-window (current-buffer)) (+ status 3))\n (switch-to-buffer malyon-status-buffer)\n (malyon-prepare-status-buffer status)\n (malyon-opcode-set-cursor 1 1)\n (other-window 1))\n (switch-to-buffer malyon-transcript-buffer)\n (setq malyon-window-configuration (current-window-configuration)))\n\n;; getting and setting the machine state\n\n(defun malyon-current-game-state ()\n \"Return the current state of the interpreter.\"\n (vector malyon-instruction-pointer\n malyon-stack-pointer\n malyon-frame-pointer\n (copy-sequence malyon-stack)\n (copy-sequence malyon-story-file)\n malyon-game-state-quetzal))\n\n(defun malyon-set-game-state (state)\n \"Installs the given state as the new state of the interpreter.\"\n (setq malyon-instruction-pointer (aref state 0))\n (setq malyon-stack-pointer (aref state 1))\n (setq malyon-frame-pointer (aref state 2))\n (setq malyon-stack (copy-sequence (aref state 3)))\n (setq malyon-story-file (copy-sequence (aref state 4)))\n (setq malyon-game-state-quetzal (aref state 5))\n (save-excursion\n (malyon-erase-buffer malyon-status-buffer)\n (malyon-split-buffer-windows 0)\n (setq malyon-last-cursor-position-after-input\n (malyon-point-max malyon-transcript-buffer))))\n\n;; file utilities\n\n(defsubst malyon-write-byte-to-file (byte)\n \"Write a byte to a file.\"\n (insert-char (logand 255 byte) 1))\n\n(defsubst malyon-write-word-to-file (word)\n \"Write a word to the last opened file.\"\n (insert-char (logand 255 (lsh word -8)) 1)\n (insert-char (logand 255 word) 1))\n\n(defsubst malyon-write-dword-to-file (dword)\n \"Write a dword to the last opened file.\"\n (insert-char (logand 255 (lsh dword -24)) 1)\n (insert-char (logand 255 (lsh dword -16)) 1)\n (insert-char (logand 255 (lsh dword -8)) 1)\n (insert-char (logand 255 dword) 1))\n\n(defsubst malyon-write-chunk-id-to-file (id)\n \"Write a quetzal chunk id to the last opened file.\"\n (insert id))\n\n(defsubst malyon-read-byte-from-file ()\n \"Read the next byte from a file.\"\n (if (= (point) (point-max))\n 0\n (forward-char 1)\n (malyon-char-to-int (malyon-char-before))))\n\n(defsubst malyon-read-word-from-file ()\n \"Read the next word from the last opened file.\"\n (logior (lsh (malyon-read-byte-from-file) 8) (malyon-read-byte-from-file)))\n\n(defsubst malyon-read-dword-from-file ()\n \"Read the next dword from the last opened file.\"\n (logior (lsh (malyon-read-byte-from-file) 24)\n (lsh (malyon-read-byte-from-file) 16)\n (lsh (malyon-read-byte-from-file) 8)\n (malyon-read-byte-from-file)))\n\n(defsubst malyon-read-chunk-id-from-file ()\n \"Read a quetzal chunk id from the last opened file.\"\n (string (malyon-int-to-char (malyon-read-byte-from-file))\n (malyon-int-to-char (malyon-read-byte-from-file))\n (malyon-int-to-char (malyon-read-byte-from-file))\n (malyon-int-to-char (malyon-read-byte-from-file))))\n\n(defun malyon-get-file-name (address)\n \"Retrieves the file name stored at address.\"\n (let ((name (make-string (malyon-read-byte address) ? ))\n (i 0))\n (while (< i (length name))\n (aset name i (malyon-read-byte (+ address 1 i)))\n (setq i (+ 1 i)))\n name))\n\n;; saving data to disk\n\n(defun malyon-save-file (file &optional table length)\n \"Save the current game state or a memory section to disk.\"\n (interactive \"FSave file: \")\n (condition-case nil\n (save-excursion\n (set-buffer (create-file-buffer file))\n (malyon-disable-multibyte)\n (malyon-erase-buffer)\n (cond (table (malyon-save-table table length))\n (malyon-game-state-quetzal\n (malyon-save-quetzal-state (malyon-current-game-state)))\n (t\n (malyon-save-game-state (malyon-current-game-state))))\n (let ((coding-system-for-write 'binary))\n (write-file file))\n (kill-buffer nil)\n 1)\n (error 0)))\n\n(defun malyon-save-table (table length)\n \"Save the given section of memory to the file.\"\n (let ((i 0)\n (j table))\n (while (< i length)\n (malyon-write-byte-to-file (malyon-read-byte j))\n (setq i (+ 1 i)\n j (+ 1 j)))))\n\n(defun malyon-save-game-state (state)\n \"Saves the game state to disk.\"\n (let ((ip (aref state 0))\n (sp (aref state 1))\n (fp (aref state 2))\n (stack (aref state 3))\n (mem (aref state 4))\n (dyn (malyon-read-word 14))\n (i 0))\n (malyon-write-word-to-file (length malyon-story-file-name))\n (while (< i (length malyon-story-file-name))\n (malyon-write-byte-to-file (aref malyon-story-file-name i))\n (setq i (+ 1 i)))\n (malyon-write-dword-to-file ip)\n (malyon-write-word-to-file sp)\n (malyon-write-word-to-file fp)\n (malyon-write-word-to-file dyn)\n (setq i 0)\n (while (<= i sp)\n (malyon-write-dword-to-file (aref stack i))\n (setq i (+ 1 i)))\n (setq i 0)\n (while (< i dyn)\n (malyon-write-byte-to-file (aref mem i))\n (setq i (+ 1 i)))))\n\n(defun malyon-save-quetzal-state (state)\n \"Saves the game state to disk in quetzal format.\"\n (goto-char (point-min))\n (malyon-save-quetzal-ifhd state)\n (malyon-save-quetzal-cmem state)\n (malyon-save-quetzal-stks state)\n (goto-char (point-min))\n (malyon-write-chunk-id-to-file \"IFZS\")\n (goto-char (point-min))\n (malyon-write-dword-to-file (- (point-max) (point-min)))\n (goto-char (point-min))\n (malyon-write-chunk-id-to-file \"FORM\"))\n\n(defun malyon-save-quetzal-ifhd (state)\n \"Saves the IFhd chunk of the quetzal format.\"\n (malyon-write-chunk-id-to-file \"IFhd\")\n (malyon-write-dword-to-file 13)\n (malyon-write-word-to-file (malyon-read-word 2))\n (malyon-write-word-to-file (malyon-read-word 18))\n (malyon-write-word-to-file (malyon-read-word 20))\n (malyon-write-word-to-file (malyon-read-word 22))\n (malyon-write-word-to-file (malyon-read-word 28))\n (malyon-write-byte-to-file (lsh (aref state 0) -16))\n (malyon-write-byte-to-file (lsh (aref state 0) -8))\n (malyon-write-byte-to-file (aref state 0))\n (malyon-write-byte-to-file 0))\n\n(defun malyon-save-quetzal-cmem (state)\n \"Saves the CMem chunk of the quetzal format.\"\n (let ((beginning (point-max))\n (original (aref malyon-game-state-restart 4))\n (current (aref state 4))\n (size (malyon-read-word 14))\n (byte 0)\n (count 0)\n (i 0))\n (goto-char (point-max))\n (while (< i size)\n (setq byte (logxor (aref current i) (aref original i)))\n (if (zerop byte)\n (setq count (+ 1 count))\n (while (> count 0)\n (malyon-write-byte-to-file 0)\n (setq count (- count 1))\n (malyon-write-byte-to-file (min 255 count))\n (setq count (- count (min 255 count))))\n (malyon-write-byte-to-file byte))\n (setq i (+ 1 i)))\n (setq size (- (point-max) beginning))\n (if (zerop (mod size 2)) '() (malyon-write-byte-to-file 0))\n (goto-char beginning)\n (malyon-write-chunk-id-to-file \"CMem\")\n (malyon-write-dword-to-file size)))\n\n(defun malyon-save-quetzal-stks (state)\n \"Saves the Stks chunk of the quetzal format.\"\n (let ((beginning (point-max))\n (size 0))\n (goto-char (point-max))\n (malyon-save-quetzal-stack-frame (- (aref state 2) 4)\n (aref state 1)\n (aref state 3))\n (setq size (- (point-max) beginning))\n (if (zerop (mod size 2)) '() (malyon-write-byte-to-file 0))\n (goto-char beginning)\n (malyon-write-chunk-id-to-file \"Stks\")\n (malyon-write-dword-to-file size)))\n\n(defun malyon-save-quetzal-stack-frame (fp sp stack)\n \"Saves the stack frames for the Stks chunk.\"\n (let* ((frame (malyon-get-stack-frame fp sp stack))\n (frame-id (aref frame 0))\n (previous-fp (aref frame 1))\n (previous-sp (aref frame 2))\n (return-addr (aref frame 3))\n (result-addr (aref frame 4))\n (local-vars (aref frame 5))\n (num-args (aref frame 6))\n (eval-stack (aref frame 7)))\n (if (> frame-id 0)\n (malyon-save-quetzal-stack-frame previous-fp previous-sp stack))\n (malyon-write-byte-to-file (lsh return-addr -16))\n (malyon-write-byte-to-file (lsh return-addr -8))\n (malyon-write-byte-to-file return-addr)\n (if (zerop frame-id)\n (malyon-write-byte-to-file 0)\n (malyon-write-byte-to-file (logior (if result-addr 0 16)\n (length local-vars))))\n (malyon-write-byte-to-file (if result-addr result-addr 0))\n (malyon-write-byte-to-file (- (lsh 1 num-args) 1))\n (malyon-write-word-to-file (length eval-stack))\n (while (not (null local-vars))\n (malyon-write-word-to-file (car local-vars))\n (setq local-vars (cdr local-vars)))\n (while (not (null eval-stack))\n (malyon-write-word-to-file (car eval-stack))\n (setq eval-stack (cdr eval-stack)))))\n\n;; restoring data from disk\n\n(defvar malyon-restore-data-error nil\n \"An error message if restoring data from a file failed.\")\n\n(defvar malyon-restore-quetzal-stack nil\n \"A temporary stack for restoring quetzal game states.\")\n\n(defvar malyon-restore-quetzal-stack-pointer nil\n \"A temporary stack pointer for restoring quetzal game states.\")\n\n(defvar malyon-restore-quetzal-frame-pointer nil\n \"A temporary frame-pointer for restoring quetzal game states.\")\n\n(defun malyon-restore-file (file &optional table length)\n \"Restore a game state or a memory section from disk.\"\n (interactive \"fLoad file: \")\n (if (not (and (file-exists-p file) (file-readable-p file)))\n 0\n (condition-case nil\n (save-excursion\n (setq malyon-restore-data-error nil)\n (set-buffer (create-file-buffer file))\n (malyon-disable-multibyte)\n (malyon-erase-buffer)\n (let ((coding-system-for-read 'binary))\n (insert-file-contents file))\n (goto-char (point-min))\n (if table\n (malyon-restore-table table length)\n (let* ((first (malyon-read-chunk-id-from-file))\n (second (malyon-read-dword-from-file))\n (third (malyon-read-chunk-id-from-file)))\n (if (and (string= \"FORM\" first) (string= \"IFZS\" third))\n (malyon-restore-quetzal-state (+ 8 second))\n (goto-char (point-min))\n (malyon-restore-game-state))))\n (kill-buffer nil)\n (if (null malyon-restore-data-error)\n 2\n (message malyon-restore-data-error)\n 0))\n (error 0))))\n\n(defun malyon-restore-table (table length)\n \"Restore the given section of memory from a file.\"\n (let ((i 0)\n (j table))\n (while (< i length)\n (malyon-store-byte j (malyon-read-byte-from-file))\n (setq i (+ 1 i)\n j (+ 1 j)))))\n\n(defun malyon-restore-game-state ()\n \"Restore a saved game state from disk.\"\n (let ((len 0)\n (name 0)\n (story 0)\n (ip 0)\n (sp 0)\n (fp 0)\n (dyn 0)\n (stack (copy-sequence malyon-stack))\n (mem (copy-sequence malyon-story-file))\n (i 0))\n (setq len (malyon-read-word-from-file))\n (setq name (make-string len ? ))\n (while (< i len)\n (aset name i (malyon-read-byte-from-file))\n (setq i (+ 1 i)))\n (setq ip (malyon-read-dword-from-file))\n (setq sp (malyon-read-word-from-file))\n (setq fp (malyon-read-word-from-file))\n (setq dyn (malyon-read-word-from-file))\n (setq i 0)\n (while (<= i sp)\n (aset stack i (malyon-read-dword-from-file))\n (setq i (+ 1 i)))\n (setq i 0)\n (while (< i dyn)\n (aset mem i (malyon-read-byte-from-file))\n (setq i (+ 1 i)))\n (setq name (file-name-nondirectory name))\n (setq story (file-name-nondirectory malyon-story-file-name))\n (if (or (string-match name story) (string-match story name))\n (malyon-set-game-state (vector ip sp fp stack mem nil))\n (setq malyon-restore-data-error \"Invalid save file.\"))))\n\n(defun malyon-restore-quetzal-state (size)\n \"Restore a saved quetzal game state from disk.\"\n (let ((chunk-id nil)\n (chunk-len 0)\n (ip 0)\n (memory nil)\n (stack nil)\n (beginning 0))\n (while (< (point) size)\n (setq chunk-id (malyon-read-chunk-id-from-file))\n (setq chunk-len (malyon-read-dword-from-file))\n (setq beginning (point))\n (cond ((string= chunk-id \"IFhd\")\n (setq ip (malyon-restore-quetzal-ifhd chunk-len)))\n ((string= chunk-id \"CMem\")\n (setq memory (malyon-restore-quetzal-cmem chunk-len)))\n ((string= chunk-id \"UMem\")\n (setq memory (malyon-restore-quetzal-umem chunk-len)))\n ((string= chunk-id \"Stks\")\n (setq stack (malyon-restore-quetzal-stks chunk-len))))\n (if (zerop (mod chunk-len 2)) '() (setq chunk-len (+ 1 chunk-len)))\n (goto-char (+ beginning chunk-len)))\n (cond ((and ip memory stack)\n (malyon-set-game-state (vector ip\n (aref stack 0)\n (aref stack 1)\n (aref stack 2)\n memory\n t)))\n ((null malyon-restore-data-error)\n (setq malyon-restore-data-error \"invalid quetzal file.\")))))\n\n(defun malyon-restore-quetzal-ifhd (size)\n \"Restore an IFhd chunk from disk. Return the instruction pointer.\"\n (if (and (= (malyon-read-word-from-file) (malyon-read-word 2))\n (= (malyon-read-word-from-file) (malyon-read-word 18))\n (= (malyon-read-word-from-file) (malyon-read-word 20))\n (= (malyon-read-word-from-file) (malyon-read-word 22))\n (= (malyon-read-word-from-file) (malyon-read-word 28)))\n (logior (lsh (malyon-read-byte-from-file) 16)\n (lsh (malyon-read-byte-from-file) 8)\n (malyon-read-byte-from-file))\n (setq malyon-restore-data-error \"quetzal file doesn't belong to game.\")\n nil))\n\n(defun malyon-restore-quetzal-cmem (size)\n \"Restore a CMem chunk from disk. Return the entire memory layout.\"\n (let ((memory (copy-sequence (aref malyon-game-state-restart 4)))\n (max-size (+ (point) size))\n (byte 0)\n (i 0))\n (while (< (point) max-size)\n (setq byte (malyon-read-byte-from-file))\n (if (zerop byte)\n (setq i (+ 1 i (malyon-read-byte-from-file)))\n (aset memory i (logxor byte (aref memory i)))\n (setq i (+ 1 i))))\n memory))\n\n(defun malyon-restore-quetzal-umem (size)\n \"Restore a UMem chunk from disk. Return the entire memory layout.\"\n (let ((memory (copy-sequence (aref malyon-game-state-restart 4)))\n (i 0))\n (while (< i size)\n (aset memory i (malyon-read-byte-from-file))\n (setq i (+ 1 i)))\n memory))\n\n(defun malyon-restore-quetzal-stks (size)\n \"Restore a Stks chunk from disk. Return a vector containing the \nstack pointer, the frame pointer, and the stack itself.\"\n (let ((i 0) (frame-id 0))\n (setq malyon-restore-quetzal-stack\n (copy-sequence (aref malyon-game-state-restart 3)))\n (setq malyon-restore-quetzal-stack-pointer -1)\n (setq malyon-restore-quetzal-frame-pointer 2)\n (while (< i size)\n (let* ((beginning (point))\n (return3 (malyon-read-byte-from-file))\n (return2 (malyon-read-byte-from-file))\n (return1 (malyon-read-byte-from-file))\n (return-addr (logior (lsh return3 16) (lsh return2 8) return1))\n (result-locals (malyon-read-byte-from-file))\n (has-result (zerop (logand 16 result-locals)))\n (num-locals (logand 15 result-locals))\n (result-addr (malyon-read-byte-from-file))\n (arg-flags (+ 1 (malyon-read-byte-from-file)))\n (num-args 0)\n (eval-size (malyon-read-word-from-file))\n (local-vars '())\n (eval-stack '()))\n (while (> num-locals 0)\n (setq local-vars (cons (malyon-read-word-from-file) local-vars))\n (setq num-locals (- num-locals 1)))\n (while (> eval-size 0)\n (setq eval-stack (cons (malyon-read-word-from-file) eval-stack))\n (setq eval-size (- eval-size 1)))\n (while (> arg-flags 1)\n (setq arg-flags (lsh arg-flags -1))\n (setq num-args (+ num-args 1)))\n (malyon-push-stack-frame frame-id\n return-addr\n (if (zerop frame-id)\n nil\n (if has-result result-addr nil))\n (reverse local-vars)\n num-args\n (reverse eval-stack))\n (setq frame-id (+ 1 frame-id))\n (setq i (+ i (- (point) beginning)))))\n (vector malyon-restore-quetzal-stack-pointer\n malyon-restore-quetzal-frame-pointer\n malyon-restore-quetzal-stack)))\n\n;; object table management\n\n(defsubst malyon-object-address (object)\n \"Compute the address at which the object is stored.\"\n (+ malyon-object-table\n (* 2 malyon-object-properties)\n (* malyon-object-table-entry-size (- object 1))))\n\n(defsubst malyon-object-read-parent (address)\n \"Return the parent.\"\n (if (< malyon-story-version 5)\n (malyon-read-byte (+ 4 address))\n (malyon-read-word (+ 6 address))))\n\n(defsubst malyon-object-read-sibling (address)\n \"Return the next sibling.\"\n (if (< malyon-story-version 5)\n (malyon-read-byte (+ 5 address))\n (malyon-read-word (+ 8 address))))\n\n(defsubst malyon-object-read-child (address)\n \"Return the first child.\"\n (if (< malyon-story-version 5)\n (malyon-read-byte (+ 6 address))\n (malyon-read-word (+ 10 address))))\n\n(defsubst malyon-object-store-parent (address value)\n \"Set the parent.\"\n (if (< malyon-story-version 5)\n (malyon-store-byte (+ 4 address) value)\n (malyon-store-word (+ 6 address) value)))\n\n(defsubst malyon-object-store-sibling (address value)\n \"Set the next sibling.\"\n (if (< malyon-story-version 5)\n (malyon-store-byte (+ 5 address) value)\n (malyon-store-word (+ 8 address) value)))\n\n(defsubst malyon-object-store-child (address value)\n \"Set the first child.\"\n (if (< malyon-story-version 5)\n (malyon-store-byte (+ 6 address) value)\n (malyon-store-word (+ 10 address) value)))\n\n(defun malyon-find-property (object property)\n \"Return the address of the object's property, or 0 if it doesn't exist.\"\n (let ((next (malyon-first-property object))\n (number 0))\n (setq number (logand (malyon-read-byte next) malyon-object-properties))\n (while (> number property)\n (setq next (malyon-next-property next))\n (setq number (logand (malyon-read-byte next) malyon-object-properties)))\n (if (= number property) next 0)))\n\n(defun malyon-first-property (object)\n \"Get the address of the object's first property.\"\n (let ((header (malyon-read-word (+ malyon-object-property-offset\n (malyon-object-address object)))))\n (+ header 1 (* 2 (malyon-read-byte header)))))\n\n(defun malyon-next-property (property)\n \"Get the address of the following property.\"\n (let ((size (malyon-read-byte property))\n (addr (+ property 1)))\n (+ 1 addr (cond ((< malyon-story-version 5) (lsh size -5))\n ((zerop (logand 128 size)) (lsh size -6))\n (t\n (let ((second (logand 63 (malyon-read-byte addr))))\n (if (= 0 second) 64 second)))))))\n\n(defun malyon-remove-object (object)\n \"Remove the object from the children list of its parent.\"\n (let* ((address (malyon-object-address object))\n (parent (malyon-object-read-parent address))\n (sibling (malyon-object-read-sibling address)))\n (malyon-object-store-parent address 0)\n (malyon-object-store-sibling address 0)\n (if (\/= parent 0)\n (let ((parent-addr (malyon-object-address parent)))\n (let ((children (malyon-object-read-child parent-addr)))\n (if (or (= children 0) (= children object))\n (malyon-object-store-child parent-addr sibling)\n (let ((this (malyon-object-address children)))\n (let ((next (malyon-object-read-sibling this)))\n (while (\/= next object)\n (setq this (malyon-object-address next))\n (setq next (malyon-object-read-sibling this)))\n (malyon-object-store-sibling this sibling)))))))))\n\n;; function calls and code branches\n\n(defun malyon-call-routine (routine arguments &optional result)\n \"Call a routine with the given arguments and return its result.\"\n (if (= routine 0)\n (if result (malyon-store-variable result 0) 0)\n (malyon-push-stack (if result 0 1))\n (malyon-push-stack (if result result 0))\n (malyon-push-stack malyon-instruction-pointer)\n (malyon-push-stack\n (logior (lsh (- malyon-stack-pointer malyon-frame-pointer) 8)\n (length arguments)))\n (setq malyon-instruction-pointer (* malyon-packed-multiplier routine))\n (let ((args (malyon-read-code-byte)) (value nil))\n (if malyon-game-state-quetzal\n (let ((id (lsh (aref malyon-stack malyon-frame-pointer) -8)))\n (malyon-push-stack (logior (lsh (+ 1 id) 8) args))))\n (setq malyon-frame-pointer malyon-stack-pointer)\n (while (> args 0)\n (setq value (if (< malyon-story-version 5) (malyon-read-code-word) 0))\n (malyon-push-stack (if (null arguments) value (car arguments)))\n (setq arguments (cdr arguments))\n (setq args (- args 1))))))\n\n(defun malyon-jump-if (condition)\n \"Jump depending on the condition and the following jump data.\"\n (let ((byte (malyon-read-code-byte))\n (offset nil)\n (iftrue nil))\n (setq iftrue (\/= 0 (logand byte 128)))\n (setq offset (logand byte 63))\n (if (= 0 (logand byte 64)) \n (progn\n (setq offset (logior (lsh offset 8) (malyon-read-code-byte)))\n (if (>= offset 8192) (setq offset (- offset 16384)))))\n (if (or (and iftrue condition) (and (not iftrue) (not condition)))\n (progn\n (cond ((= offset 0) (malyon-opcode-rfalse))\n ((= offset 1) (malyon-opcode-rtrue))\n (t (setq\n malyon-instruction-pointer \n (+ malyon-instruction-pointer offset -2))))))))\n\n(defun malyon-return (value)\n \"Return from a routine.\"\n (setq malyon-stack-pointer malyon-frame-pointer)\n (if malyon-game-state-quetzal (malyon-pop-stack))\n (setq malyon-frame-pointer\n (- malyon-stack-pointer 1 (lsh (malyon-pop-stack) -8)))\n (setq malyon-instruction-pointer (malyon-pop-stack))\n (let ((result (malyon-pop-stack))\n (store (malyon-pop-stack)))\n (if (zerop store)\n (malyon-return-store result value)\n (malyon-return-ignore result value))))\n\n(defun malyon-return-ignore (where value)\n \"Return from a routine ignoring the result.\")\n\n(defun malyon-return-store (where value)\n \"Return from a routine storing the result.\"\n (malyon-store-variable where value))\n\n(defun malyon-push-initial-frame ()\n \"Push the initial stack frame required in quetzal mode.\"\n (if malyon-game-state-quetzal\n (progn\n (malyon-push-stack 1)\n (malyon-push-stack 0)\n (malyon-push-stack 0)\n (malyon-push-stack 0)\n (malyon-push-stack 0))))\n\n(defun malyon-get-stack-frame (fp sp stack)\n \"Return a decoded stack frame in quetzal mode.\nThe result is a vector containing the frame id, the fp of the\nprevious frame, the sp of the previous frame, the return address,\nthe result variable if any, a list of local variables, the number\nof arguments, and a list of the evaluation stack elements.\"\n (let* ((has-result (zerop (aref stack fp)))\n (result-addr (if has-result (aref stack (+ 1 fp)) nil))\n (return-addr (aref stack (+ 2 fp)))\n (offset (lsh (aref stack (+ 3 fp)) -8))\n (num-args (logand 255 (aref stack (+ 3 fp))))\n (frame-id (lsh (aref stack (+ 4 fp)) -8))\n (num-locals (logand 255 (aref stack (+ 4 fp))))\n (start-locals (+ 5 fp))\n (start-eval (+ 5 fp num-locals))\n (local-vars '())\n (eval-stack '()))\n (if (not (zerop num-locals))\n (setq local-vars \n (malyon-vector-to-list stack start-locals start-eval)))\n (if (> sp start-eval)\n (setq eval-stack \n (malyon-vector-to-list stack start-eval (+ 1 sp))))\n (vector frame-id\n (- fp offset 2)\n (- fp 1)\n return-addr\n result-addr\n local-vars\n num-args\n eval-stack)))\n\n(defsubst malyon-restore-quetzal-push-stack (value)\n \"Push a value onto the restore quetzal stack.\"\n (setq malyon-restore-quetzal-stack-pointer\n (+ malyon-restore-quetzal-stack-pointer 1))\n (aset malyon-restore-quetzal-stack\n malyon-restore-quetzal-stack-pointer\n value))\n\n(defun malyon-push-stack-frame\n (frame-id return-addr result local-vars num-args eval-stack)\n \"Pushes a new stack frame in quetzal mode.\"\n (malyon-restore-quetzal-push-stack (if result 0 1))\n (malyon-restore-quetzal-push-stack (if result result 0))\n (malyon-restore-quetzal-push-stack return-addr)\n (malyon-restore-quetzal-push-stack\n (logior (lsh (- malyon-restore-quetzal-stack-pointer\n malyon-restore-quetzal-frame-pointer) 8)\n num-args))\n (malyon-restore-quetzal-push-stack\n (logior (lsh frame-id 8) (length local-vars)))\n (setq malyon-restore-quetzal-frame-pointer\n malyon-restore-quetzal-stack-pointer)\n (while (not (null local-vars))\n (malyon-restore-quetzal-push-stack (car local-vars))\n (setq local-vars (cdr local-vars)))\n (while (not (null eval-stack))\n (malyon-restore-quetzal-push-stack (car eval-stack))\n (setq eval-stack (cdr eval-stack))))\n\n;; other stuff\n\n(defvar malyon-aread-text nil\n \"Text buffer for user input.\")\n\n(defvar malyon-aread-parse nil\n \"Parse buffer for user input.\")\n\n(defvar malyon-aread-beginning-of-line nil\n \"The beginning of the input line.\")\n\n;; execution\n\n(defun malyon-interpreter ()\n \"Run the z code interpreter on the given story file.\"\n (condition-case nil\n (progn\n (malyon-restore-window-configuration)\n (if malyon-story-file\n (catch 'malyon-end-of-interpreter-loop\n (setq malyon-last-cursor-position-after-input\n (malyon-point-max malyon-transcript-buffer))\n (malyon-execute))))\n (error\n (malyon-fatal-error \"unspecified internal runtime error.\"))))\n\n(defsubst malyon-fetch-variable-operands (specifier)\n \"Fetch a variable number of operands based on the specifier argument.\"\n (let ((var (logand specifier 49152))\n (op '()))\n (setq specifier (logand 65535 specifier))\n (while (\/= 0 specifier)\n (cond ((= var 0) (setq op (cons (malyon-read-code-word) op)))\n ((= var 16384) (setq op (cons (malyon-read-code-byte) op)))\n ((= var 32768) (setq op (cons (malyon-read-variable\n (malyon-read-code-byte)) op)))\n (t (setq specifier 0)))\n (setq specifier (logand 65535 (lsh specifier 2)))\n (setq var (logand specifier 49152)))\n (nreverse op)))\n\n(defsubst malyon-fetch-extended (opcode)\n \"Fetch operands for an extended instruction.\"\n (malyon-fetch-variable-operands\n (logior (lsh (malyon-read-code-byte) 8) 255)))\n\n(defsubst malyon-fetch-variable (opcode)\n \"Fetch operands for a variable instruction.\"\n (malyon-fetch-variable-operands\n (if (or (= opcode 236) (= opcode 250))\n (malyon-read-code-word)\n (logior (lsh (malyon-read-code-byte) 8) 255))))\n\n(defsubst malyon-fetch-short (opcode)\n \"Fetch operands for a short instruction.\"\n (let ((op (logand opcode 48)))\n (cond ((= op 0) (list (malyon-read-code-word)))\n ((= op 16) (list (malyon-read-code-byte)))\n ((= op 32) (list (malyon-read-variable (malyon-read-code-byte)))))))\n\n(defsubst malyon-fetch-long (instr)\n \"Fetch operands for a long instruction.\"\n (let ((byte1 (malyon-read-code-byte))\n (byte2 (malyon-read-code-byte)))\n (list (if (= (logand instr 64) 0) byte1 (malyon-read-variable byte1))\n (if (= (logand instr 32) 0) byte2 (malyon-read-variable byte2)))))\n\n(defun malyon-execute ()\n \"Execute z code instructions.\nLoad the next instruction opcode and its operands and execute it.\nRepeat ad infinitum.\"\n (let ((opcode) (operands)); (pc))\n (while t\n; (setq pc malyon-instruction-pointer)\n (setq opcode (malyon-read-code-byte))\n (setq operands (cond ((= opcode 190) \n (setq opcode (+ 256 (malyon-read-code-byte)))\n (malyon-fetch-extended opcode))\n ((>= opcode 192)\n (malyon-fetch-variable opcode))\n ((>= opcode 128)\n (malyon-fetch-short opcode))\n (t\n (malyon-fetch-long opcode))))\n; (malyon-trace-opcode pc opcode operands)\n (apply (aref malyon-opcodes opcode) operands))))\n\n;; opcodes\n\n(defsubst malyon-number (n)\n \"Convert an unsigned number into a signed one.\"\n (if (< n 32768) n (- n 65536)))\n\n(defun malyon-opcode-add (a b)\n \"Addition.\"\n (malyon-store-variable (malyon-read-code-byte)\n (+ (malyon-number a) (malyon-number b))))\n\n(defun malyon-opcode-and (a b)\n \"Bitwise and.\"\n (malyon-store-variable (malyon-read-code-byte) (logand a b)))\n\n(defun malyon-opcode-aread (text parse &optional time routine)\n \"Read input text.\"\n (setq malyon-aread-text text)\n (setq malyon-aread-parse parse)\n (goto-char (point-max))\n (setq malyon-aread-beginning-of-line (point))\n; Some games violate these assumptions for the \"Quit\" question.\n; (if (> 3 (malyon-read-byte text))\n; (malyon-fatal-error \"text buffer less than 3 bytes.\"))\n; (if (and (not (zerop parse)) (> 2 (malyon-read-byte parse)))\n; (malyon-fatal-error \"parse buffer less than 2 bytes.\"))\n (malyon-more malyon-keymap-read)\n (throw 'malyon-end-of-interpreter-loop 'malyon-waiting-for-input))\n\n(defun malyon-opcode-art-shift (value places)\n \"Arithmetic shift.\"\n (malyon-store-variable (malyon-read-code-byte) (ash value places)))\n\n(defun malyon-opcode-buffer-mode (mode)\n \"Toggles buffering of text in the transcript window.\"\n (setq malyon-transcript-buffer-buffered (\/= 0 mode)))\n\n(defun malyon-opcode-calln (routine &rest arguments)\n \"Call a routine and ignore the result.\"\n (malyon-call-routine routine arguments))\n\n(defun malyon-opcode-calls (routine &rest arguments)\n \"Call a routine and store the result.\"\n (malyon-call-routine routine arguments (malyon-read-code-byte)))\n\n(defun malyon-opcode-catch ()\n \"Return the current stack frame.\"\n (malyon-store-variable\n (malyon-read-code-byte)\n (if malyon-game-state-quetzal\n (lsh (aref malyon-stack malyon-frame-pointer) -8)\n malyon-frame-pointer)))\n\n(defun malyon-opcode-check-arg-count (count)\n \"Tests the number of arguments passed to routine.\"\n (malyon-jump-if\n (<= count (logand 255 (aref malyon-stack \n (if malyon-game-state-quetzal\n (- malyon-frame-pointer 1)\n malyon-frame-pointer))))))\n\n(defun malyon-opcode-check-unicode (char)\n \"Check whether the given character is valid for input\/output.\"\n (malyon-store-variable (malyon-read-code-byte) 0))\n\n(defun malyon-opcode-clear-attr (object attribute)\n \"Clear the given attribute in the given object.\"\n (let ((attributes (malyon-object-address object))\n (byte (lsh attribute -3)))\n (malyon-store-byte (+ attributes byte)\n (logand (malyon-read-byte (+ attributes byte))\n (logxor (lsh 128 (- (logand attribute 7)))\n 255)))))\n\n(defun malyon-opcode-copy-table (first second size)\n \"Copies first table onto second one.\"\n (let* ((length (abs (malyon-number size)))\n (zero (zerop second))\n (forward (or (< (malyon-number size) 0) (> first second)))\n (i 0)\n (a (if forward first (+ first length -1)))\n (b (if forward (if zero first second) (+ second length -1))))\n (while (< i length)\n (malyon-store-byte b (if zero 0 (malyon-read-byte a)))\n (setq i (+ i 1)\n a (if forward (+ a 1) (- a 1))\n b (if forward (+ b 1) (- b 1))))))\n\n(defun malyon-opcode-dec (var)\n \"Decrement variable.\"\n (malyon-store-variable var\n (- (malyon-number (malyon-read-variable var)) 1)))\n\n(defun malyon-opcode-dec-chk (variable threshold)\n \"Decrement variable and jump if it's less than the given value.\"\n (let ((value (malyon-number (malyon-read-variable variable))))\n (malyon-store-variable variable (- value 1))\n (malyon-jump-if (< (- value 1) (malyon-number threshold)))))\n\n(defun malyon-opcode-div (a b)\n \"Division.\"\n (if (zerop b) (malyon-fatal-error \"division by 0.\"))\n (malyon-store-variable (malyon-read-code-byte)\n (\/ (malyon-number a) (malyon-number b))))\n\n(defun malyon-opcode-encode-text (text length from encoded)\n \"Encode the zscii text starting at from with the given length.\nThe result is stored at encoded.\"\n (let* ((i length)\n (j encoded)\n (l '())\n (word '()))\n (while (< 0 i)\n (setq l (cons (malyon-read-byte (+ text from i -1)) l)\n i (- i 1)))\n (setq word (malyon-encode-dictionary-word\n (append (malyon-mapcan 'malyon-encode-into-ztext l)\n '(5 5 5 5 5 5 5 5))))\n (while (< i 6)\n (malyon-store-byte j (car l))\n (setq i (+ 1 i)\n j (+ 1 j)\n l (cdr word)))))\n\n(defun malyon-opcode-erase-line (value)\n \"Erases the rest of the line.\"\n (if (= value 1)\n (if (eq malyon-transcript-buffer (current-buffer))\n (kill-line nil)\n (save-excursion\n (let ((i (current-column)))\n (while (<= i malyon-max-column)\n (insert ? )\n (delete-char 1)\n (setq i (+ 1 i))))))))\n\n(defun malyon-opcode-erase-window (window)\n \"Erase the contents of the given window.\"\n (save-excursion\n (let ((w (malyon-number window)))\n (if (or (= w 0) (= w -1) (= w -2))\n (malyon-erase-buffer malyon-transcript-buffer))\n (if (or (= w 1) (= w -1) (= w -2))\n (malyon-erase-buffer malyon-status-buffer))\n (if (= w -1)\n (malyon-split-buffer-windows 0)))\n (setq malyon-last-cursor-position-after-input\n (malyon-point-max malyon-transcript-buffer))))\n\n(defun malyon-opcode-get-child (object)\n \"Get the first child of the given object and jump.\"\n (let ((child (malyon-object-read-child (malyon-object-address object))))\n (malyon-store-variable (malyon-read-code-byte) child)\n (malyon-jump-if (\/= 0 child))))\n\n(defun malyon-opcode-get-cursor (array)\n \"Retrieves the current cursor position.\"\n (save-excursion\n (set-buffer malyon-status-buffer)\n (malyon-store-word array (- (count-lines (point-min) (point)) 1))\n (malyon-store-word (+ 2 array) (+ 1 (current-column)))))\n\n(defun malyon-opcode-get-next-prop (object property)\n \"Retrieve the first or next property id of object.\"\n (let ((next (malyon-first-property object))\n (number 0))\n (if (zerop property)\n '()\n (setq number (logand (malyon-read-byte next)\n malyon-object-properties))\n (setq next (malyon-next-property next))\n (while (> number property)\n (setq number (logand (malyon-read-byte next)\n malyon-object-properties))\n (setq next (malyon-next-property next)))\n (if (\/= number property)\n (malyon-fatal-error \"property does not exist.\")))\n (setq number (logand (malyon-read-byte next) malyon-object-properties))\n (malyon-store-variable (malyon-read-code-byte) number)))\n \n(defun malyon-opcode-get-parent (object)\n \"Get the parent of the given object.\"\n (malyon-store-variable (malyon-read-code-byte)\n (malyon-object-read-parent\n (malyon-object-address object))))\n\n(defun malyon-opcode-get-prop (object property)\n \"Get the value of the object's property.\"\n (let* ((address (malyon-find-property object property))\n (size (malyon-read-byte address)))\n (malyon-store-variable \n (malyon-read-code-byte)\n (cond ((zerop address)\n (malyon-read-word (+ malyon-object-table (* 2 (- property 1)))))\n ((and (< malyon-story-version 5) (zerop (lsh size -5)))\n (malyon-read-byte (+ address 1)))\n ((and (>= malyon-story-version 5) (zerop (logand 192 size)))\n (malyon-read-byte (+ address 1)))\n (t\n (malyon-read-word (+ address 1)))))))\n\n(defun malyon-opcode-get-prop-addr (object property)\n \"Get the address of the object's property.\"\n (let* ((address (malyon-find-property object property))\n (size (malyon-read-byte address))\n (offset (if (< malyon-story-version 5)\n 1\n (if (zerop (logand 128 size)) 1 2))))\n (malyon-store-variable (malyon-read-code-byte)\n (if (zerop address) 0 (+ address offset)))))\n\n(defun malyon-opcode-get-prop-len (property)\n \"Get the length of the object's property.\"\n (let ((size (malyon-read-byte (- property 1))))\n (malyon-store-variable\n (malyon-read-code-byte)\n (cond ((< malyon-story-version 5) (+ 1 (lsh size -5)))\n ((zerop (logand 128 size)) (+ 1 (lsh size -6)))\n ((zerop (logand 63 size)) 64)\n (t (logand 63 size))))))\n\n(defun malyon-opcode-get-sibling (object)\n \"Get the next object in the tree and jump.\"\n (let ((sibling (malyon-object-read-sibling (malyon-object-address object))))\n (malyon-store-variable (malyon-read-code-byte) sibling)\n (malyon-jump-if (\/= 0 sibling))))\n\n(defun malyon-opcode-illegal (&rest ignore)\n \"Print an error message and exit the interpreter.\"\n (malyon-fatal-error \"illegal opcode.\"))\n\n(defun malyon-opcode-inc (var)\n \"Increment variable.\"\n (malyon-store-variable var\n (+ (malyon-number (malyon-read-variable var)) 1)))\n\n(defun malyon-opcode-inc-chk (variable threshold)\n \"Increment variable and jump if it's greater than the given value.\"\n (let ((value (malyon-number (malyon-read-variable variable))))\n (malyon-store-variable variable (+ value 1))\n (malyon-jump-if (> (+ value 1) (malyon-number threshold)))))\n\n(defun malyon-opcode-input-stream (number)\n \"Select the given input stream. Only the keyboard is supported.\"\n (if (zerop (malyon-number number))\n '()\n (message \"Only the keyboard is supported as an input stream.\")))\n\n(defun malyon-opcode-insert-obj (object destination)\n \"Insert an object into the children list of another.\"\n (let ((child (malyon-object-address object))\n (parent (malyon-object-address destination)))\n (malyon-remove-object object)\n (malyon-object-store-parent child destination)\n (malyon-object-store-sibling child (malyon-object-read-child parent))\n (malyon-object-store-child parent object)))\n\n(defun malyon-opcode-je (a &rest rest)\n \"Jump if first operand equals any of the following.\"\n (malyon-jump-if (member (malyon-number a) (mapcar 'malyon-number rest))))\n\n(defun malyon-opcode-jg (a b)\n \"Jump if first operand > second operand.\"\n (malyon-jump-if (> (malyon-number a) (malyon-number b))))\n\n(defun malyon-opcode-jin (child parent)\n \"Jump if second object is parent of the first one.\"\n (malyon-jump-if\n (= parent (malyon-object-read-parent (malyon-object-address child)))))\n\n(defun malyon-opcode-jl (a b)\n \"Jump if first operand < second operand.\"\n (malyon-jump-if (< (malyon-number a) (malyon-number b))))\n\n(defun malyon-opcode-jump (offset)\n \"Jump unconditionally.\"\n (setq malyon-instruction-pointer (+ malyon-instruction-pointer\n (malyon-number offset) -2)))\n\n(defun malyon-opcode-jz (a)\n \"Jump if operand = 0.\"\n (malyon-jump-if (zerop a)))\n\n(defun malyon-opcode-load (variable)\n \"Load a variable.\"\n (malyon-store-variable (malyon-read-code-byte)\n (malyon-read-variable variable)))\n\n(defun malyon-opcode-loadb (array index)\n \"Load an array element into a variable.\"\n (malyon-store-variable (malyon-read-code-byte)\n (malyon-read-byte (+ array index))))\n\n(defun malyon-opcode-loadw (array index)\n \"Load an array element into a variable.\"\n (malyon-store-variable (malyon-read-code-byte)\n (malyon-read-word (+ array (* 2 index)))))\n\n(defun malyon-opcode-log-shift (value places)\n \"Logical shift.\"\n (malyon-store-variable (malyon-read-code-byte) (lsh value places)))\n\n(defun malyon-opcode-mod (a b)\n \"Modulo.\"\n (malyon-store-variable (malyon-read-code-byte)\n (mod (malyon-number a) (malyon-number b))))\n\n(defun malyon-opcode-mul (a b)\n \"Multiplication.\"\n (malyon-store-variable (malyon-read-code-byte)\n (* (malyon-number a) (malyon-number b))))\n\n(defun malyon-opcode-new-line ()\n \"Print a newline.\"\n (malyon-newline))\n\n(defun malyon-opcode-nop (&rest ignore)\n \"Do nothing.\")\n\n(defun malyon-opcode-not (a)\n \"Bitwise not.\"\n (malyon-store-variable (malyon-read-code-byte) (logand 65535 (lognot a))))\n\n(defun malyon-opcode-or (a b)\n \"Bitwise or.\"\n (malyon-store-variable (malyon-read-code-byte) (logior a b)))\n\n(defun malyon-opcode-output-stream (stream &optional table)\n \"Select an output stream.\"\n (let ((stream (malyon-number stream)))\n (cond ((< 0 stream) (malyon-add-output-stream stream table))\n ((> 0 stream) (malyon-remove-output-stream (- stream))))))\n\n(defun malyon-opcode-piracy ()\n \"Piracy check, effectively an unconditional jump.\"\n (malyon-jump-if 1))\n\n(defun malyon-opcode-pop ()\n \"Pop a value off the stack.\"\n (malyon-pop-stack))\n\n(defun malyon-opcode-print ()\n \"Print a string.\"\n (setq malyon-instruction-pointer\n (malyon-print-text malyon-instruction-pointer)))\n\n(defun malyon-opcode-print-addr (address)\n \"Print a string.\"\n (malyon-print-text address))\n\n(defun malyon-opcode-print-char (c)\n \"Print a character.\"\n (malyon-print (char-to-string c)))\n\n(defun malyon-opcode-print-num (n)\n \"Print a number.\"\n (malyon-print (number-to-string (malyon-number n))))\n\n(defun malyon-opcode-print-obj (obj)\n \"Print the short name of the object.\"\n (malyon-print-text\n (+ 1 (malyon-read-word (+ malyon-object-property-offset\n (malyon-object-address obj))))))\n\n(defun malyon-opcode-print-paddr (address)\n \"Print a string.\"\n (malyon-print-text (* malyon-packed-multiplier address)))\n\n(defun malyon-opcode-print-ret ()\n \"Print a string, print a newline, return true\/1.\"\n (setq malyon-instruction-pointer\n (malyon-print-text malyon-instruction-pointer))\n (malyon-newline)\n (malyon-return 1))\n\n(defun malyon-opcode-print-table (text width &optional height skip)\n \"Print the given table.\"\n (if (not height) (setq height 1))\n (if (not skip) (setq skip 0))\n (let ((column (current-column))\n (address text)\n (y 0)\n (x 0))\n (while (< y height)\n (if (zerop y)\n '()\n (malyon-newline)\n (malyon-print-characters (make-string column ? )))\n (setq x 0)\n (while (< x width)\n (malyon-output-character (malyon-read-byte address))\n (setq address (+ 1 address))\n (setq x (+ 1 x)))\n (setq address (+ skip address))\n (setq y (+ 1 y)))))\n\n(defun malyon-opcode-print-unicode (char)\n \"Prints a unicode character.\")\n\n(defun malyon-opcode-pull (variable)\n \"Pull value off stack.\"\n (malyon-store-variable variable (malyon-pop-stack)))\n\n(defun malyon-opcode-push (value)\n \"Push value onto stack.\"\n (malyon-push-stack value))\n\n(defun malyon-opcode-put-prop (object property value)\n \"Set the object's property to the given value.\"\n (let* ((address (malyon-find-property object property))\n (size (malyon-read-byte address)))\n (cond ((= address 0)\n (malyon-fatal-error \"property does not exist.\"))\n ((and (< malyon-story-version 5) (zerop (lsh size -5)))\n (malyon-store-byte (+ 1 address) (logand 255 value)))\n ((and (>= malyon-story-version 5) (zerop (logand size 192)))\n (malyon-store-byte (+ 1 address) (logand 255 value)))\n (t\n (malyon-store-word (+ 1 address) value)))))\n\n(defun malyon-opcode-quit ()\n \"End the game immediately.\"\n (malyon-adjust-transcript)\n (malyon-cleanup)\n (throw 'malyon-end-of-interpreter-loop 'malyon-opcode-quit))\n\n(defun malyon-opcode-random (limit)\n \"Generate a random number or set the seed value.\"\n (malyon-store-variable (malyon-read-code-byte)\n (if (>= 0 (malyon-number limit))\n 0\n (+ 1 (random (malyon-number limit))))))\n\n(defun malyon-opcode-read-char (&optional device &rest ignore)\n \"Read a character.\"\n (if (and device (\/= 1 device))\n (malyon-fatal-error \"illegal device specified in read_char.\"))\n (if (eq malyon-transcript-buffer (current-buffer))\n (goto-char (point-max)))\n (message \"[Press a key.]\")\n (malyon-more malyon-keymap-readchar)\n (throw 'malyon-end-of-interpreter-loop 'malyon-waiting-for-character))\n\n(defun malyon-opcode-remove-obj (object)\n \"Remove an object from its parent's children list.\"\n (malyon-remove-object object))\n\n(defun malyon-opcode-restart ()\n \"Restart the game.\"\n (malyon-set-game-state malyon-game-state-restart))\n\n(defun malyon-opcode-restore (&optional table bytes name)\n \"Restore a saved game state or a section of memory from a file.\"\n (let ((result (if name\n (malyon-restore-file\n (malyon-get-file-name name) table bytes)\n (call-interactively 'malyon-restore-file))))\n (if (< malyon-story-version 5)\n (malyon-jump-if (not (zerop result)))\n (malyon-store-variable (malyon-read-code-byte) result))))\n\n(defun malyon-opcode-restore-undo ()\n \"Restore game state for undo.\"\n (if malyon-game-state-undo\n (malyon-set-game-state malyon-game-state-undo))\n (malyon-store-variable (malyon-read-code-byte) 2))\n\n(defun malyon-opcode-ret (value)\n \"Return a value.\"\n (malyon-return value))\n\n(defun malyon-opcode-ret-popped ()\n \"Return top of stack.\"\n (malyon-return (malyon-pop-stack)))\n\n(defun malyon-opcode-rfalse ()\n \"Return false\/0.\"\n (malyon-return 0))\n\n(defun malyon-opcode-rtrue ()\n \"Return true\/1.\"\n (malyon-return 1))\n\n(defun malyon-opcode-save (&optional table bytes name)\n \"Save the current game state or a section of memory to a file.\"\n (let ((result (if name\n (malyon-save-file (malyon-get-file-name name) table bytes)\n (call-interactively 'malyon-save-file))))\n (if (< malyon-story-version 5)\n (malyon-jump-if (not (zerop result)))\n (malyon-store-variable (malyon-read-code-byte) result))))\n\n(defun malyon-opcode-save-undo ()\n \"Save game state for undo.\"\n (setq malyon-game-state-undo (malyon-current-game-state))\n (malyon-store-byte (malyon-read-code-byte) 1))\n\n(defun malyon-opcode-scan-table (x table len &optional form)\n \"Scan the given table for the first occurrence of x.\"\n (if (not form) (setq form 130))\n (let ((inc (logand 127 form))\n (byte (zerop (logand 128 form)))\n (addr table)\n (found 0)\n (index 0))\n (while (and (zerop found) (< index len))\n (setq found\n (if byte\n (if (= x (malyon-read-byte addr)) addr 0)\n (if (= x (malyon-read-word addr)) addr 0)))\n (setq addr (+ addr inc))\n (setq index (+ index 1)))\n (malyon-store-variable (malyon-read-code-byte) found)\n (malyon-jump-if (not (zerop found)))))\n\n(defun malyon-opcode-set-attr (object attribute)\n \"Set the given attribute in the given object.\"\n (let ((attributes (malyon-object-address object))\n (byte (lsh attribute -3)))\n (malyon-store-byte (+ attributes byte)\n (logior (malyon-read-byte (+ attributes byte))\n (lsh 128 (- (logand attribute 7)))))))\n\n(defun malyon-opcode-set-color (foreground background)\n \"Sets the fore- and background colors ie. does nothing.\")\n\n(defun malyon-opcode-set-cursor (&optional line column)\n \"Set the cursor.\"\n (if (eq malyon-transcript-buffer (current-buffer))\n (goto-char (point-max))\n (if malyon-status-buffer-delayed-split\n (progn\n (malyon-split-buffer-windows malyon-status-buffer-delayed-split)\n (other-window 1)))\n (if line '() (setq line (count-lines (point-min) (point))))\n (if column '() (setq column (current-column)))\n (if (> line malyon-status-buffer-lines)\n (progn\n (malyon-split-buffer-windows line)\n (other-window 1)))\n (goto-char (point-min))\n (if (and (<= 1 line) (<= line malyon-status-buffer-lines))\n (forward-line line)\n (beginning-of-line))\n (if (and (<= 1 column) (<= column malyon-max-column))\n (forward-char (- column 1))\n (beginning-of-line))\n (setq malyon-status-buffer-point (point))))\n\n(defun malyon-opcode-set-font (font)\n \"Sets the font if available or 0 otherwise.\"\n (malyon-store-variable (malyon-read-code-byte) 0))\n\n(defun malyon-opcode-set-text-style (style)\n \"Set the text style\/face.\"\n (let ((face (assq style malyon-faces)))\n (setq malyon-current-face (if face (cdr face) 'malyon-face-plain))))\n\n(defun malyon-opcode-set-window (window)\n \"Set the current window.\"\n (malyon-restore-window-configuration)\n (setq malyon-current-window window)\n (malyon-update-output-streams)\n (if (zerop window)\n (if (not (eq malyon-transcript-buffer (current-buffer)))\n (other-window 1))\n (if (not (eq malyon-status-buffer (current-buffer)))\n (other-window 1))\n (malyon-opcode-set-cursor 1 1)))\n\n(defun malyon-opcode-show-status ()\n \"Display the status line.\"\n (save-excursion\n (malyon-opcode-split-window 1)\n (malyon-restore-window-configuration)\n (malyon-opcode-set-window 1)\n (malyon-prepare-status-buffer 1)\n (malyon-opcode-set-cursor 1 1)\n (malyon-opcode-print-obj (malyon-read-global-variable 0))\n (if (<= (current-column) (- (current-fill-column) 10))\n (let* ((x (malyon-read-global-variable 1))\n (y (malyon-read-global-variable 2))\n (hours (if (> x 12) (- x 12) x))\n (ampm (if (> x 12) \"PM\" \"AM\"))\n (score (format \"%4d\/%4d\" x y))\n (time (format \"%02d:%02d%s\" hours y ampm)))\n (malyon-opcode-set-cursor 1 (- (current-fill-column) 10))\n (malyon-print (if malyon-score-game score time))))\n (malyon-opcode-set-window 0)\n (malyon-adjust-transcript)))\n\n(defun malyon-opcode-split-window (size)\n \"Split upper and lower window.\"\n (malyon-set-window-configuration size))\n\n(defun malyon-opcode-store (variable value)\n \"Store a value in a variable.\"\n (malyon-store-variable variable value))\n\n(defun malyon-opcode-storeb (array index value)\n \"Store a value in an array at the given index.\"\n (malyon-store-byte (+ array index) value))\n\n(defun malyon-opcode-storew (array index value)\n \"Store a value in an array at the given index.\"\n (malyon-store-word (+ array (* 2 index)) value))\n\n(defun malyon-opcode-sub (a b)\n \"Subtraction.\"\n (malyon-store-variable (malyon-read-code-byte)\n (- (malyon-number a) (malyon-number b))))\n\n(defun malyon-opcode-test (bitmap flags)\n \"Test if all of the flags are set in the bitmap.\"\n (malyon-jump-if (= flags (logand bitmap flags))))\n\n(defun malyon-opcode-test-attr (object attribute)\n \"Jump depending on the given attribute in the given object.\"\n (malyon-jump-if \n (\/= 0 (logand (malyon-read-byte (+ (malyon-object-address object)\n (lsh attribute -3)))\n (lsh 128 (- (logand attribute 7)))))))\n\n(defun malyon-opcode-throw (value frame)\n \"Return from the given stack frame.\"\n (if malyon-game-state-quetzal\n (let ((id (lsh (aref malyon-stack malyon-frame-pointer) -8)))\n (while (\/= frame id)\n (setq malyon-stack-pointer malyon-frame-pointer)\n (malyon-pop-stack)\n (setq malyon-frame-pointer\n (- malyon-stack-pointer 1 (lsh (malyon-pop-stack) -8)))\n (malyon-pop-stack)\n (malyon-pop-stack)\n (setq id (lsh (aref malyon-stack malyon-frame-pointer) -8))))\n (setq malyon-frame-pointer frame))\n (malyon-return value))\n\n(defun malyon-opcode-tokenise (text parse &optional dict flag)\n \"Perform lexical analysis on the text buffer.\"\n (let* ((words (malyon-text-to-words text dict))\n (word (car words))\n (start (car word))\n (len (malyon-cadr word))\n (code (malyon-caddr word))\n (entry (malyon-lookup dict code))\n (i 0))\n (while (not (or (null words) (= i (malyon-read-byte parse))))\n (if (and (zerop entry) flag (\/= 0 flag))\n '()\n (malyon-store-word (+ 2 parse (* 4 i)) entry)\n (malyon-store-byte (+ 4 parse (* 4 i)) len)\n (malyon-store-byte (+ 5 parse (* 4 i)) start))\n (setq words (cdr words)\n word (car words)\n start (car word)\n len (malyon-cadr word)\n code (malyon-caddr word)\n entry (malyon-lookup dict code)\n i (+ 1 i)))\n (malyon-store-byte (+ 1 parse) i)))\n\n(defun malyon-opcode-verify ()\n \"Verify the correctness of the story file.\"\n (let ((length (+ 1 (* malyon-packed-multiplier (malyon-read-word 26))))\n (sum 0)\n (i 64))\n (while (< i length)\n (setq sum (mod (+ sum (malyon-read-byte i)) 65536)\n i (+ 1 i)))\n (malyon-jump-if (= (malyon-read-word 28) sum))))\n\n;; keymap utilities\n\n(defun malyon-end-input ()\n \"Store the input line in a text buffer and perform lexical analysis.\"\n (interactive)\n (condition-case nil\n (progn\n (malyon-adjust-transcript)\n (switch-to-buffer malyon-transcript-buffer)\n (goto-char (point-max))\n (let* ((input (downcase\n (buffer-substring-no-properties\n (if (< malyon-aread-beginning-of-line (point))\n malyon-aread-beginning-of-line\n (point))\n (point))))\n (vec (malyon-string-to-vector input))\n (text (apply 'vector (mapcar 'malyon-unicode-to-zscii vec)))\n (len (min (malyon-read-byte malyon-aread-text) (length text)))\n (i 0))\n (malyon-history-insert input)\n (if (>= malyon-story-version 5)\n (malyon-store-byte (+ malyon-aread-text 1) len))\n (while (< i len)\n (malyon-store-byte\n (+ malyon-aread-text (if (< malyon-story-version 5) 1 2) i)\n (malyon-char-to-int (aref text i)))\n (setq i (+ 1 i)))\n (if (< malyon-story-version 5)\n (malyon-store-byte (+ malyon-aread-text 1 len) 0)))\n (if (\/= 0 malyon-aread-parse)\n (malyon-opcode-tokenise malyon-aread-text malyon-aread-parse))\n (newline)\n (if (>= malyon-story-version 5)\n (malyon-store-variable (malyon-read-code-byte) 10))\n (malyon-interpreter))\n (error\n (malyon-fatal-error \"unspecified internal runtime error.\"))))\n\n(defun malyon-more-char ()\n \"Page down in More mode.\"\n (interactive)\n (condition-case nil\n (scroll-up)\n (error))\n (if (>= (count-lines (point) (point-max))\n (malyon-window-displayed-height))\n (message \"[More]\")\n (goto-char (point-max))\n (malyon-adjust-transcript)\n (use-local-map malyon-more-continue-keymap)))\n\n(defun malyon-more-char-status ()\n \"Wait for a key then continue.\"\n (interactive)\n (condition-case nil\n (progn\n (malyon-adjust-transcript)\n (use-local-map malyon-more-continue-keymap)\n (malyon-interpreter))\n (error\n (malyon-fatal-error \"unspecified internal runtime error.\"))))\n\n(defun malyon-wait-char ()\n \"Store the input character in a variable and resume execution.\"\n (interactive)\n (condition-case nil\n (progn\n (malyon-store-variable \n (malyon-read-code-byte)\n (malyon-char-to-int (malyon-unicode-to-zscii last-command-char)))\n (use-local-map malyon-keymap-read)\n (malyon-interpreter))\n (error\n (malyon-fatal-error \"unspecified internal runtime error.\"))))\n\n(defun malyon-history-previous-char (arg)\n \"Display the previous item in the input history.\"\n (interactive \"p\")\n (let ((input (malyon-history-previous)))\n (cond ((> malyon-aread-beginning-of-line (point))\n (funcall malyon-history-saved-up arg))\n (input\n (save-excursion\n (set-buffer malyon-transcript-buffer)\n (delete-region malyon-aread-beginning-of-line (point-max)))\n (goto-char (point-max))\n (insert input)\n (malyon-adjust-transcript)))))\n\n(defun malyon-history-next-char (arg)\n \"Display the next item in the input history.\"\n (interactive \"p\")\n (let ((input (malyon-history-next)))\n (cond ((> malyon-aread-beginning-of-line (point))\n (funcall malyon-history-saved-down arg))\n (input\n (save-excursion\n (set-buffer malyon-transcript-buffer)\n (delete-region malyon-aread-beginning-of-line (point-max)))\n (goto-char (point-max))\n (insert input)\n (malyon-adjust-transcript)))))\n\n(defun malyon-beginning-of-line (arg)\n \"Go to the beginning of the line.\"\n (interactive \"p\")\n (if (> malyon-aread-beginning-of-line (point))\n (beginning-of-line)\n (goto-char malyon-aread-beginning-of-line)))\n\n(defun malyon-kill-region (arg)\n \"Kill region.\"\n (interactive \"p\")\n (if (<= malyon-aread-beginning-of-line (point))\n (kill-region (point) (mark))\n (message \"Editing is restricted to the input prompt.\")))\n\n(defun malyon-kill-line (arg)\n \"Kill rest of the current line.\"\n (interactive \"p\")\n (if (<= malyon-aread-beginning-of-line (point))\n (kill-line)\n (message \"Editing is restricted to the input prompt.\")))\n\n(defun malyon-kill-word (arg)\n \"Kill the current word.\"\n (interactive \"p\")\n (if (<= malyon-aread-beginning-of-line (point))\n (kill-word 1)\n (message \"Editing is restricted to the input prompt.\")))\n\n(defun malyon-yank (arg)\n \"Yank.\"\n (interactive \"p\")\n (if (<= malyon-aread-beginning-of-line (point))\n (yank)\n (message \"Editing is restricted to the input prompt.\")))\n\n(defun malyon-yank-pop (arg)\n \"Yank pop.\"\n (interactive \"p\")\n (if (<= malyon-aread-beginning-of-line (point))\n (yank-pop 1)\n (message \"Editing is restricted to the input prompt.\")))\n\n(defun malyon-delete-char (arg)\n \"Delete a character.\"\n (interactive \"p\")\n (if (<= malyon-aread-beginning-of-line (point))\n (delete-char 1)\n (message \"Editing is restricted to the input prompt.\")))\n\n(defun malyon-backward-delete-char (arg)\n \"Delete a character backwards.\"\n (interactive \"p\")\n (if (< malyon-aread-beginning-of-line (point))\n (backward-delete-char-untabify 1)\n (message \"Editing is restricted to the input prompt.\")))\n\n(defun malyon-self-insert-command (arg)\n \"Insert a character.\"\n (interactive \"p\")\n (if (> malyon-aread-beginning-of-line (point))\n (goto-char (point-max)))\n (self-insert-command 1))\n\n;; tracing utility\n\n(defun malyon-trace-file ()\n \"Turn tracing on for a particular file.\"\n (let ((trace\n (get-buffer-create\n (concat \"Malyon Trace \" malyon-story-file-name))))\n (if trace\n (save-excursion\n (set-buffer trace)\n (malyon-erase-buffer)\n (insert (concat \"Tracing \" malyon-story-file-name \"...\"))\n (newline)))))\n \n(defun malyon-trace-newline ()\n \"Output tracing newline.\"\n (let ((trace (get-buffer (concat \"Malyon Trace \" malyon-story-file-name))))\n (if trace\n (save-excursion\n (set-buffer trace)\n (goto-char (point-max))\n (newline)))))\n\n(defun malyon-trace-opcode (pc opcode operands)\n \"Output a z code instruction.\"\n (malyon-trace-string\n (format \"%8d %-3d %-25s %s\\n\"\n pc\n opcode\n (symbol-name (aref malyon-opcodes opcode))\n (apply 'concat (malyon-mapcan\n (lambda (x)\n (list \" \"\n (number-to-string\n (if (malyon-characterp x)\n (malyon-char-to-int x)\n x))))\n operands)))))\n\n(defun malyon-trace-string (s)\n \"Output tracing string.\"\n (let ((trace (get-buffer (concat \"Malyon Trace \" malyon-story-file-name))))\n (if (and trace s)\n (save-excursion\n (set-buffer trace)\n (goto-char (point-max))\n (insert s)))))\n\n(defun malyon-trace-object (o)\n \"Output tracing object.\"\n (let ((trace (get-buffer (concat \"Malyon Trace \" malyon-story-file-name))))\n (if (and trace o)\n (save-excursion\n (set-buffer trace)\n (goto-char (point-max))\n (prin1 o trace)))))\n\n;;; announce malyon-mode\n\n(provide 'malyon-mode)\n(provide 'malyon)\n\n;;; malyon-mode.el ends here\n","avg_line_length":35.7198022861,"max_line_length":79,"alphanum_fraction":0.6583178378} {"size":4011,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; misc\/config-publishing\/initialise.el --- common initialisation procudure -*- lexical-binding: t; -*-\n\n(setq start-time (float-time)\n exit-code 0)\n\n(defvar script-root default-directory)\n(defvar config-root (file-name-directory ; $DOOM_DIR\/\n (directory-file-name\n (file-name-directory ; $DOOM_DIR\/misc\n (directory-file-name\n (file-name-directory load-file-name))))))\n\n;;; Report errors\n\n(setq debug-on-error t\n doom-debug-p t)\n\n(defvar log-file \"unnamed-log.txt\")\n\n(write-region \"\" nil log-file)\n\n;;; Messaging\n\n(defvar message-colour t)\n\n(defun logged-message (msg)\n (unless inhibit-message\n (let ((inhibit-message t)\n (coding-system-for-write 'utf-8))\n (princ #'external-debugging-output #'ignore)\n (append-to-file msg nil log-file)\n (append-to-file \"\\n\" nil log-file)))\n msg)\n\n(advice-add 'message :filter-return #'logged-message)\n\n(defun red-error (orig-fn &rest args)\n (message \"\\033[0;31m\" 'unmodified)\n (apply orig-fn args)\n (message \"\\033[0m\" 'unmodified)\n (setq exit-code 1))\n\n(defun timed-coloured-message (orig-fn format-str &rest args)\n (cond\n ((eq (car args) 'unmodified)\n (apply orig-fn format-str (cdr args)))\n ((or (not format-str) (string-match-p \"\\\\[%\\\\\\\\4.1fs\\\\]\" format-str))\n (apply orig-fn format-str args))\n (t\n (apply orig-fn\n (concat (if (string-match-p \"^\\\\[[0-9;]+\\\\]\" format-str)\n (replace-regexp-in-string\n \"^\\\\(?:\\\\[\\\\([0-9;]+\\\\)\\\\] ?\\\\)?\"\n \"\\033[\\\\1m[%4.1fs] \"\n format-str)\n (concat \"[%4.1fs] \" format-str))\n \"\\033[0;90m\")\n (append (list (- (float-time) start-time))\n args)))))\n\n(when message-colour\n (advice-add 'debug :around #'red-error)\n (advice-add 'message :around #'timed-coloured-message))\n\n;;; Initialisation\n\n(defun initialise (&optional full)\n (advice-add 'theme-magic-from-emacs :override #'ignore)\n (advice-add 'format-all-buffer :override #'ignore)\n\n (if full\n (load (expand-file-name \"~\/.emacs.d\/init.el\"))\n (setq gc-cons-threshold 16777216\n gcmh-high-cons-threshold 16777216)\n (load (expand-file-name \"core\/core.el\" user-emacs-directory) nil t)\n (require 'core-cli)\n (doom-initialize))\n\n (defalias 'y-or-n-p #'ignore)\n\n (advice-add 'ask-user-about-supersession-threat :override #'ignore)\n\n (after! undo-tree\n (global-undo-tree-mode -1)\n (advice-add 'undo-tree-mode :override #'ignore)\n (remove-hook 'write-file-functions #'undo-tree-save-history-from-hook)\n (remove-hook 'kill-buffer-hook #'undo-tree-save-history-from-hook)\n (remove-hook 'find-file-hook #'undo-tree-load-history-from-hook)))\n\n;;; Publishing\n\n(defvar publish-dir (expand-file-name \"publish\/\" config-root))\n\n(defvar known-existing-dirs (list config-root))\n(defun ensure-dir-exists (file-or-dir)\n (let ((dir (file-name-directory (expand-file-name file-or-dir config-root))))\n (unless (member dir known-existing-dirs)\n (unless (file-exists-p dir)\n (make-directory dir t))\n (push dir known-existing-dirs))))\n\n(defun publish (&rest files)\n \"Move each file into `publish'.\nNames containing \\\"*\\\" are treate as a glob.\"\n (dolist (file files)\n (if (string-match-p \"\\\\*\" file)\n (apply #'publish\n (directory-files (expand-file-name (or (file-name-directory file) \".\/\") config-root)\n t\n (dired-glob-regexp (file-name-nondirectory file))))\n (message (concat (when message-colour \"[34] \") \"Publishing %s\") file)\n (let ((target (replace-regexp-in-string (regexp-quote config-root)\n publish-dir\n (expand-file-name file config-root))))\n (ensure-dir-exists target)\n (copy-file (expand-file-name file config-root) target t)))))\n","avg_line_length":34.2820512821,"max_line_length":104,"alphanum_fraction":0.589877836} {"size":1648,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; whitespace-cleanup-mode-autoloads.el --- automatically extracted autoloads\n;;\n;;; Code:\n(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n\f\n;;;### (autoloads nil \"whitespace-cleanup-mode\" \"whitespace-cleanup-mode.el\"\n;;;;;; (22684 5772 0 0))\n;;; Generated autoloads from whitespace-cleanup-mode.el\n\n(autoload 'whitespace-cleanup-mode \"whitespace-cleanup-mode\" \"\\\nAutomatically call `whitespace-cleanup' on save.\n\n\\(fn &optional ARG)\" t nil)\n\n(put 'whitespace-cleanup-mode 'safe-local-variable 'booleanp)\n\n(defvar global-whitespace-cleanup-mode nil \"\\\nNon-nil if Global Whitespace-Cleanup mode is enabled.\nSee the `global-whitespace-cleanup-mode' command\nfor a description of this minor mode.\nSetting this variable directly does not take effect;\neither customize it (see the info node `Easy Customization')\nor call the function `global-whitespace-cleanup-mode'.\")\n\n(custom-autoload 'global-whitespace-cleanup-mode \"whitespace-cleanup-mode\" nil)\n\n(autoload 'global-whitespace-cleanup-mode \"whitespace-cleanup-mode\" \"\\\nToggle Whitespace-Cleanup mode in all buffers.\nWith prefix ARG, enable Global Whitespace-Cleanup mode if ARG is positive;\notherwise, disable it. If called from Lisp, enable the mode if\nARG is omitted or nil.\n\nWhitespace-Cleanup mode is enabled in all buffers where\n`turn-on-whitespace-cleanup-mode' would do it.\nSee `whitespace-cleanup-mode' for more information on Whitespace-Cleanup mode.\n\n\\(fn &optional ARG)\" t nil)\n\n;;;***\n\f\n;; Local Variables:\n;; version-control: never\n;; no-byte-compile: t\n;; no-update-autoloads: t\n;; End:\n;;; whitespace-cleanup-mode-autoloads.el ends here\n","avg_line_length":35.0638297872,"max_line_length":92,"alphanum_fraction":0.755461165} {"size":1415,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(defun sanityinc\/utf8-locale-p (v)\n \"Return whether locale string V relates to a UTF-8 locale.\"\n (and v (string-match \"UTF-8\" v)))\n\n(defun sanityinc\/locale-is-utf8-p ()\n \"Return t iff the \\\"locale\\\" command or environment variables prefer UTF-8.\"\n (or (sanityinc\/utf8-locale-p (and (executable-find \"locale\") (shell-command-to-string \"locale\")))\n (sanityinc\/utf8-locale-p (getenv \"LC_ALL\"))\n (sanityinc\/utf8-locale-p (getenv \"LC_CTYPE\"))\n (sanityinc\/utf8-locale-p (getenv \"LANG\"))))\n\n(when (or window-system (sanityinc\/locale-is-utf8-p))\n (set-language-environment 'utf-8)\n (setq locale-coding-system 'utf-8)\n (set-default-coding-systems 'utf-8)\n (set-terminal-coding-system 'utf-8)\n (set-selection-coding-system (if (eq system-type 'windows-nt) 'utf-16-le 'utf-8))\n (prefer-coding-system 'utf-8))\n\n(defun my\/markdown-preview-file ()\n \"use Marked 2 to preview the current file\"\n (interactive)\n (shell-command\n (format \"open -a 'Marked 2.app' %s\"\n (shell-quote-argument (buffer-file-name)))))\n(global-set-key \"\\C-cm\" 'my\/markdown-preview-file)\n\n(require 'evil)\n\n(custom-set-variables\n '(markdown-command \"\/usr\/local\/bin\/pandoc\"))\n(provide 'init-locales)\n\n(add-hook 'org-mode-hook (lambda () (setq truncate-lines nil)))\n\n(setq org-agenda-files (list \"~\/Dropbox\/org-mode\/work.org\" \"~\/Dropbox\/org-mode\/home.org\"))\n\n(setenv \"PATH\" (concat (getenv \"PATH\") \":\/Library\/TeX\/texbin\"))\n","avg_line_length":36.2820512821,"max_line_length":99,"alphanum_fraction":0.6862190813} {"size":11667,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":";;; helm-font --- Font and ucs selection for Helm -*- lexical-binding: t -*-\n\n;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto \n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Code:\n\n(require 'cl-lib)\n(require 'helm)\n(require 'helm-help)\n\n\f\n(defgroup helm-font nil\n \"Related applications to display fonts in helm.\"\n :group 'helm)\n\n(defcustom helm-ucs-recent-size 10\n \"Number of recent chars to keep.\"\n :type 'integer\n :group 'helm-font)\n\n(defcustom helm-ucs-actions\n '((\"Insert character\" . helm-ucs-insert-char)\n (\"Insert character name\" . helm-ucs-insert-name)\n (\"Insert character code in hex\" . helm-ucs-insert-code)\n (\"Kill marked characters\" . helm-ucs-kill-char)\n (\"Kill name\" . helm-ucs-kill-name)\n (\"Kill code\" . helm-ucs-kill-code))\n \"Actions for `helm-source-ucs'.\"\n :group 'helm-font\n :type '(alist :key-type string :value-type function))\n\n(defvar helm-ucs-map\n (let ((map (make-sparse-keymap)))\n (set-keymap-parent map helm-map)\n (define-key map (kbd \"\") 'helm-ucs-persistent-delete)\n (define-key map (kbd \"\") 'helm-ucs-persistent-backward)\n (define-key map (kbd \"\") 'helm-ucs-persistent-forward)\n (define-key map (kbd \"C-c SPC\") 'helm-ucs-persistent-insert-space)\n map)\n \"Keymap for `helm-ucs'.\")\n\n(defface helm-ucs-char\n '((((class color) (background dark)) (:foreground \"Gold\")))\n \"Face used to display ucs characters.\"\n :group 'helm-font)\n\f\n;;; Xfont selection\n;;\n;;\n(defvar helm-xfonts-cache nil)\n(defvar helm-previous-font nil)\n(defvar helm-source-xfonts\n (helm-build-sync-source \"X Fonts\"\n :init (lambda ()\n (unless helm-xfonts-cache\n (setq helm-xfonts-cache\n (x-list-fonts \"*\")))\n ;; Save current font so it can be restored in cleanup\n (setq helm-previous-font (cdr (assq 'font (frame-parameters)))))\n :candidates 'helm-xfonts-cache\n :action '((\"Copy font to kill ring\" . (lambda (elm)\n (kill-new elm)))\n (\"Set font\" . (lambda (elm)\n (kill-new elm)\n (set-frame-font elm 'keep-size)\n (message \"Font copied to kill ring\"))))\n :cleanup (lambda ()\n ;; Restore previous font\n (set-frame-font helm-previous-font 'keep-size))\n :persistent-action (lambda (new-font)\n (set-frame-font new-font 'keep-size)\n (kill-new new-font))\n :persistent-help \"Preview font and copy to kill-ring\"))\n\n\f\n;;; \ud835\udd4c\ud835\udd54\ud835\udd64 \ud835\udd4a\ud835\udd6a\ud835\udd5e\ud835\udd53\ud835\udd60\ud835\udd5d \ud835\udd54\ud835\udd60\ud835\udd5e\ud835\udd61\ud835\udd5d\ud835\udd56\ud835\udd65\ud835\udd5a\ud835\udd60\ud835\udd5f\n;;\n;;\n(defvar helm-ucs--max-len nil)\n(defvar helm-ucs--names nil)\n(defvar helm-ucs-history nil)\n(defvar helm-ucs-recent nil\n \"Ring of recent `helm-ucs' selections.\")\n\n(defun helm-calculate-ucs-alist-max-len (names)\n \"Calculate the length of the longest NAMES list candidate.\"\n (cl-loop for (_n . v) in names\n maximize (length (format \"#x%x:\" v)) into code\n maximize (max 1 (string-width (format \"%c\" v))) into char\n finally return (cons code char)))\n\n(defun helm-calculate-ucs-hash-table-max-len (names)\n \"Calculate the length of the longest NAMES hash table candidate.\"\n (cl-loop for _n being the hash-keys of names\n using (hash-values v)\n maximize (length (format \"#x%x:\" v)) into code\n maximize (max 1 (string-width (format \"%c\" v))) into char\n finally return (cons code char)))\n\n(defun helm-calculate-ucs-max-len ()\n \"Calculate the length of longest `ucs-names' candidate.\"\n (let ((ucs-struct (ucs-names)))\n (if (hash-table-p ucs-struct)\n (helm-calculate-ucs-hash-table-max-len ucs-struct)\n (helm-calculate-ucs-alist-max-len ucs-struct))))\n\n(defun helm-ucs-collect-symbols-alist (names)\n \"Collect ucs symbols from the NAMES list.\"\n (cl-loop with pr = (make-progress-reporter\n \"collecting ucs names\"\n 0 (length names))\n for (n . v) in names\n for count from 1\n for xcode = (format \"#x%x:\" v)\n for len = (length xcode)\n for diff = (- (car helm-ucs--max-len) len)\n for code = (format \"(#x%x): \" v)\n for char = (propertize (format \"%c\" v)\n 'face 'helm-ucs-char)\n unless (or (string= \"\" n)\n ;; `char-displayable-p' return a font object or\n ;; t for some char that are displayable but have\n ;; no special font (e.g 10) so filter out char\n ;; with no font.\n (not (fontp (char-displayable-p (read xcode)))))\n collect\n (concat code (make-string diff ? )\n char \" \" n)\n and do (progress-reporter-update pr count)))\n\n(defun helm-ucs-collect-symbols-hash-table (names)\n \"Collect ucs symbols from the NAMES hash-table.\"\n (cl-loop with pr = (make-progress-reporter\n \"collecting ucs names\"\n 0 (hash-table-count names))\n for n being the hash-keys of names\n using (hash-values v)\n for count from 1\n for xcode = (format \"#x%x:\" v)\n for len = (length xcode)\n for diff = (- (car helm-ucs--max-len) len)\n for code = (format \"(#x%x): \" v)\n for char = (propertize (format \"%c\" v)\n 'face 'helm-ucs-char)\n unless (or (string= \"\" n)\n (not (fontp (char-displayable-p (read xcode)))))\n collect\n (concat code (make-string diff ? )\n char \" \" n)\n and do (progress-reporter-update pr count)))\n\n(defun helm-ucs-collect-symbols (ucs-struct)\n \"Collect ucs symbols from UCS-STRUCT.\n\nDepending on the Emacs version, the variable `ucs-names' can\neither be an alist or a hash-table.\"\n (if (hash-table-p ucs-struct)\n (helm-ucs-collect-symbols-hash-table ucs-struct)\n (helm-ucs-collect-symbols-alist ucs-struct)))\n\n(defun helm-ucs-init ()\n \"Initialize an helm buffer with ucs symbols.\nOnly math* symbols are collected.\"\n (unless helm-ucs--max-len\n (setq helm-ucs--max-len\n (helm-calculate-ucs-max-len)))\n (or helm-ucs--names\n (setq helm-ucs--names\n (helm-ucs-collect-symbols (ucs-names)))))\n\n;; Actions (insertion)\n\n(defun helm-ucs-match (candidate n)\n \"Return the N part of an ucs CANDIDATE.\nWhere N=1 is the ucs code, N=2 the ucs char and N=3 the ucs name.\"\n (when (string-match\n \"^(\\\\(#x[a-f0-9]+\\\\)): *\\\\(.\\\\) *\\\\([^:]+\\\\)+\"\n candidate)\n (match-string n candidate)))\n\n(defun helm-ucs-save-recentest (candidate)\n (let ((lst (cons candidate (delete candidate helm-ucs-recent))))\n (setq helm-ucs-recent\n (if (> (length lst) helm-ucs-recent-size)\n (nbutlast lst 1)\n lst))))\n\n(defun helm-ucs-insert (candidate n)\n \"Insert the N part of CANDIDATE.\"\n (with-helm-current-buffer\n (helm-ucs-save-recentest candidate)\n (insert (helm-ucs-match candidate n))))\n\n(defun helm-ucs-insert-char (candidate)\n \"Insert ucs char part of CANDIDATE at point.\"\n (helm-ucs-insert candidate 2))\n\n(defun helm-ucs-insert-code (candidate)\n \"Insert ucs code part of CANDIDATE at point.\"\n (helm-ucs-insert candidate 1))\n\n(defun helm-ucs-insert-name (candidate)\n \"Insert ucs name part of CANDIDATE at point.\"\n (helm-ucs-insert candidate 3))\n\n;; Kill actions\n(defun helm-ucs-kill-char (_candidate)\n \"Action that concatenate ucs marked chars.\"\n (let ((marked (helm-marked-candidates)))\n (cl-loop for candidate in marked\n do (helm-ucs-save-recentest candidate))\n (kill-new (mapconcat (lambda (x)\n (helm-ucs-match x 2))\n marked \"\"))))\n\n(defun helm-ucs-kill-code (candidate)\n (helm-ucs-save-recentest candidate)\n (kill-new (helm-ucs-match candidate 1)))\n\n(defun helm-ucs-kill-name (candidate)\n (helm-ucs-save-recentest candidate)\n (kill-new (helm-ucs-match candidate 3)))\n\n;; Navigation in current-buffer (persistent)\n\n(defun helm-ucs-forward-char (_candidate)\n (with-helm-current-buffer\n (forward-char 1)))\n\n(defun helm-ucs-backward-char (_candidate)\n (with-helm-current-buffer\n (forward-char -1)))\n\n(defun helm-ucs-delete-backward (_candidate)\n (with-helm-current-buffer\n (delete-char -1)))\n\n(defun helm-ucs-insert-space (_candidate)\n (with-helm-current-buffer\n (insert \" \")))\n\n(defun helm-ucs-persistent-forward ()\n (interactive)\n (with-helm-alive-p\n (helm-attrset 'action-forward 'helm-ucs-forward-char)\n (helm-execute-persistent-action 'action-forward)))\n(put 'helm-ucs-persistent-forward 'helm-only t)\n\n(defun helm-ucs-persistent-backward ()\n (interactive)\n (with-helm-alive-p\n (helm-attrset 'action-back 'helm-ucs-backward-char)\n (helm-execute-persistent-action 'action-back)))\n(put 'helm-ucs-persistent-backward 'helm-only t)\n\n(defun helm-ucs-persistent-delete ()\n (interactive)\n (with-helm-alive-p\n (helm-attrset 'action-delete 'helm-ucs-delete-backward)\n (helm-execute-persistent-action 'action-delete)))\n(put 'helm-ucs-persistent-delete 'helm-only t)\n\n(defun helm-ucs-persistent-insert-space ()\n (interactive)\n (with-helm-alive-p\n (helm-attrset 'action-insert-space 'helm-ucs-insert-space)\n (helm-execute-persistent-action 'action-insert-space)))\n\n(defvar helm-source-ucs-recent\n (helm-build-sync-source \"Recent UCS\"\n :action helm-ucs-actions\n :candidates (lambda () helm-ucs-recent)\n :help-message helm-ucs-help-message\n :keymap helm-ucs-map\n :volatile t))\n\n(defvar helm-source-ucs\n (helm-build-in-buffer-source \"UCS names\"\n :data #'helm-ucs-init\n :get-line #'buffer-substring\n :help-message 'helm-ucs-help-message\n :filtered-candidate-transformer\n (lambda (candidates _source) (sort candidates #'helm-generic-sort-fn))\n :action helm-ucs-actions\n :persistent-action (lambda (candidate)\n (helm-ucs-insert-char candidate)\n (helm-force-update))\n :keymap helm-ucs-map)\n \"Source for collecting `ucs-names' math symbols.\")\n\f\n;;;###autoload\n(defun helm-select-xfont ()\n \"Preconfigured `helm' to select Xfont.\"\n (interactive)\n (helm :sources 'helm-source-xfonts\n :buffer \"*helm select xfont*\"))\n\n;;;###autoload\n(defun helm-ucs (arg)\n \"Preconfigured helm for `ucs-names'.\n\nCalled with a prefix arg force reloading cache.\"\n (interactive \"P\")\n (when arg\n (setq helm-ucs--names nil\n helm-ucs--max-len nil\n ucs-names nil))\n (let ((char (helm-aif (char-after) (string it))))\n (helm :sources (list helm-source-ucs-recent helm-source-ucs)\n :history 'helm-ucs-history\n :input (and char (multibyte-string-p char) char)\n :buffer \"*helm ucs*\")))\n\n(provide 'helm-font)\n\n;; Local Variables:\n;; byte-compile-warnings: (not obsolete)\n;; coding: utf-8\n;; indent-tabs-mode: nil\n;; End:\n\n;;; helm-font.el ends here\n","avg_line_length":34.7232142857,"max_line_length":76,"alphanum_fraction":0.6188394617} {"size":14945,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; -*- lexical-binding: t; no-byte-compile: t; -*-\n\n;;\n;;; Variables\n\n(defvar doom-auto-accept (getenv \"YES\")\n \"If non-nil, Doom will auto-accept any confirmation prompts during batch\ncommands like `doom-cli-packages-install', `doom-cli-packages-update' and\n`doom-packages-autoremove'.\")\n\n(defvar doom-auto-discard (getenv \"FORCE\")\n \"If non-nil, discard all local changes while updating.\")\n\n(defvar doom--cli-p nil)\n(defvar doom--cli-commands (make-hash-table :test 'equal))\n(defvar doom--cli-groups (make-hash-table :test 'equal))\n(defvar doom--cli-group nil)\n\n(cl-defstruct\n (doom-cli\n (:constructor nil)\n (:constructor\n make-doom-cli\n (name &key desc aliases optlist arglist plist fn\n &aux\n (optlist\n (cl-loop for (symbol options desc) in optlist\n for ((_ . options) (_ . params))\n = (seq-group-by #'stringp options)\n collect\n (make-doom-cli-option :symbol symbol\n :flags options\n :args params\n :desc desc))))))\n (name nil :read-only t)\n (desc \"TODO\")\n aliases\n optlist\n arglist\n plist\n (fn (lambda (_) (print! \"But nobody came!\"))))\n\n(cl-defstruct doom-cli-option\n (symbol)\n (flags ())\n (args ())\n (desc \"TODO\"))\n\n(defun doom--cli-get-option (cli flag)\n (cl-find-if (doom-partial #'member flag)\n (doom-cli-optlist cli)\n :key #'doom-cli-option-flags))\n\n(defun doom--cli-process (cli args)\n (let* ((args (copy-sequence args))\n (arglist (copy-sequence (doom-cli-arglist cli)))\n (expected (or (cl-position-if (doom-rpartial #'memq cl--lambda-list-keywords)\n arglist)\n (length arglist)))\n (got 0)\n restvar\n rest\n alist)\n (catch 'done\n (while args\n (let ((arg (pop args)))\n (cond ((eq (car arglist) '&rest)\n (setq restvar (cadr arglist)\n rest (cons arg args))\n (throw 'done t))\n\n ((string-match \"^\\\\(--\\\\([a-zA-Z0-9][a-zA-Z0-9-_]*\\\\)\\\\)\\\\(?:=\\\\(.+\\\\)\\\\)?$\" arg)\n (let* ((fullflag (match-string 1 arg))\n (opt (doom--cli-get-option cli fullflag)))\n (unless opt\n (user-error \"Unrecognized switch %S\" (concat \"--\" (match-string 2 arg))))\n (setf (alist-get (doom-cli-option-symbol opt) alist)\n (or (if (doom-cli-option-args opt)\n (or (match-string 3 arg)\n (pop args)\n (user-error \"%S expected an argument, but got none\"\n fullflag))\n (if (match-string 3 arg)\n (user-error \"%S was not expecting an argument, but got %S\"\n fullflag (match-string 3 arg))\n fullflag))))))\n\n ((string-match \"^\\\\(-\\\\([a-zA-Z0-9]+\\\\)\\\\)$\" arg)\n (let ((fullflag (match-string 1 arg))\n (flag (match-string 2 arg)))\n (dolist (switch (split-string flag \"\" t))\n (if-let (opt (doom--cli-get-option cli (concat \"-\" switch)))\n (setf (alist-get (doom-cli-option-symbol opt) alist)\n (if (doom-cli-option-args opt)\n (or (pop args)\n (user-error \"%S expected an argument, but got none\"\n fullflag))\n fullflag))\n (user-error \"Unrecognized switch %S\" (concat \"-\" switch))))))\n\n (arglist\n (cl-incf got)\n (let ((spec (pop arglist)))\n (when (eq spec '&optional)\n (setq spec (pop arglist)))\n (setf (alist-get spec alist) arg))\n (when (null arglist)\n (throw 'done t)))\n\n (t\n (push arg args)\n (throw 'done t))))))\n (when (< got expected)\n (error \"Expected %d arguments, got %d\" expected got))\n (when rest\n (setf (alist-get restvar alist) rest))\n alist))\n\n(defun doom-cli-get (command)\n \"Return a CLI object associated by COMMAND name (string).\"\n (cond ((null command) nil)\n ((doom-cli-p command) command)\n ((doom-cli-get\n (gethash (cond ((symbolp command) command)\n ((stringp command) (intern command))\n (command))\n doom--cli-commands)))))\n\n(defun doom-cli-internal-p (cli)\n \"Return non-nil if CLI is an internal (non-public) command.\"\n (string-prefix-p \":\" (doom-cli-name cli)))\n\n(defun doom-cli-execute (command &optional args)\n \"Execute COMMAND (string) with ARGS (list of strings).\n\nExecutes a cli defined with `defcli!' with the name or alias specified by\nCOMMAND, and passes ARGS to it.\"\n (if-let (cli (doom-cli-get command))\n (funcall (doom-cli-fn cli)\n (doom--cli-process cli args))\n (user-error \"Couldn't find any %S command\" command)))\n\n(defmacro defcli! (name speclist &optional docstring &rest body)\n \"Defines a CLI command.\n\nCOMMAND is a symbol or a list of symbols representing the aliases for this\ncommand. DOCSTRING is a string description; its first line should be short\n(under 60 characters), as it will be used as a summary for 'doom help'.\n\nSPECLIST is a specification for options and arguments, which can be a list\nspecification for an option\/switch in the following format:\n\n (VAR [FLAGS... ARGS...] DESCRIPTION)\n\nOtherwise, SPECLIST accepts the same argument specifiers as `defun'.\n\nBODY will be run when this dispatcher is called.\"\n (declare (indent 2) (doc-string 3))\n (unless (stringp docstring)\n (push docstring body)\n (setq docstring \"TODO\"))\n (let ((names (doom-enlist name))\n (optlist (cl-remove-if-not #'listp speclist))\n (arglist (cl-remove-if #'listp speclist))\n (plist (cl-loop for (key val) on body by #'cddr\n if (keywordp key)\n nconc (list key val) into plist\n else return plist)))\n `(let ((name ',(car names))\n (aliases ',(cdr names))\n (plist ',plist))\n (when doom--cli-group\n (setq plist (plist-put plist :group doom--cli-group)))\n (puthash\n name\n (make-doom-cli (symbol-name name)\n :desc ,docstring\n :aliases (mapcar #'symbol-name aliases)\n :arglist ',arglist\n :optlist ',optlist\n :plist plist\n :fn\n (lambda (--alist--)\n (ignore --alist--)\n (let ,(cl-loop for opt in speclist\n for optsym = (if (listp opt) (car opt) opt)\n unless (memq optsym cl--lambda-list-keywords)\n collect (list optsym `(cdr (assq ',optsym --alist--))))\n ,@(unless (plist-get plist :bare)\n '((unless doom-init-p\n (doom-initialize 'force 'noerror)\n (doom-initialize-modules))))\n ,@body)))\n doom--cli-commands)\n (when aliases\n (mapc (doom-rpartial #'puthash name doom--cli-commands)\n aliases)))))\n\n(defmacro defcligroup! (name docstring &rest body)\n \"Declare all enclosed cli commands are part of the NAME group.\"\n (declare (indent defun) (doc-string 2))\n `(let ((doom--cli-group ,name))\n (puthash doom--cli-group ,docstring doom--cli-groups)\n ,@body))\n\n\n;;\n;;; Straight hacks\n\n(defvar doom--cli-straight-discard-options\n '(\"^Delete remote \\\"[^\\\"]+\\\", re-create it with correct \"\n \"^Reset branch \"\n \"^Abort merge$\"\n \"^Discard changes$\"))\n\n;; HACK Remove dired & magit options from prompt, since they're inaccessible in\n;; noninteractive sessions.\n(advice-add #'straight-vc-git--popup-raw :override #'straight--popup-raw)\n\n;; HACK Replace GUI popup prompts (which hang indefinitely in tty Emacs) with\n;; simple prompts.\n(defadvice! doom--straight-fallback-to-y-or-n-prompt-a (orig-fn &optional prompt)\n :around #'straight-are-you-sure\n (or doom-auto-accept\n (if noninteractive\n (y-or-n-p (format! \"%s\" (or prompt \"\")))\n (funcall orig-fn prompt))))\n\n(defadvice! doom--straight-fallback-to-tty-prompt-a (orig-fn prompt actions)\n \"Modifies straight to prompt on the terminal when in noninteractive sessions.\"\n :around #'straight--popup-raw\n (if (not noninteractive)\n (funcall orig-fn prompt actions)\n ;; We can't intercept C-g, so no point displaying any options for this key\n ;; when C-c is the proper way to abort batch Emacs.\n (delq! \"C-g\" actions 'assoc)\n ;; HACK These are associated with opening dired or magit, which isn't\n ;; possible in tty Emacs, so...\n (delq! \"e\" actions 'assoc)\n (delq! \"g\" actions 'assoc)\n (if doom-auto-discard\n (cl-loop with doom-auto-accept = t\n for (_key desc func) in actions\n when desc\n when (cl-find-if (doom-rpartial #'string-match-p desc)\n doom--cli-straight-discard-options)\n return (funcall func))\n (print! (start \"%s\") (red prompt))\n (print-group!\n (terpri)\n (let (options)\n (print-group!\n (print! \" 1) Abort\")\n (cl-loop for (_key desc func) in actions\n when desc\n do (push func options)\n and do\n (print! \"%2s) %s\" (1+ (length options))\n (if (cl-find-if (doom-rpartial #'string-match-p desc)\n doom--cli-straight-discard-options)\n (concat desc \" (Recommended)\")\n desc))))\n (terpri)\n (let* ((options\n (cons (lambda ()\n (let ((doom-format-indent 0))\n (terpri)\n (print! (warn \"Aborted\")))\n (kill-emacs 1))\n (nreverse options)))\n (prompt\n (format! \"How to proceed? (%s) \"\n (mapconcat #'number-to-string\n (number-sequence 1 (length options))\n \", \")))\n answer fn)\n (while (null (nth (setq answer (1- (read-number prompt)))\n options))\n (print! (warn \"%s is not a valid answer, try again.\")\n answer))\n (funcall (nth answer options))))))))\n\n(defadvice! doom--straight-respect-print-indent-a (args)\n \"Indent straight progress messages to respect `doom-format-indent', so we\ndon't have to pass whitespace to `straight-use-package's fourth argument\neverywhere we use it (and internally).\"\n :filter-args #'straight-use-package\n (cl-destructuring-bind\n (melpa-style-recipe &optional no-clone no-build cause interactive)\n args\n (list melpa-style-recipe no-clone no-build\n (if (and (not cause)\n (boundp 'doom-format-indent)\n (> doom-format-indent 0))\n (make-string (1- (or doom-format-indent 1)) 32)\n cause)\n interactive)))\n\n\n;;\n;;; Dependencies\n\n(require 'seq)\n\n;; Eagerly load these libraries because we may be in a session that hasn't been\n;; fully initialized (e.g. where autoloads files haven't been generated or\n;; `load-path' populated).\n(load! \"autoload\/cli\")\n(load! \"autoload\/debug\")\n(load! \"autoload\/files\")\n(load! \"autoload\/format\")\n(load! \"autoload\/plist\")\n\n\n;;\n;;; CLI Commands\n\n(load! \"cli\/help\")\n(load! \"cli\/install\")\n\n(defcligroup! \"Maintenance\"\n \"For managing your config and packages\"\n (defcli! (sync s refresh re)\n ((if-necessary-p [\"-n\" \"--if-necessary\"] \"Only regenerate autoloads files if necessary\")\n (inhibit-envvar-p [\"-e\"] \"Don't regenerate the envvar file\")\n (prune-p [\"-p\" \"--prune\"] \"Purge orphaned packages & regraft repos\"))\n \"Synchronize your config with Doom Emacs.\n\nThis is the equivalent of running autoremove, install, autoloads, then\nrecompile. Run this whenever you:\n\n 1. Modify your `doom!' block,\n 2. Add or remove `package!' blocks to your config,\n 3. Add or remove autoloaded functions in module autoloaded files.\n 4. Update Doom outside of Doom (e.g. with git)\n\nIt will ensure that unneeded packages are removed, all needed packages are\ninstalled, autoloads files are up-to-date and no byte-compiled files have gone\nstale.\"\n :bare t\n (let (success)\n ;; Ensures that no pre-existing state pollutes the generation of the new\n ;; autoloads files.\n (dolist (file (list doom-autoload-file doom-package-autoload-file))\n (delete-file file)\n (delete-file (byte-compile-dest-file file)))\n\n (doom-initialize 'force 'noerror)\n (doom-initialize-modules)\n\n (print! (start \"Synchronizing your config with Doom Emacs...\"))\n (print-group!\n (when (and (not inhibit-envvar-p)\n (file-exists-p doom-env-file))\n (doom-cli-reload-env-file 'force))\n\n (doom-cli-reload-core-autoloads)\n (doom-cli-packages-install)\n (doom-cli-packages-build)\n (doom-cli-packages-purge prune-p 'builds-p prune-p prune-p)\n (doom-cli-reload-package-autoloads)\n (doom-cli-byte-compile nil 'recompile)\n t)))\n\n (load! \"cli\/env\")\n (load! \"cli\/upgrade\")\n (load! \"cli\/packages\")\n (load! \"cli\/autoloads\"))\n\n(defcligroup! \"Diagnostics\"\n \"For troubleshooting and diagnostics\"\n (load! \"cli\/doctor\")\n (load! \"cli\/debug\")\n (load! \"cli\/test\"))\n\n(defcligroup! \"Compilation\"\n \"For compiling Doom and your config\"\n (load! \"cli\/byte-compile\"))\n\n(defcligroup! \"Utilities\"\n \"Conveniences for interacting with Doom externally\"\n (defcli! run ()\n \"Run Doom Emacs from bin\/doom's parent directory.\n\nAll arguments are passed on to Emacs.\n\n doom run\n doom run -nw init.el\n\nWARNING: this command exists for convenience and testing. Doom will suffer\nadditional overhead by being started this way. For the best performance, it is\nbest to run Doom out of ~\/.emacs.d and ~\/.doom.d.\")\n\n ;; (load! \"cli\/batch\")\n ;; (load! \"cli\/org\")\n )\n\n(provide 'core-cli)\n;;; core-cli.el ends here\n","avg_line_length":37.3625,"max_line_length":97,"alphanum_fraction":0.5395115423} {"size":238926,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; erlang.el --- Major modes for editing and running Erlang -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2004 Free Software Foundation, Inc.\n;; Author: Anders Lindgren\n;; Keywords: erlang, languages, processes\n;; Date: 2011-12-11\n;; Version: 2.8.4\n;; Package-Requires: ((emacs \"24.3\"))\n\n;; %CopyrightBegin%\n;;\n;; Copyright Ericsson AB 1996-2020. All Rights Reserved.\n;;\n;; Licensed under the Apache License, Version 2.0 (the \"License\");\n;; you may not use this file except in compliance with the License.\n;; You may obtain a copy of the License at\n;;\n;; http:\/\/www.apache.org\/licenses\/LICENSE-2.0\n;;\n;; Unless required by applicable law or agreed to in writing, software\n;; distributed under the License is distributed on an \"AS IS\" BASIS,\n;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n;; See the License for the specific language governing permissions and\n;; limitations under the License.\n;;\n;; %CopyrightEnd%\n;;\n\n;; Lars Thors\u00e9n's modifications of 2000-06-07 included.\n;; The original version of this package was written by Robert Virding.\n;;\n;;; Commentary:\n\n;; Introduction:\n;; ------------\n;;\n;; This package provides support for the programming language Erlang.\n;; The package provides an editing mode with lots of bells and\n;; whistles, compilation support, and it makes it possible for the\n;; user to start Erlang shells that run inside Emacs.\n;;\n;; See the Erlang distribution for full documentation of this package.\n\n;; Installation:\n;; ------------\n;;\n;; Place this file in Emacs load path, byte-compile it, and add the\n;; following line to the appropriate init file:\n;;\n;; (require 'erlang-start)\n;;\n;; The full documentation contains much more extensive description of\n;; the installation procedure.\n\n;; Reporting Bugs:\n;; --------------\n;;\n;; Please send bug reports to the following email address:\n;; erlang-bugs@erlang.org\n;; or if you have a patch suggestion to:\n;; erlang-patches@erlang.org\n;; Please state as exactly as possible:\n;; - Version number of Erlang Mode (see the menu), Emacs, Erlang,\n;; and of any other relevant software.\n;; - What the expected result was.\n;; - What you did, preferably in a repeatable step-by-step form.\n;; - A description of the unexpected result.\n;; - Relevant pieces of Erlang code causing the problem.\n;; - Personal Emacs customisations, if any.\n;;\n;; Should the Emacs generate an error, please set the Emacs variable\n;; `debug-on-error' to `t'. Repeat the error and enclose the debug\n;; information in your bug-report.\n;;\n;; To toggle the variable you can use the following command:\n;; M-x toggle-debug-on-error RET\n;;; Code:\n\n(eval-when-compile (require 'cl))\n(require 'align)\n(require 'comint)\n(require 'tempo)\n\n;; Variables:\n\n(defgroup erlang nil\n \"The Erlang programming language.\"\n :group 'languages)\n\n(defconst erlang-version \"2.8.4\"\n \"The version number of Erlang mode.\")\n\n(defcustom erlang-root-dir nil\n \"The directory where the Erlang man pages are installed. The\nname should not contain a trailing slash.\n\nShould this variable be nil, no manual pages will show up in the\nErlang mode menu unless man pages have been downloaded by Erlang\nmode (see below).\n\nYou can download the Erlang man pages automatically by placing\nthe following lines in your Emacs init file or by executing the\nEmacs command `M-x erlang-man-download-ask RET' (the download URL\ncan be customized with the Emacs variable\nerlang-man-download-url):\n\n (require 'erlang)\n (erlang-man-download)\n\n\"\n :group 'erlang\n :type '(restricted-sexp :match-alternatives (stringp 'nil))\n :safe (lambda (val) (or (eq nil val) (stringp val))))\n\n(defvar erlang-menu-items '(erlang-menu-base-items\n erlang-menu-skel-items\n erlang-menu-shell-items\n erlang-menu-compile-items\n erlang-menu-man-items\n erlang-menu-personal-items\n erlang-menu-version-items)\n \"List of menu item list to combine to create Erlang mode menu.\n\nExternal programs which temporarily add menu items to the Erlang mode\nmenu may use this variable. Please use the function `add-hook' to add\nitems.\n\nPlease call the function `erlang-menu-init' after every change to this\nvariable.\")\n\n(defvar erlang-menu-base-items\n '((\"Indent\"\n ((\"Indent Line\" erlang-indent-command)\n (\"Indent Region \" erlang-indent-region mark-active)\n (\"Indent Clause\" erlang-indent-clause)\n (\"Indent Function\" erlang-indent-function)\n (\"Indent Buffer\" erlang-indent-current-buffer)))\n (\"Edit\"\n ((\"Fill Comment\" erlang-fill-paragraph)\n (\"Comment Region\" comment-region mark-active)\n (\"Uncomment Region\" uncomment-region mark-active)\n nil\n (\"Beginning of Function\" erlang-beginning-of-function)\n (\"End of Function\" erlang-end-of-function)\n (\"Mark Function\" erlang-mark-function)\n nil\n (\"Beginning of Clause\" erlang-beginning-of-clause)\n (\"End of Clause\" erlang-end-of-clause)\n (\"Mark Clause\" erlang-mark-clause)\n nil\n (\"New Clause\" erlang-generate-new-clause)\n (\"Clone Arguments\" erlang-clone-arguments)\n nil\n (\"Align Arrows\" erlang-align-arrows)))\n (\"Syntax Highlighting\"\n ((\"Level 4\" erlang-font-lock-level-4)\n (\"Level 3\" erlang-font-lock-level-3)\n (\"Level 2\" erlang-font-lock-level-2)\n (\"Level 1\" erlang-font-lock-level-1)\n (\"Off\" erlang-font-lock-level-0)))\n (\"TAGS\"\n ((\"Find Tag\" find-tag)\n (\"Find Next Tag\" erlang-find-next-tag)\n ;(\"Find Regexp\" find-tag-regexp)\n (\"Complete Word\" erlang-complete-tag)\n (\"Tags Apropos\" tags-apropos)\n (\"Search Files\" tags-search))))\n \"Description of menu used in Erlang mode.\n\nThis variable must be a list. The elements are either nil representing\na horizontal line or a list with two or three elements. The first is\nthe name of the menu item, the second is the function to call, or a\nsubmenu, on the same same form as ITEMS. The third optional argument\nis an expression which is evaluated every time the menu is displayed.\nShould the expression evaluate to nil the menu item is ghosted.\n\nExample:\n '((\\\"Func1\\\" function-one)\n (\\\"SubItem\\\"\n ((\\\"Yellow\\\" function-yellow)\n (\\\"Blue\\\" function-blue)))\n nil\n (\\\"Region Function\\\" spook-function midnight-variable))\n\nCall the function `erlang-menu-init' after modifying this variable.\")\n\n(defvar erlang-menu-shell-items\n '(nil\n (\"Shell\"\n ((\"Start New Shell\" erlang-shell)\n (\"Display Shell\" erlang-shell-display))))\n \"Description of the Shell menu used by Erlang mode.\n\nPlease see the documentation of `erlang-menu-base-items'.\")\n\n(defvar erlang-menu-compile-items\n '((\"Compile\"\n ((\"Compile Buffer\" erlang-compile)\n (\"Display Result\" erlang-compile-display)\n (\"Next Error\" erlang-next-error))))\n \"Description of the Compile menu used by Erlang mode.\n\nPlease see the documentation of `erlang-menu-base-items'.\")\n\n(defvar erlang-menu-version-items\n '(nil\n (\"Version\" erlang-version))\n \"Description of the version menu used in Erlang mode.\")\n\n(defvar erlang-menu-personal-items nil\n \"Description of personal menu items used in Erlang mode.\n\nPlease see the variable `erlang-menu-base-items' for a description\nof the format.\")\n\n(defvar erlang-menu-man-items nil\n \"The menu containing man pages.\n\nThe format of the menu should be compatible with `erlang-menu-base-items'.\nThis variable is added to the list of Erlang menus stored in\n`erlang-menu-items'.\")\n\n(defvar erlang-menu-skel-items '()\n \"Description of the menu containing the skeleton entries.\nThe menu is in the form described by the variable `erlang-menu-base-items'.\")\n\n(defvar erlang-mode-hook nil\n \"Functions to run when Erlang mode is activated.\n\nThis hook is used to change the behaviour of Erlang mode. It is\nnormally used by the user to personalise the programming environment.\nWhen used in a site init file, it could be used to customise Erlang\nmode for all users on the system.\n\nThe functions added to this hook are run every time Erlang mode is\nstarted. See also `erlang-load-hook', a hook which is run once,\nwhen Erlang mode is loaded into Emacs, and `erlang-shell-mode-hook'\nwhich is run every time a new inferior Erlang shell is started.\n\nTo use a hook, create an Emacs lisp function to perform your actions\nand add the function to the hook by calling `add-hook'.\n\nThe following example binds the key sequence C-c C-c to the command\n`erlang-compile' (normally bound to C-c C-k). The example also\nactivates Font Lock mode to fontify the buffer and adds a menu\ncontaining all functions defined in the current buffer.\n\nTo use the example, copy the following lines to your `~\/.emacs' file:\n\n (add-hook 'erlang-mode-hook 'my-erlang-mode-hook)\n\n (defun my-erlang-mode-hook ()\n (local-set-key \\\"\\\\C-c\\\\C-c\\\" 'erlang-compile)\n (if window-system\n (progn\n (setq font-lock-maximum-decoration t)\n (font-lock-mode 1)))\n (if (and window-system (fboundp 'imenu-add-to-menubar))\n (imenu-add-to-menubar \\\"Imenu\\\")))\")\n\n(defvar erlang-load-hook nil\n \"Functions to run when Erlang mode is loaded.\n\nThis hook is used to change the behaviour of Erlang mode. It is\nnormally used by the user to personalise the programming environment.\nWhen used in a site init file, it could be used to customize Erlang\nmode for all users on the system.\n\nThe difference between this hook and `erlang-mode-hook' and\n`erlang-shell-mode-hook' is that the functions in this hook\nis only called once, when the Erlang mode is loaded into Emacs\nthe first time.\n\nNatural actions for the functions added to this hook are actions which\nonly should be performed once, and actions which should be performed\nbefore starting Erlang mode. For example, a number of variables are\nused by Erlang mode before `erlang-mode-hook' is run.\n\nThe following example sets the variable `erlang-root-dir' so that the\nmanual pages can be retrieved (note that you must set the value of\n`erlang-root-dir' to match the location of Erlang on your system):\n\n (add-hook 'erlang-load-hook 'my-erlang-load-hook)\n\n (defun my-erlang-load-hook ()\n (setq erlang-root-dir \\\"\/usr\/local\/erlang\\\"))\")\n\n(defvar erlang-new-file-hook nil\n \"Functions to run when a new Erlang source file is being edited.\n\nA useful function is `tempo-template-erlang-normal-header'.\n\\(This function only exists when the `tempo' package is available.)\")\n\n(defcustom erlang-check-module-name 'ask\n \"Non-nil means check that module name and file name agrees when saving.\n\nIf the value of this variable is the symbol `ask', the user is\nprompted. If the value is t the source is silently changed.\"\n :group 'erlang\n :type '(choice (const :tag \"Check on save\" 'ask)\n (const :tag \"Don't check on save\" t)))\n\n(defvar erlang-electric-commands\n '(erlang-electric-comma\n erlang-electric-semicolon\n erlang-electric-gt)\n \"List of activated electric commands.\n\nThe list should contain the electric commands which should be active.\nCurrently, the available electric commands are:\n `erlang-electric-comma'\n `erlang-electric-semicolon'\n `erlang-electric-gt'\n `erlang-electric-newline'\n\nShould the variable be bound to t, all electric commands\nare activated.\n\nTo deactivate all electric commands, set this variable to nil.\")\n\n(defcustom erlang-electric-newline-inhibit t\n \"Set to non-nil to inhibit newline after electric command.\n\nThis is useful since a lot of people press return after executing an\nelectric command.\n\nIn order to work, the command must also be in the\nlist `erlang-electric-newline-inhibit-list'.\n\nNote that commands in this list are required to set the variable\n`erlang-electric-newline-inhibit' to nil when the newline shouldn't be\ninhibited.\"\n :group 'erlang\n :type 'boolean\n :safe 'booleanp)\n\n(defvar erlang-electric-newline-inhibit-list\n '(erlang-electric-semicolon\n erlang-electric-comma\n erlang-electric-gt)\n \"Commands which can inhibit the next newline.\")\n\n(defcustom erlang-electric-semicolon-insert-blank-lines nil\n \"Number of blank lines inserted before header, or nil.\n\nThis variable controls the behaviour of `erlang-electric-semicolon'\nwhen a new function header is generated. When nil, no blank line is\ninserted between the current line and the new header. When bound to a\nnumber it represents the number of blank lines which should be\ninserted.\"\n :type '(restricted-sexp :match-alternatives (integerp 'nil))\n :group 'erlang)\n\n(defvar erlang-electric-semicolon-criteria\n '(erlang-next-lines-empty-p\n erlang-at-keyword-end-p\n erlang-at-end-of-function-p)\n \"List of functions controlling `erlang-electric-semicolon'.\nThe functions in this list are called, in order, whenever a semicolon\nis typed. Each function in the list is called with no arguments,\nand should return one of the following values:\n\n nil -- no determination made, continue checking\n 'stop -- do not create prototype for next line\n (anything else) -- insert prototype, and stop checking\n\nIf every function in the list is called with no determination made,\nthen no prototype is inserted.\n\nThe test is performed by the function `erlang-test-criteria-list'.\")\n\n(defvar erlang-electric-comma-criteria\n '(erlang-stop-when-inside-argument-list\n erlang-stop-when-at-guard\n erlang-next-lines-empty-p\n erlang-at-keyword-end-p\n erlang-at-end-of-clause-p\n erlang-at-end-of-function-p)\n \"List of functions controlling `erlang-electric-comma'.\nThe functions in this list are called, in order, whenever a comma\nis typed. Each function in the list is called with no arguments,\nand should return one of the following values:\n\n nil -- no determination made, continue checking\n 'stop -- do not create prototype for next line\n (anything else) -- insert prototype, and stop checking\n\nIf every function in the list is called with no determination made,\nthen no prototype is inserted.\n\nThe test is performed by the function `erlang-test-criteria-list'.\")\n\n(defvar erlang-electric-arrow-criteria\n '(erlang-stop-when-in-type-spec\n erlang-next-lines-empty-p\n erlang-at-end-of-function-p)\n \"List of functions controlling the arrow aspect of `erlang-electric-gt'.\nThe functions in this list are called, in order, whenever a `>'\nis typed. Each function in the list is called with no arguments,\nand should return one of the following values:\n\n nil -- no determination made, continue checking\n 'stop -- do not create prototype for next line\n (anything else) -- insert prototype, and stop checking\n\nIf every function in the list is called with no determination made,\nthen no prototype is inserted.\n\nThe test is performed by the function `erlang-test-criteria-list'.\")\n\n(defvar erlang-electric-newline-criteria\n '(t)\n \"List of functions controlling `erlang-electric-newline'.\n\nThe electric newline commands indents the next line. Should the\ncurrent line begin with a comment the comment start is copied to\nthe newly created line.\n\nThe functions in this list are called, in order, whenever a comma\nis typed. Each function in the list is called with no arguments,\nand should return one of the following values:\n\n nil -- no determination made, continue checking\n 'stop -- do not create prototype for next line\n (anything else) -- trigger the electric command.\n\nIf every function in the list is called with no determination made,\nthen no prototype is inserted. Should the atom t be a member of the\nlist, it is treated as a function triggering the electric command.\n\nThe test is performed by the function `erlang-test-criteria-list'.\")\n\n(defcustom erlang-next-lines-empty-threshold 2\n \"Number of blank lines required to activate an electric command.\n\nActually, this value controls the behaviour of the function\n`erlang-next-lines-empty-p' which normally is a member of the\ncriteria lists controlling the electric commands. (Please see\nthe variables `erlang-electric-semicolon-criteria' and\n`erlang-electric-comma-criteria'.)\n\nThe variable is bound to a threshold value, a number, representing the\nnumber of lines which must be empty.\n\nSetting this variable to zero, electric commands will always be\ntriggered by `erlang-next-lines-empty-p', unless inhibited by other\nrules.\n\nShould this variable be nil, `erlang-next-lines-empty-p' will never\ntrigger an electric command. The same effect would be reached if the\nfunction `erlang-next-lines-empty-p' would be removed from the criteria\nlists.\n\nNote that even if `erlang-next-lines-empty-p' should not trigger an\nelectric command, other functions in the criteria list could.\"\n :group 'erlang\n :type '(restricted-sexp :match-alternatives (integerp 'nil))\n :safe (lambda (val) (or (eq val nil) (integerp val))))\n\n(defcustom erlang-new-clause-with-arguments nil\n \"Non-nil means that the arguments are cloned when a clause is generated.\n\nA new function header can be generated by calls to the function\n`erlang-generate-new-clause' and by use of the electric semicolon.\"\n :group 'erlang\n :type 'boolean\n :safe 'booleanp)\n\n(defcustom erlang-compile-use-outdir t\n \"When nil, go to the directory containing source file when compiling.\n\nThis is a workaround for a bug in the `outdir' option of compile. If the\noutdir is not in the current load path, Erlang doesn't load the object\nmodule after it has been compiled.\n\nTo activate the workaround, place the following in your `~\/.emacs' file:\n (setq erlang-compile-use-outdir nil)\"\n :group 'erlang\n :type 'boolean\n :safe 'booleanp)\n\n(defcustom erlang-indent-level 4\n \"Indentation of Erlang calls\/clauses within blocks.\"\n :group 'erlang\n :type 'integer\n :safe 'integerp)\n\n(defcustom erlang-icr-indent nil\n \"Indentation of Erlang if\/case\/receive patterns.\nnil means keeping default behavior. When non-nil, indent to the column of\nif\/case\/receive.\"\n :group 'erlang\n :type 'boolean\n :safe 'booleanp)\n\n(defcustom erlang-indent-guard 2\n \"Indentation of Erlang guards.\"\n :group 'erlang\n :type 'integer\n :safe 'integerp)\n\n(defcustom erlang-argument-indent 2\n \"Indentation of the first argument in a function call.\nWhen nil, indent to the column after the `(' of the\nfunction.\"\n :group 'erlang\n :type '(restricted-sexp :match-alternatives (integerp 'nil))\n :safe (lambda (val) (or (eq val nil) (integerp val))))\n\n(defcustom erlang-tab-always-indent t\n \"Non-nil means TAB in Erlang mode should always re-indent the current line,\nregardless of where in the line point is when the TAB command is used.\"\n :group 'erlang\n :type 'boolean\n :safe 'booleanp)\n\n(defcustom erlang-max-files-to-visit-for-refining-xrefs 32\n \"Upper limit how many files to visit for checking arity.\nWhen `nil' there is no limit.\"\n :group 'erlang\n :type '(restricted-sexp :match-alternatives (integerp 'nil))\n :safe (lambda (val) (or (eq val nil) (integerp val))))\n\n(defvar erlang-man-inhibit (eq system-type 'windows-nt)\n \"Inhibit the creation of the Erlang Manual Pages menu.\n\nThe Windows distribution of Erlang does not include man pages, hence\nthere is no attempt to create the menu.\")\n\n(defvar erlang-man-dirs\n '((\"Man - Commands\" \"\/man\/man1\" t)\n (\"Man - Modules\" \"\/man\/man3\" t)\n (\"Man - Files\" \"\/man\/man4\" t)\n (\"Man - Applications\" \"\/man\/man6\" t))\n \"The man directories displayed in the Erlang menu.\n\nEach item in the list should be a list with three elements, the first\nthe name of the menu, the second the directory, and the last a flag.\nShould the flag the nil, the directory is absolute, should it be non-nil\nthe directory is relative to the variable `erlang-root-dir'.\")\n\n(defvar erlang-man-max-menu-size 35\n \"The maximum number of menu items in one menu allowed.\")\n\n(defvar erlang-man-display-function 'erlang-man-display\n \"Function used to display man page.\n\nThe function is called with one argument, the name of the file\ncontaining the man page. Use this variable when the default\nfunction, `erlang-man-display', does not work on your system.\")\n\n(defvar erlang-compile-extra-opts '()\n \"Additional options to the compilation command.\nThis is an elisp list of options. Each option can be either:\n- an atom\n- a dotted pair\n- a string\nExample: '(bin_opt_info (i . \\\"\/path1\/include\\\") (i . \\\"\/path2\/include\\\"))\")\n\n(defvar erlang-compile-command-function-alist\n '((\".erl\\\\'\" . inferior-erlang-compute-erl-compile-command)\n (\".xrl\\\\'\" . inferior-erlang-compute-leex-compile-command)\n (\".yrl\\\\'\" . inferior-erlang-compute-yecc-compile-command)\n (\".\" . inferior-erlang-compute-erl-compile-command))\n \"Alist of filename patterns vs corresponding compilation functions.\nEach element looks like (REGEXP . FUNCTION). Compiling a file whose name\nmatches REGEXP specifies FUNCTION to use to compute the compilation\ncommand. The FUNCTION will be called with two arguments: module name and\ndefault compilation options, like output directory. The FUNCTION\nis expected to return a string.\")\n\n(defvar erlang-leex-compile-opts '()\n \"Options to pass to leex when compiling xrl files.\nThis is an elisp list of options. Each option can be either:\n- an atom\n- a dotted pair\n- a string\")\n\n(defvar erlang-yecc-compile-opts '()\n \"Options to pass to yecc when compiling yrl files.\nThis is an elisp list of options. Each option can be either:\n- an atom\n- a dotted pair\n- a string\")\n\n(eval-and-compile\n (defvar erlang-regexp-modern-p t\n \"Non-nil when this version of Emacs uses a modern version of regexp.\nSupporting \\_< and \\_> This is determined by checking the version of Emacs used.\"))\n\n(eval-and-compile\n (defconst erlang-atom-quoted-regexp\n \"'\\\\(?:[^\\\\']\\\\|\\\\(?:\\\\\\\\.\\\\)\\\\)*'\"\n \"Regexp describing a single-quoted atom\"))\n\n(eval-and-compile\n (defconst erlang-atom-regular-regexp\n (if erlang-regexp-modern-p\n \"\\\\_<[[:lower:]]\\\\(?:\\\\sw\\\\|\\\\s_\\\\)*\\\\_>\"\n \"\\\\<[[:lower:]]\\\\(?:\\\\sw\\\\|\\\\s_\\\\)*\\\\>\")\n \"Regexp describing a regular (non-quoted) atom\"))\n\n(eval-and-compile\n (defconst erlang-atom-regexp\n (concat \"\\\\(\" erlang-atom-quoted-regexp \"\\\\|\"\n erlang-atom-regular-regexp \"\\\\)\")\n \"Regexp describing an Erlang atom.\"))\n\n(eval-and-compile\n (defconst erlang-atom-regexp-matches 1\n \"Number of regexp parenthesis pairs in `erlang-atom-regexp'.\n\nThis is used to determine parenthesis matches in complex regexps which\ncontains `erlang-atom-regexp'.\"))\n\n\n(eval-and-compile\n (defconst erlang-variable-regexp\n (if erlang-regexp-modern-p\n \"\\\\_<\\\\([[:upper:]_]\\\\(?:\\\\sw\\\\|\\\\s_\\\\)*\\\\)\\\\_>\"\n \"\\\\<\\\\([[:upper:]_]\\\\(?:\\\\sw\\\\|\\\\s_\\\\)*\\\\)\\\\>\")\n \"Regexp which should match an Erlang variable.\n\nThe regexp must be surrounded with a pair of regexp parentheses.\"))\n\n(eval-and-compile\n (defconst erlang-variable-regexp-matches 1\n \"Number of regexp parenthesis pairs in `erlang-variable-regexp'.\n\nThis is used to determine matches in complex regexps which contains\n`erlang-variable-regexp'.\"))\n\n(defconst erlang-module-function-regexp\n (eval-when-compile\n (concat erlang-atom-regexp \":\" erlang-atom-regexp))\n \"Regexp matching an erlang module:function.\")\n\n(defconst erlang-name-regexp\n (concat \"\\\\(\"\n \"\\\\(?:\\\\sw\\\\|\\\\s_\\\\)+\"\n \"\\\\|\"\n erlang-atom-quoted-regexp\n \"\\\\)\")\n \"Matches a name of a function, macro or record\")\n\n(defconst erlang-id-regexp\n (concat \"\\\\(?:\\\\(qualified-function\\\\|record\\\\|macro\\\\|module\\\\) \\\\)?\"\n \"\\\\(?:\" erlang-atom-regexp \":\\\\)?\"\n erlang-name-regexp \"?\"\n \"\\\\(?:\/\\\\([0-9]+\\\\)\\\\)?\"))\n\n(eval-and-compile\n (defun erlang-regexp-opt (strings &optional paren)\n \"Like `regexp-opt', except if PAREN is `symbols', then the\nresulting regexp is surrounded by \\\\_< and \\\\_>.\"\n (if (eq paren 'symbols)\n (if erlang-regexp-modern-p\n (concat \"\\\\_<\" (regexp-opt strings t) \"\\\\_>\")\n (concat \"\\\\<\" (regexp-opt strings t) \"\\\\>\"))\n (regexp-opt strings paren))))\n\n\n(eval-and-compile\n (defvar erlang-keywords\n '(\"after\"\n \"begin\"\n \"catch\"\n \"case\"\n \"cond\"\n \"end\"\n \"fun\"\n \"if\"\n \"let\"\n \"of\"\n \"receive\"\n \"try\"\n \"when\")\n \"Erlang reserved keywords\"))\n\n(eval-and-compile\n (defconst erlang-keywords-regexp (erlang-regexp-opt erlang-keywords 'symbols)))\n\n(eval-and-compile\n (defvar erlang-operators\n '(\"and\"\n \"andalso\"\n \"band\"\n \"bnot\"\n \"bor\"\n \"bsl\"\n \"bsr\"\n \"bxor\"\n \"div\"\n \"not\"\n \"or\"\n \"orelse\"\n \"rem\"\n \"xor\")\n \"Erlang operators\"))\n;; What about these?\n;; '+' '-' '*' '\/' '>', '>=', '<', '=<', '=:=', '==', '=\/=', '\/='\n\n(eval-and-compile\n (defconst erlang-operators-regexp (erlang-regexp-opt erlang-operators 'symbols)))\n\n\n(eval-and-compile\n (defvar erlang-guards\n '(\"is_atom\"\n \"is_binary\"\n \"is_bitstring\"\n \"is_boolean\"\n \"is_float\"\n \"is_function\"\n \"is_integer\"\n \"is_list\"\n \"is_map\"\n \"is_number\"\n \"is_pid\"\n \"is_port\"\n \"is_record\"\n \"is_reference\"\n \"is_tuple\"\n \"atom\"\n \"binary\"\n \"bitstring\"\n \"boolean\"\n ;;\"float\" ; Not included to avoid clashes with the bif float\/1\n \"function\"\n \"integer\"\n \"list\"\n \"number\"\n \"pid\"\n \"port\"\n \"record\"\n \"reference\"\n \"tuple\")\n \"Erlang guards\"))\n\n(eval-and-compile\n (defconst erlang-guards-regexp (erlang-regexp-opt erlang-guards 'symbols)))\n\n(eval-and-compile\n (defvar erlang-predefined-types\n '(\"any\"\n \"arity\"\n \"boolean\"\n \"byte\"\n \"char\"\n \"cons\"\n \"deep_string\"\n \"iodata\"\n \"iolist\"\n \"maybe_improper_list\"\n \"module\"\n \"mfa\"\n \"nil\"\n \"neg_integer\"\n \"none\"\n \"non_neg_integer\"\n \"nonempty_list\"\n \"nonempty_improper_list\"\n \"nonempty_maybe_improper_list\"\n \"nonempty_string\"\n \"no_return\"\n \"pos_integer\"\n \"string\"\n \"term\"\n \"timeout\"\n \"map\")\n \"Erlang type specs types\"))\n\n(eval-and-compile\n (defconst erlang-predefined-types-regexp\n (erlang-regexp-opt erlang-predefined-types 'symbols)))\n\n\n(eval-and-compile\n (defvar erlang-int-bifs\n '(\"abs\"\n \"apply\"\n \"atom_to_binary\"\n \"atom_to_list\"\n \"binary_to_atom\"\n \"binary_to_existing_atom\"\n \"binary_to_float\"\n \"binary_to_integer\"\n \"binary_to_list\"\n \"binary_to_term\"\n \"binary_part\"\n \"bit_size\"\n \"bitsize\"\n \"bitstring_to_list\"\n \"byte_size\"\n \"ceil\"\n \"check_old_code\"\n \"check_process_code\"\n \"date\"\n \"delete_module\"\n \"demonitor\"\n \"disconnect_node\"\n \"element\"\n \"erase\"\n \"error\"\n \"exit\"\n \"floor\"\n \"float\"\n \"float_to_binary\"\n \"float_to_list\"\n \"garbage_collect\"\n \"get\"\n \"get_keys\"\n \"group_leader\"\n \"halt\"\n \"hd\"\n \"integer_to_list\"\n \"integer_to_binary\"\n \"iolist_size\"\n \"iolist_to_binary\"\n \"is_alive\"\n \"is_atom\"\n \"is_binary\"\n \"is_bitstring\"\n \"is_boolean\"\n \"is_float\"\n \"is_function\"\n \"is_integer\"\n \"is_list\"\n \"is_map\"\n \"is_map_key\"\n \"is_number\"\n \"is_pid\"\n \"is_port\"\n \"is_process_alive\"\n \"is_record\"\n \"is_reference\"\n \"is_tuple\"\n \"length\"\n \"link\"\n \"list_to_atom\"\n \"list_to_binary\"\n \"list_to_bitstring\"\n \"list_to_existing_atom\"\n \"list_to_float\"\n \"list_to_integer\"\n \"list_to_pid\"\n \"list_to_port\"\n \"list_to_ref\"\n \"list_to_tuple\"\n \"load_module\"\n \"make_ref\"\n \"map_get\"\n \"map_size\"\n \"max\"\n \"min\"\n \"module_loaded\"\n \"monitor\"\n \"monitor_node\"\n \"node\"\n \"nodes\"\n \"now\"\n \"open_port\"\n \"pid_to_list\"\n \"port_close\"\n \"port_command\"\n \"port_connect\"\n \"port_control\"\n \"port_to_list\"\n \"pre_loaded\"\n \"process_flag\"\n \"process_info\"\n \"processes\"\n \"purge_module\"\n \"put\"\n \"ref_to_list\"\n \"register\"\n \"registered\"\n \"round\"\n \"self\"\n \"setelement\"\n \"size\"\n \"spawn\"\n \"spawn_link\"\n \"spawn_monitor\"\n \"spawn_opt\"\n \"split_binary\"\n \"statistics\"\n \"term_to_binary\"\n \"time\"\n \"throw\"\n \"tl\"\n \"trunc\"\n \"tuple_size\"\n \"tuple_to_list\"\n \"unlink\"\n \"unregister\"\n \"whereis\")\n \"Erlang built-in functions (BIFs)\"))\n\n(eval-and-compile\n (defconst erlang-int-bif-regexp (erlang-regexp-opt erlang-int-bifs 'symbols)))\n\n\n(eval-and-compile\n (defvar erlang-ext-bifs\n '(\"adler32\"\n \"adler32_combine\"\n \"alloc_info\"\n \"alloc_sizes\"\n \"append\"\n \"append_element\"\n \"bump_reductions\"\n \"call_on_load_function\"\n \"cancel_timer\"\n \"crasher\"\n \"crc32\"\n \"crc32_combine\"\n \"decode_packet\"\n \"delay_trap\"\n \"delete_element\"\n \"display\"\n \"display_nl\"\n \"display_string\"\n \"dist_get_stat\"\n \"dist_ctrl_get_data\"\n \"dist_ctrl_get_data_notification\"\n \"dist_ctrl_get_opt\"\n \"dist_ctrl_input_handler\"\n \"dist_ctrl_put_data\"\n \"dist_ctrl_set_opt\"\n \"dmonitor_node\"\n \"dt_append_vm_tag_data\"\n \"dt_get_tag\"\n \"dt_get_tag_data\"\n \"dt_prepend_vm_tag_data\"\n \"dt_put_tag\"\n \"dt_restore_tag\"\n \"dt_spread_tag\"\n \"convert_time_unit\"\n \"exit_signal\"\n \"external_size\"\n \"finish_after_on_load\"\n \"finish_loading\"\n \"format_cpu_topology\"\n \"fun_info\"\n \"fun_info_mfa\"\n \"fun_to_list\"\n \"function_exported\"\n \"garbage_collect_message_area\"\n \"gather_gc_info_result\"\n \"get_cookie\"\n \"get_module_info\"\n \"get_stacktrace\"\n \"has_prepared_code_on_load\"\n \"hibernate\"\n \"insert_element\"\n \"iolist_to_iovec\"\n \"is_builtin\"\n \"load_nif\"\n \"loaded\"\n \"localtime\"\n \"localtime_to_universaltime\"\n \"make_fun\"\n \"make_tuple\"\n \"match_spec_test\"\n \"md5\"\n \"md5_final\"\n \"md5_init\"\n \"md5_update\"\n \"memory\"\n \"module_info\"\n \"monitor_node\"\n \"monotonic_time\"\n \"nif_error\"\n \"phash\"\n \"phash2\"\n \"port_call\"\n \"port_get_data\"\n \"port_info\"\n \"port_set_data\"\n \"ports\"\n \"posixtime_to_universaltime\"\n \"prepare_loading\"\n \"process_display\"\n \"raise\"\n \"read_timer\"\n \"resume_process\"\n \"send\"\n \"send_after\"\n \"send_nosuspend\"\n \"seq_trace\"\n \"seq_trace_info\"\n \"seq_trace_print\"\n \"set_cookie\"\n \"set_cpu_topology\"\n \"setnode\"\n \"spawn_opt\"\n \"start_timer\"\n \"subtract\"\n \"suspend_process\"\n \"system_flag\"\n \"system_info\"\n \"system_monitor\"\n \"system_profile\"\n \"system_time\"\n \"trace\"\n \"trace_delivered\"\n \"trace_info\"\n \"trace_pattern\"\n \"time_offset\"\n \"timestamp\"\n \"universaltime\"\n \"universaltime_to_localtime\"\n \"universaltime_to_posixtime\"\n \"unique_integer\"\n \"yield\")\n \"Erlang built-in functions (BIFs) that needs erlang: prefix\"))\n\n(eval-and-compile\n (defconst erlang-ext-bif-regexp\n (erlang-regexp-opt (append erlang-int-bifs erlang-ext-bifs) 'symbols)))\n\n\n(defvar erlang-defun-prompt-regexp (concat \"^\" erlang-atom-regexp \"\\\\s *(\")\n \"Regexp which should match beginning of a clause.\")\n\n(defvar erlang-file-name-extension-regexp \"\\\\.erl$\"\n \"Regexp which should match an Erlang file name.\n\nThis regexp is used when an Erlang module name is extracted from the\nname of an Erlang source file.\n\nThe regexp should only match the section of the file name which should\nbe excluded from the module name.\n\nTo match all files set this variable to \\\"\\\\\\\\(\\\\\\\\..*\\\\\\\\|\\\\\\\\)$\\\".\nThe matches all except the extension. This is useful if the Erlang\ntags system should interpret tags on the form `module:tag' for\nfiles written in other languages than Erlang.\")\n\n(defvar erlang-inferior-shell-split-window t\n \"If non-nil, when starting an inferior shell, split windows.\nIf nil, the inferior shell replaces the window. This is the traditional\nbehaviour.\")\n\n(defvar erlang-mode-map\n (let ((map (make-sparse-keymap)))\n (define-key map \";\" 'erlang-electric-semicolon)\n (define-key map \",\" 'erlang-electric-comma)\n (define-key map \"<\" 'erlang-electric-lt)\n (define-key map \">\" 'erlang-electric-gt)\n (define-key map \"\\C-m\" 'erlang-electric-newline)\n (define-key map [(backspace)] 'backward-delete-char-untabify)\n (define-key map \"\\M-q\" 'erlang-fill-paragraph)\n (define-key map \"\\M-\\t\" 'erlang-complete-tag)\n (define-key map \"\\C-c\\M-\\t\" 'tempo-complete-tag)\n (define-key map \"\\M-+\" 'erlang-find-next-tag)\n (define-key map \"\\C-c\\M-a\" 'erlang-beginning-of-clause)\n (define-key map \"\\C-c\\M-b\" 'tempo-backward-mark)\n (define-key map \"\\C-c\\M-e\" 'erlang-end-of-clause)\n (define-key map \"\\C-c\\M-f\" 'tempo-forward-mark)\n (define-key map \"\\C-c\\M-h\" 'erlang-mark-clause)\n (define-key map \"\\C-c\\C-c\" 'comment-region)\n (define-key map \"\\C-c\\C-j\" 'erlang-generate-new-clause)\n (define-key map \"\\C-c\\C-k\" 'erlang-compile)\n (define-key map \"\\C-c\\C-l\" 'erlang-compile-display)\n (define-key map \"\\C-c\\C-s\" 'erlang-show-syntactic-information)\n (define-key map \"\\C-c\\C-q\" 'erlang-indent-function)\n (define-key map \"\\C-c\\C-u\" 'uncomment-region)\n (define-key map \"\\C-c\\C-y\" 'erlang-clone-arguments)\n (define-key map \"\\C-c\\C-a\" 'erlang-align-arrows)\n (define-key map \"\\C-c\\C-z\" 'erlang-shell-display)\n (define-key map \"\\C-c\\C-d\" 'erlang-man-function-no-prompt)\n map)\n \"Keymap used in Erlang mode.\")\n(defvar erlang-mode-abbrev-table nil\n \"Abbrev table in use in Erlang-mode buffers.\")\n(defvar erlang-mode-syntax-table nil\n \"Syntax table in use in Erlang-mode buffers.\")\n\n\n\n(defvar erlang-skel-file \"erlang-skels\"\n \"The type of erlang-skeletons that should be used, default\n uses edoc type, for the old type, standard comments,\n set \\\"erlang-skels-old\\\" in your .emacs and restart.\n\n Or define your own and set the variable to that file.\")\n\n;; Tempo skeleton templates:\n(load erlang-skel-file)\n\n;; Font-lock variables\n\n;; The next few variables define different Erlang font-lock patterns.\n;; They could be appended to form a custom font-lock appearance.\n;;\n;; The function `erlang-font-lock-set-face' could be used to change\n;; the face of a pattern.\n;;\n;; Note that Erlang strings and atoms are highlighted with using\n;; syntactic analysis.\n\n(defvar erlang-font-lock-keywords-function-header\n (list\n (list (concat \"^\" erlang-atom-regexp \"\\\\s-*(\")\n 1 'font-lock-function-name-face t))\n \"Font lock keyword highlighting a function header.\")\n\n(defface erlang-font-lock-exported-function-name-face\n '((default (:inherit font-lock-function-name-face)))\n \"Face used for highlighting exported functions.\"\n :group 'erlang)\n\n(defvar erlang-font-lock-exported-function-name-face\n 'erlang-font-lock-exported-function-name-face)\n\n(defvar erlang-inhibit-exported-function-name-face nil\n \"Inhibit separate face for exported functions\")\n\n(defvar erlang-font-lock-keywords-exported-function-header\n (list\n (list #'erlang-match-next-exported-function\n 1 'erlang-font-lock-exported-function-name-face t))\n \"Font lock keyword highlighting an exported function header.\")\n\n(defvar erlang-font-lock-keywords-int-bifs\n (list\n (list (concat erlang-int-bif-regexp \"\\\\s-*(\")\n 1 'font-lock-builtin-face))\n \"Font lock keyword highlighting built in functions.\")\n\n(defvar erlang-font-lock-keywords-ext-bifs\n (list\n (list (concat \"\\\\<\\\\(erlang\\\\)\\\\s-*:\\\\s-*\" erlang-ext-bif-regexp \"\\\\s-*(\")\n '(1 'font-lock-builtin-face)\n '(2 'font-lock-builtin-face)))\n \"Font lock keyword highlighting built in functions.\")\n\n(defvar erlang-font-lock-keywords-int-function-calls\n (list\n (list (concat erlang-atom-regexp \"\\\\s-*(\")\n 1 'font-lock-type-face))\n \"Font lock keyword highlighting an internal function call.\")\n\n(defvar erlang-font-lock-keywords-ext-function-calls\n (list\n (list (concat erlang-atom-regexp \"\\\\s-*:\\\\s-*\"\n erlang-atom-regexp \"\\\\s-*(\")\n '(1 'font-lock-type-face)\n '(2 'font-lock-type-face)))\n \"Font lock keyword highlighting an external function call.\")\n\n(defvar erlang-font-lock-keywords-fun-n\n (list\n (list (concat \"\\\\(\" erlang-atom-regexp \"\/[0-9]+\\\\)\")\n 1 'font-lock-type-face))\n \"Font lock keyword highlighting a fun descriptor in F\/N format.\")\n\n(defvar erlang-font-lock-keywords-operators\n (list\n (list erlang-operators-regexp\n 1 'font-lock-builtin-face))\n \"Font lock keyword highlighting Erlang operators.\")\n\n(defvar erlang-font-lock-keywords-dollar\n (list\n (list \"\\\\(\\\\$\\\\([^\\\\]\\\\|\\\\\\\\\\\\([^0-7^\\n]\\\\|[0-7]+\\\\|\\\\^[a-zA-Z]\\\\)\\\\)\\\\)\"\n 1 'font-lock-constant-face))\n \"Font lock keyword highlighting numbers in ASCII form (e.g. $A).\")\n\n(defvar erlang-font-lock-keywords-arrow\n (list\n (list \"->\\\\(\\\\s \\\\|$\\\\)\" 1 'font-lock-function-name-face))\n \"Font lock keyword highlighting clause arrow.\")\n\n(defvar erlang-font-lock-keywords-lc\n (list\n (list \"\\\\(<-\\\\|<=\\\\|||\\\\)\\\\(\\\\s \\\\|$\\\\)\" 1 'font-lock-keyword-face))\n \"Font lock keyword highlighting list comprehension operators.\")\n\n(defvar erlang-font-lock-keywords-keywords\n (list\n (list erlang-keywords-regexp 1 'font-lock-keyword-face))\n \"Font lock keyword highlighting Erlang keywords.\")\n\n(defvar erlang-font-lock-keywords-attr\n (list\n (list (concat \"^\\\\(-\" erlang-atom-regexp \"\\\\)\\\\(\\\\s-\\\\|\\\\.\\\\|(\\\\)\")\n 1 (if (boundp 'font-lock-preprocessor-face)\n 'font-lock-preprocessor-face\n 'font-lock-constant-face)))\n \"Font lock keyword highlighting attributes.\")\n\n(defvar erlang-font-lock-keywords-quotes\n (list\n (list \"`\\\\([-+a-zA-Z0-9_:*][-+a-zA-Z0-9_:*]+\\\\)'\"\n 1\n 'font-lock-keyword-face\n t))\n \"Font lock keyword highlighting words in single quotes in comments.\n\nThis is not the highlighting of Erlang strings and atoms, which\nare highlighted by syntactic analysis.\")\n\n(defvar erlang-font-lock-keywords-guards\n (list\n (list (concat \"[^:]\" erlang-guards-regexp \"\\\\s-*(\")\n 1 'font-lock-builtin-face))\n \"Font lock keyword highlighting guards.\")\n\n(defvar erlang-font-lock-keywords-predefined-types\n (list\n (list (concat \"[^:]\" erlang-predefined-types-regexp \"\\\\s-*(\")\n 1 'font-lock-builtin-face))\n \"Font lock keyword highlighting predefined types.\")\n\n\n(defvar erlang-font-lock-keywords-macros\n (list\n (list (concat \"?\\\\s-*\\\\(\" erlang-atom-regexp\n \"\\\\|\" erlang-variable-regexp \"\\\\)\")\n 1 'font-lock-constant-face)\n (list (concat \"^\\\\(-\\\\(?:define\\\\|ifn?def\\\\)\\\\)\\\\s-*(\\\\s-*\\\\(\" erlang-atom-regexp\n \"\\\\|\" erlang-variable-regexp \"\\\\)\")\n (if (boundp 'font-lock-preprocessor-face)\n (list 1 'font-lock-preprocessor-face t)\n (list 1 'font-lock-constant-face t))\n (list 3 'font-lock-type-face t t))\n (list \"^-e\\\\(lse\\\\|ndif\\\\)\\\\>\" 0 'font-lock-preprocessor-face t))\n \"Font lock keyword highlighting macros.\nThis must be placed in front of `erlang-font-lock-keywords-vars'.\")\n\n(defvar erlang-font-lock-keywords-records\n (list\n (list (concat \"#\\\\s *\" erlang-atom-regexp)\n 1 'font-lock-type-face)\n ;; Don't highlight numerical constants.\n (list (if erlang-regexp-modern-p\n \"\\\\_<[0-9]+#\\\\([0-9a-zA-Z]+\\\\)\"\n \"\\\\<[0-9]+#\\\\([0-9a-zA-Z]+\\\\)\")\n 1 nil t)\n (list (concat \"^-record\\\\s-*(\\\\s-*\" erlang-atom-regexp)\n 1 'font-lock-type-face))\n \"Font lock keyword highlighting Erlang records.\nThis must be placed in front of `erlang-font-lock-keywords-vars'.\")\n\n(defvar erlang-font-lock-keywords-vars\n (list\n (list (concat \"[^#]\" erlang-variable-regexp) ; no numerical constants\n 1 'font-lock-variable-name-face))\n \"Font lock keyword highlighting Erlang variables.\nMust be preceded by `erlang-font-lock-keywords-macros' to work properly.\")\n\n(defvar erlang-font-lock-descr-string\n \"Font-lock keywords used by Erlang Mode.\n\nThere exists three levels of Font Lock keywords for Erlang:\n `erlang-font-lock-keywords-1' - Function headers and reserved keywords.\n `erlang-font-lock-keywords-2' - Bifs, guards and `single quotes'.\n `erlang-font-lock-keywords-3' - Variables, macros and records.\n `erlang-font-lock-keywords-4' - Exported functions, Function names,\n Funs, LCs (not Atoms).\n\nTo use a specific level, please set the variable\n`font-lock-maximum-decoration' to the appropriate level. Note that the\nvariable must be set before Erlang mode is activated.\n\nExample:\n (setq font-lock-maximum-decoration 2)\")\n\n(defvar erlang-font-lock-keywords-1\n (append erlang-font-lock-keywords-function-header\n erlang-font-lock-keywords-dollar\n erlang-font-lock-keywords-arrow\n erlang-font-lock-keywords-keywords\n )\n ;; DocStringOrig: erlang-font-lock-keywords\n erlang-font-lock-descr-string)\n\n(defvar erlang-font-lock-keywords-2\n (append erlang-font-lock-keywords-1\n erlang-font-lock-keywords-int-bifs\n erlang-font-lock-keywords-ext-bifs\n erlang-font-lock-keywords-attr\n erlang-font-lock-keywords-quotes\n erlang-font-lock-keywords-guards\n )\n ;; DocStringCopy: erlang-font-lock-keywords\n erlang-font-lock-descr-string)\n\n(defvar erlang-font-lock-keywords-3\n (append erlang-font-lock-keywords-2\n erlang-font-lock-keywords-operators\n erlang-font-lock-keywords-macros\n erlang-font-lock-keywords-records\n erlang-font-lock-keywords-vars\n erlang-font-lock-keywords-predefined-types\n )\n ;; DocStringCopy: erlang-font-lock-keywords\n erlang-font-lock-descr-string)\n\n(defvar erlang-font-lock-keywords-4\n (append erlang-font-lock-keywords-3\n erlang-font-lock-keywords-exported-function-header\n erlang-font-lock-keywords-int-function-calls\n erlang-font-lock-keywords-ext-function-calls\n erlang-font-lock-keywords-fun-n\n erlang-font-lock-keywords-lc\n )\n ;; DocStringCopy: erlang-font-lock-keywords\n erlang-font-lock-descr-string)\n\n(defvar erlang-font-lock-keywords erlang-font-lock-keywords-4\n ;; DocStringCopy: erlang-font-lock-keywords\n erlang-font-lock-descr-string)\n\n(defvar erlang-font-lock-syntax-table nil\n \"Syntax table used by Font Lock mode.\n\nThe difference between this and the standard Erlang Mode\nsyntax table is that `_' is treated as part of words by\nthis syntax table.\")\n\n(defvar erlang-replace-etags-tags-completion-table nil\n \"Internal flag used by advice `erlang-replace-tags-table'.\nThis is non-nil when `etags-tags-completion-table' should be\nreplaced by `erlang-etags-tags-completion-table'.\")\n\n\n;;; Avoid errors while compiling this file.\n\n;; defvar some obsolete variables, which we still support for\n;; backwards compatibility reasons.\n(eval-when-compile\n (defvar comment-indent-hook)\n (defvar dabbrev-case-fold-search)\n (defvar tempo-match-finder)\n (defvar compilation-menu-map)\n (defvar next-error-last-buffer))\n\n(eval-when-compile\n (require 'comint)\n (require 'tempo)\n (require 'compile))\n\n\n(defun erlang-version ()\n \"Return the current version of Erlang mode.\"\n (interactive)\n (if (called-interactively-p 'interactive)\n (message \"Erlang mode version %s, written by Anders Lindgren\"\n erlang-version))\n erlang-version)\n\n;;;###autoload\n(define-derived-mode erlang-mode prog-mode \"Erlang\"\n \"Major mode for editing Erlang source files in Emacs.\nIt knows about syntax and comment, it can indent code, it is capable\nof fontifying the source file, the TAGS commands are aware of Erlang\nmodules, and the Erlang man pages can be accessed.\n\nShould this module, \\\"erlang.el\\\", be installed properly, Erlang mode\nis activated whenever an Erlang source or header file is loaded into\nEmacs. To indicate this, the mode line should contain the word\n\\\"Erlang\\\".\n\nThe main feature of Erlang mode is indentation, press TAB and the\ncurrent line will be indented correctly.\n\nComments starting with only one `%' are indented to the column stored\nin the variable `comment-column'. Comments starting with two `%':s\nare indented with the same indentation as code. Comments starting\nwith at least three `%':s are indented to the first column.\n\nHowever, Erlang mode contains much more, this is a list of the most\nuseful commands:\n TAB - Indent the line.\n C-c C-q - Indent current function.\n M-; - Create a comment at the end of the line.\n M-q - Fill a comment, i.e. wrap lines so that they (hopefully)\n will look better.\n M-a - Goto the beginning of an Erlang clause.\n M-C-a - Ditto for function.\n M-e - Goto the end of an Erlang clause.\n M-C-e - Ditto for function.\n M-h - Mark current Erlang clause.\n M-C-h - Ditto for function.\n C-c C-z - Start, or switch to, an inferior Erlang shell.\n C-c C-k - Compile current file.\n C-x ` - Next error.\n , - Electric comma.\n ; - Electric semicolon.\n\nErlang mode check the name of the file against the module name when\nsaving, whenever a mismatch occurs Erlang mode offers to modify the\nsource.\n\nThe variable `erlang-electric-commands' controls the electric\ncommands. To deactivate all of them, set it to nil.\n\nThere exists a large number of commands and variables in the Erlang\nmodule. Please press `M-x apropos RET erlang RET' to see a complete\nlist. Press `C-h f name-of-function RET' and `C-h v name-of-variable\nRET'to see the full description of functions and variables,\nrespectively.\n\nOn entry to this mode the contents of the hook `erlang-mode-hook' is\nexecuted.\n\nPlease see the beginning of the file `erlang.el' for more information\nand examples of hooks.\n\nOther commands:\n\\\\{erlang-mode-map}\"\n ;; Use our own syntax table function\n :syntax-table nil\n (erlang-syntax-table-init)\n (erlang-electric-init)\n (erlang-menu-init)\n (erlang-mode-variables)\n (erlang-check-module-name-init)\n (erlang-man-init)\n (erlang-tags-init)\n (erlang-font-lock-init)\n (erlang-skel-init)\n (tempo-use-tag-list 'erlang-tempo-tags)\n (when (and (fboundp 'add-function) (fboundp 'erldoc-eldoc-function))\n (or eldoc-documentation-function\n (setq-local eldoc-documentation-function #'ignore))\n (add-function :before-until (local 'eldoc-documentation-function)\n #'erldoc-eldoc-function))\n (run-hooks 'erlang-mode-hook)\n\n ;; Align maps.\n (add-to-list 'align-rules-list\n '(erlang-maps\n (regexp . \"\\\\(\\\\s-*\\\\)\\\\(=>\\\\)\\\\s-*\")\n (modes . '(erlang-mode))\n (repeat . t)))\n ;; Align records and :: specs\n (add-to-list 'align-rules-list\n '(erlang-record-specs\n (regexp . \"\\\\(\\\\s-*\\\\)\\\\(=\\\\).*\\\\(::\\\\)*\\\\s-*\")\n (modes . '(erlang-mode))\n (repeat . t)))\n (if (zerop (buffer-size))\n (run-hooks 'erlang-new-file-hook)))\n\n;;;###autoload\n(dolist (r '(\"\\\\.erl$\" \"\\\\.app\\\\.src$\" \"\\\\.escript\"\n \"\\\\.hrl$\" \"\\\\.xrl$\" \"\\\\.yrl\" \"\/ebin\/.+\\\\.app\"))\n (add-to-list 'auto-mode-alist (cons r 'erlang-mode)))\n\n(defun erlang-syntax-table-init ()\n (erlang-ensure-syntax-table-is-initialized)\n (set-syntax-table erlang-mode-syntax-table))\n\n(defun erlang-ensure-syntax-table-is-initialized ()\n (unless erlang-mode-syntax-table\n (let ((table (make-syntax-table)))\n (modify-syntax-entry ?\\n \">\" table)\n (modify-syntax-entry ?\\\" \"\\\"\" table)\n (modify-syntax-entry ?# \".\" table)\n ;; (modify-syntax-entry ?$ \"\\\\\" table) ;; Creates problems with indention afterwards\n ;; (modify-syntax-entry ?$ \"'\" table) ;; Creates syntax highlighting and indention problems\n (modify-syntax-entry ?$ \"\/\" table) ;; Misses the corner case \"string that ends with $\"\n ;; we have to live with that for now..it is the best alternative\n ;; that can be worked around with \"string that ends with \\$\"\n (modify-syntax-entry ?% \"<\" table)\n (modify-syntax-entry ?& \".\" table)\n (modify-syntax-entry ?\\' \"\\\"\" table)\n (modify-syntax-entry ?* \".\" table)\n (modify-syntax-entry ?+ \".\" table)\n (modify-syntax-entry ?- \".\" table)\n (modify-syntax-entry ?\/ \".\" table)\n (modify-syntax-entry ?: \".\" table)\n (modify-syntax-entry ?< \".\" table)\n (modify-syntax-entry ?= \".\" table)\n (modify-syntax-entry ?> \".\" table)\n (modify-syntax-entry ?\\\\ \"\\\\\" table)\n (modify-syntax-entry ?_ \"_\" table)\n (modify-syntax-entry ?| \".\" table)\n (modify-syntax-entry ?^ \"'\" table)\n\n ;; Pseudo bit-syntax: Latin1 double angle quotes as parens.\n ;;(modify-syntax-entry ?\\253 \"(?\\273\" table)\n ;;(modify-syntax-entry ?\\273 \")?\\253\" table)\n\n (setq erlang-mode-syntax-table table))))\n\n\n\n(defun erlang-electric-init ()\n ;; Set up electric character functions to work with\n ;; delsel\/pending-del mode. Also, set up text properties for bit\n ;; syntax handling.\n (mapc #'(lambda (cmd)\n (put cmd 'delete-selection t)) ;for delsel (Emacs)\n '(erlang-electric-semicolon\n erlang-electric-comma\n erlang-electric-gt))\n\n (put 'bitsyntax-open-outer 'syntax-table '(4 . ?>))\n (put 'bitsyntax-open-outer 'rear-nonsticky '(category))\n (put 'bitsyntax-open-inner 'rear-nonsticky '(category))\n (put 'bitsyntax-close-inner 'rear-nonsticky '(category))\n (put 'bitsyntax-close-outer 'syntax-table '(5 . ?<))\n (put 'bitsyntax-close-outer 'rear-nonsticky '(category))\n (make-local-variable 'parse-sexp-lookup-properties)\n (setq parse-sexp-lookup-properties 't))\n\n\n(defun erlang-mode-variables ()\n (or erlang-mode-abbrev-table\n (define-abbrev-table 'erlang-mode-abbrev-table ()))\n (setq local-abbrev-table erlang-mode-abbrev-table)\n (make-local-variable 'paragraph-start)\n (setq paragraph-start (concat \"^$\\\\|\" page-delimiter))\n (make-local-variable 'paragraph-separate)\n (setq paragraph-separate paragraph-start)\n (make-local-variable 'paragraph-ignore-fill-prefix)\n (setq paragraph-ignore-fill-prefix t)\n (make-local-variable 'defun-prompt-regexp)\n (setq defun-prompt-regexp erlang-defun-prompt-regexp)\n (make-local-variable 'comment-start)\n (setq comment-start \"%\")\n (make-local-variable 'comment-start-skip)\n (setq comment-start-skip \"%+\\\\s *\")\n (make-local-variable 'comment-column)\n (setq comment-column 48)\n (make-local-variable 'indent-line-function)\n (setq indent-line-function 'erlang-indent-command)\n (make-local-variable 'indent-region-function)\n (setq indent-region-function 'erlang-indent-region)\n (set (make-local-variable 'comment-indent-function) 'erlang-comment-indent)\n (set (make-local-variable 'parse-sexp-ignore-comments) t)\n (set (make-local-variable 'dabbrev-case-fold-search) nil)\n (set (make-local-variable 'imenu-prev-index-position-function)\n 'erlang-beginning-of-function)\n (set (make-local-variable 'imenu-extract-index-name-function)\n 'erlang-get-function-name-and-arity)\n (set (make-local-variable 'tempo-match-finder)\n \"[^-a-zA-Z0-9_]\\\\([-a-zA-Z0-9_]*\\\\)\\\\=\")\n (set (make-local-variable 'beginning-of-defun-function)\n 'erlang-beginning-of-function)\n (set (make-local-variable 'end-of-defun-function) 'erlang-end-of-function)\n (set (make-local-variable 'open-paren-in-column-0-is-defun-start) nil)\n (set (make-local-variable 'fill-paragraph-function) 'erlang-fill-paragraph)\n (set (make-local-variable 'comment-add) 1)\n (set (make-local-variable 'outline-regexp) \"[[:lower:]0-9_]+ *(.*) *-> *$\")\n (set (make-local-variable 'outline-level) (lambda () 1))\n (set (make-local-variable 'add-log-current-defun-function)\n 'erlang-current-defun))\n\n(defun erlang-font-lock-init ()\n \"Initialize Font Lock for Erlang mode.\"\n (or erlang-font-lock-syntax-table\n (setq erlang-font-lock-syntax-table\n (let ((table (copy-syntax-table erlang-mode-syntax-table)))\n (modify-syntax-entry ?_ \"w\" table)\n table)))\n (set (make-local-variable 'font-lock-syntax-table)\n erlang-font-lock-syntax-table)\n (set (make-local-variable (if (boundp 'syntax-begin-function)\n 'syntax-begin-function\n 'font-lock-beginning-of-syntax-function))\n 'erlang-beginning-of-clause)\n (make-local-variable 'font-lock-keywords)\n (let ((level (cond ((boundp 'font-lock-maximum-decoration)\n (symbol-value 'font-lock-maximum-decoration))\n ((boundp 'font-lock-use-maximal-decoration)\n (symbol-value 'font-lock-use-maximal-decoration))\n (t nil))))\n (if (consp level)\n (setq level (cdr-safe (or (assq 'erlang-mode level)\n (assq t level)))))\n ;; `level' can here be:\n ;; A number - The fontification level\n ;; nil - Use the default\n ;; t - Use maximum\n (cond ((eq level nil)\n (set 'font-lock-keywords erlang-font-lock-keywords))\n ((eq level 1)\n (set 'font-lock-keywords erlang-font-lock-keywords-1))\n ((eq level 2)\n (set 'font-lock-keywords erlang-font-lock-keywords-2))\n ((eq level 3)\n (set 'font-lock-keywords erlang-font-lock-keywords-3))\n (t\n (set 'font-lock-keywords erlang-font-lock-keywords-4))))\n\n ;; Modern font-locks can handle the above much more elegantly:\n (set (make-local-variable 'font-lock-defaults)\n '((erlang-font-lock-keywords erlang-font-lock-keywords-1\n erlang-font-lock-keywords-2\n erlang-font-lock-keywords-3\n erlang-font-lock-keywords-4)\n nil nil ((?_ . \"w\")) erlang-beginning-of-clause\n (font-lock-mark-block-function . erlang-mark-clause)\n (font-lock-syntactic-keywords\n ;; A dollar sign right before the double quote that ends a\n ;; string is not a character escape.\n ;;\n ;; And a \"string\" consists of a double quote not escaped by a\n ;; dollar sign, any number of non-backslash non-newline\n ;; characters or escaped backslashes, a dollar sign\n ;; (otherwise we wouldn't care) and a double quote. This\n ;; doesn't match multi-line strings, but this is probably\n ;; the best we can get, since while font-locking we don't\n ;; know whether matching started inside a string: limiting\n ;; search to a single line keeps things sane.\n . ((\"\\\\(?:^\\\\|[^$]\\\\)\\\"\\\\(?:[^\\\"\\n]\\\\|\\\\\\\\\\\"\\\\)*\\\\(\\\\$\\\\)\\\"\" 1 \"w\")\n ;; Likewise for atoms\n (\"\\\\(?:^\\\\|[^$]\\\\)'\\\\(?:[^'\\n]\\\\|\\\\\\\\'\\\\)*\\\\(\\\\$\\\\)'\" 1 \"w\")\n ;; And the dollar sign in $\\\" or $\\' escapes two\n ;; characters, not just one.\n (\"\\\\(\\\\$\\\\)\\\\\\\\[\\\"']\" 1 \"'\"))))))\n\n\n\n;; Useful when defining your own keywords.\n(defun erlang-font-lock-set-face (ks &rest faces)\n \"Replace the face components in a list of keywords.\n\nThe first argument, KS, is a list of keywords. The rest of the\narguments are expressions to replace the face information with. The\nfirst expression replaces the face of the first keyword, the second\nexpression the second keyword etc.\n\nShould an expression be nil, the face of the corresponding keyword is\nnot changed.\n\nShould fewer expressions than keywords be given, the last expression\nis used for all remaining keywords.\n\nNormally, the expressions are just atoms representing the new face.\nThey could however be more complex, returning different faces in\ndifferent situations.\n\nThis function only handles keywords with elements on the forms:\n (REGEXP NUMBER FACE)\n (REGEXP NUMBER FACE OVERWRITE)\n\nThis could be used when defining your own special font-lock setup, e.g:\n\n\\(setq my-font-lock-keywords\n (append erlang-font-lock-keywords-function-header\n erlang-font-lock-keywords-dollar\n (erlang-font-lock-set-face\n erlang-font-lock-keywords-macros 'my-neon-green-face)\n (erlang-font-lock-set-face\n erlang-font-lock-keywords-lc 'my-deep-red 'my-light-red)\n erlang-font-lock-keywords-attr))\n\nFor a more elaborate example, please see the beginning of the file\n`erlang.el'.\"\n (let ((res '()))\n (while ks\n (let* ((regexp (car (car ks)))\n (number (car (cdr (car ks))))\n (new-face (if (and faces (car faces))\n (car faces)\n (car (cdr (cdr (car ks))))))\n (overwrite (car (cdr (cdr (cdr (car ks))))))\n (new-keyword (list regexp number new-face)))\n (if overwrite (nconc new-keyword (list overwrite)))\n (setq res (cons new-keyword res))\n (setq ks (cdr ks))\n (if (and faces (cdr faces))\n (setq faces (cdr faces)))))\n (nreverse res)))\n\n\n(defun erlang-font-lock-level-0 ()\n ;; DocStringOrig: font-cmd\n \"Unfontify current buffer.\"\n (interactive)\n (font-lock-mode 0))\n\n\n(defun erlang-font-lock-level-1 ()\n ;; DocStringCopy: font-cmd\n \"Fontify current buffer at level 1.\nThis highlights function headers, reserved keywords, strings and comments.\"\n (interactive)\n (require 'font-lock)\n (set 'font-lock-keywords erlang-font-lock-keywords-1)\n (font-lock-mode 1)\n (funcall (symbol-function 'font-lock-fontify-buffer)))\n\n\n(defun erlang-font-lock-level-2 ()\n ;; DocStringCopy: font-cmd\n \"Fontify current buffer at level 2.\nThis highlights level 1 features (see `erlang-font-lock-level-1')\nplus bifs, guards and `single quotes'.\"\n (interactive)\n (require 'font-lock)\n (set 'font-lock-keywords erlang-font-lock-keywords-2)\n (font-lock-mode 1)\n (funcall (symbol-function 'font-lock-fontify-buffer)))\n\n\n(defun erlang-font-lock-level-3 ()\n ;; DocStringCopy: font-cmd\n \"Fontify current buffer at level 3.\nThis highlights level 2 features (see `erlang-font-lock-level-2')\nplus variables, macros and records.\"\n (interactive)\n (require 'font-lock)\n (set 'font-lock-keywords erlang-font-lock-keywords-3)\n (font-lock-mode 1)\n (funcall (symbol-function 'font-lock-fontify-buffer)))\n\n(defun erlang-font-lock-level-4 ()\n ;; DocStringCopy: font-cmd\n \"Fontify current buffer at level 4.\nThis highlights level 3 features (see `erlang-font-lock-level-2')\nplus variables, macros and records.\"\n (interactive)\n (require 'font-lock)\n (set 'font-lock-keywords erlang-font-lock-keywords-4)\n (font-lock-mode 1)\n (funcall (symbol-function 'font-lock-fontify-buffer)))\n\n\n(defun erlang-menu-init ()\n \"Init menus for Erlang mode.\n\nThe variable `erlang-menu-items' contain a description of the Erlang\nmode menu. Normally, the list contains atoms, representing variables\nbound to pieces of the menu.\n\nPersonal extensions could be added to `erlang-menu-personal-items'.\n\nThis function should be called if any variable describing the\nmenu configuration is changed.\"\n (erlang-menu-install \"Erlang\" erlang-menu-items erlang-mode-map))\n\n\n(defun erlang-menu-install (name items keymap)\n \"Install a menu in Emacs based on an abstract description.\n\nNAME is the name of the menu.\n\nITEMS is a list. The elements are either nil representing a horizontal\nline or a list with two or three elements. The first is the name of\nthe menu item, the second the function to call, or a submenu, on the\nsame same form as ITEMS. The third optional element is an expression\nwhich is evaluated every time the menu is displayed. Should the\nexpression evaluate to nil the menu item is ghosted.\n\nKEYMAP is the keymap to add to menu to.\n\nPlease see the variable `erlang-menu-base-items'.\"\n (define-key keymap (vector 'menu-bar (intern name))\n (erlang-menu-make-keymap name items)))\n\n\n(defun erlang-menu-make-keymap (name items)\n \"Build a menu.\"\n (let ((menumap (funcall (symbol-function 'make-sparse-keymap)\n name))\n (count 0)\n id def first second third)\n (setq items (reverse items))\n (while items\n ;; Replace any occurrence of atoms by their value.\n (while (and items (atom (car items)) (not (null (car items))))\n (if (and (boundp (car items))\n (listp (symbol-value (car items))))\n (setq items (append (reverse (symbol-value (car items)))\n (cdr items)))\n (setq items (cdr items))))\n (setq first (car-safe (car items)))\n (setq second (car-safe (cdr-safe (car items))))\n (setq third (car-safe (cdr-safe (cdr-safe (car items)))))\n (cond ((null first)\n (setq count (+ count 1))\n (setq id (intern (format \"separator-%d\" count)))\n (setq def '(\"--\" . nil)))\n ((and (consp second) (eq (car second) 'lambda))\n (setq count (+ count 1))\n (setq id (intern (format \"lambda-%d\" count)))\n (setq def (cons first second)))\n ((symbolp second)\n (setq id second)\n (setq def (cons first second)))\n (t\n (setq count (+ count 1))\n (setq id (intern (format \"submenu-%d\" count)))\n (setq def (erlang-menu-make-keymap first second))))\n (define-key menumap (vector id) def)\n (if third\n (put id 'menu-enable third))\n (setq items (cdr items)))\n (cons name menumap)))\n\n(defun erlang-menu-substitute (items alist)\n \"Substitute functions in menu described by ITEMS.\n\nThe menu ITEMS is updated destructively.\n\nALIST is list of pairs where the car is the old function and cdr the new.\"\n (let (first second pair)\n (while items\n (setq first (car-safe (car items)))\n (setq second (car-safe (cdr-safe (car items))))\n (cond ((null first))\n ((symbolp second)\n (setq pair (and second (assq second alist)))\n (if pair\n (setcar (cdr (car items)) (cdr pair))))\n ((and (consp second) (eq (car second) 'lambda)))\n (t\n (erlang-menu-substitute second alist)))\n (setq items (cdr items)))))\n\n\n(defun erlang-menu-add-above (entry above items)\n \"Add menu ENTRY above menu entry ABOVE in menu ITEMS.\nDo nothing if the items already should be in the menu.\nShould ABOVE not be in the list, the entry is added at\nthe bottom of the menu.\n\nThe new menu is returned. No guarantee is given that the original\nmenu is left unchanged.\n\nThe equality test is performed by `eq'.\n\nExample: (erlang-menu-add-above 'my-erlang-menu-items\n 'erlang-menu-man-items)\"\n (erlang-menu-add-below entry above items t))\n\n\n(defun erlang-menu-add-below (entry below items &optional above-p)\n \"Add menu ENTRY below menu items BELOW in the Erlang menu.\nDo nothing if the items already should be in the menu.\nShould BELOW not be in the list, items is added at the bottom\nof the menu.\n\nThe new menu is returned. No guarantee is given that the original\nmenu is left unchanged.\n\nThe equality test is performed by `eq'.\n\nExample:\n\n\\(setq erlang-menu-items\n (erlang-menu-add-below 'my-erlang-menu-items\n 'erlang-menu-base-items\n erlang-menu-items))\"\n (if (memq entry items)\n items ; Return the original menu.\n (let ((head '())\n (done nil)\n res)\n (while (not done)\n (cond ((null items)\n (setq res (append head (list entry)))\n (setq done t))\n ((eq below (car items))\n (setq res\n (if above-p\n (append head (cons entry items))\n (append head (cons (car items)\n (cons entry (cdr items))))))\n (setq done t))\n (t\n (setq head (append head (list (car items))))\n (setq items (cdr items)))))\n res)))\n\n(defun erlang-menu-delete (entry items)\n \"Delete ENTRY from menu ITEMS.\n\nThe new menu is returned. No guarantee is given that the original\nmenu is left unchanged.\"\n (delq entry items))\n\n;; Man code:\n\n(defun erlang-man-init ()\n \"Add menus containing the manual pages of the Erlang.\n\nThe variable `erlang-man-dirs' contains entries describing\nthe location of the manual pages.\"\n (interactive)\n (if (or erlang-man-inhibit\n (and (boundp 'menu-bar-mode)\n (not menu-bar-mode)))\n ()\n (setq erlang-menu-man-items\n '(nil\n (\"Man - Function\" erlang-man-function)\n (\"Man - Function Under Cursor\" erlang-man-function-no-prompt)))\n (if erlang-man-dirs\n (setq erlang-menu-man-items\n (append erlang-menu-man-items\n (erlang-man-make-top-menu erlang-man-dirs))))\n (setq erlang-menu-items\n (erlang-menu-add-above 'erlang-menu-man-items\n 'erlang-menu-version-items\n erlang-menu-items))\n (erlang-menu-init)))\n\n\n(defun erlang-man-uninstall ()\n \"Remove the man pages from the Erlang mode.\"\n (interactive)\n (setq erlang-menu-items\n (erlang-menu-delete 'erlang-menu-man-items erlang-menu-items))\n (erlang-menu-init))\n\n\n;; The man menu is a hierarchal structure, with the manual sections\n;; at the top, described by `erlang-man-dirs'. The next level could\n;; either be the manual pages if not to many, otherwise it is an index\n;; menu whose submenus will contain up to `erlang-man-max-menu-size'\n;; manual pages.\n\n(defun erlang-man-make-top-menu (dir-list)\n \"Create one menu entry per element of DIR-LIST.\nThe format is described in the documentation of `erlang-man-dirs'.\"\n (let ((menu '())\n dir)\n (while dir-list\n (setq dir (cond ((nth 2 (car dir-list))\n ;; Relative to `erlang-root-dir'.\n (erlang-man-dir (nth 1 (car dir-list)) t))\n (t\n ;; Absolute\n (nth 1 (car dir-list)))))\n (if (and dir\n (file-readable-p dir))\n (setq menu (cons (list (car (car dir-list))\n (erlang-man-make-middle-menu\n (erlang-man-get-files dir)))\n menu)))\n (setq dir-list (cdr dir-list)))\n ;; Should no menus be found, generate a menu item which\n ;; will display a help text, when selected.\n (if menu\n (nreverse menu)\n '((\"Man Pages\"\n ((\"Error! Why?\" erlang-man-describe-error)))))))\n\n\n(defcustom erlang-man-download-url \"http:\/\/erlang.org\/download\/otp_doc_man_22.1.tar.gz\"\n \"The URL from which the erlang-man-download function will\n download Erlang man pages \"\n :type 'string)\n\n(defun erlang-man-user-local-emacs-dir ()\n \"Returns the directory where man pages that are downloaded by\nthe functions erlang-man-download and erlang-man-download-ask are\nstored.\"\n (concat (file-name-as-directory (locate-user-emacs-file \"cache\"))\n (file-name-as-directory \"erlang_mode_man_pages\"))\n )\n\n(defun erlang-man-download (&optional download-url-param)\n \"Downloads the Erlang man pages into the\n\\\"cache\/erlang_mode_man_pages\\\" subdirectory under the user's\nEmacs directory, if the man pages haven't been downloaded\nalready. The URL from which the man pages are downloaded can be\nconfigured with the variable \\\"erlang-man-download-url\\\"\"\n (interactive)\n (let* ((download-url (or download-url-param erlang-man-download-url))\n (downloaded-man-dir (erlang-man-user-local-emacs-dir))\n (downloaded-man-url-file (concat\n (file-name-as-directory downloaded-man-dir)\n \"erlang_man_download_url\")))\n (if (and (file-exists-p downloaded-man-url-file)\n (string= download-url (with-temp-buffer\n (insert-file-contents downloaded-man-url-file)\n (buffer-string))))\n downloaded-man-dir\n (let ((man-file (concat (file-name-as-directory downloaded-man-dir) \"man.tar.gz\")))\n (message \"Downloading: %s to %s\" download-url man-file)\n (require 'url)\n (mkdir downloaded-man-dir t)\n (url-copy-file download-url man-file t)\n ;; Write the download URL to a file so that future calls to\n ;; erlang-man-download can check if the man cache should be\n ;; updated\n (write-region download-url nil downloaded-man-url-file)\n ;; url-copy-file unpacks the zip archive (at least on my\n ;; system) but this behavior is undocumented so do a tar with\n ;; the z flag as well\n (message \"Note that %s will only be unpacked automatically if your system has the tar tool in its path\" man-file)\n (shell-command (format \"tar -x -z -f %s -C %s\" man-file downloaded-man-dir))\n (message \"The error message above can be ignored if everything works fine\")\n (message \"Unpacking man pages using the command \\\"%s\\\"\"\n (format \"tar -x -f %s -C %s\" man-file downloaded-man-dir))\n (shell-command (format \"tar -x -f %s -C %s\" man-file downloaded-man-dir))\n (message \"Restarting erlang-mode\")\n (erlang-mode)\n downloaded-man-dir\n )\n )\n )\n )\n\n(defun erlang-man-download-ask (&optional subdir)\n \"Downloads the Erlang man pages into the\n\\\"cache\/erlang_mode_man_pages\\\" subdirectory under the user's\nEmacs directory, if the man pages haven't been downloaded\nalready. This function ask the user to confirm before downloading\nand lets the user edit the download URL. The function\nerlang-man-download downloads the man pages without prompting the\nuser.\"\n (interactive)\n (if (y-or-n-p \"Could not find Erlang man pages on your system. Do you want to download them?\")\n (let ((download-url (read-string \"URL to download man pages from: \" erlang-man-download-url)))\n (concat (directory-file-name (erlang-man-download download-url)) (or subdir \"\")))))\n\n\n(defun erlang-man-dir (subdir &optional no-download)\n (let ((default-man-dir (if erlang-root-dir\n (concat (directory-file-name (concat\n (file-name-as-directory erlang-root-dir)\n (file-name-as-directory \"lib\")\n (file-name-as-directory \"erlang\")))\n subdir)))\n (alt-man-dir (if erlang-root-dir\n (concat (directory-file-name erlang-root-dir) subdir)))\n (downloaded-man-dir (erlang-man-user-local-emacs-dir)))\n (if (and erlang-root-dir (file-directory-p default-man-dir))\n default-man-dir\n (if (and erlang-root-dir (file-directory-p alt-man-dir))\n alt-man-dir\n (if (file-directory-p (concat (directory-file-name downloaded-man-dir) subdir))\n (concat (directory-file-name downloaded-man-dir) subdir)\n (and (not no-download) (erlang-man-download-ask subdir)))))))\n\n;; Should the menu be to long, let's split it into a number of\n;; smaller menus. Warning, this code contains beautiful\n;; destructive operations!\n(defun erlang-man-make-middle-menu (filelist)\n \"Create the second level menu from FILELIST.\n\nShould the list be longer than `erlang-man-max-menu-size', a tree of\nmenus is created.\"\n (if (<= (length filelist) erlang-man-max-menu-size)\n (erlang-man-make-menu filelist)\n (let ((menu '())\n (filelist (copy-sequence filelist))\n segment submenu pair)\n (while filelist\n (setq pair (nthcdr (- erlang-man-max-menu-size 1) filelist))\n (setq segment filelist)\n (if (null pair)\n (setq filelist nil)\n (setq filelist (cdr pair))\n (setcdr pair nil))\n (setq submenu (erlang-man-make-menu segment))\n (setq menu (cons (list (concat (car (car submenu))\n \" -- \"\n (car (car (reverse submenu))))\n submenu)\n menu)))\n (nreverse menu))))\n\n\n(defun erlang-man-make-menu (filelist)\n \"Make a leaf menu based on FILELIST.\"\n (let ((menu '())\n item)\n (while filelist\n (setq item (erlang-man-make-menu-item (car filelist)))\n (if item\n (setq menu (cons item menu)))\n (setq filelist (cdr filelist)))\n (nreverse menu)))\n\n\n(defun erlang-man-make-menu-item (file)\n \"Create a menu item containing the name of the man page.\"\n (and (string-match \".+\/\\\\([^\/]+\\\\)\\\\.\\\\([124-9]\\\\|3\\\\(erl\\\\)?\\\\)\\\\(\\\\.gz\\\\)?$\" file)\n (let ((page (substring file (match-beginning 1) (match-end 1))))\n (list (capitalize page)\n (list 'lambda '()\n '(interactive)\n (list 'funcall 'erlang-man-display-function\n file))))))\n\n\n(defun erlang-man-get-files (dir)\n \"Return files in directory DIR.\"\n (directory-files dir t \".+\\\\.\\\\([124-9]\\\\|3\\\\(erl\\\\)?\\\\)\\\\(\\\\.gz\\\\)?\\\\'\"))\n\n\n(defun erlang-man-module (&optional module)\n \"Find manual page for MODULE, defaults to module of function under point.\nThis function is aware of imported functions.\"\n (interactive\n (list (let* ((mod (erlang-default-module))\n (input (read-string\n (format \"Manual entry for module%s: \"\n (if (or (null mod) (string= mod \"\"))\n \"\"\n (format \" (default %s)\" mod))))))\n (if (string= input \"\")\n mod\n input))))\n (setq module (or module\n (erlang-default-module)))\n (when (or (null module) (string= module \"\"))\n (error \"No Erlang module name given\"))\n (let ((dir-list erlang-man-dirs)\n (pat (concat \"\/\" (regexp-quote module)\n \"\\\\.\\\\([124-9]\\\\|3\\\\(erl\\\\)?\\\\)\\\\(\\\\.gz\\\\)?$\"))\n (file nil)\n file-list)\n (while (and dir-list (null file))\n (let ((dir (if (nth 2 (car dir-list))\n (erlang-man-dir (nth 1 (car dir-list)))\n (nth 1 (car dir-list)))))\n (when (file-directory-p dir)\n (setq file-list (erlang-man-get-files dir))\n (while (and file-list (null file))\n (if (string-match pat (car file-list))\n (setq file (car file-list)))\n (setq file-list (cdr file-list))))\n (setq dir-list (cdr dir-list))))\n (if file\n (funcall erlang-man-display-function file)\n ;; Did not found the manual file. Fallback to manual-entry.\n (manual-entry module))))\n\n(defun erlang-default-module ()\n (let ((id (erlang-get-identifier-at-point)))\n (if (eq (erlang-id-kind id) 'qualified-function)\n (erlang-id-module id)\n (erlang-id-name id))))\n\n\n;; Warning, the function `erlang-man-function' is a hack!\n;; It links itself into the man code in a non-clean way. I have\n;; chosen to keep it since it provides a very useful functionality\n;; which is not possible to achieve using a clean approach.\n;; \/ AndersL\n;;\n;; The previous hack seems to have broken in Emacs 25. This is fixed\n;; by trying to find the function in the man buffer a few times with a\n;; delay in between (see function\n;; erlang-man-repeated-search-for-function). This fix is also a hack\n;; but it should be quite robust and will work even if the function\n;; that erlang-man-function-display-man-page tries to hook into\n;; disappears or changes.\n\n(defvar erlang-man-function-name nil\n \"Name of function for last `erlang-man-function' call.\nUsed for communication between `erlang-man-function' and the\npatch to `Man-notify-when-ready'.\")\n\n(defun erlang-man-function-display-man-page (name)\n \"Helper function for erlang-man-function. Displays the man page\n text for the Erlang function named name if it can be found.\"\n (let ((modname nil)\n (funcname nil))\n (cond ((string-match \":\" name)\n (setq modname (substring name 0 (match-beginning 0)))\n (setq funcname (substring name (match-end 0) nil)))\n ((stringp name)\n (setq modname name)))\n (when (or (null modname) (string= modname \"\"))\n (error \"No Erlang module name given\"))\n (cond ((fboundp 'Man-notify-when-ready)\n ;; From Emacs 19: The man command could possibly start an\n ;; asynchronous process, i.e. we must hook ourselves into\n ;; the system to be activated when the man-process\n ;; terminates.\n (if (null funcname)\n ()\n (erlang-man-patch-notify)\n (setq erlang-man-function-name funcname))\n (condition-case err\n (erlang-man-module modname)\n (error (setq erlang-man-function-name nil)\n (signal (car err) (cdr err)))))\n (t\n (erlang-man-module modname)\n (when funcname\n (erlang-man-repeated-search-for-function nil\n funcname\n modname))))))\n\n(defun erlang-man-function (&optional name)\n \"Find manual page for NAME, where NAME is module:function.\nThe entry for `function' is displayed.\n\nThis function is aware of imported functions.\"\n (interactive\n (list (let* ((default (erlang-default-function-or-module))\n (input (read-string\n (format\n \"Manual entry for `module:func' or `module'%s: \"\n (if default\n (format \" (default %s)\" default)\n \"\")))))\n (if (string= input \"\")\n default\n input))))\n (require 'man)\n (setq name (or name\n (erlang-default-function-or-module)))\n (erlang-man-function-display-man-page name))\n\n\n(defun erlang-man-function-no-prompt ()\n \"Find manual page for the function under the cursor.\nThe man entry for `function' is displayed. This function\nprovides the same functionality as erlang-man-function except for\nthat it does not ask the user to confirm the function name before\nopening the man page for the function.\"\n (interactive)\n (let ((name (erlang-default-function-or-module)))\n (if name\n (erlang-man-function name)\n (error \"No function name under the cursor\"))))\n\n(defun erlang-man-repeated-search-for-function (man-buffer\n function-name\n &optional\n module-name)\n \"This function tries to scroll MAN-BUFFER to the documentation\nof function FUNCTION-NAME. The function will try again a few\ntimes if the documentation for FUNCTION-NAME can't be found. This\nis necessary as the man page is loaded asynchronously from Emacs\n19 and the correct function to hook into depends on the Emacs\nversion. The function will automatically try to find the correct\nbuffer from the list of opened buffers if MAN-BUFFER is nil. The\noptional parameter MODULE-NAME will make the search for the\nbuffer more accurate.\"\n (let* ((time-between-attempts 0.5)\n (max-wait-time 5.1)\n (search-for-function\n (lambda (self\n time-waited\n time-between-attempts\n max-wait-time\n man-buffer\n function-name\n module-name\n )\n (when (and (not (erlang-man-find-function man-buffer function-name module-name))\n (<= (+ time-waited time-between-attempts)\n max-wait-time))\n (message \"Finding function %s...\" function-name)\n ; Call this function again later\n (run-at-time time-between-attempts nil\n self\n self\n (+ time-waited time-between-attempts)\n time-between-attempts\n max-wait-time\n man-buffer\n function-name\n module-name)\n ))))\n (funcall search-for-function\n search-for-function\n 0.0\n time-between-attempts\n max-wait-time\n man-buffer\n function-name\n module-name)))\n\n;; Should the defadvice be at the top level, the package `advice' would\n;; be required. Now it is only required when this functionality\n;; is used. (Emacs 19 specific.)\n(defun erlang-man-patch-notify ()\n \"Patch the function `Man-notify-when-ready' to search for function.\nThe variable `erlang-man-function-name' is assumed to be bound to\nthe function name, or to nil.\n\nThe reason for patching a function is that under Emacs 19, the man\ncommand is executed asynchronously.\"\n (condition-case nil\n (require 'advice)\n ;; This should never happened since this is only called when\n ;; running under Emacs 19.\n (error (error (concat \"This command needs the package `advice', \"\n \"please upgrade your Emacs.\"))))\n (require 'man)\n (defadvice Man-notify-when-ready\n (after erlang-Man-notify-when-ready activate)\n \"Set point at the documentation of the function name in\n`erlang-man-function-name' when the man page is displayed.\"\n (if erlang-man-function-name\n (erlang-man-repeated-search-for-function (ad-get-arg 0)\n erlang-man-function-name)\n (setq erlang-man-function-name nil))))\n\n\n\n\n(defun erlang-man-find-function (buf func &optional module-name)\n \"Find manual page for function `erlang-man-function-name' in buffer BUF.\nThe function will automatically try to find the correct buffer among the\nopened buffers if BUF is nil. The optional parameter MODULE-NAME will make\nthe search for the buffer more accurate.\"\n (let ((buffer (or buf\n (progn\n ; find buffer containing man page\n (require 'cl-lib)\n (car (cl-remove-if-not (lambda (buf)\n (string-match\n (or module-name \"\")\n (format \"%s\" buf)))\n (cl-remove-if-not\n (lambda (buf)\n (string-match\n \"[Mm][Aa][Nn]\"\n (format \"%s\" buf)))\n (buffer-list))))))))\n (if (and func buffer)\n (let ((win (get-buffer-window buffer)))\n (if win\n (progn\n (set-buffer buffer)\n (goto-char (point-min))\n (if (re-search-forward\n (concat \"^[ \\t]*\\\\([a-z0-9_]*[ \\t]*:\\\\)?[ \\t]*\" func \"[ \\t]*([A-Za-z0-9 \\t:,_()]*)[ \\t]*->\")\n (point-max) t)\n (progn\n (forward-word -1)\n (set-window-point win (point))\n (message \"Found documentation for function `%s'\" func)\n t)\n (if (re-search-forward\n (concat \"^[ \\t]*\\\\([a-z0-9_]*[ \\t]*:\\\\)?[ \\t]*\" func \"[ \\t]*\\(\")\n (point-max) t)\n (progn\n (forward-word -1)\n (set-window-point win (point))\n (message \"Found documentation for function `%s'\" func)\n t)\n (progn\n (message \"Could not find function `%s'\" func)\n nil)))))))))\n\n(defvar erlang-man-file-regexp\n \"\\\\(.*\\\\)\/man[^\/]*\/\\\\([^.]+\\\\)\\\\.\\\\([124-9]\\\\|3\\\\(erl\\\\)?\\\\)\\\\(\\\\.gz\\\\)?$\")\n\n(defun erlang-man-display (file)\n \"Display FILE as a `man' file.\nThis is the default manual page display function.\nThe variables `erlang-man-display-function' contains the function\nto be used.\"\n (require 'man)\n (if file\n (let ((process-environment (copy-sequence process-environment)))\n (if (string-match erlang-man-file-regexp file)\n (let ((dir (substring file (match-beginning 1) (match-end 1)))\n (page (substring file (match-beginning 2) (match-end 2))))\n (setenv \"MANPATH\" dir)\n (manual-entry page))\n (error \"Can't find man page for %s\\n\" file)))))\n\n\n(defun erlang-man-describe-error ()\n \"Describe why the manual pages weren't found.\"\n (interactive)\n (with-output-to-temp-buffer \"*Erlang Man Error*\"\n (princ \"Normally, this menu should contain Erlang manual pages.\n\nIn order to find the manual pages, the variable `erlang-root-dir'\nshould be bound to the name of the directory containing the Erlang\ninstallation. The name should not include the final slash.\n\nPractically, you should add a line on the following form to\nyour ~\/.emacs, or ask your system administrator to add it to\nthe site init file:\n (setq erlang-root-dir \\\"\/the\/erlang\/root\/dir\/goes\/here\\\")\n\nFor example:\n (setq erlang-root-dir \\\"\/usr\/local\/erlang\\\")\n\nAlternatively, you can download the Erlang man pages\nautomatically by placing the following lines in your Emacs init\nfile or by executing the Emacs command `M-x\nerlang-man-download-ask RET' (the download URL can be customized\nwith the Emacs variable erlang-man-download-url):\n\n (require 'erlang)\n (erlang-man-download)\n\nAfter installing the line\/lines in your Emacs init file or after\nrunning the command `M-x erlang-man-download-ask RET', kill and\nrestart Emacs, or restart Erlang mode with the command `M-x\nerlang-mode RET'.\")))\n\n;; Skeleton code:\n\n;; This code is based on the package `tempo' which is part of modern\n;; Emacsen.\n\n(defvar erlang-skel)\n(defun erlang-skel-init ()\n \"Generate the skeleton functions and menu items.\nThe variable `erlang-skel' contains the name and descriptions of\nall skeletons.\n\nThe skeleton routines are based on the `tempo' package. Should this\npackage not be present, this function does nothing.\"\n (interactive)\n (require 'tempo)\n (let ((skel erlang-skel)\n (menu '()))\n (while skel\n (cond ((null (car skel))\n (setq menu (cons nil menu)))\n (t\n (funcall (symbol-function 'tempo-define-template)\n (concat \"erlang-\" (nth 1 (car skel)))\n ;; The tempo template used contains an `include'\n ;; function call only, hence changes to the\n ;; variables describing the templates take effect\n ;; immediately.\n (list (list 'erlang-skel-include (nth 2 (car skel))))\n (nth 1 (car skel))\n (car (car skel))\n 'erlang-tempo-tags)\n (setq menu (cons (erlang-skel-make-menu-item\n (car skel)) menu))))\n (setq skel (cdr skel)))\n (setq erlang-menu-skel-items\n (list nil (list \"Skeletons\" (nreverse menu))))\n (setq erlang-menu-items\n (erlang-menu-add-above 'erlang-menu-skel-items\n 'erlang-menu-version-items\n erlang-menu-items))\n (erlang-menu-init)))\n\n(defun erlang-skel-make-menu-item (skel)\n (let ((func (intern (concat \"tempo-template-erlang-\" (nth 1 skel)))))\n (cond ((null (nth 3 skel))\n (list (car skel) func))\n (t\n (list (car skel)\n (list 'lambda '()\n '(interactive)\n (list 'funcall\n (list 'quote (nth 3 skel))\n (list 'quote func))))))))\n\n;; Functions designed to be added to the skeleton menu.\n;; (Not normally used)\n(defun erlang-skel-insert (func)\n \"Insert skeleton generated by FUNC and goto first tempo mark.\"\n (save-excursion (funcall func))\n (funcall (symbol-function 'tempo-forward-mark)))\n\n(defun erlang-skel-header (func)\n \"Insert the header generated by FUNC at the beginning of the buffer.\"\n (goto-char (point-min))\n (save-excursion (funcall func))\n (funcall (symbol-function 'tempo-forward-mark)))\n\n\n;; Functions used inside the skeleton descriptions.\n(defun erlang-skel-skip-blank ()\n (skip-chars-backward \" \\t\")\n nil)\n\n(defun erlang-skel-include (&rest args)\n \"Include a template inside another template.\n\nExample of use, assuming that `erlang-skel-func' is defined:\n\n (defvar foo-skeleton '(\\\"%%% New function:\\\"\n (erlang-skel-include erlang-skel-func)))\n\nTechnically, this function returns the `tempo' attribute`(l ...)' which\ncan contain other `tempo' attributes. Please see the function\n`tempo-define-template' for a description of the `(l ...)' attribute.\"\n (let ((res '())\n entry)\n (while args\n (setq entry (car args))\n (while entry\n (setq res (cons (car entry) res))\n (setq entry (cdr entry)))\n (setq args (cdr args)))\n (cons 'l (nreverse res))))\n\n(defvar erlang-skel-separator-length 70)\n\n(defun erlang-skel-separator (&optional percent)\n \"Return a comment separator.\"\n (let ((percent (or percent 3)))\n (concat (make-string percent ?%)\n (make-string (- erlang-skel-separator-length percent) ?-)\n \"\\n\")))\n\n(defun erlang-skel-double-separator (&optional percent)\n \"Return a comment separator.\"\n (let ((percent (or percent 3)))\n (concat (make-string percent ?%)\n (make-string (- erlang-skel-separator-length percent) ?=)\n \"\\n\")))\n\n(defun erlang-skel-dd-mmm-yyyy ()\n \"Return the current date as a string in \\\"DD Mon YYYY\\\" form.\nThe first character of DD is space if the value is less than 10.\"\n (let ((date (current-time-string)))\n (format \"%2d %s %s\"\n (string-to-number (substring date 8 10))\n (substring date 4 7)\n (substring date -4))))\n\n;; Indentation code:\n\n(defun erlang-indent-command (&optional whole-exp)\n \"Indent current line as Erlang code.\nWith argument, indent any additional lines of the same clause\nrigidly along with this one.\"\n (interactive \"P\")\n (if whole-exp\n ;; If arg, always indent this line as Erlang\n ;; and shift remaining lines of clause the same amount.\n (let ((shift-amt (erlang-indent-line))\n beg end)\n (save-excursion\n (if erlang-tab-always-indent\n (beginning-of-line))\n (setq beg (point))\n (erlang-end-of-clause 1)\n (setq end (point))\n (goto-char beg)\n (forward-line 1)\n (setq beg (point)))\n (if (> end beg)\n (indent-code-rigidly beg end shift-amt \"\\n\")))\n (if (and (not erlang-tab-always-indent)\n (save-excursion\n (skip-chars-backward \" \\t\")\n (not (bolp))))\n (insert-tab)\n (erlang-indent-line))))\n\n\n(defun erlang-indent-line ()\n \"Indent current line as Erlang code.\nReturn the amount the indentation changed by.\"\n (let ((pos (- (point-max) (point)))\n indent beg\n shift-amt)\n (beginning-of-line 1)\n (setq beg (point))\n (skip-chars-forward \" \\t\")\n (cond ((looking-at \"%\")\n (setq indent (funcall comment-indent-function))\n (setq shift-amt (- indent (current-column))))\n (t\n (setq indent (erlang-calculate-indent))\n (cond ((null indent)\n (setq indent (current-indentation)))\n ((eq indent t)\n ;; This should never occur here.\n (error \"Erlang mode error\"))\n ;;((= (char-syntax (following-char)) ?\\))\n ;; (setq indent (1- indent)))\n )\n (setq shift-amt (- indent (current-column)))))\n (if (zerop shift-amt)\n nil\n (delete-region beg (point))\n (indent-to indent))\n ;; If initial point was within line's indentation, position\n ;; after the indentation. Else stay at same point in text.\n (if (> (- (point-max) pos) (point))\n (goto-char (- (point-max) pos)))\n (run-hooks 'erlang-indent-line-hook)\n shift-amt))\n\n\n(defun erlang-indent-region (beg end)\n \"Indent region of Erlang code.\n\nThis is automagically called by the user level function `indent-region'.\"\n (interactive \"r\")\n (save-excursion\n (let ((case-fold-search nil)\n (continue t)\n (from-end (- (point-max) end))\n indent-point;; The beginning of the current line\n indent;; The indent amount\n state)\n (goto-char beg)\n (beginning-of-line)\n (setq indent-point (point))\n (erlang-beginning-of-clause)\n ;; Parse the Erlang code from the beginning of the clause to\n ;; the beginning of the region.\n (while (< (point) indent-point)\n (let ((pt (point)))\n (setq state (erlang-partial-parse pt indent-point state))\n (if (= pt (point))\n (error \"Illegal syntax\"))))\n ;; Indent every line in the region\n (while continue\n (goto-char indent-point)\n (skip-chars-forward \" \\t\")\n (cond ((looking-at \"%\")\n ;; Do not use our stack to help the user to customize\n ;; comment indentation.\n (setq indent (funcall comment-indent-function)))\n ((looking-at \"$\")\n ;; Don't indent empty lines.\n (setq indent 0))\n (t\n (setq indent\n (save-excursion\n (erlang-calculate-stack-indent (point) state)))\n (cond ((null indent)\n (setq indent (current-indentation)))\n ((eq indent t)\n ;; This should never occur here.\n (error \"Erlang mode error\"))\n ;;((= (char-syntax (following-char)) ?\\))\n ;; (setq indent (1- indent)))\n )))\n (if (zerop (- indent (current-column)))\n nil\n (delete-region indent-point (point))\n (indent-to indent))\n ;; Find the next line in the region\n (goto-char indent-point)\n (save-excursion\n (forward-line 1)\n (setq indent-point (point)))\n (if (>= from-end (- (point-max) indent-point))\n (setq continue nil)\n (while (< (point) indent-point)\n (let ((pt (point)))\n (setq state (erlang-partial-parse\n pt indent-point state))\n (if (= pt (point))\n (error \"Illegal syntax\")))))))))\n\n\n(defun erlang-indent-current-buffer ()\n \"Indent current buffer as Erlang code.\"\n (interactive)\n (save-excursion\n (save-restriction\n (widen)\n (erlang-indent-region (point-min) (point-max)))))\n\n\n(defun erlang-indent-function ()\n \"Indent current Erlang function.\"\n (interactive)\n (save-excursion\n (let ((end (progn (erlang-end-of-function 1) (point)))\n (beg (progn (erlang-beginning-of-function 1) (point))))\n (erlang-indent-region beg end))))\n\n\n(defun erlang-indent-clause ()\n \"Indent current Erlang clause.\"\n (interactive)\n (save-excursion\n (let ((end (progn (erlang-end-of-clause 1) (point)))\n (beg (progn (erlang-beginning-of-clause 1) (point))))\n (erlang-indent-region beg end))))\n\n\n(defmacro erlang-push (x stack) (list 'setq stack (list 'cons x stack)))\n(defmacro erlang-pop (stack) (list 'setq stack (list 'cdr stack)))\n;; Would much prefer to make caddr a macro but this clashes.\n(defun erlang-caddr (x) (car (cdr (cdr x))))\n\n\n(defun erlang-calculate-indent (&optional parse-start)\n \"Compute appropriate indentation for current line as Erlang code.\nReturn nil if line starts inside string, t if in a comment.\"\n (save-excursion\n (let ((indent-point (point))\n (case-fold-search nil)\n (state nil))\n (if parse-start\n (goto-char parse-start)\n (erlang-beginning-of-clause))\n (while (< (point) indent-point)\n (let ((pt (point)))\n (setq state (erlang-partial-parse pt indent-point state))\n (if (= pt (point))\n (error \"Illegal syntax\"))))\n (erlang-calculate-stack-indent indent-point state))))\n\n(defun erlang-show-syntactic-information ()\n \"Show syntactic information for current line.\"\n\n (interactive)\n\n (save-excursion\n (let ((starting-point (point))\n (case-fold-search nil)\n (state nil))\n (erlang-beginning-of-clause)\n (while (< (point) starting-point)\n (setq state (erlang-partial-parse (point) starting-point state)))\n (message \"%S\" state))))\n\n\n(defun erlang-partial-parse (from to &optional state)\n \"Parse Erlang syntax starting at FROM until TO, with an optional STATE.\nValue is list (stack token-start token-type in-what).\"\n (goto-char from) ; Start at the beginning\n (erlang-skip-blank to)\n (let ((cs (char-syntax (following-char)))\n (stack (car state))\n (token (point))\n in-what)\n (cond\n\n ;; Done: Return previous state.\n ((>= token to)\n (setq token (nth 1 state))\n (setq cs (nth 2 state))\n (setq in-what (nth 3 state)))\n\n ;; Word constituent: check and handle keywords.\n ((= cs ?w)\n (cond ((looking-at \"\\\\(end\\\\|after\\\\)[^_a-zA-Z0-9]\")\n ;; Must pop top icr layer, `after' will push a new\n ;; layer next.\n (progn\n (while (and stack (eq (car (car stack)) '->))\n (erlang-pop stack))\n (if (and stack (memq (car (car stack)) '(icr begin fun try)))\n (erlang-pop stack))))\n ((looking-at \"catch\\\\b.*of\")\n t)\n ((looking-at \"catch\\\\b\\\\s *\\\\($\\\\|%\\\\|.*->\\\\)\")\n ;; Must pop top icr layer, `catch' in try\/catch\n ;;will push a new layer next.\n (progn\n (while (and stack (eq (car (car stack)) '->))\n (erlang-pop stack))\n (if (and stack (memq (car (car stack)) '(icr begin try)))\n (erlang-pop stack))))\n )\n (cond ((looking-at \"\\\\(if\\\\|case\\\\|receive\\\\)[^_a-zA-Z0-9]\")\n ;; Must push a new icr (if\/case\/receive) layer.\n (erlang-push (list 'icr token (current-column)) stack))\n ((looking-at \"\\\\(try\\\\|after\\\\)[^_a-zA-Z0-9]\")\n ;; Must handle separately, try catch or try X of -> catch\n ;; same for `after', it could be\n ;; receive after Time -> X end, or\n ;; try after X end\n (erlang-push (list 'try token (current-column)) stack))\n ((looking-at \"\\\\(of\\\\)[^_a-zA-Z0-9]\")\n ;; Must handle separately, try X of -> catch\n (if (and stack (eq (car (car stack)) 'try))\n (let ((try-column (nth 2 (car stack)))\n (try-pos (nth 1 (car stack))))\n (erlang-pop stack)\n (erlang-push (list 'icr try-pos try-column) stack))))\n\n ((looking-at \"\\\\(fun\\\\)[^_a-zA-Z0-9]\")\n ;; Push a new layer if we are defining a `fun'\n ;; expression, not when we are refering an existing\n ;; function. 'fun's defines are only indented one level now.\n (if (save-excursion\n (goto-char (match-end 1))\n (erlang-skip-blank to)\n ;; Use erlang-variable-regexp here to look for an\n ;; optional variable name to match EEP37 named funs.\n (if (looking-at erlang-variable-regexp)\n (progn\n (goto-char (match-end 0))\n (erlang-skip-blank to)))\n (eq (following-char) ?\\())\n (erlang-push (list 'fun token (current-column)) stack)))\n ((looking-at \"\\\\(begin\\\\)[^_a-zA-Z0-9]\")\n (erlang-push (list 'begin token (current-column)) stack))\n ;; Normal when case\n ;;((looking-at \"when\\\\s \")\n ;;((looking-at \"when\\\\s *\\\\($\\\\|%\\\\)\")\n ((looking-at \"when[^_a-zA-Z0-9]\")\n (erlang-push (list 'when token (current-column)) stack))\n ((looking-at \"catch\\\\b.*of\")\n t)\n ((looking-at \"catch\\\\b\\\\s *\\\\($\\\\|%\\\\|.*->\\\\)\")\n (erlang-push (list 'icr token (current-column)) stack))\n ;;(erlang-push (list '-> token (current-column)) stack))\n ;;((looking-at \"^of$\")\n ;; (erlang-push (list 'icr token (current-column)) stack)\n ;;(erlang-push (list '-> token (current-column)) stack))\n )\n (forward-sexp 1))\n ;; String: Try to skip over it. (Catch error if not complete.)\n ((= cs ?\\\")\n (condition-case nil\n (progn\n (forward-sexp 1)\n (if (> (point) to)\n (progn\n (setq in-what 'string)\n (goto-char to))))\n (error\n (setq in-what 'string)\n (goto-char to))))\n\n ;; Expression prefix e.i. $ or ^ (Note ^ can be in the character\n ;; literal $^ or part of string and $ outside of a string denotes\n ;; a character literal)\n ((= cs ?')\n (cond\n ((= (following-char) ?\\\") ;; $ or ^ was the last char in a string\n (forward-char 1))\n (t\n ;; Maybe a character literal, quote the next char to avoid\n ;; situations as $\" being seen as the begining of a string.\n ;; Note the quoting something in the middle of a string is harmless.\n (quote (following-char))\n (forward-char 1))))\n\n ;; Symbol constituent or punctuation\n\n ((memq cs '(?. ?_))\n (cond\n\n ;; Clause end\n ((= (following-char) ?\\;)\n (if (eq (car (car (last stack))) 'spec)\n (while (memq (car (car stack)) '(when ::))\n (erlang-pop stack)))\n (if (and stack (eq (car (car stack)) '->))\n (erlang-pop stack))\n (forward-char 1))\n\n ;; Parameter separator\n ((looking-at \",\")\n (forward-char 1)\n (if (and stack (eq (car (car stack)) '::))\n ;; Type or spec\n (erlang-pop stack)))\n\n ;; Function end\n ((looking-at \"\\\\.\\\\(\\\\s \\\\|\\n\\\\|\\\\s<\\\\)\")\n (setq stack nil)\n (forward-char 1))\n\n ;; Function head\n ((looking-at \"->\")\n (if (and stack (eq (car (car stack)) 'when))\n (erlang-pop stack))\n (erlang-push (list '-> token (current-column)) stack)\n (forward-char 2))\n\n ;; List-comprehension divider\n ((looking-at \"||\")\n (erlang-push (list '|| token (current-column)) stack)\n (forward-char 2))\n\n ;; Bit-syntax open. Note that map syntax allows \"<<\" to follow \":=\"\n ;; or \"=>\" without intervening whitespace, so handle that case here\n ((looking-at \"\\\\(:=\\\\|=>\\\\)?<<\")\n (erlang-push (list '<< token (current-column)) stack)\n (forward-char (- (match-end 0) (match-beginning 0))))\n\n ;; Bit-syntax close\n ((looking-at \">>\")\n (while (memq (car (car stack)) '(|| ->))\n (erlang-pop stack))\n (cond ((eq (car (car stack)) '<<)\n (erlang-pop stack))\n ((memq (car (car stack)) '(icr begin fun))\n (error \"Missing `end'\"))\n (t\n (error \"Unbalanced parentheses\")))\n (forward-char 2))\n\n ;; Macro\n ((= (following-char) ??)\n ;; Skip over the ?\n (forward-char 1)\n )\n\n ;; Type spec's\n ((looking-at \"-type\\\\s \\\\|-opaque\\\\s \")\n (if stack\n (forward-char 1)\n (erlang-push (list 'type token (current-column)) stack)\n (forward-char 6)))\n ((looking-at \"-spec\\\\s \")\n (if stack\n (forward-char 1)\n (forward-char 6)\n (erlang-push (list 'spec (point) (current-column)) stack)\n (skip-chars-forward \"^(\\n\")\n (erlang-push (list 'spec_arg (point) (current-column)) stack)\n ))\n\n ;; Type spec delimiter\n ((looking-at \"::\")\n (erlang-push (list ':: token (current-column)) stack)\n (forward-char 2))\n\n ;; Don't follow through in the clause below\n ;; '|' don't need spaces around it\n ((looking-at \"|\")\n (forward-char 1))\n\n ;; Other punctuation: Skip over it and any following punctuation\n ((= cs ?.)\n ;; Skip over all characters in the operand.\n (skip-syntax-forward \".\"))\n\n ;; Other char: Skip over it.\n (t\n (forward-char 1))))\n\n ;; Open parenthesis\n ((= cs ?\\()\n (erlang-push (list '\\( token (current-column)) stack)\n (forward-char 1))\n\n ;; Close parenthesis\n ((= cs ?\\))\n (while (memq (car (car stack)) '(|| -> :: when))\n (erlang-pop stack))\n (cond ((eq (car (car stack)) '\\()\n (erlang-pop stack)\n (if (and (eq (car (car stack)) 'fun)\n (or (eq (car (car (last stack))) 'spec)\n (eq (car (car (last stack))) 'type))) ;; -type()\n ;; Inside fun type def ') closes fun definition\n (erlang-pop stack)))\n ((eq (car (car stack)) 'icr)\n (erlang-pop stack)\n ;; Normal catch not try-catch might have caused icr\n ;; and then incr should be removed and is not an error.\n (if (eq (car (car stack)) '\\()\n (erlang-pop stack)\n (error \"Missing `end'\")\n ))\n ((eq (car (car stack)) 'begin)\n (error \"Missing `end'\"))\n (t\n (error \"Unbalanced parenthesis\"))\n )\n (forward-char 1))\n\n ;; Character quote: Skip it and the quoted char.\n ((= cs ?\/)\n (forward-char 2))\n\n ;; Character escape: Skip it and the escape sequence.\n ((= cs ?\\\\)\n (forward-char 1)\n (skip-syntax-forward \"w\"))\n\n ;; Everything else\n (t\n (forward-char 1)))\n (list stack token cs in-what)))\n\n(defun erlang-calculate-stack-indent (indent-point state)\n \"From the given last position and state (stack) calculate indentation.\nReturn nil if inside string, t if in a comment.\"\n (let* ((stack (and state (car state)))\n (token (nth 1 state))\n (stack-top (and stack (car stack))))\n (cond ((null state) ;No state\n 0)\n ((nth 3 state)\n ;; Return nil or t.\n (eq (nth 3 state) 'comment))\n ((null stack)\n (if (looking-at \"when[^_a-zA-Z0-9]\")\n erlang-indent-guard\n 0))\n ((eq (car stack-top) '\\()\n ;; Element of list, tuple or part of an expression,\n (cond ((null erlang-argument-indent)\n ;; indent to next column.\n (1+ (nth 2 stack-top)))\n ((= (char-syntax (following-char)) ?\\))\n (goto-char (nth 1 stack-top))\n (cond ((erlang-record-or-function-args-p)\n ;; Line ends with parenthesis.\n (let ((previous (erlang-indent-find-preceding-expr))\n (stack-pos (nth 2 stack-top)))\n (if (>= previous stack-pos) stack-pos\n (- (+ previous erlang-argument-indent) 1))))\n (t\n (nth 2 stack-top))))\n ((looking-at \"||\")\n (erlang-indent-element stack-top indent-point token))\n ((memq (following-char) '(?, ?|))\n ;; a comma at the start of the line: line up with opening parenthesis.\n (min (nth 2 stack-top)\n (erlang-indent-element stack-top indent-point token)))\n (t\n (erlang-indent-element stack-top indent-point token))))\n ;;\n ((eq (car stack-top) '<<)\n ;; Element of binary (possible comprehension) expression,\n (cond ((null erlang-argument-indent)\n ;; indent to next column.\n (+ 2 (nth 2 stack-top)))\n ((looking-at \"\\\\(>>\\\\)[^_a-zA-Z0-9]\")\n (nth 2 stack-top))\n ((= (following-char) ?,)\n (min (+ (nth 2 stack-top) 1)\n (- (erlang-indent-to-first-element stack-top 2) 1)))\n (t\n (erlang-indent-to-first-element stack-top 2))))\n\n ((memq (car stack-top) '(icr fun spec_arg))\n ;; The default indentation is the column of the option\n ;; directly following the keyword. (This does not apply to\n ;; `case'.) Should no option be on the same line, the\n ;; indentation is the indentation of the keyword +\n ;; `erlang-indent-level'.\n ;;\n ;; `after' should be indented to the same level as the\n ;; corresponding receive.\n (cond ((looking-at \"\\\\(after\\\\|of\\\\)\\\\($\\\\|[^_a-zA-Z0-9]\\\\)\")\n (nth 2 stack-top))\n ((looking-at \"when[^_a-zA-Z0-9]\")\n ;; Handling one when part\n (+ (nth 2 stack-top) erlang-indent-level erlang-indent-guard))\n (t\n (save-excursion\n (goto-char (nth 1 stack-top))\n (if (and erlang-icr-indent\n (looking-at \"\\\\(if\\\\|case\\\\|receive\\\\|try\\\\)[^_a-zA-Z0-9]\"))\n (+ (nth 2 stack-top) erlang-icr-indent)\n (if (looking-at \"\\\\(case\\\\|receive\\\\|try\\\\)[^_a-zA-Z0-9]\")\n (+ (nth 2 stack-top) erlang-indent-level)\n (skip-chars-forward \"a-z\")\n (skip-chars-forward \" \\t\")\n (if (memq (following-char) '(?% ?\\n))\n (+ (nth 2 stack-top) erlang-indent-level)\n (current-column))))))))\n ((and (eq (car stack-top) '||) (looking-at \"\\\\(]\\\\|>>\\\\)[^_a-zA-Z0-9]\"))\n (nth 2 (car (cdr stack))))\n ;; Real indentation, where operators create extra indentation etc.\n ((memq (car stack-top) '(-> || try begin))\n (if (looking-at \"\\\\(of\\\\)[^_a-zA-Z0-9]\")\n (nth 2 stack-top)\n (goto-char (nth 1 stack-top))\n ;; Check if there is more code after the '->' on the\n ;; same line. If so use this indentation as base, else\n ;; use parent indentation + 2 * level as base.\n (let ((off erlang-indent-level)\n (skip 2))\n (cond ((null (cdr stack))) ; Top level in function.\n ((eq (car stack-top) 'begin)\n (setq skip 5))\n ((eq (car stack-top) 'try)\n (setq skip 5))\n ((eq (car stack-top) '->)\n ;; If in fun definition use standard indent level not double\n ;;(if (not (eq (car (car (cdr stack))) 'fun))\n ;; Removed it made multi clause Named fun's look too bad\n (setq off (+ erlang-indent-level\n (if (not erlang-icr-indent)\n erlang-indent-level\n erlang-icr-indent)))))\n (let ((base (erlang-indent-find-base stack indent-point off skip)))\n ;; Special cases\n (goto-char indent-point)\n (cond ((looking-at \"\\\\(;\\\\|end\\\\|after\\\\)\\\\($\\\\|[^_a-zA-Z0-9]\\\\)\")\n (if (eq (car stack-top) '->)\n (erlang-pop stack))\n (cond ((and stack (looking-at \";\"))\n (+ (erlang-caddr (car stack)) (- erlang-indent-level 2)))\n (stack (erlang-caddr (car stack)))\n (t off)))\n ((looking-at \"catch\\\\b\\\\($\\\\|[^_a-zA-Z0-9]\\\\)\")\n ;; Are we in a try\n (let ((start (if (eq (car stack-top) '->)\n (car (cdr stack))\n stack-top)))\n (if (null start) nil\n (goto-char (nth 1 start)))\n (cond ((looking-at \"try\\\\($\\\\|[^_a-zA-Z0-9]\\\\)\")\n (progn\n (if (eq (car stack-top) '->)\n (erlang-pop stack))\n (if stack\n (erlang-caddr (car stack))\n 0)))\n (t (erlang-indent-standard indent-point token base 'nil))))) ;; old catch\n ;; Indent result types\n ((eq (car (car (cdr stack))) 'spec_arg)\n (setq base (+ (erlang-caddr (car (last stack))) erlang-indent-level))\n (erlang-indent-standard indent-point token base 'nil))\n (t\n (erlang-indent-standard indent-point token base 'nil)\n ))))\n ))\n ((eq (car stack-top) 'when)\n (goto-char (nth 1 stack-top))\n (if (looking-at \"when\\\\s *\\\\($\\\\|%\\\\)\")\n (progn\n (erlang-pop stack)\n (if (and stack (memq (nth 0 (car stack)) '(icr fun)))\n (progn\n (goto-char (nth 1 (car stack)))\n (+ (nth 2 (car stack)) erlang-indent-guard\n ;; receive XYZ or receive\n ;; XYZ\n ;; This if thing does not seem to be needed\n ;;(if (looking-at \"[a-z]+\\\\s *\\\\($\\\\|%\\\\)\")\n ;; erlang-indent-level\n ;; (* 2 erlang-indent-level))))\n (* 2 erlang-indent-level)))\n ;;erlang-indent-level))\n (+ erlang-indent-level erlang-indent-guard)))\n ;; \"when\" is followed by code, let's indent to the same\n ;; column.\n (forward-char 4) ; Skip \"when\"\n (skip-chars-forward \" \\t\")\n (current-column)))\n ;; Type and Spec indentation\n ((eq (car stack-top) '::)\n (if (looking-at \"[},)]\")\n ;; Closing function spec, record definition with types,\n ;; or a comma at the start of the line\n ;; pop stack and recurse\n (erlang-calculate-stack-indent indent-point\n (cons (erlang-pop stack) (cdr state)))\n (cond ((null erlang-argument-indent)\n ;; indent to next column.\n (+ 2 (nth 2 stack-top)))\n ((looking-at \"::[^_a-zA-Z0-9]\")\n (nth 2 stack-top))\n (t\n (let ((start-alternativ (if (looking-at \"|\") 2 0)))\n (goto-char (nth 1 stack-top))\n (- (cond ((looking-at \"::\\\\s *\\\\($\\\\|%\\\\)\")\n ;; Line ends with ::\n (if (eq (car (car (last stack))) 'spec)\n (+ (erlang-indent-find-preceding-expr 1)\n erlang-argument-indent)\n (+ (erlang-indent-find-preceding-expr 2)\n erlang-argument-indent)))\n (t\n ;; Indent to the same column as the first\n ;; argument.\n (goto-char (+ 2 (nth 1 stack-top)))\n (skip-chars-forward \" \\t\")\n (current-column))) start-alternativ))))))\n )))\n\n(defun erlang-indent-to-first-element (stack-top extra)\n ;; Indent to the same column as the first\n ;; argument. extra should be 1 for lists tuples or 2 for binaries\n (goto-char (+ (nth 1 stack-top) extra))\n (skip-chars-forward \" \\t\")\n (current-column))\n\n(defun erlang-indent-element (stack-top indent-point token)\n (goto-char (nth 1 stack-top))\n (let ((base (cond ((erlang-record-or-function-args-p)\n ;; Line ends with parenthesis.\n (erlang-indent-parenthesis (nth 2 stack-top)))\n (t\n (erlang-indent-to-first-element stack-top 1)))))\n (erlang-indent-standard indent-point token base 't)))\n\n(defun erlang-indent-standard (indent-point token base inside-parenthesis)\n \"Standard indent when in blocks or tuple or arguments.\n Look at last thing to see in what state we are, move relative to the base.\"\n (goto-char token)\n (cond ((looking-at \"||\\\\|,\\\\|->\\\\||\")\n base)\n ((erlang-at-keyword)\n (+ (current-column) erlang-indent-level))\n ((or (= (char-syntax (following-char)) ?.)\n (erlang-at-operator))\n (+ base erlang-indent-level))\n (t\n (goto-char indent-point)\n (cond ((memq (following-char) '(?\\( ))\n ;; Function application.\n (+ (erlang-indent-find-preceding-expr)\n erlang-argument-indent))\n ;; Empty line, or end; treat it as the end of\n ;; the block. (Here we have a choice: should\n ;; the user be forced to reindent continued\n ;; lines, or should the \"end\" be reindented?)\n\n ;; Avoid treating comments a continued line.\n ((= (following-char) ?%)\n base)\n ((and (= (following-char) ?,) inside-parenthesis)\n ;; a comma at the start of the line line up with parenthesis\n (- base 1))\n ;; Continued line (e.g. line beginning\n ;; with an operator.)\n (t\n (if (or (erlang-at-operator) (not inside-parenthesis))\n (+ base erlang-indent-level)\n base))))))\n\n(defun erlang-indent-find-base (stack indent-point &optional offset skip)\n \"Find the base column for current stack.\"\n (or skip (setq skip 2))\n (or offset (setq offset erlang-indent-level))\n (save-excursion\n (let* ((stack-top (car stack)))\n (goto-char (nth 1 stack-top))\n (if (< skip (- (point-max) (point)))\n (progn\n (forward-char skip)\n (if (looking-at \"\\\\s *\\\\($\\\\|%\\\\)\")\n (progn\n (if (memq (car stack-top) '(-> ||))\n (erlang-pop stack))\n ;; Take parent identation + offset,\n ;; else just erlang-indent-level if no parent\n (if stack\n (+ (erlang-caddr (car stack))\n offset)\n erlang-indent-level))\n (erlang-skip-blank indent-point)\n (current-column)))\n (+ (current-column) skip)))))\n\n\n;; Does not handle `begin' .. `end'.\n(defun erlang-indent-find-preceding-expr (&optional arg)\n \"Return the first column of the preceding expression.\nThis assumes that the preceding expression is either simple\n\\(i.e. an atom) or parenthesized.\"\n (save-excursion\n (or arg (setq arg 1))\n (ignore-errors (forward-sexp (- arg)))\n (let ((col (current-column)))\n (skip-chars-backward \" \\t\")\n ;; Special hack to handle: (note line break)\n ;; [#myrecord{\n ;; foo = foo}]\n ;; where the call (forward-sexp -1) will fail when point is at the `#'.\n (or\n (ignore-errors\n ;; Needed to match the colon in \"'foo':'bar'\".\n (cond ((eq (preceding-char) ?:)\n (backward-char 1)\n (forward-sexp -1)\n (current-column))\n ((eq (preceding-char) ?#)\n ;; We may now be at:\n ;; - either a construction of a new record\n ;; - or update of a record, in which case we want\n ;; the column of the expression to be updated.\n ;;\n ;; To see which of the two cases we are at, we first\n ;; move an expression backwards, check for keywords,\n ;; then immediately an expression forwards. Moving\n ;; backwards skips past tokens like `,' or `->', but\n ;; when moving forwards again, we won't skip past such\n ;; tokens. We use this: if, after having moved\n ;; forwards, we're back where we started, then it was\n ;; a record update.\n ;; The check for keywords is to detect cases like:\n ;; case Something of #record_construction{...}\n (backward-char 1)\n (let ((record-start (point))\n (record-start-col (current-column)))\n (forward-sexp -1)\n (let ((preceding-expr-col (current-column))\n ;; white space definition according to erl_scan\n (white-space \"\\000-\\040\\200-\\240\"))\n (if (erlang-at-keyword)\n ;; The (forward-sexp -1) call moved past a keyword\n (1+ record-start-col)\n (forward-sexp 1)\n (skip-chars-forward white-space record-start)\n ;; Are we back where we started? If so, it was an update.\n (if (= (point) record-start)\n preceding-expr-col\n (goto-char record-start)\n (1+ (current-column)))))))\n (t col)))\n col))))\n\n(defun erlang-record-or-function-args-p ()\n (and (looking-at \"[({]\\\\s *\\\\($\\\\|%\\\\)\")\n (or (eq (following-char) ?\\( )\n (save-excursion\n (ignore-errors (forward-sexp (- 1)))\n (eq (preceding-char) ?#)))))\n\n(defun erlang-indent-parenthesis (stack-position)\n (let ((previous (erlang-indent-find-preceding-expr)))\n (cond ((eq previous stack-position) ;; tuple or map not a record\n (1+ stack-position))\n ((> previous stack-position)\n (+ stack-position erlang-argument-indent))\n (t\n (+ previous erlang-argument-indent)))))\n\n(defun erlang-skip-blank (&optional lim)\n \"Skip over whitespace and comments until limit reached.\"\n (or lim (setq lim (point-max)))\n (let (stop)\n (while (and (not stop) (< (point) lim))\n (cond ((= (following-char) ?%)\n (skip-chars-forward \"^\\n\" lim))\n ((= (following-char) ?\\n)\n (skip-chars-forward \"\\n\" lim))\n ((looking-at \"\\\\s \")\n (if (re-search-forward \"\\\\S \" lim 'move)\n (forward-char -1)))\n (t\n (setq stop t))))\n stop))\n\n(defun erlang-at-keyword ()\n \"Are we looking at an Erlang keyword which will increase indentation?\"\n (looking-at (concat \"\\\\(when\\\\|if\\\\|fun\\\\|case\\\\|begin\\\\|\"\n \"of\\\\|receive\\\\|after\\\\|catch\\\\|try\\\\)\\\\b\")))\n\n(defun erlang-at-operator ()\n \"Are we looking at an Erlang operator?\"\n (looking-at\n \"\\\\(bnot\\\\|div\\\\|mod\\\\|band\\\\|bor\\\\|bxor\\\\|bsl\\\\|bsr\\\\)\\\\b\"))\n\n(defun erlang-comment-indent ()\n \"Compute Erlang comment indentation.\n\nUsed both by `indent-for-comment' and the Erlang specific indentation\ncommands.\"\n (cond ((looking-at \"%%%\") 0)\n ((looking-at \"%%\")\n (or (erlang-calculate-indent)\n (current-indentation)))\n (t\n (save-excursion\n (skip-chars-backward \" \\t\")\n (max (if (bolp) 0 (1+ (current-column)))\n comment-column)))))\n\n;;; Erlang movement commands\n\n;; All commands below work as movement commands. I.e. if the point is\n;; at the end of the clause, and the command `erlang-end-of-clause' is\n;; executed, the point is moved to the end of the NEXT clause. (This\n;; mimics the behaviour of `end-of-defun'.)\n;;\n;; Personally I would like to rewrite them to be \"pure\", and add a set\n;; of movement functions, like `erlang-next-clause',\n;; `erlang-previous-clause', and the same for functions.\n;;\n;; The current implementation makes it hopeless to use the functions as\n;; subroutines in more complex commands. \/andersl\n\n(defun erlang-beginning-of-clause (&optional arg)\n \"Move backward to previous start of clause.\nWith argument, do this that many times.\nReturn t unless search stops due to end of buffer.\"\n (interactive \"p\")\n (or arg (setq arg 1))\n (if (< arg 0)\n ;; Step back to the end of the previous line, unless we are at\n ;; the beginning of the buffer. The reason for this move is\n ;; that the regexp below includes the last character of the\n ;; previous line.\n (if (bobp)\n (or (looking-at \"\\n\")\n (forward-char 1))\n (forward-char -1)\n (if (looking-at \"\\\\`\\n\")\n (forward-char 1))))\n ;; The regexp matches a function header that isn't\n ;; included in a string.\n (and (re-search-forward \"\\\\(\\\\`\\\\|\\\\`\\n\\\\|[^\\\\]\\n\\\\)\\\\(-?[a-z]\\\\|'\\\\|-\\\\)\"\n nil 'move (- arg))\n (let ((beg (match-beginning 2)))\n (and beg (goto-char beg))\n t)))\n\n(defun erlang-end-of-clause (&optional arg)\n \"Move to the end of the current clause.\nWith argument, do this that many times.\"\n (interactive \"p\")\n (or arg (setq arg 1))\n (while (and (looking-at \"[ \\t]*[%\\n]\")\n (zerop (forward-line 1))))\n ;; Move to the next clause.\n (erlang-beginning-of-clause (- arg))\n (beginning-of-line);; Just to be sure...\n (let ((continue t))\n (while (and (not (bobp)) continue)\n (forward-line -1)\n (unless (looking-at \"[ \\t]*[%\\n]\")\n (end-of-line)\n (setq continue nil)))))\n\n(defun erlang-mark-clause ()\n \"Put mark at end of clause, point at beginning.\"\n (interactive)\n (push-mark (point))\n (erlang-end-of-clause 1)\n ;; Sets the region.\n (push-mark (point) nil t)\n (erlang-beginning-of-clause 1)\n ;; The above function deactivates the mark.\n (if (boundp 'deactivate-mark)\n (funcall (symbol-function 'set) 'deactivate-mark nil)))\n\n(defun erlang-beginning-of-function (&optional arg)\n \"Move backward to previous start of function.\nWith positive argument, do this that many times.\nWith negative argument, search forward.\n\nReturn t unless search stops due to end of buffer.\"\n (interactive \"p\")\n (or arg (setq arg 1))\n (cond\n ;; Search backward\n ((> arg 0)\n (while (and (> arg 0)\n (and (erlang-beginning-of-clause 1)\n (let ((start (point))\n (name (erlang-name-of-function))\n (arity (erlang-get-function-arity)))\n ;; Note: \"arity\" is nil for e.g. \"-import\", hence\n ;; two \"-import\" clauses are not considered to\n ;; be part of the same function.\n (while (and (erlang-beginning-of-clause 1)\n (string-equal name\n (erlang-name-of-function))\n arity\n (equal arity\n (erlang-get-function-arity)))\n (setq start (point)))\n (goto-char start)\n t)))\n (setq arg (1- arg))))\n ;; Search forward\n ((< arg 0)\n (end-of-line)\n (erlang-beginning-of-clause 1)\n ;; Step -arg functions forward.\n (while (and (< arg 0)\n ;; Step one function forward, or stop if the end of\n ;; the buffer was reached. Return t if we found the\n ;; function.\n (let ((name (erlang-name-of-function))\n (arity (erlang-get-function-arity))\n (found (erlang-beginning-of-clause -1)))\n (while (and found\n (string-equal name (erlang-name-of-function))\n arity\n (equal arity\n (erlang-get-function-arity)))\n (setq found (erlang-beginning-of-clause -1)))\n found))\n (setq arg (1+ arg)))))\n (zerop arg))\n\n\n(defun erlang-end-of-function (&optional arg)\n \"Move forward to next end of function.\n\nWith argument, do this that many times.\nWith negative argument go towards the beginning of the buffer.\"\n (interactive \"p\")\n (or arg (setq arg 1))\n (let ((first t))\n ;; Forward\n (while (and (> arg 0) (< (point) (point-max)))\n (let ((pos (point)))\n (while (progn\n (if (and first\n (progn\n (forward-char 1)\n (erlang-beginning-of-clause 1)))\n nil\n (or (bobp) (forward-char -1))\n (erlang-beginning-of-clause -1))\n (setq first nil)\n (erlang-pass-over-function)\n (skip-chars-forward \" \\t\")\n (if (looking-at \"[%\\n]\")\n (forward-line 1))\n (<= (point) pos))))\n (setq arg (1- arg)))\n ;; Backward\n (while (< arg 0)\n (let ((pos (point)))\n (erlang-beginning-of-clause 1)\n (erlang-pass-over-function)\n (forward-line 1)\n (if (>= (point) pos)\n (if (erlang-beginning-of-function 2)\n (progn\n (erlang-pass-over-function)\n (skip-chars-forward \" \\t\")\n (if (looking-at \"[%\\n]\")\n (forward-line 1)))\n (goto-char (point-min)))))\n (setq arg (1+ arg)))))\n\n(eval-and-compile\n (if (default-boundp 'beginning-of-defun-function)\n (defalias 'erlang-mark-function 'mark-defun)\n (defun erlang-mark-function ()\n \"Put mark at end of function, point at beginning.\"\n (interactive)\n (push-mark (point))\n (erlang-end-of-function 1)\n ;; Sets the region.\n (push-mark (point) nil t)\n (erlang-beginning-of-function 1)\n ;; The above function deactivates the mark.\n (if (boundp 'deactivate-mark)\n (funcall (symbol-function 'set) 'deactivate-mark nil)))))\n\n(defun erlang-pass-over-function ()\n (while (progn\n (erlang-skip-blank)\n (and (not (looking-at \"\\\\.\\\\(\\\\s \\\\|\\n\\\\|\\\\s<\\\\)\"))\n (not (eobp))))\n (forward-sexp 1))\n (if (not (eobp))\n (forward-char 1)))\n\n(defun erlang-name-of-function ()\n (save-excursion\n ;; Skip over attribute leader.\n (if (looking-at \"-[ \\t]*\")\n (re-search-forward \"-[ \\t]*\" nil 'move))\n (let ((start (point)))\n (forward-sexp 1)\n (buffer-substring start (point)))))\n\n\n;;; Miscellaneous\n\n(defun erlang-fill-paragraph (&optional justify)\n \"Like \\\\[fill-paragraph], but handle Erlang comments.\nIf any of the current line is a comment, fill the comment or the\nparagraph of it that point is in, preserving the comment's indentation\nand initial `%':s.\"\n (interactive \"P\")\n (let ((has-comment nil)\n ;; If has-comment, the appropriate fill-prefix for the comment.\n comment-fill-prefix)\n ;; Figure out what kind of comment we are looking at.\n (save-excursion\n (beginning-of-line)\n (cond\n ;; Find the command prefix.\n ((looking-at (concat \"\\\\s *\" comment-start-skip))\n (setq has-comment t)\n (setq comment-fill-prefix (buffer-substring (match-beginning 0)\n (match-end 0))))\n ;; A line with some code, followed by a comment? Remember that the\n ;; % which starts the comment shouldn't be part of a string or\n ;; character.\n ((progn\n (while (not (looking-at \"%\\\\|$\"))\n (skip-chars-forward \"^%\\n\\\"\\\\\\\\\")\n (cond\n ((eq (char-after (point)) ?\\\\) (forward-char 2))\n ((eq (char-after (point)) ?\\\") (forward-sexp 1))))\n (looking-at comment-start-skip))\n (setq has-comment t)\n (setq comment-fill-prefix\n (concat (make-string (current-column) ? )\n (buffer-substring (match-beginning 0) (match-end 0)))))))\n (if (not has-comment)\n (fill-paragraph justify)\n ;; Narrow to include only the comment, and then fill the region.\n (save-restriction\n (narrow-to-region\n ;; Find the first line we should include in the region to fill.\n (save-excursion\n (while (and (zerop (forward-line -1))\n (looking-at \"^\\\\s *%\")))\n ;; We may have gone to far. Go forward again.\n (or (looking-at \"^\\\\s *%\")\n (forward-line 1))\n (point))\n ;; Find the beginning of the first line past the region to fill.\n (save-excursion\n (while (progn (forward-line 1)\n (looking-at \"^\\\\s *%\")))\n (point)))\n ;; Lines with only % on them can be paragraph boundaries.\n (let ((paragraph-start (concat paragraph-start \"\\\\|^[ \\t%]*$\"))\n (paragraph-separate (concat paragraph-start \"\\\\|^[ \\t%]*$\"))\n (fill-prefix comment-fill-prefix))\n (fill-paragraph justify))))))\n\n(defun erlang-generate-new-clause ()\n \"Create additional Erlang clause header.\n\nParses the source file for the name of the current Erlang function.\nCreate the header containing the name, A pair of parentheses,\nand an arrow. The space between the function name and the\nfirst parenthesis is preserved. The point is placed between\nthe parentheses.\"\n (interactive)\n (let ((name (save-excursion\n (and (erlang-beginning-of-clause)\n (erlang-get-function-name t))))\n (arrow (save-excursion\n (and (erlang-beginning-of-clause)\n (erlang-get-function-arrow)))))\n (if (or (null arrow) (null name))\n (error \"Can't find name of current Erlang function\"))\n (if (and (bolp) (eolp))\n nil\n (end-of-line)\n (newline))\n (insert name)\n (save-excursion\n (insert \") \" arrow))\n (if erlang-new-clause-with-arguments\n (erlang-clone-arguments))))\n\n\n(defun erlang-clone-arguments ()\n \"Insert, at the point, the argument list of the previous clause.\n\nThe mark is set at the beginning of the inserted text, the point\nat the end.\"\n (interactive)\n (let ((args (save-excursion\n (beginning-of-line)\n (and (erlang-beginning-of-clause)\n (erlang-get-function-arguments))))\n (p (point)))\n (if (null args)\n (error \"Can't clone argument list\"))\n (insert args)\n (set-mark p)))\n\n;;; Information retrieval functions.\n\n(defun erlang-get-module ()\n \"Return the name of the module as specified by `-module'.\n\nReturn nil if file contains no `-module' attribute.\"\n (save-excursion\n (save-restriction\n (widen)\n (goto-char (point-min))\n (let ((md (match-data)))\n (unwind-protect\n (if (re-search-forward\n (eval-when-compile\n (concat \"^-module\\\\s *(\\\\s *\\\\(\\\\(\"\n erlang-atom-regexp\n \"\\\\)?\\\\)\\\\s *)\\\\s *\\\\.\"))\n (point-max) t)\n (erlang-remove-quotes\n (buffer-substring-no-properties (match-beginning 1)\n (match-end 1)))\n nil)\n (store-match-data md))))))\n\n\n(defun erlang-get-module-from-file-name (&optional file)\n \"Extract the module name from a file name.\n\nFirst, the directory part is removed. Second, the part of the file name\nmatching `erlang-file-name-extension-regexp' is removed.\n\nShould the match fail, nil is returned.\n\nBy modifying `erlang-file-name-extension-regexp' to match files other\nthan Erlang source files, Erlang specific functions could be applied on\nnon-Erlang files. Most notably; the support for Erlang modules in the\ntags system could be used by files written in other languages.\"\n (or file (setq file buffer-file-name))\n (if (null file)\n nil\n (setq file (file-name-nondirectory file))\n (if (string-match erlang-file-name-extension-regexp file)\n (substring file 0 (match-beginning 0))\n nil)))\n\n\n;; Used by `erlang-get-export' and `erlang-get-import'.\n\n(defun erlang-get-function-arity-list ()\n \"Parse list of `function\/arity' as used by `-import' and `-export'.\n\nPoint must be before the opening bracket. When the\nfunction returns the point will be placed after the closing bracket.\n\nThe function does not return an error if the list is incorrectly\nformatted.\n\nReturn list of (function . arity). The order of the returned list\ncorresponds to the order of the parsed Erlang list.\"\n (let ((res '()))\n (erlang-skip-blank)\n (forward-char 1)\n (if (not (eq (preceding-char) ?\\[))\n '() ; Not looking at an Erlang list.\n (while ; Note: `while' has no body.\n (progn\n (erlang-skip-blank)\n (and (looking-at (eval-when-compile\n (concat erlang-atom-regexp \"\/\\\\([0-9]+\\\\)\\\\>\")))\n (progn\n (setq res (cons\n (cons\n (erlang-remove-quotes\n (buffer-substring-no-properties\n (match-beginning 1) (match-end 1)))\n (string-to-number\n (buffer-substring-no-properties\n (match-beginning\n (+ 1 erlang-atom-regexp-matches))\n (match-end\n (+ 1 erlang-atom-regexp-matches)))))\n res))\n (goto-char (match-end 0))\n (erlang-skip-blank)\n (forward-char 1)\n ;; Test if there are more exported functions.\n (eq (preceding-char) ?,))))))\n (nreverse res)))\n\n\n;;; Note that `-export' and the open parenthesis must be written on\n;;; the same line.\n\n(defun erlang-get-export ()\n \"Return a list of `(function . arity)' as specified by `-export'.\"\n (save-excursion\n (goto-char (point-min))\n (let ((md (match-data))\n (res '()))\n (unwind-protect\n (progn\n (while (re-search-forward \"^-export\\\\s *(\" (point-max) t)\n (erlang-skip-blank)\n (setq res (nconc res (erlang-get-function-arity-list))))\n res)\n (store-match-data md)))))\n\n\n(defun erlang-get-import ()\n \"Parse an Erlang source file for imported functions.\n\nReturn an alist with module name as car part and list of conses containing\nfunction and arity as cdr part.\"\n (save-excursion\n (goto-char (point-min))\n (let ((md (match-data))\n (res '()))\n (unwind-protect\n (progn\n (while (re-search-forward \"^-import\\\\s *(\" (point-max) t)\n (erlang-skip-blank)\n (if (looking-at erlang-atom-regexp)\n (let ((module (erlang-remove-quotes\n (buffer-substring-no-properties\n (match-beginning 0)\n (match-end 0)))))\n (goto-char (match-end 0))\n (erlang-skip-blank)\n (if (eq (following-char) ?,)\n (progn\n (forward-char 1)\n (erlang-skip-blank)\n (let ((funcs (erlang-get-function-arity-list))\n (pair (assoc module res)))\n (if pair\n (setcdr pair (nconc (cdr pair) funcs))\n (setq res (cons (cons module funcs)\n res)))))))))\n (nreverse res))\n (store-match-data md)))))\n\n\n(defun erlang-get-function-name (&optional arg)\n \"Return name of current function, or nil.\n\nIf optional argument is non-nil, everything up to and including\nthe first `(' is returned.\n\nNormally used in conjunction with `erlang-beginning-of-clause', e.g.:\n (save-excursion\n (if (not (eobp)) (forward-char 1))\n (and (erlang-beginning-of-clause)\n (erlang-get-function-name t)))\"\n (let ((n (if arg 0 1)))\n (and (looking-at (eval-when-compile\n (concat \"^\" erlang-atom-regexp \"\\\\s *(\")))\n (buffer-substring-no-properties (match-beginning n) (match-end n)))))\n\n\n(defun erlang-get-function-arrow ()\n \"Return arrow of current function, could be \\\"->\\\" or nil.\n\nNormally used in conjunction with `erlang-beginning-of-clause', e.g.:\n (save-excursion\n (if (not (eobp)) (forward-char 1))\n (and (erlang-beginning-of-clause)\n (erlang-get-function-arrow)))\"\n (and\n (save-excursion\n (re-search-forward \"->\" (point-max) t)\n (buffer-substring-no-properties (- (point) 2) (+ (point) 1)))))\n\n(defun erlang-get-function-arity ()\n \"Return the number of arguments of function at point, or nil.\"\n (erlang-get-arity-after-regexp (concat \"^\" erlang-atom-regexp \"\\\\s *(\")))\n\n(defun erlang-get-argument-list-arity ()\n \"Return the number of arguments in argument list at point, or nil.\nThe point should be before the opening parenthesis of the\nargument list before calling this function.\"\n (erlang-get-arity-after-regexp \"\\\\s *(\"))\n\n(defun erlang-get-arity-after-regexp (regexp)\n \"Return the number of arguments in argument list after REGEXP, or nil.\"\n (when (looking-at regexp)\n (save-excursion\n (goto-char (match-end 0))\n (erlang-get-arity))))\n\n(defun erlang-get-arity ()\n \"Return the number of arguments in argument list at point, or nil.\nThe point should be after the opening parenthesis of the argument\nlist before calling this function.\"\n (condition-case nil\n (let ((res 0)\n (cont t))\n (while cont\n (cond ((eobp)\n (setq res nil)\n (setq cont nil))\n ((looking-at \"\\\\s *)\")\n (setq cont nil))\n ((looking-at \"\\\\s *\\\\($\\\\|%\\\\)\")\n (forward-line 1))\n ((looking-at \"\\\\s *<<[^>]*?>>\")\n (when (zerop res)\n (setq res (+ 1 res)))\n (goto-char (match-end 0)))\n ((looking-at \"\\\\s *,\")\n (setq res (+ 1 res))\n (goto-char (match-end 0)))\n (t\n (when (zerop res)\n (setq res (+ 1 res)))\n (forward-sexp 1))))\n res)\n (error nil)))\n\n\n(defun erlang-get-function-name-and-arity ()\n \"Return the name and arity of the function at point, or nil.\nThe return value is a string of the form \\\"foo\/1\\\".\"\n (let ((name (erlang-get-function-name))\n (arity (erlang-get-function-arity)))\n (and name arity (format \"%s\/%d\" name arity))))\n\n(defun erlang-get-function-arguments ()\n \"Return arguments of current function, or nil.\"\n (if (not (looking-at (eval-when-compile\n (concat \"^\" erlang-atom-regexp \"\\\\s *(\"))))\n nil\n (save-excursion\n (condition-case nil\n (let ((start (match-end 0)))\n (goto-char (- start 1))\n (forward-sexp)\n (buffer-substring-no-properties start (- (point) 1)))\n (error nil)))))\n\n\n;; erlang-get-function-under-point is replaced by\n;; erlang-get-identifier-at-point as far as internal erlang.el usage\n;; is concerned. But it is kept for backward compatibility. It is\n;; used by erldoc.el and maybe other code out there.\n(defun erlang-get-function-under-point ()\n \"Return the module and function under the point, or nil.\n\nShould no explicit module name be present at the point, the\nlist of imported functions is searched.\n\nThe following could be returned:\n (\\\"module\\\" \\\"function\\\") -- Both module and function name found.\n (nil \\\"function\\\") -- No module name was found.\n nil -- No function name found.\n\nSee also `erlang-get-identifier-at-point'.\"\n (let* ((id (erlang-get-identifier-at-point))\n (kind (erlang-id-kind id))\n (module (erlang-id-module id))\n (name (erlang-id-name id)))\n (cond ((eq kind 'qualified-function)\n (list module name))\n (name\n (list nil name)))))\n\n(defun erlang-get-identifier-at-point ()\n \"Return the erlang identifier at point, or nil.\n\nShould no explicit module name be present at the point, the\nlist of imported functions is searched.\n\nWhen an identifier is found return a list with 4 elements:\n\n1. Kind - One of the symbols qualified-function, record, macro,\nmodule or nil.\n\n2. Module - Module name string or nil. In case of a\nqualified-function the module is explicitly specified (like\nmodule:fun()) and the search fails if no entries with correct\nmodule are found. For other kinds the module is guessed: either\nfetched from import statements or it is assumed to be the local\nmodule. In these cases the module is just a preference. If no\nmatching entries are found the search will be retried without\nregard to module.\n\n3. Name - String name of function, module, record or macro.\n\n4. Arity - Integer in case of functions and macros if the number\nof arguments could be found, otherwise nil.\"\n (save-excursion\n (let (case-fold-search)\n (save-match-data\n (if (eq (char-syntax (following-char)) ? )\n (skip-chars-backward \" \\t\"))\n (skip-chars-backward \"[:word:]_:'\")\n (cond ((and (eq (preceding-char) ??)\n (looking-at (concat \"\\\\(MODULE\\\\):\" erlang-atom-regexp)))\n (erlang-get-qualified-function-id-at-point (erlang-get-module)))\n ((looking-at erlang-module-function-regexp)\n (erlang-get-qualified-function-id-at-point))\n ((looking-at (concat erlang-atom-regexp \":\"))\n (erlang-get-module-id-at-point))\n ((looking-at erlang-name-regexp)\n (erlang-get-some-other-id-at-point)))))))\n\n(defun erlang-get-qualified-function-id-at-point (&optional module)\n (let ((kind 'qualified-function)\n (module (or module\n (erlang-remove-quotes\n (buffer-substring-no-properties\n (match-beginning 1) (match-end 1)))))\n (name (erlang-remove-quotes\n (buffer-substring-no-properties\n (match-beginning (1+ erlang-atom-regexp-matches))\n (match-end (1+ erlang-atom-regexp-matches)))))\n (arity (progn\n (goto-char (match-end 0))\n (erlang-get-argument-list-arity))))\n (list kind module name arity)))\n\n(defun erlang-get-module-id-at-point ()\n (let ((kind 'module)\n (module nil)\n (name (erlang-remove-quotes\n (buffer-substring-no-properties (match-beginning 1)\n (match-end 1))))\n (arity nil))\n (list kind module name arity)))\n\n(defun erlang-get-some-other-id-at-point ()\n (let ((name (erlang-remove-quotes\n (buffer-substring-no-properties\n (match-beginning 0) (match-end 0))))\n (imports (erlang-get-import))\n kind module arity)\n (while (and imports (null module))\n (if (assoc name (cdr (car imports)))\n (setq module (car (car imports)))\n (setq imports (cdr imports))))\n (cond ((eq (preceding-char) ?#)\n (setq kind 'record))\n ((eq (preceding-char) ??)\n (setq kind 'macro))\n ((and (null module) (not (member name erlang-int-bifs)))\n (setq module (erlang-get-module))))\n (setq arity (progn\n (goto-char (match-end 0))\n (erlang-get-argument-list-arity)))\n (list kind module name arity)))\n\n(defmacro erlang-with-id (slots id-string &rest body)\n (declare (indent 2))\n (let ((id-var (make-symbol \"id\")))\n `(let* ((,id-var (erlang-id-to-list ,id-string))\n ,@(mapcar (lambda (slot)\n (list slot\n (list (intern (format \"erlang-id-%s\" slot))\n id-var)))\n slots))\n ,@body)))\n\n(defun erlang-id-to-string (id)\n (when id\n (erlang-with-id (kind module name arity) id\n (format \"%s%s%s%s\"\n (if kind (format \"%s \" kind) \"\")\n (if module (format \"%s:\" module) \"\")\n name\n (if arity (format \"\/%s\" arity) \"\")))))\n\n(defun erlang-id-to-list (id)\n (if (listp id)\n id\n (save-match-data\n (erlang-ensure-syntax-table-is-initialized)\n (with-syntax-table erlang-mode-syntax-table\n (let (case-fold-search)\n (when (string-match erlang-id-regexp id)\n (list (when (match-string 1 id)\n (intern (match-string 1 id)))\n (match-string 2 id)\n (match-string 3 id)\n (when (match-string 4 id)\n (string-to-number (match-string 4 id))))))))))\n\n(defun erlang-id-kind (id)\n (car (erlang-id-to-list id)))\n\n(defun erlang-id-module (id)\n (nth 1 (erlang-id-to-list id)))\n\n(defun erlang-id-name (id)\n (nth 2 (erlang-id-to-list id)))\n\n(defun erlang-id-arity (id)\n (nth 3 (erlang-id-to-list id)))\n\n\n(defun erlang-default-function-or-module ()\n (erlang-with-id (kind module name) (erlang-get-identifier-at-point)\n (let ((x (cond ((eq kind 'module)\n (format \"%s:\" name))\n ((eq kind 'record)\n (format \"-record(%s\" name))\n ((eq kind 'macro)\n (format \"-define(%s\" name))\n (t\n name))))\n (if module\n (format \"%s:%s\" module x)\n x))))\n\n\n;; TODO: Escape single quotes inside the string without\n;; replace-regexp-in-string.\n(defun erlang-add-quotes-if-needed (str)\n \"Return STR, possibly with quotes.\"\n (let ((case-fold-search nil)) ; force string matching to be case sensitive\n (if (and (stringp str)\n (not (string-match (eval-when-compile\n (concat \"\\\\`\" erlang-atom-regexp \"\\\\'\"))\n str)))\n (progn\n (setq str (replace-regexp-in-string \"'\" \"\\\\'\" str t t ))\n (concat \"'\" str \"'\"))\n str)))\n\n\n(defun erlang-remove-quotes (str)\n \"Return STR without quotes, if present.\"\n (let ((md (match-data)))\n (prog1\n (if (string-match \"\\\\`'\\\\(.*\\\\)'\\\\'\" str)\n (substring str 1 -1)\n str)\n (store-match-data md))))\n\n(defun erlang-match-next-exported-function (max)\n \"Returns non-nil if there is an exported function in the current\nbuffer between point and MAX.\"\n (block nil\n (while (and (not erlang-inhibit-exported-function-name-face)\n (erlang-match-next-function max))\n (when (erlang-last-match-exported-p)\n (return (match-data))))))\n\n(defun erlang-match-next-function (max)\n \"Searches forward in current buffer for the next erlang function,\nbounded by position MAX.\"\n (re-search-forward erlang-defun-prompt-regexp max 'move-point))\n\n(defun erlang-last-match-exported-p ()\n \"Returns non-nil if match-data describes the name and arity of an\nexported function.\"\n (save-excursion\n (save-match-data\n (goto-char (match-beginning 1))\n (erlang-function-exported-p\n (erlang-remove-quotes (erlang-get-function-name))\n (erlang-get-function-arity)))))\n\n(defun erlang-function-exported-p (name arity)\n \"Returns non-nil if function of name and arity is exported in current buffer.\"\n (save-excursion\n (let* ((old-match-data (match-data))\n (exports (erlang-get-export)))\n (store-match-data old-match-data)\n (member (cons name arity) exports))))\n\n\n;;; Check module name\n\n;; The function `write-file', bound to C-x C-w, calls\n;; `set-visited-file-name' which clears the hook. :-(\n;; To make sure that the hook always is present, we advise\n;; `set-visited-file-name'.\n(defun erlang-check-module-name-init ()\n \"Initialize the functionality to compare file and module names.\n\nUnless we have `before-save-hook', we advice the function\n`set-visited-file-name' since it clears the variable\n`local-write-file-hooks'.\"\n (if (boundp 'before-save-hook)\n (add-hook 'before-save-hook 'erlang-check-module-name nil t)\n (require 'advice)\n (when (fboundp 'ad-advised-definition-p)\n (unless (ad-advised-definition-p 'set-visited-file-name)\n (defadvice set-visited-file-name (after erlang-set-visited-file-name\n activate)\n (if (eq major-mode 'erlang-mode)\n (add-hook 'local-write-file-hooks 'erlang-check-module-name))))\n (add-hook 'local-write-file-hooks 'erlang-check-module-name))))\n\n\n(defun erlang-check-module-name ()\n \"If the module name doesn't match file name, ask for permission to change.\n\nThe variable `erlang-check-module-name' controls the behaviour of this\nfunction. It it is nil, this function does nothing. If it is t, the\nsource is silently changed. If it is set to the atom `ask', the user\nis prompted.\n\nThis function is normally placed in the hook `local-write-file-hooks'.\"\n (if erlang-check-module-name\n (let ((mn (erlang-add-quotes-if-needed\n (erlang-get-module)))\n (fn (erlang-add-quotes-if-needed\n (erlang-get-module-from-file-name (buffer-file-name)))))\n (if (and (stringp mn) (stringp fn))\n (or (string-equal mn fn)\n (if (or (eq erlang-check-module-name t)\n (y-or-n-p\n \"Module does not match file name. Modify source? \"))\n (save-excursion\n (save-restriction\n (widen)\n (goto-char (point-min))\n (if (re-search-forward\n (eval-when-compile\n (concat \"^-module\\\\s *(\\\\s *\\\\(\\\\(\"\n erlang-atom-regexp\n \"\\\\)?\\\\)\\\\s *)\\\\s *\\\\.\"))\n (point-max) t)\n (progn\n (goto-char (match-beginning 1))\n (delete-region (match-beginning 1)\n (match-end 1))\n (insert fn))))))))))\n ;; Must return nil since it is added to `local-write-file-hook'.\n nil)\n\n\n;;; Electric functions.\n\n(defun erlang-electric-semicolon (&optional arg)\n \"Insert a semicolon character and possibly a prototype for the next line.\n\nThe variable `erlang-electric-semicolon-criteria' states a criterion,\nwhen fulfilled a newline is inserted, the next line is indented and a\nprototype for the next line is inserted. Normally the prototype\nconsists of \\\" ->\\\". Should the semicolon end the clause a new clause\nheader is generated.\n\nThe variable `erlang-electric-semicolon-insert-blank-lines' controls\nthe number of blank lines inserted between the current line and new\nfunction header.\n\nBehaves just like the normal semicolon when supplied with a\nnumerical arg, point is inside string or comment, or when there are\nnon-whitespace characters following the point on the current line.\"\n (interactive \"P\")\n (self-insert-command (prefix-numeric-value arg))\n (if (or arg\n (and (listp erlang-electric-commands)\n (not (memq 'erlang-electric-semicolon\n erlang-electric-commands)))\n (erlang-in-literal)\n (not (looking-at \"\\\\s *\\\\(%.*\\\\)?$\"))\n (null (erlang-test-criteria-list\n erlang-electric-semicolon-criteria)))\n (setq erlang-electric-newline-inhibit nil)\n (setq erlang-electric-newline-inhibit t)\n (undo-boundary)\n (erlang-indent-line)\n (end-of-line)\n (newline)\n (if (condition-case nil\n (progn (erlang-indent-line) t)\n (error (if (bolp) (delete-char -1))))\n (if (not (bolp))\n (save-excursion\n (insert \" ->\"))\n (condition-case nil\n (progn\n (erlang-generate-new-clause)\n (if erlang-electric-semicolon-insert-blank-lines\n (save-excursion\n (beginning-of-line)\n (newline\n erlang-electric-semicolon-insert-blank-lines))))\n (error (if (bolp) (delete-char -1))))))))\n\n\n(defun erlang-electric-comma (&optional arg)\n \"Insert a comma character and possibly a new indented line.\nThe variable `erlang-electric-comma-criteria' states a criterion,\nwhen fulfilled a newline is inserted and the next line is indented.\n\nBehaves just like the normal comma when supplied with a\nnumerical arg, point is inside string or comment, or when there are\nnon-whitespace characters following the point on the current line.\"\n (interactive \"P\")\n\n (self-insert-command (prefix-numeric-value arg))\n\n (if (or arg\n (and (listp erlang-electric-commands)\n (not (memq 'erlang-electric-comma erlang-electric-commands)))\n (erlang-in-literal)\n (not (looking-at \"\\\\s *\\\\(%.*\\\\)?$\"))\n (null (erlang-test-criteria-list\n erlang-electric-comma-criteria)))\n (setq erlang-electric-newline-inhibit nil)\n (setq erlang-electric-newline-inhibit t)\n (undo-boundary)\n (erlang-indent-line)\n (end-of-line)\n (newline)\n (condition-case nil\n (erlang-indent-line)\n (error (if (bolp) (delete-char -1))))))\n\n(defun erlang-electric-lt (&optional arg)\n \"Insert a less-than sign, and optionally mark it as an open paren.\"\n\n (interactive \"p\")\n\n (self-insert-command arg)\n\n ;; Was this the second char in bit-syntax open (`<<')?\n (unless (<= (point) 2)\n (save-excursion\n (backward-char 2)\n (when (and (eq (char-after (point)) ?<)\n (not (eq (get-text-property (point) 'category)\n 'bitsyntax-open-inner)))\n ;; Then mark the two chars...\n (put-text-property (point) (1+ (point))\n 'category 'bitsyntax-open-outer)\n (forward-char 1)\n (put-text-property (point) (1+ (point))\n 'category 'bitsyntax-open-inner)\n ;;...and unmark any subsequent less-than chars.\n (forward-char 1)\n (while (eq (char-after (point)) ?<)\n (remove-text-properties (point) (1+ (point))\n '(category nil))\n (forward-char 1))))))\n\n(defun erlang-after-bitsyntax-close ()\n \"Return t if point is immediately after a bit-syntax close parenthesis (`>>').\"\n (and (>= (point) 3)\n (save-excursion\n (backward-char 2)\n (and (eq (char-after (point)) ?>)\n (not (eq (get-text-property (point) 'category)\n 'bitsyntax-close-outer))))))\n\n(defun erlang-after-arrow ()\n \"Return true if point is immediately after a function arrow (`->').\"\n (and (>= (point) 2)\n (and\n (save-excursion\n (backward-char)\n (eq (char-before (point)) ?-))\n (or (not (listp erlang-electric-commands))\n (memq 'erlang-electric-gt\n erlang-electric-commands))\n (not (erlang-in-literal))\n (looking-at \"\\\\s *\\\\(%.*\\\\)?$\")\n (erlang-test-criteria-list erlang-electric-arrow-criteria))))\n\n\n(defun erlang-electric-gt (&optional arg)\n \"Insert a greater-than sign, and optionally mark it as a close paren.\"\n\n (interactive \"p\")\n\n (self-insert-command arg)\n\n (cond\n ;; Did we just write a bit-syntax close (`>>')?\n ((erlang-after-bitsyntax-close)\n (save-excursion\n ;; Then mark the two chars...\n (backward-char 2)\n (put-text-property (point) (1+ (point))\n 'category 'bitsyntax-close-inner)\n (forward-char)\n (put-text-property (point) (1+ (point))\n 'category 'bitsyntax-close-outer)\n ;;...and unmark any subsequent greater-than chars.\n (forward-char)\n (while (eq (char-after (point)) ?>)\n (remove-text-properties (point) (1+ (point))\n '(category nil))\n (forward-char))))\n\n ;; Did we just write a function arrow (`->')?\n ((erlang-after-arrow)\n (let ((erlang-electric-newline-inhibit t))\n (undo-boundary)\n (end-of-line)\n (newline)\n (condition-case nil\n (erlang-indent-line)\n (error (if (bolp) (delete-char -1))))))\n\n ;; Then it's just a plain greater-than.\n (t\n nil)))\n\n\n(defun erlang-electric-arrow (&optional arg)\n \"Insert a '>'-sign and possibly a new indented line.\n\nThis command is only `electric' when the `>' is part of an `->' arrow.\nThe variable `erlang-electric-arrow-criteria' states a sequence of\ncriteria, which decides when a newline should be inserted and the next\nline indented.\n\nIt behaves just like the normal greater than sign when supplied with a\nnumerical arg, point is inside string or comment, or when there are\nnon-whitespace characters following the point on the current line.\n\nAfter being split\/merged into `erlang-after-arrow' and\n`erlang-electric-gt', it is now unused and disabled.\"\n (interactive \"P\")\n (let ((prec (preceding-char)))\n (self-insert-command (prefix-numeric-value arg))\n (if (or arg\n (and (listp erlang-electric-commands)\n (not (memq 'erlang-electric-arrow\n erlang-electric-commands)))\n (not (eq prec ?-))\n (erlang-in-literal)\n (not (looking-at \"\\\\s *\\\\(%.*\\\\)?$\"))\n (null (erlang-test-criteria-list\n erlang-electric-arrow-criteria)))\n (setq erlang-electric-newline-inhibit nil)\n (setq erlang-electric-newline-inhibit t)\n (undo-boundary)\n (end-of-line)\n (newline)\n (condition-case nil\n (erlang-indent-line)\n (error (if (bolp) (delete-char -1)))))))\n\n\n(defun erlang-electric-newline (&optional arg)\n \"Break line at point and indent, continuing comment if within one.\nThe variable `erlang-electric-newline-criteria' states a criterion,\nwhen fulfilled a newline is inserted and the next line is indented.\n\nShould the current line begin with a comment, and the variable\n`comment-multi-line' be non-nil, a new comment start is inserted.\n\nShould the previous command be another electric command we assume that\nthe user pressed newline out of old habit, hence we will do nothing.\"\n (interactive \"P\")\n (cond ((and (not arg)\n erlang-electric-newline-inhibit\n (memq last-command erlang-electric-newline-inhibit-list))\n ()) ; Do nothing!\n ((or arg\n (and (listp erlang-electric-commands)\n (not (memq 'erlang-electric-newline\n erlang-electric-commands)))\n (null (erlang-test-criteria-list\n erlang-electric-newline-criteria)))\n (newline (prefix-numeric-value arg)))\n (t\n (if (and comment-multi-line\n (save-excursion\n (beginning-of-line)\n (looking-at (concat \"\\\\s *\" comment-start-skip))))\n (let ((str (buffer-substring\n (or (match-end 1) (match-beginning 0))\n (min (match-end 0) (point)))))\n (newline)\n (undo-boundary)\n (insert str))\n (newline)\n (undo-boundary)\n (indent-according-to-mode)))))\n\n\n(defun erlang-test-criteria-list (criteria)\n \"Given a list of criterion functions, test if criteria are fulfilled.\n\nEach element in the criteria list can a function returning nil, t or\nthe atom `stop'. t means that the criterion is fulfilled, `stop' means\nthat it isn't fulfilled and that the search should stop,\nand nil means continue searching.\n\nShould the list contain the atom t the criterion is assumed to be\nfulfilled, unless preceded by a function returning `stop', of course.\n\nShould the argument be the atom t instead of a list, the criterion is\nassumed to be trivially true.\n\nShould all functions return nil, the criteria are assumed not to be\nfulfilled.\n\nReturn t if criteria fulfilled, nil otherwise.\"\n (if (eq criteria t)\n t\n (save-excursion\n (let ((answer nil))\n (while (and criteria (null answer))\n (if (eq (car criteria) t)\n (setq answer t)\n (setq answer (funcall (car criteria))))\n (setq criteria (cdr criteria)))\n (if (and answer (not (eq answer 'stop)))\n t\n nil)))))\n\n\n(defun erlang-in-literal ()\n \"Test if point is in string, quoted atom or comment.\n\nReturn one of the three atoms `atom', `string', and `comment'.\nShould the point be inside none of the above mentioned types of\ncontext, nil is returned.\"\n (save-excursion\n (let ((state (funcall (symbol-function 'syntax-ppss))))\n (cond ((eq (nth 3 state) ?') 'atom)\n ((nth 3 state) 'string)\n ((nth 4 state) 'comment)\n (t nil)))))\n\n\n(defun erlang-at-end-of-function-p ()\n \"Test if point is at end of an Erlang function.\n\nThis function is designed to be a member of a criteria list.\"\n (eq (save-excursion (erlang-skip-blank) (point))\n (save-excursion\n (erlang-beginning-of-function -1) (point))))\n\n\n(defun erlang-at-end-of-clause-p ()\n \"Test if point is at end of an Erlang clause.\n\nThis function is designed to be a member of a criteria list.\"\n (eq (save-excursion (erlang-skip-blank) (point))\n (save-excursion\n (erlang-beginning-of-clause -1) (point))))\n\n\n(defun erlang-stop-when-inside-argument-list ()\n \"Return `stop' if inside parenthesis list, nil otherwise.\n\nKnows about the list comprehension syntax. When the point is\nafter `||', `stop' is not returned.\n\nThis function is designed to be a member of a criteria list.\"\n (save-excursion\n (condition-case nil\n (let ((orig-point (point))\n (state nil))\n (up-list -1)\n (if (not (eq (following-char) ?\\[))\n 'stop\n ;; Do not return `stop' when inside a list comprehension\n ;; construction. (The point must be after `||').\n (while (< (point) orig-point)\n (let ((pt (point)))\n (setq state (erlang-partial-parse pt orig-point state))\n (if (= pt (point))\n (error \"Illegal syntax\"))))\n (if (and (car state) (eq (car (car (car state))) '||))\n nil\n 'stop)))\n (error\n nil))))\n\n\n(defun erlang-stop-when-at-guard ()\n \"Return `stop' when at function guards.\n\nThis function is designed to be a member of a criteria list.\"\n (save-excursion\n (beginning-of-line)\n (if (and (looking-at (eval-when-compile\n (concat \"^\" erlang-atom-regexp \"\\\\s *(\")))\n (not (looking-at\n (eval-when-compile\n (concat \"^\" erlang-atom-regexp \".*->\")))))\n 'stop\n nil)))\n\n\n(defun erlang-stop-when-in-type-spec ()\n \"Return `stop' when in a type spec line.\n\nThis function is designed to be a member of a criteria list.\"\n (save-excursion\n (beginning-of-line)\n (when (save-match-data (looking-at \"-\\\\(spec\\\\|type\\\\|callback\\\\)\"))\n 'stop)))\n\n\n(defun erlang-next-lines-empty-p ()\n \"Return non-nil if next lines are empty.\n\nThe variable `erlang-next-lines-empty-threshold' contains the number\nof lines required to be empty.\n\nA line containing only spaces and tabs is considered empty.\n\nThis function is designed to be a member of a criteria list.\"\n (and erlang-next-lines-empty-threshold\n (save-excursion\n (let ((left erlang-next-lines-empty-threshold)\n (cont t))\n (while (and cont (> left 0))\n (forward-line 1)\n (setq cont (looking-at \"\\\\s *$\"))\n (setq left (- left 1)))\n cont))))\n\n\n(defun erlang-at-keyword-end-p ()\n \"Test if next readable token is the keyword end.\n\nThis function is designed to be a member of a criteria list.\"\n (save-excursion\n (erlang-skip-blank)\n (looking-at \"end[^_a-zA-Z0-9]\")))\n\n\n;;; Erlang tags support which is aware of erlang modules.\n\n(eval-when-compile\n (require 'etags))\n\n\n;; Variables:\n\n(defvar erlang-tags-function-alist\n '((find-tag . erlang-find-tag)\n (find-tag-other-window . erlang-find-tag-other-window)\n (find-tag-regexp . erlang-find-tag-regexp)\n (find-tag-other-frame . erlang-find-tag-other-frame))\n \"Alist of old tags commands and the replacement functions.\")\n\n(defvar erlang-tags-installed nil\n \"Non-nil when the Erlang tags system is installed.\")\n(defvar erlang-tags-file-list '()\n \"List of files in tag list. Used when finding tag on form `module:'.\")\n(defvar erlang-tags-completion-table nil\n \"Like `tags-completion-table', this table contains `tag' and `module:tag'.\")\n(defvar erlang-tags-buffer-installed-p nil\n \"Non-nil when Erlang module recognising functions installed.\")\n(defvar erlang-tags-buffer-list '()\n \"Temporary list of buffers.\")\n(defvar erlang-tags-orig-completion-table nil\n \"Temporary storage for `tags-completion-table'.\")\n(defvar erlang-tags-orig-tag-order nil\n \"Temporary storage for `find-tag-tag-order'.\")\n(defvar erlang-tags-orig-regexp-tag-order nil\n \"Temporary storage for `find-tag-regexp-tag-order'.\")\n(defvar erlang-tags-orig-search-function nil\n \"Temporary storage for `find-tag-search-function'.\")\n(defvar erlang-tags-orig-regexp-search-function nil\n \"Temporary storage for `find-tag-regexp-search-function'.\")\n(defvar erlang-tags-orig-format-hooks nil\n \"Temporary storage for `tags-table-format-hooks'.\") ;v19\n(defvar erlang-tags-orig-format-functions nil\n \"Temporary storage for `tags-table-format-functions'.\") ;v > 19\n\n(defun erlang-tags-init ()\n \"Install an alternate version of tags, aware of Erlang modules.\n\nAfter calling this function, the tags functions are aware of\nErlang modules. Tags can be entered on the for `module:tag' as well\nas on the old form `tag'.\n\nIn the completion list, `module:tag' and `module:' shows up.\"\n (interactive)\n (require 'etags)\n (set (make-local-variable 'find-tag-default-function)\n 'erlang-find-tag-for-completion)\n (if (>= emacs-major-version 25)\n (add-hook 'xref-backend-functions\n #'erlang-etags--xref-backend nil t)\n (erlang-tags-define-keys (current-local-map))\n (setq erlang-tags-installed t)))\n\n\n\n;; Set all keys bound to `find-tag' et.al. in the global map and the\n;; menu to `erlang-find-tag' et.al. in `map'.\n;;\n;; The function `substitute-key-definition' does not work properly\n;; in all version of Emacs.\n\n(defun erlang-tags-define-keys (map)\n \"Bind tags commands to keymap MAP aware of Erlang modules.\"\n (let ((alist erlang-tags-function-alist))\n (while alist\n (let* ((old (car (car alist)))\n (new (cdr (car alist)))\n (keys (append (where-is-internal old global-map))))\n (while keys\n (define-key map (car keys) new)\n (setq keys (cdr keys))))\n (setq alist (cdr alist))))\n ;; Update the menu.\n (erlang-menu-substitute erlang-menu-base-items erlang-tags-function-alist)\n (erlang-menu-init))\n\n;; Return `t' since it is used inside `tags-loop-form'.\n;;;###autoload\n(defun erlang-find-tag (modtagname &optional next-p regexp-p)\n \"Like `find-tag'. Capable of retrieving Erlang modules.\n\nTags can be given on the forms `tag', `module:', `module:tag'.\"\n (interactive (erlang-tag-interactive \"Find `module:tag' or `tag': \"))\n (switch-to-buffer (erlang-find-tag-noselect modtagname next-p regexp-p))\n t)\n\n\n;; Code mainly from `find-tag-other-window' in `etags.el'.\n;;;###autoload\n(defun erlang-find-tag-other-window (tagname &optional next-p regexp-p)\n \"Like `find-tag-other-window' but aware of Erlang modules.\"\n (interactive (erlang-tag-interactive\n \"Find `module:tag' or `tag' other window: \"))\n\n ;; This is to deal with the case where the tag is found in the\n ;; selected window's buffer; without this, point is moved in both\n ;; windows. To prevent this, we save the selected window's point\n ;; before doing find-tag-noselect, and restore it afterwards.\n (let* ((window-point (window-point (selected-window)))\n (tagbuf (erlang-find-tag-noselect tagname next-p regexp-p))\n (tagpoint (progn (set-buffer tagbuf) (point))))\n (set-window-point (prog1\n (selected-window)\n (switch-to-buffer-other-window tagbuf)\n ;; We have to set this new window's point; it\n ;; might already have been displaying a\n ;; different portion of tagbuf, in which case\n ;; switch-to-buffer-other-window doesn't set\n ;; the window's point from the buffer.\n (set-window-point (selected-window) tagpoint))\n window-point)))\n\n\n(defun erlang-find-tag-other-frame (tagname &optional next-p)\n \"Like `find-tag-other-frame' but aware of Erlang modules.\"\n (interactive (erlang-tag-interactive\n \"Find `module:tag' or `tag' other frame: \"))\n (let ((pop-up-frames t))\n (erlang-find-tag-other-window tagname next-p)))\n\n\n(defun erlang-find-tag-regexp (regexp &optional next-p other-window)\n \"Like `find-tag-regexp' but aware of Erlang modules.\"\n (interactive (if (fboundp 'find-tag-regexp)\n (erlang-tag-interactive\n \"Find `module:regexp' or `regexp': \")\n (error \"This version of Emacs can't find tags by regexps\")))\n (funcall (if other-window\n 'erlang-find-tag-other-window\n 'erlang-find-tag)\n regexp next-p t))\n\n\n;; Just like C-u M-. This could be added to the menu.\n(defun erlang-find-next-tag ()\n \"Find next tag, like \\\\[find-tag] with prefix arg.\"\n (interactive)\n (let ((current-prefix-arg '(4)))\n (if erlang-tags-installed\n (call-interactively 'erlang-find-tag)\n (call-interactively 'find-tag))))\n\n\n;; Mimics `find-tag-noselect' found in `etags.el', but uses `find-tag' to\n;; be compatible with `tags.el'.\n;;\n;; Handles three cases:\n;; * `module:' Loop over all possible file names. Stop if a file-name\n;; without extension and directory matches the module.\n;;\n;; * `module:tag'\n;; Emacs 19: Replace test functions with functions aware of\n;; Erlang modules. Tricky because the etags system wasn't\n;; built for these kind of operations...\n;;\n;; Emacs 18: We loop over `find-tag' until we find a file\n;; whose module matches the requested module. The\n;; drawback is that a lot of files could be loaded into\n;; Emacs.\n;;\n;; * `tag' Just give it to `find-tag'.\n\n(defun erlang-find-tag-noselect (modtagname &optional next-p regexp-p)\n \"Like `find-tag-noselect' but aware of Erlang modules.\"\n (interactive (erlang-tag-interactive \"Find `module:tag' or `tag': \"))\n (or modtagname\n (setq modtagname (symbol-value 'last-tag)))\n (funcall (symbol-function 'set) 'last-tag modtagname)\n ;; `tags.el' uses this variable to record how M-, would\n ;; know where to restart a tags command.\n (if (boundp 'tags-loop-form)\n (funcall (symbol-function 'set)\n 'tags-loop-form '(erlang-find-tag nil t)))\n (save-window-excursion\n (cond\n ((string-match \":$\" modtagname)\n ;; Only the module name was given. Read all files whose file name\n ;; match.\n (let ((modname (substring modtagname 0 (match-beginning 0)))\n (file nil))\n (if (not next-p)\n (save-excursion\n (visit-tags-table-buffer)\n (setq erlang-tags-file-list\n (funcall (symbol-function 'tags-table-files)))))\n (while (null file)\n (or erlang-tags-file-list\n (save-excursion\n (if (and (funcall\n (symbol-function 'visit-tags-table-buffer) 'same)\n (funcall\n (symbol-function 'visit-tags-table-buffer) t))\n (setq erlang-tags-file-list\n (funcall (symbol-function 'tags-table-files)))\n (error \"No %stags containing %s\" (if next-p \"more \" \"\")\n modtagname))))\n (if erlang-tags-file-list\n (let ((this-module (erlang-get-module-from-file-name\n (car erlang-tags-file-list))))\n (if (and (stringp this-module)\n (string= modname this-module))\n (setq file (car erlang-tags-file-list)))\n (setq erlang-tags-file-list (cdr erlang-tags-file-list)))))\n (set-buffer (or (get-file-buffer file)\n (find-file-noselect file)))))\n\n ((string-match \":\" modtagname)\n (progn\n (erlang-tags-install-module-check)\n (unwind-protect\n (funcall (symbol-function 'find-tag)\n modtagname next-p regexp-p)\n (erlang-tags-remove-module-check))))\n (t\n (funcall (symbol-function 'find-tag) modtagname next-p regexp-p)))\n (current-buffer))) ; Return the new buffer.\n\n\n\n\n\n\n\n;; Process interactive arguments for erlang-find-tag-*.\n;;\n;; Negative arguments work only for `etags', not `tags'. This is not\n;; a problem since negative arguments means step back into the\n;; history list, a feature not implemented in `tags'.\n\n(defun erlang-tag-interactive (prompt)\n (condition-case nil\n (require 'etags)\n (error\n (require 'tags)))\n (if current-prefix-arg\n (list nil (if (< (prefix-numeric-value current-prefix-arg) 0)\n '-\n t))\n (let* ((default (erlang-default-function-or-module))\n (prompt (if default\n (format \"%s(default %s) \" prompt default)\n prompt))\n (spec (completing-read prompt 'erlang-tags-complete-tag)))\n (list (if (equal spec \"\")\n (or default (error \"There is no default tag\"))\n spec)))))\n\n\n;; Search tag functions which are aware of Erlang modules. The tactic\n;; is to store new search functions into the local variables of the\n;; TAGS buffers. The variables are restored directly after the\n;; search. The situation is complicated by the fact that new TAGS\n;; files can be loaded during the search.\n;;\n\n(defun erlang-tags-install-module-check ()\n \"Install our own tag search functions.\"\n ;; Make sure our functions are installed in TAGS files loaded\n ;; into Emacs while searching.\n (setq erlang-tags-orig-format-functions\n (symbol-value 'tags-table-format-functions))\n (funcall (symbol-function 'set) 'tags-table-format-functions\n (cons 'erlang-tags-recognize-tags-table\n erlang-tags-orig-format-functions))\n (setq erlang-tags-buffer-list '())\n\n ;; Install our functions in the TAGS files already resident.\n (save-excursion\n (let ((files (symbol-value 'tags-table-computed-list)))\n (while files\n (if (stringp (car files))\n (if (get-file-buffer (car files))\n (progn\n (set-buffer (get-file-buffer (car files)))\n (erlang-tags-install-local))))\n (setq files (cdr files))))))\n\n\n(defun erlang-tags-install-local ()\n \"Install our tag search functions in current buffer.\"\n (if erlang-tags-buffer-installed-p\n ()\n ;; Mark this buffer as \"installed\" and record.\n (set (make-local-variable 'erlang-tags-buffer-installed-p) t)\n (setq erlang-tags-buffer-list\n (cons (current-buffer) erlang-tags-buffer-list))\n\n ;; Save the original values.\n (set (make-local-variable 'erlang-tags-orig-tag-order)\n (symbol-value 'find-tag-tag-order))\n (set (make-local-variable 'erlang-tags-orig-regexp-tag-order)\n (symbol-value 'find-tag-regexp-tag-order))\n (set (make-local-variable 'erlang-tags-orig-search-function)\n (symbol-value 'find-tag-search-function))\n (set (make-local-variable 'erlang-tags-orig-regexp-search-function)\n (symbol-value 'find-tag-regexp-search-function))\n\n ;; Install our own functions.\n (set (make-local-variable 'find-tag-search-function)\n 'erlang-tags-search-forward)\n (set (make-local-variable 'find-tag-regexp-search-function)\n 'erlang-tags-regexp-search-forward)\n (set (make-local-variable 'find-tag-tag-order)\n (mapcar #'erlang-make-order-function-aware-of-modules\n erlang-tags-orig-tag-order))\n (set (make-local-variable 'find-tag-regexp-tag-order)\n (mapcar #'erlang-make-order-function-aware-of-modules\n erlang-tags-orig-regexp-tag-order))))\n\n(defun erlang-make-order-function-aware-of-modules (f)\n `(lambda (tag)\n (let (mod)\n (when (string-match \":\" tag)\n (setq mod (substring tag 0 (match-beginning 0)))\n (setq tag (substring tag (match-end 0) nil)))\n (and (funcall ',f tag)\n (or (null mod)\n (erlang-tag-at-point-match-module-p mod))))))\n\n(defun erlang-tag-at-point-match-module-p (mod)\n (string-equal mod (erlang-get-module-from-file-name\n (funcall (symbol-function 'file-of-tag)))))\n\n\n(defun erlang-tags-remove-module-check ()\n \"Remove our own tags search functions.\"\n (funcall (symbol-function 'set)\n 'tags-table-format-functions\n erlang-tags-orig-format-functions)\n\n ;; Remove our functions from the TAGS files. (Note that\n ;; `tags-table-computed-list' need not be the same list as when\n ;; the search was started.)\n (save-excursion\n (let ((buffers erlang-tags-buffer-list))\n (while buffers\n (if (buffer-name (car buffers))\n (progn\n (set-buffer (car buffers))\n (erlang-tags-remove-local)))\n (setq buffers (cdr buffers))))))\n\n\n(defun erlang-tags-remove-local ()\n \"Remove our tag search functions from current buffer.\"\n (if (null erlang-tags-buffer-installed-p)\n ()\n (funcall (symbol-function 'set) 'erlang-tags-buffer-installed-p nil)\n (funcall (symbol-function 'set)\n 'find-tag-tag-order erlang-tags-orig-tag-order)\n (funcall (symbol-function 'set)\n 'find-tag-regexp-tag-order erlang-tags-orig-regexp-tag-order)\n (funcall (symbol-function 'set)\n 'find-tag-search-function erlang-tags-orig-search-function)\n (funcall (symbol-function 'set)\n 'find-tag-regexp-search-function\n erlang-tags-orig-regexp-search-function)))\n\n\n(defun erlang-tags-recognize-tags-table ()\n \"Install our functions in all loaded TAGS files.\n\nThis function is added to `tags-table-format-hooks\/functions' when searching\nfor a tag on the form `module:tag'.\"\n (if (null (funcall (symbol-function 'etags-recognize-tags-table)))\n nil\n (erlang-tags-install-local)\n t))\n\n\n(defun erlang-tags-search-forward (tag &optional bound noerror count)\n \"Forward search function, aware of Erlang module prefix.\"\n (if (string-match \":\" tag)\n (setq tag (substring tag (match-end 0) nil)))\n ;; Avoid unintended recursion.\n (if (eq erlang-tags-orig-search-function 'erlang-tags-search-forward)\n (search-forward tag bound noerror count)\n (funcall erlang-tags-orig-search-function tag bound noerror count)))\n\n\n(defun erlang-tags-regexp-search-forward (tag &optional bound noerror count)\n \"Forward regexp search function, aware of Erlang module prefix.\"\n (if (string-match \":\" tag)\n (setq tag (substring tag (match-end 0) nil)))\n (if (eq erlang-tags-orig-regexp-search-function\n 'erlang-tags-regexp-search-forward)\n (re-search-forward tag bound noerror count)\n (funcall erlang-tags-orig-regexp-search-function\n tag bound noerror count)))\n\n;;; Tags completion, Emacs 19 `etags' specific.\n;;;\n;;; The basic idea is to create a second completion table `erlang-tags-\n;;; completion-table' containing all normal tags plus tags on the form\n;;; `module:tag' and `module:'.\n\n(if (fboundp 'advice-add)\n ;; Emacs 24.4+\n (progn\n (require 'etags)\n (advice-add 'etags-tags-completion-table :around\n #'erlang-etags-tags-completion-table-advice))\n ;; Emacs 23.1-24.3\n (defadvice etags-tags-completion-table (around\n erlang-replace-tags-table\n activate)\n (if erlang-replace-etags-tags-completion-table\n (setq ad-return-value (erlang-etags-tags-completion-table))\n ad-do-it)))\n\n(defun erlang-etags-tags-completion-table-advice (oldfun)\n (if erlang-replace-etags-tags-completion-table\n (erlang-etags-tags-completion-table)\n (funcall oldfun)))\n\n(defun erlang-complete-tag ()\n \"Perform tags completion on the text around point.\nCompletes to the set of names listed in the current tags table.\n\nShould the Erlang tags system be installed this command knows\nabout Erlang modules.\"\n (interactive)\n (require 'etags)\n (let ((erlang-replace-etags-tags-completion-table t))\n (complete-tag)))\n\n\n(defun erlang-find-tag-for-completion ()\n (let ((start (save-excursion\n (skip-chars-backward \"[:word:][:digit:]_:'\")\n (point))))\n (unless (eq start (point))\n (buffer-substring-no-properties start (point)))))\n\n\n;; Based on `tags-complete-tag', but this one uses\n;; `erlang-tags-completion-table' instead of `tags-completion-table'.\n;;\n;; This is the entry-point called by system function `completing-read'.\n;;\n;; Used for minibuffer completion in Emacs 19-24 and completion in\n;; erlang buffers in Emacs 19-22.\n(defun erlang-tags-complete-tag (string predicate what)\n (with-current-buffer (window-buffer (minibuffer-selected-window))\n (save-excursion\n ;; If we need to ask for the tag table, allow that.\n (let ((enable-recursive-minibuffers t))\n (visit-tags-table-buffer))\n (if (eq what t)\n (all-completions string (erlang-tags-completion-table) predicate)\n (try-completion string (erlang-tags-completion-table) predicate)))))\n\n\n;; `tags-completion-table' calls itself recursively, make it\n;; call our own wedge instead. Note that the recursive call\n;; is very rare; it only occurs when a tags-file contains\n;; `include'-statements.\n(defun erlang-tags-completion-table ()\n \"Build completion table. Tags on the form `tag' or `module:tag'.\"\n (setq erlang-tags-orig-completion-table\n (symbol-function 'tags-completion-table))\n (fset 'tags-completion-table\n (symbol-function 'erlang-tags-completion-table-1))\n (unwind-protect\n (erlang-tags-completion-table-1)\n (fset 'tags-completion-table\n erlang-tags-orig-completion-table)))\n\n(defun erlang-tags-completion-table-1 ()\n (make-local-variable 'erlang-tags-completion-table)\n (or erlang-tags-completion-table\n (let ((tags-completion-table nil)\n (tags-completion-table-function\n 'erlang-etags-tags-completion-table))\n (funcall erlang-tags-orig-completion-table)\n (setq erlang-tags-completion-table tags-completion-table))))\n\n\n\n;; Emacs 25 expects this function to return a list (and it is ok for\n;; it to include duplicates). Older emacsen expects an obarray.\n(defun erlang-etags-tags-completion-table ()\n (if (>= emacs-major-version 25)\n (erlang-etags-tags-completion-table-list)\n (let ((obarray (make-vector 511 0)))\n (dolist (tag (erlang-etags-tags-completion-table-list))\n (intern tag obarray))\n obarray)))\n\n;; Based on `etags-tags-completion-table'. The difference is that we\n;; add three strings to the list, the tag, module: and module:tag.\n;; The module is extracted from the file name of a tag. (This one\n;; only works if we are looking at an `etags' file. However, this is\n;; the only format supported by Emacs, so far.)\n(defun erlang-etags-tags-completion-table-list ()\n (let ((progress-reporter\n (make-progress-reporter\n (format \"Making tags completion table for %s...\" buffer-file-name)\n (point-min) (point-max)))\n table module)\n (save-excursion\n (goto-char (point-min))\n (while (progn\n (while (and (eq (following-char) ?\\f)\n (looking-at \"\\f\\n\\\\([^,\\n]*\\\\),.*\\n\"))\n (let ((file (buffer-substring (match-beginning 1)\n (match-end 1))))\n (setq module (erlang-get-module-from-file-name file))\n (when module\n (push (concat module \":\") table)\n (push (concat module \":module_info\") table))\n (forward-line 2)))\n ;; This regexp matches an explicit tag name or the\n ;; place where it would start.\n (re-search-forward\n \"[\\f\\t\\n\\r()=,; ]?\\177\\\\\\(?:\\\\([^\\n\\001]+\\\\)\\001\\\\)?\"\n nil t))\n (let ((tag (if (match-beginning 1)\n ;; There is an explicit tag name.\n (buffer-substring (match-beginning 1) (match-end 1))\n ;; No explicit tag name. Backtrack a little,\n ;; and look for the implicit one.\n (goto-char (match-beginning 0))\n (skip-chars-backward \"^\\f\\t\\n\\r()=,; \")\n (buffer-substring (point) (match-beginning 0)))))\n (forward-line 1)\n (push tag table)\n (when (stringp module)\n (push (concat module \":\" tag) table))\n (progress-reporter-update progress-reporter (point)))))\n table))\n\n\n\n\n;;; Xref backend erlang-etags\n\n;; In GNU Emacs 25 xref was introduced. It is a framework for cross\n;; referencing commands, in particular commands for finding\n;; definitions. It does not replace etags. It rather resides on top\n;; of it and provides user-friendly commands. The idea is that the\n;; user commands should be the same regardless of what backend does\n;; the actual finding of definitions.\n\n;; The backend below is a wrapper around the built-in etags backend.\n;; It adds awareness of the module:tag syntax in a similar way that is\n;; done above for the old etags commands.\n;;\n;; In addition arity is also considered when jumping to definitions.\n;; There is however currently no information about arity in the TAGS\n;; file. Also two functions with the same name but different arity\n;; _sometimes_ get one TAGS entry each and sometimes are joined in one\n;; single entry. If they are directly consecutive they will be\n;; joined. If there are other functions etc in between then they will\n;; get one entry each.\n;;\n;; These limitations are present in both the etags program shipped\n;; with GNU Emacs and the tags.erl program in this repository.\n;;\n;; Therefore erlang.el must complement the information in TAGS by\n;; visiting files and checking arity. When searching for popular\n;; function names (like init, handle_call etc) in a big TAGS file\n;; (like one indexing this repository) this may be quite\n;; time-consuming. There exists therefore an upper limit for the\n;; number of files to visit (called\n;; `erlang-max-files-to-visit-for-refining-xrefs').\n;;\n;; As mentioned this xref implementation is based on the etags xref\n;; implementation. But in the cases where arity is considered the\n;; etags information structures (class xref-etags-location) will be\n;; translated to our own structures which include arity (class\n;; erlang-xref-location). This translation is started in the function\n;; `erlang-refine-xrefs'.\n\n;; I mention this as a head up that some of the functions below deal\n;; with xref items with xref-etags-location and some deal with xref\n;; items with erlang-xref-location.\n\n(defun erlang-etags--xref-backend () 'erlang-etags)\n\n(defun erlang-soft-require (feature)\n (when (locate-library (symbol-name feature))\n (require feature)))\n\n(when (and (erlang-soft-require 'xref)\n (erlang-soft-require 'cl-generic)\n (erlang-soft-require 'eieio)\n (erlang-soft-require 'etags))\n ;; The purpose of using eval here is to avoid compilation\n ;; warnings in emacsen without cl-defmethod etc.\n (eval\n '(progn\n (cl-defmethod xref-backend-identifier-at-point ((_backend\n (eql erlang-etags)))\n (if (eq this-command 'xref-find-references)\n (if (use-region-p)\n (buffer-substring-no-properties (region-beginning)\n (region-end))\n (thing-at-point 'symbol))\n (erlang-id-to-string (erlang-get-identifier-at-point))))\n\n (cl-defmethod xref-backend-definitions ((_backend (eql erlang-etags))\n identifier)\n (erlang-xref-find-definitions identifier))\n\n (cl-defmethod xref-backend-apropos ((_backend (eql erlang-etags))\n identifier)\n (erlang-xref-find-definitions identifier t))\n\n (cl-defmethod xref-backend-identifier-completion-table\n ((_backend (eql erlang-etags)))\n (let ((erlang-replace-etags-tags-completion-table t))\n (tags-completion-table)))\n\n (defclass erlang-xref-location (xref-file-location)\n ((arity :type fixnum :initarg :arity\n :reader erlang-xref-location-arity))\n :documentation \"An erlang location is a file location plus arity.\")\n\n ;; This method definition only calls the superclass which is\n ;; the default behaviour if it was not defined. It is only\n ;; needed for \"upgrade\" purposes. In version 2.8.1 of\n ;; erlang.el this method was defined differently and in case\n ;; user switch to a new erlang.el without restarting Emacs\n ;; this method needs to be redefined.\n (cl-defmethod xref-location-marker ((locus erlang-xref-location))\n (cl-call-next-method locus)))))\n\n;; If this function returns a single xref the user will jump to that\n;; directly. If two or more xrefs are returned a *xref* window is\n;; displayed and the user can choose where to jump. Hence we want to\n;; return a single xref when we are pretty sure that is where the user\n;; wants to go. Otherwise return all possible xrefs but sort them so\n;; that xrefs in the local file is first and if arity is known sort\n;; the xrefs with matching arity before others.\n\n;; Note that the arity sorting work may partly be undone later when\n;; the hits are presented in the *xref* buffer since they then will be\n;; grouped together by file. Ie when one file have one hit with\n;; correct arity and others with wrong arity these hits will be\n;; grouped together and may end up before hits with correct arity.\n(defun erlang-xref-find-definitions (identifier &optional is-regexp)\n (erlang-with-id (kind module name arity) identifier\n (cond ((eq kind 'module)\n (erlang-xref-find-definitions-module name))\n ((eq kind 'qualified-function)\n (erlang-xref-find-definitions-qualified-function module\n name\n arity\n is-regexp))\n (module\n (erlang-xref-find-definitions-module-tag kind\n module\n name\n arity\n is-regexp))\n (t\n (erlang-xref-find-definitions-tag kind name arity is-regexp)))))\n\n(defun erlang-xref-find-definitions-module (module)\n (and (fboundp 'xref-make)\n (fboundp 'xref-make-file-location)\n (let* ((first-time t)\n (cbuf (current-buffer))\n xrefs matching-files)\n (save-excursion\n (while (erlang-visit-tags-table-buffer (not first-time) cbuf)\n (setq first-time nil)\n (let ((files (tags-table-files)))\n (while files\n (let* ((file (car files))\n (m (erlang-get-module-from-file-name file)))\n (when (and m (string-equal m module))\n (unless (member file matching-files)\n (push file\n matching-files)\n (push (xref-make file\n (xref-make-file-location file 1 0))\n xrefs))))\n (setq files (cdr files))))))\n (nreverse xrefs))))\n\n(defun erlang-xref-find-definitions-qualified-function (module\n tag\n arity\n is-regexp)\n \"Find definitions of TAG in MODULE preferably with arity ARITY.\nIf one single perfect match was found return only that (ignoring\nother definitions matching TAG). If IS-REGEXP is non-nil then\nTAG is a regexp.\"\n (let* ((xrefs (when (fboundp 'etags--xref-find-definitions)\n (etags--xref-find-definitions tag is-regexp)))\n (xrefs-split (erlang-split-xrefs-on-module xrefs module))\n (module-xrefs (car xrefs-split))\n (module-xrefs (erlang-refine-xrefs module-xrefs\n 'qualified-function\n tag\n is-regexp)))\n (or (erlang-single-arity-match module-xrefs arity)\n (erlang-sort-by-arity module-xrefs arity))))\n\n\n;; We will end up here when erlang-get-some-other-id-at-point either\n;; found module among the import statements or module is just the\n;; current local file.\n(defun erlang-xref-find-definitions-module-tag (kind\n module\n tag\n arity\n is-regexp)\n \"Find definitions of TAG preferably in MODULE and with arity ARITY.\nReturn definitions outside MODULE if none are found inside. If\nIS-REGEXP is non-nil then TAG is a regexp.\n\nIf one single perfect match was found return only that (ignoring\nother definitions matching TAG).\"\n (let* ((xrefs (when (fboundp 'etags--xref-find-definitions)\n (etags--xref-find-definitions tag is-regexp)))\n (xrefs-split (erlang-split-xrefs-on-module xrefs module))\n (module-xrefs (car xrefs-split))\n (module-xrefs (erlang-refine-xrefs module-xrefs\n kind\n tag\n is-regexp)))\n (or (erlang-single-arity-match module-xrefs arity)\n (erlang-xref-find-definitions-tag kind tag arity is-regexp xrefs))))\n\n(defun erlang-xref-find-definitions-tag (kind\n tag\n arity\n is-regexp\n &optional xrefs)\n \"Find definitions of TAG preferably in local file and with arity ARITY.\nIf one single perfect match was found return only that (ignoring\nother definitions matching TAG). If no such local match was\nfound then look for a matching BIF in the same way. If IS-REGEXP\nis non-nil then TAG is a regexp.\"\n (let* ((regexp (erlang-etags-regexp kind tag is-regexp))\n (xrefs (or xrefs\n (when (fboundp 'etags--xref-find-definitions)\n (etags--xref-find-definitions regexp t))))\n (xrefs-split (erlang-split-xrefs xrefs))\n (local-xrefs (car xrefs-split))\n (local-xrefs (erlang-refine-xrefs local-xrefs\n kind\n tag\n is-regexp))\n (bif-xrefs (cadr xrefs-split))\n (other-xrefs (caddr xrefs-split)))\n (or (erlang-single-arity-match local-xrefs arity)\n ;; No local match, look for a matching BIF.\n (progn\n (setq bif-xrefs (erlang-refine-xrefs bif-xrefs\n kind\n tag\n is-regexp))\n (erlang-single-arity-match bif-xrefs arity))\n (progn\n (setq other-xrefs (erlang-refine-xrefs other-xrefs\n kind\n tag\n is-regexp))\n (and (null local-xrefs)\n (null bif-xrefs)\n ;; No local of BIF matches at all. Is there a single\n ;; arity match among the rest?\n (erlang-single-arity-match other-xrefs arity)))\n (append (erlang-sort-by-arity local-xrefs arity)\n (erlang-sort-by-arity bif-xrefs arity)\n (erlang-sort-by-arity other-xrefs arity)))))\n\n\n(defun erlang-refine-xrefs (xrefs kind tag is-regexp)\n (if (or (memq kind '(record module))\n ;; No support for apropos here.\n is-regexp\n (erlang-too-many-files-in-xrefs xrefs))\n xrefs\n (when (and xrefs\n (fboundp 'xref-item-location)\n (fboundp 'xref-location-group)\n (fboundp 'slot-value))\n (let (files)\n (cl-loop for xref in xrefs\n for loc = (xref-item-location xref)\n for file = (xref-location-group loc)\n do (pushnew file files :test 'string-equal))\n (or (cl-loop for file in files\n append (erlang-xrefs-in-file file kind tag is-regexp))\n ;; Failed for some reason. Pretend like it is raining and\n ;; return the unrefined xrefs.\n xrefs)))))\n\n(defun erlang-too-many-files-in-xrefs (xrefs)\n (and erlang-max-files-to-visit-for-refining-xrefs\n (let ((files-to-visit (delete-dups\n (mapcar #'erlang-xref-truename-file\n xrefs))))\n (if (< (length files-to-visit)\n erlang-max-files-to-visit-for-refining-xrefs)\n nil\n (message (concat \"Too many hits to consider arity (see \"\n \"`erlang-max-files-to-visit-for-refining-xrefs')\"))\n t))))\n\n(defun erlang-xrefs-in-file (file kind tag is-regexp)\n (when (fboundp 'make-instance)\n (with-current-buffer (find-file-noselect file)\n (save-excursion\n (goto-char (point-min))\n (let ((regexp (concat ; \"^\"\n (erlang-etags-regexp kind tag is-regexp)\n \"\\\\s *(\"))\n last-arity)\n (cl-loop while (re-search-forward regexp nil t)\n for name = (match-string-no-properties 1)\n for arity = (save-excursion\n (erlang-get-arity))\n for loc = (make-instance 'erlang-xref-location\n :file file\n :line (line-number-at-pos)\n :column 0\n :arity arity)\n for sum = (erlang-xref-summary kind name arity)\n when (and arity\n (not (eq arity last-arity)))\n collect (make-instance 'xref-item\n :summary sum\n :location loc)\n do (setq last-arity arity)))))))\n\n(defun erlang-xref-summary (kind tag arity)\n (format \"%s%s%s\"\n (if (memq kind '(record macro module))\n (format \"%s \" kind)\n \"\")\n tag\n (if arity (format \"\/%s\" arity) \"\")))\n\n(defun erlang-single-arity-match (xrefs wanted-arity)\n \"Attempt to find one perfect match.\n\nIf we have all information needed to consider arity then return a\nsingle perfect match or nothing. If there are more than one\nmatch nothing is returned.\n\nIf we don't have all information needed to consider arity just\nreturn XREFS as is.\"\n (if (erlang-should-consider-arity-p xrefs wanted-arity)\n (let ((nr-matches 0)\n match)\n (while (and xrefs\n (< nr-matches 2))\n (let* ((xref (car xrefs))\n (arity (erlang-xref-arity xref)))\n (when (eq arity wanted-arity)\n (setq match xref\n nr-matches (1+ nr-matches)))\n (setq xrefs (cdr xrefs))))\n (when (eq nr-matches 1)\n (list match)))\n (when (eq (length xrefs) 1)\n xrefs)))\n\n(defun erlang-sort-by-arity (xrefs wanted-arity)\n (if (erlang-should-consider-arity-p xrefs wanted-arity)\n (let (matches non-matches)\n (while xrefs\n (let* ((xref (car xrefs))\n (arity (erlang-xref-arity xref)))\n (push xref (if (eq arity wanted-arity)\n matches\n non-matches))\n (setq xrefs (cdr xrefs))))\n (append (reverse matches) (reverse non-matches) xrefs))\n xrefs))\n\n(defun erlang-should-consider-arity-p (xrefs wanted-arity)\n (and wanted-arity\n xrefs\n (fboundp 'erlang-xref-location-p)\n (fboundp 'xref-item-location)\n (erlang-xref-location-p (xref-item-location (car xrefs)))))\n\n(defun erlang-etags-regexp (kind tag is-regexp)\n (let ((tag-regexp (concat \"\\\\(\"\n (if is-regexp\n tag\n (regexp-quote tag))\n \"\\\\)\")))\n (concat (if is-regexp \"\" \"^\")\n (cond ((eq kind 'record)\n (concat \"-record\\\\s-*(\\\\s-*\" tag-regexp))\n ((eq kind 'macro)\n (concat \"-define\\\\s-*(\\\\s-*\" tag-regexp))\n (t\n tag-regexp))\n (if is-regexp \"\" \"\\\\_>\"))))\n\n(defun erlang-xref-arity (xref)\n (and (fboundp 'erlang-xref-location-arity)\n (fboundp 'xref-item-location)\n (erlang-xref-location-arity (xref-item-location xref))))\n\n(defun erlang-split-xrefs-on-module (xrefs module)\n (let (local-xrefs non-local-xrefs)\n (dolist (xref xrefs)\n (if (string-equal (erlang-xref-module xref)\n module)\n (push xref local-xrefs)\n (push xref non-local-xrefs)))\n (cons (reverse local-xrefs)\n (reverse non-local-xrefs))))\n\n(defun erlang-split-xrefs (xrefs)\n (let ((current-file (and (buffer-file-name)\n (file-truename (buffer-file-name))))\n local-xrefs bif-xrefs other-xrefs)\n (dolist (xref xrefs)\n (cond ((string-equal (erlang-xref-truename-file xref) current-file)\n (push xref local-xrefs))\n ((string-equal (erlang-xref-module xref) \"erlang\")\n (push xref bif-xrefs))\n (t\n (push xref other-xrefs))))\n (list (reverse local-xrefs)\n (reverse bif-xrefs)\n (reverse other-xrefs))))\n\n(defun erlang-xref-module (xref)\n (erlang-get-module-from-file-name (erlang-xref-file xref)))\n\n(defun erlang-xref-truename-file (xref)\n (let ((file (erlang-xref-file xref)))\n (and file\n (file-truename file))))\n\n(defun erlang-xref-file (xref)\n (and (fboundp 'xref-location-group)\n (fboundp 'xref-item-location)\n (xref-location-group (xref-item-location xref))))\n\n(defun erlang-visit-tags-table-buffer (cont cbuf)\n (if (< emacs-major-version 26)\n (visit-tags-table-buffer cont)\n ;; Remove this with-no-warnings when Emacs 26 is the required\n ;; version minimum.\n (with-no-warnings\n (visit-tags-table-buffer cont cbuf))))\n\n;;;\n;;; Prepare for other methods to run an Erlang slave process.\n;;;\n\n(defvar erlang-shell-function 'inferior-erlang\n \"Command to execute start a new Erlang shell.\n\nChange this variable to use your favorite\nErlang compilation package.\")\n\n(defvar erlang-shell-display-function 'inferior-erlang-run-or-select\n \"Command to execute to display Erlang shell.\n\nChange this variable to use your favorite\nErlang compilation package.\")\n\n(defvar erlang-compile-function 'inferior-erlang-compile\n \"Command to execute to compile current buffer.\n\nChange this variable to use your favorite\nErlang compilation package.\")\n\n(defvar erlang-compile-erlang-function \"c\"\n \"Erlang function to call to compile an erlang file.\")\n\n(defvar erlang-compile-display-function 'inferior-erlang-run-or-select\n \"Command to execute to view last compilation.\n\nChange this variable to use your favorite\nErlang compilation package.\")\n\n(defvar erlang-next-error-function 'inferior-erlang-next-error\n \"Command to execute to go to the next error.\n\nChange this variable to use your favorite Erlang compilation\npackage.\")\n\n\n;;;###autoload\n(defun erlang-shell ()\n \"Start a new Erlang shell.\n\nThe variable `erlang-shell-function' decides which method to use,\ndefault is to start a new Erlang host. It is possible that, in the\nfuture, a new shell on an already running host will be started.\"\n (interactive)\n (call-interactively erlang-shell-function))\n\n\n;;;###autoload (autoload 'run-erlang \"erlang\" \"Start a new Erlang shell.\" t)\n\n;; It is customary for Emacs packages to supply a function on this\n;; form, even though it violates the `erlang-*' name convention.\n(defalias 'run-erlang 'erlang-shell)\n\n\n(defun erlang-shell-display ()\n \"Display an Erlang shell, or start a new.\"\n (interactive)\n (call-interactively erlang-shell-display-function))\n\n\n;;;###autoload\n(defun erlang-compile ()\n \"Compile Erlang module in current buffer.\"\n (interactive)\n (call-interactively erlang-compile-function))\n\n\n(defun erlang-compile-display ()\n \"Display compilation output.\"\n (interactive)\n (call-interactively erlang-compile-display-function))\n\n\n(defun erlang-next-error ()\n \"Display next error message from the latest compilation.\"\n (interactive)\n (call-interactively erlang-next-error-function))\n\n\n\n;;;\n;;; Erlang Shell Mode -- Major mode used for Erlang shells.\n;;;\n\n;; This mode is designed to be implementation independent,\n;; e.g. it does not assume that we are running an inferior\n;; Erlang, there exists a lot of other possibilities.\n\n(defvar erlang-shell-buffer-name \"*erlang*\"\n \"The name of the Erlang link shell buffer.\")\n\n(defcustom erlang-shell-prompt-read-only t\n \"If non-nil, the prompt will be read-only.\n\nAlso see the description of `ielm-prompt-read-only'.\"\n :type 'boolean\n :package-version '(erlang . \"2.8.0\"))\n\n(defvar erlang-shell-mode-map\n (let ((map (make-sparse-keymap)))\n (define-key map \"\\M-\\t\" 'erlang-complete-tag)\n\n ;; Normally the other way around.\n (define-key map \"\\C-a\" 'comint-bol)\n (define-key map \"\\C-c\\C-a\" 'beginning-of-line)\n\n (define-key map \"\\C-d\" nil) ; Was `comint-delchar-or-maybe-eof'\n (define-key map \"\\M-\\C-m\" 'compile-goto-error)\n map)\n \"Keymap used by Erlang shells.\")\n\n(defvar erlang-input-ring-file-name \"~\/.erlang_history\"\n \"When non-nil, file name used to store Erlang shell history information.\")\n\n(define-derived-mode erlang-shell-mode comint-mode \"Erlang Shell\"\n \"Major mode for interacting with an Erlang shell.\n\nThe following special commands are available:\n\\\\{erlang-shell-mode-map}\"\n (erlang-mode-variables)\n ;; Needed when compiling directly from the Erlang shell.\n (setq compilation-last-buffer (current-buffer))\n (setq comint-prompt-regexp \"^[^>=]*> *\")\n (make-local-variable 'comint-prompt-read-only)\n (setq comint-prompt-read-only erlang-shell-prompt-read-only)\n (setq comint-eol-on-send t)\n (setq comint-input-ignoredups t)\n (setq comint-scroll-show-maximum-output t)\n (setq comint-scroll-to-bottom-on-output t)\n (add-hook 'comint-output-filter-functions\n 'inferior-erlang-strip-delete nil t)\n (add-hook 'comint-output-filter-functions\n 'inferior-erlang-strip-ctrl-m nil t)\n (setq comint-input-ring-file-name erlang-input-ring-file-name)\n (comint-read-input-ring t)\n (make-local-variable 'kill-buffer-hook)\n (add-hook 'kill-buffer-hook 'comint-write-input-ring)\n (compilation-minor-mode 1)\n (set (make-local-variable 'minor-mode-overriding-map-alist)\n `((compilation-minor-mode\n . ,(let ((map (make-sparse-keymap)))\n ;; It would be useful to put keymap properties on the\n ;; error lines so that we could use RET and mouse-2\n ;; on them directly.\n (when (boundp 'compilation-skip-threshold) ; new compile.el\n (define-key map [mouse-2] #'erlang-mouse-2-command)\n (define-key map \"\\C-m\" #'erlang-RET-command))\n (if (boundp 'compilation-menu-map)\n (define-key map [menu-bar compilation]\n (cons \"Errors\" compilation-menu-map)))\n map))))\n (erlang-tags-init))\n\n\n(defun erlang-mouse-2-command (event)\n \"Command bound to `mouse-2' in inferior Erlang buffer.\nSelects Comint or Compilation mode command as appropriate.\"\n (interactive \"e\")\n (if (save-window-excursion\n (save-excursion\n (mouse-set-point event)\n (consp (get-text-property (line-beginning-position) 'message))))\n (call-interactively (lookup-key compilation-mode-map [mouse-2]))\n (call-interactively (lookup-key comint-mode-map [mouse-2]))))\n\n(defun erlang-RET-command ()\n \"Command bound to `RET' in inferior Erlang buffer.\nSelects Comint or Compilation mode command as appropriate.\"\n (interactive)\n (if (consp (get-text-property (line-beginning-position) 'message))\n (call-interactively (lookup-key compilation-mode-map \"\\C-m\"))\n (call-interactively (lookup-key comint-mode-map \"\\C-m\"))))\n\n;;;\n;;; Inferior Erlang -- Run an Erlang shell as a subprocess.\n;;;\n\n(defvar inferior-erlang-display-buffer-any-frame nil\n \"When nil, `inferior-erlang-display-buffer' use only selected frame.\nWhen t, all frames are searched. When 'raise, the frame is raised.\")\n\n(defvar inferior-erlang-shell-type 'newshell\n \"The type of Erlang shell to use.\n\nWhen this variable is set to the atom `oldshell', the old shell is used.\nWhen set to `newshell' the new shell is used. Should the variable be\nnil, the default shell is used.\n\nThis variable influence the setting of other variables.\")\n\n(defvar inferior-erlang-machine \"erl\"\n \"The name of the Erlang shell.\")\n\n(defvar inferior-erlang-machine-options '()\n \"The options used when activating the Erlang shell.\n\nThis must be a list of strings.\")\n\n(defvar inferior-erlang-process-name \"inferior-erlang\"\n \"The name of the inferior Erlang process.\")\n\n(defvar inferior-erlang-buffer-name erlang-shell-buffer-name\n \"The name of the inferior Erlang buffer.\")\n\n(defvar inferior-erlang-prompt-timeout 60\n \"Number of seconds before `inferior-erlang-wait-prompt' timeouts.\n\nThe time specified is waited after every output made by the inferior\nErlang shell. When this variable is t, we assume that we always have\na prompt. When nil, we will wait forever, or until \\\\[keyboard-quit].\")\n\n(defvar inferior-erlang-process nil\n \"Process of last invoked inferior Erlang, or nil.\")\n\n(defvar inferior-erlang-buffer nil\n \"Buffer of last invoked inferior Erlang, or nil.\")\n\n;; Enable uniquifying Erlang shell buffers based on directory name.\n(eval-after-load \"uniquify\"\n '(add-to-list 'uniquify-list-buffers-directory-modes 'erlang-shell-mode))\n\n;;;###autoload\n(defun inferior-erlang (&optional command)\n \"Run an inferior Erlang.\nWith prefix command, prompt for command to start Erlang with.\n\nThis is just like running Erlang in a normal shell, except that\nan Emacs buffer is used for input and output.\n\\\\\nThe command line history can be accessed with \\\\[comint-previous-input] and \\\\[comint-next-input].\nThe history is saved between sessions.\n\nEntry to this mode calls the functions in the variables\n`comint-mode-hook' and `erlang-shell-mode-hook' with no arguments.\n\nThe following commands imitate the usual Unix interrupt and\nediting control characters:\n\\\\{erlang-shell-mode-map}\"\n (interactive\n (when current-prefix-arg\n (list (read-shell-command \"Erlang command: \"))))\n (require 'comint)\n (let (cmd opts)\n (if command\n (setq cmd \"sh\"\n opts (list \"-c\" command))\n (setq cmd inferior-erlang-machine\n opts inferior-erlang-machine-options)\n (cond ((eq inferior-erlang-shell-type 'oldshell)\n (setq opts (cons \"-oldshell\" opts)))\n ((eq inferior-erlang-shell-type 'newshell)\n (setq opts (append '(\"-newshell\" \"-env\" \"TERM\" \"vt100\") opts)))))\n\n ;; Using create-file-buffer and list-buffers-directory in this way\n ;; makes uniquify give each buffer a unique name based on the\n ;; directory.\n (let ((fake-file-name (expand-file-name inferior-erlang-buffer-name default-directory)))\n (setq inferior-erlang-buffer (create-file-buffer fake-file-name))\n (apply 'make-comint-in-buffer\n inferior-erlang-process-name\n inferior-erlang-buffer\n cmd\n nil opts)\n (with-current-buffer inferior-erlang-buffer\n (setq list-buffers-directory fake-file-name))))\n\n (setq inferior-erlang-process\n (get-buffer-process inferior-erlang-buffer))\n (funcall (symbol-function 'set-process-query-on-exit-flag)\n inferior-erlang-process nil)\n (if erlang-inferior-shell-split-window\n (switch-to-buffer-other-window inferior-erlang-buffer)\n (switch-to-buffer inferior-erlang-buffer))\n (if (and (not (eq system-type 'windows-nt))\n (eq inferior-erlang-shell-type 'newshell))\n (setq comint-process-echoes t))\n (erlang-shell-mode))\n\n\n(defun inferior-erlang-run-or-select ()\n \"Switch to an inferior Erlang buffer, possibly starting new process.\"\n (interactive)\n (if (null (inferior-erlang-running-p))\n (inferior-erlang)\n (inferior-erlang-display-buffer t)))\n\n\n(defun inferior-erlang-display-buffer (&optional select)\n \"Make the inferior Erlang process visible.\nThe window is returned.\n\nShould `inferior-erlang-display-buffer-any-frame' be nil the buffer is\ndisplayed in the current frame. Should it be non-nil, and the buffer\nalready is visible in any other frame, no new window will be created.\nShould it be the atom 'raise, the frame containing the window will\nbe raised.\n\nShould the optional argument SELECT be non-nil, the window is\nselected. Should the window be in another frame, that frame is raised.\n\nNote, should the mouse pointer be places outside the raised frame, that\nframe will become deselected before the next command.\"\n (interactive)\n (or (inferior-erlang-running-p)\n (error \"No inferior Erlang process is running\"))\n (let ((win (inferior-erlang-window\n inferior-erlang-display-buffer-any-frame))\n (frames-p (fboundp 'selected-frame)))\n (if (null win)\n (let ((old-win (selected-window)))\n (save-excursion\n (switch-to-buffer-other-window inferior-erlang-buffer)\n (setq win (selected-window)))\n (select-window old-win))\n (if (and window-system\n frames-p\n (or select\n (eq inferior-erlang-display-buffer-any-frame 'raise))\n (not (eq (selected-frame) (window-frame win))))\n (raise-frame (window-frame win))))\n (if select\n (select-window win))\n (sit-for 0)\n win))\n\n\n(defun inferior-erlang-running-p ()\n \"Non-nil when an inferior Erlang is running.\"\n (and inferior-erlang-process\n (memq (process-status inferior-erlang-process) '(run open))\n inferior-erlang-buffer\n (buffer-name inferior-erlang-buffer)))\n\n\n(defun inferior-erlang-window (&optional all-frames)\n \"Return the window containing the inferior Erlang, or nil.\"\n (and (inferior-erlang-running-p)\n (if all-frames\n (get-buffer-window inferior-erlang-buffer t)\n (get-buffer-window inferior-erlang-buffer))))\n\n\n(defun inferior-erlang-wait-prompt ()\n \"Wait until the inferior Erlang shell prompt appears.\"\n (if (eq inferior-erlang-prompt-timeout t)\n ()\n (or (inferior-erlang-running-p)\n (error \"No inferior Erlang shell is running\"))\n (with-current-buffer inferior-erlang-buffer\n (let ((msg nil))\n (while (save-excursion\n (goto-char (process-mark inferior-erlang-process))\n (forward-line 0)\n (not (looking-at comint-prompt-regexp)))\n (if msg\n ()\n (setq msg t)\n (message \"Waiting for Erlang shell prompt (press C-g to abort).\"))\n (or (accept-process-output inferior-erlang-process\n inferior-erlang-prompt-timeout)\n (error \"No Erlang shell prompt before timeout\")))\n (if msg (message \"\"))))))\n\n(defun inferior-erlang-send-empty-cmd-unless-already-at-prompt ()\n \"If not already at a prompt, try to send an empty cmd to get a prompt.\nThe empty command resembles hitting RET. This is useful in some\nsituations, for instance if a crash or error report from sasl\nhas been printed after the last prompt.\"\n (with-current-buffer inferior-erlang-buffer\n (if (> (point-max) 1)\n ;; make sure we get a prompt if buffer contains data\n (if (save-excursion\n (goto-char (process-mark inferior-erlang-process))\n (forward-line 0)\n (not (looking-at comint-prompt-regexp)))\n (inferior-erlang-send-command \"\")))))\n\n(autoload 'comint-send-input \"comint\")\n\n(defun inferior-erlang-send-command (cmd &optional hist)\n \"Send command CMD to the inferior Erlang.\n\nThe contents of the current command line (if any) will\nbe placed at the next prompt.\n\nIf optional second argument is non-nil the command is inserted into\nthe history list.\n\nReturn the position after the newly inserted command.\"\n (or (inferior-erlang-running-p)\n (error \"No inferior Erlang process is running\"))\n (let ((old-buffer (current-buffer))\n (insert-point (marker-position (process-mark inferior-erlang-process)))\n (insert-length (if comint-process-echoes\n 0\n (1+ (length cmd)))))\n (set-buffer inferior-erlang-buffer)\n (goto-char insert-point)\n (insert cmd)\n ;; Strange things happened if `comint-eol-on-send' is declared\n ;; in the `let' expression above, but setq:d here. The\n ;; `set-buffer' statement obviously makes the buffer local\n ;; instance of `comint-eol-on-send' shadow this one.\n ;; I'm considering this a bug in Elisp.\n ;;\n ;; This was previously cautioned against in the Lisp manual. It\n ;; has been sorted out in Emacs 21. -- fx\n (let ((comint-eol-on-send nil)\n (comint-input-filter (if hist comint-input-filter 'ignore)))\n (comint-send-input nil t))\n ;; Adjust all windows whose points are incorrect.\n (if (null comint-process-echoes)\n (walk-windows\n (function\n (lambda (window)\n (if (and (eq (window-buffer window) inferior-erlang-buffer)\n (= (window-point window) insert-point))\n (set-window-point window\n (+ insert-point insert-length)))))\n nil t))\n (set-buffer old-buffer)\n (+ insert-point insert-length)))\n\n\n(defun inferior-erlang-strip-delete (&optional _s)\n \"Remove `^H' (delete) and the characters it was supposed to remove.\"\n (interactive)\n (if (and (boundp 'comint-last-input-end)\n (boundp 'comint-last-output-start))\n (save-excursion\n (goto-char\n (if (called-interactively-p 'interactive)\n (symbol-value 'comint-last-input-end)\n (symbol-value 'comint-last-output-start)))\n (while (progn (skip-chars-forward \"^\\C-h\")\n (not (eq (point) (point-max))))\n (delete-char 1)\n (or (bolp)\n (backward-delete-char 1))))))\n\n\n;; Basically `comint-strip-ctrl-m', with a few extra checks.\n(defun inferior-erlang-strip-ctrl-m (&optional _string)\n \"Strip trailing `^M' characters from the current output group.\"\n (interactive)\n (if (and (boundp 'comint-last-input-end)\n (boundp 'comint-last-output-start))\n (let ((pmark (process-mark (get-buffer-process (current-buffer)))))\n (save-excursion\n (goto-char\n (if (called-interactively-p 'interactive)\n (symbol-value 'comint-last-input-end)\n (symbol-value 'comint-last-output-start)))\n (while (re-search-forward \"\\r+$\" pmark t)\n (replace-match \"\" t t))))))\n\n\n(defun inferior-erlang-compile (arg)\n \"Compile the file in the current buffer.\n\nWith prefix arg, compiles for debug.\n\nShould Erlang return `{error, nofile}' it could not load the object\nmodule after completing the compilation. This is due to a bug in the\ncompile command `c' when using the option `outdir'.\n\nThere exists two workarounds for this bug:\n\n 1) Place the directory in the Erlang load path.\n\n 2) Set the Emacs variable `erlang-compile-use-outdir' to nil.\n To do so, place the following line in your `~\/.emacs'-file:\n (setq erlang-compile-use-outdir nil)\"\n (interactive \"P\")\n (save-some-buffers)\n (inferior-erlang-prepare-for-input)\n (let* ((dir (inferior-erlang-compile-outdir))\n (noext (substring (erlang-local-buffer-file-name) 0 -4))\n (opts (append (list (cons 'outdir dir))\n (when arg\n (list 'debug_info 'export_all))\n erlang-compile-extra-opts))\n end)\n (with-current-buffer inferior-erlang-buffer\n (when (fboundp 'compilation-forget-errors)\n (compilation-forget-errors)))\n (setq end (inferior-erlang-send-command\n (inferior-erlang-compute-compile-command noext opts)\n nil))\n (sit-for 0)\n (inferior-erlang-wait-prompt)\n (with-current-buffer inferior-erlang-buffer\n (setq compilation-error-list nil)\n (set-marker compilation-parsing-end end))\n (setq compilation-last-buffer inferior-erlang-buffer)))\n\n(defun inferior-erlang-prepare-for-input (&optional no-display)\n \"Create an inferior erlang buffer if needed and ready it for input.\nThe buffer is displayed, according to `inferior-erlang-display-buffer'\nunless the optional NO-DISPLAY is non-nil.\"\n (or (inferior-erlang-running-p)\n (save-excursion\n (inferior-erlang)))\n (or (inferior-erlang-running-p)\n (error \"Error starting inferior Erlang shell\"))\n (if (not no-display)\n (inferior-erlang-display-buffer))\n (inferior-erlang-send-empty-cmd-unless-already-at-prompt)\n (sit-for 0)\n (inferior-erlang-wait-prompt))\n\n(defun inferior-erlang-compile-outdir ()\n \"Return the directory to compile the current buffer into.\"\n (let* ((buffer-dir (directory-file-name\n (file-name-directory (erlang-local-buffer-file-name))))\n (parent-dir (directory-file-name\n (file-name-directory buffer-dir)))\n (ebin-dir (concat (file-name-as-directory parent-dir) \"ebin\"))\n (buffer-dir-base-name (file-name-nondirectory\n (expand-file-name\n (concat (file-name-as-directory buffer-dir)\n \".\")))))\n (if (and (string= buffer-dir-base-name \"src\")\n (file-directory-p ebin-dir))\n (file-name-as-directory ebin-dir)\n (file-name-as-directory buffer-dir))))\n\n(defun inferior-erlang-compute-compile-command (module-name opts)\n (let ((ccfn erlang-compile-command-function-alist)\n ccfn-entry\n done\n result)\n (if (not (null (erlang-local-buffer-file-name)))\n (while (and (not done) (not (null ccfn)))\n (setq ccfn-entry (car ccfn))\n (setq ccfn (cdr ccfn))\n (if (string-match (car ccfn-entry) (erlang-local-buffer-file-name))\n (let ((c-fn (cdr ccfn-entry)))\n (setq done t)\n (if (not (null c-fn))\n (setq result (funcall c-fn module-name opts)))))))\n result))\n\n(defun inferior-erlang-compute-erl-compile-command (module-name opts)\n (let* ((out-dir-opt (assoc 'outdir opts))\n (out-dir (cdr out-dir-opt)))\n (if erlang-compile-use-outdir\n (format \"%s(\\\"%s\\\"%s).\"\n erlang-compile-erlang-function\n module-name\n (inferior-erlang-format-comma-opts opts))\n (let (;; Hopefully, noone else will ever use these...\n (tmpvar \"Tmp7236\")\n (tmpvar2 \"Tmp8742\"))\n (format\n (concat\n \"f(%s), {ok, %s} = file:get_cwd(), \"\n \"file:set_cwd(\\\"%s\\\"), \"\n \"%s = %s(\\\"%s\\\"%s), file:set_cwd(%s), f(%s), %s.\")\n tmpvar2 tmpvar\n out-dir\n tmpvar2\n erlang-compile-erlang-function\n module-name (inferior-erlang-format-comma-opts\n (remq out-dir-opt opts))\n tmpvar tmpvar tmpvar2)))))\n\n(defun inferior-erlang-compute-leex-compile-command (module-name opts)\n (let ((file-name (erlang-local-buffer-file-name))\n (erl-compile-expr (inferior-erlang-remove-any-trailing-dot\n (inferior-erlang-compute-erl-compile-command\n module-name opts))))\n (format (concat \"f(LErr1__), f(LErr2__), \"\n \"case case leex:file(\\\"%s\\\", [%s]) of\"\n \" ok -> ok;\"\n \" {ok,_} -> ok;\"\n \" {ok,_,_} -> ok;\"\n \" LErr1__ -> LErr1__ \"\n \"end of\"\n \" ok -> %s;\"\n \" LErr2__ -> LErr2__ \"\n \"end.\")\n file-name\n (inferior-erlang-format-comma-opts erlang-leex-compile-opts)\n erl-compile-expr)))\n\n(defun inferior-erlang-compute-yecc-compile-command (module-name opts)\n (let ((file-name (erlang-local-buffer-file-name))\n (erl-compile-expr (inferior-erlang-remove-any-trailing-dot\n (inferior-erlang-compute-erl-compile-command\n module-name opts))))\n (format (concat \"f(YErr1__), f(YErr2__), \"\n \"case case yecc:file(\\\"%s\\\", [%s]) of\"\n \" {ok,_} -> ok;\"\n \" {ok,_,_} -> ok;\"\n \" YErr1__ -> YErr1__ \"\n \"end of\"\n \" ok -> %s;\"\n \" YErr2__ -> YErr2__ \"\n \"end.\")\n file-name\n (inferior-erlang-format-comma-opts erlang-yecc-compile-opts)\n erl-compile-expr)))\n\n(defun inferior-erlang-remove-any-trailing-dot (str)\n (if (string= (substring str -1) \".\")\n (substring str 0 (1- (length str)))\n str))\n\n(defun inferior-erlang-format-comma-opts (opts)\n (if (null opts)\n \"\"\n (concat \", \" (inferior-erlang-format-opt opts))))\n\n(defun inferior-erlang-format-opt (opt)\n (cond ((stringp opt) (concat \"\\\"\" opt \"\\\"\"))\n ((vectorp opt) (inferior-erlang-tuple (append opt nil)))\n ((atom opt) (format \"%s\" opt))\n ((consp opt) (if (listp (cdr opt))\n (inferior-erlang-list opt)\n (inferior-erlang-tuple (list (car opt) (cdr opt)))))\n (t (error \"Unexpected erlang compile option %s\" opt))))\n\n(defun inferior-erlang-tuple (opts)\n (concat \"{\" (mapconcat 'inferior-erlang-format-opt\n opts\n \", \")\n \"}\"))\n\n(defun inferior-erlang-list (opts)\n (concat \"[\" (mapconcat 'inferior-erlang-format-opt\n opts\n \", \")\n \"]\"))\n\n\n(defun erlang-local-buffer-file-name ()\n ;; When editing a file remotely via tramp,\n ;; the buffer's file name may be for example\n ;; \"\/ssh:host.example.com:\/some\/path\/x.erl\"\n ;;\n ;; If I try to compile such a file using C-c C-k, an\n ;; erlang shell on the remote host is automatically\n ;; started if needed, but for it to successfully compile\n ;; the file, the c(...) command that is sent must contain\n ;; the file name \"\/some\/path\/x.erl\" without the\n ;; tramp-prefix \"\/ssh:host.example.com:\".\n (cond ((null (buffer-file-name))\n nil)\n ((erlang-tramp-remote-file-p)\n (erlang-tramp-get-localname))\n (t\n (buffer-file-name))))\n\n(defun erlang-tramp-remote-file-p ()\n (and (fboundp 'tramp-tramp-file-p)\n (tramp-tramp-file-p (buffer-file-name))))\n\n(defun erlang-tramp-get-localname ()\n (when (fboundp 'tramp-dissect-file-name)\n (let ((tramp-info (tramp-dissect-file-name (buffer-file-name))))\n (if (fboundp 'tramp-file-name-localname)\n (tramp-file-name-localname tramp-info)\n ;; In old versions of tramp, it was `tramp-file-name-path'\n ;; instead of the newer `tramp-file-name-localname'\n (when (fboundp 'tramp-file-name-path)\n (tramp-file-name-path tramp-info))))))\n\n;; `next-error' only accepts buffers with major mode `compilation-mode'\n;; or with the minor mode `compilation-minor-mode' activated.\n;; (To activate the minor mode is out of the question, since it will\n;; ruin the inferior Erlang keymap.)\n;; This is done differently in Emacs 21.\n(defun inferior-erlang-next-error (&optional argp)\n \"Just like `next-error'.\nCapable of finding error messages in an inferior Erlang buffer.\"\n (interactive \"P\")\n (let ((done nil)\n (buf (or (and (boundp 'next-error-last-buffer)\n next-error-last-buffer)\n (and (boundp 'compilation-last-buffer)\n compilation-last-buffer))))\n (if (and (bufferp buf)\n (with-current-buffer buf\n (and (eq major-mode 'erlang-shell-mode)\n (setq major-mode 'compilation-mode))))\n (unwind-protect\n (progn\n (setq done t)\n (next-error argp))\n (with-current-buffer buf\n (setq major-mode 'erlang-shell-mode))))\n (or done\n (next-error argp))))\n\n\n(defun inferior-erlang-change-directory (&optional dir)\n \"Make the inferior Erlang change directory.\nThe default is to go to the directory of the current buffer.\"\n (interactive)\n (or dir (setq dir (file-name-directory (erlang-local-buffer-file-name))))\n (or (inferior-erlang-running-p)\n (error \"No inferior Erlang is running\"))\n (inferior-erlang-display-buffer)\n (inferior-erlang-send-empty-cmd-unless-already-at-prompt)\n (inferior-erlang-wait-prompt)\n (inferior-erlang-send-command (format \"cd('%s').\" dir) nil))\n\n(defun erlang-align-arrows (start end)\n \"Align arrows (\\\"->\\\") in function clauses from START to END.\nWhen called interactively, aligns arrows after function clauses inside\nthe region.\n\nWith a prefix argument, aligns all arrows, not just those in function\nclauses.\n\nExample:\n\nsum(L) -> sum(L, 0).\nsum([H|T], Sum) -> sum(T, Sum + H);\nsum([], Sum) -> Sum.\n\nbecomes:\n\nsum(L) -> sum(L, 0).\nsum([H|T], Sum) -> sum(T, Sum + H);\nsum([], Sum) -> Sum.\"\n (interactive \"r\")\n (save-excursion\n (let (;; regexp for matching arrows. without a prefix argument,\n ;; the regexp matches function heads. With a prefix, it\n ;; matches any arrow.\n (re (if current-prefix-arg\n \"^.*\\\\(\\\\)->\"\n (eval-when-compile\n (concat \"^\" erlang-atom-regexp \".*\\\\(\\\\)->\"))))\n ;; part of regexp matching directly before the arrow\n (arrow-match-pos (if current-prefix-arg\n 1\n (1+ erlang-atom-regexp-matches)))\n ;; accumulator for positions where arrows are found, ordered\n ;; by buffer position (from greatest to smallest)\n (arrow-positions '())\n ;; accumulator for longest distance from start of line to arrow\n (most-indent 0)\n ;; marker to track the end of the region we're aligning\n (end-marker (progn (goto-char end)\n (point-marker))))\n ;; Pass 1: Find the arrow positions, adjust the whitespace\n ;; before each arrow to one space, and find the greatest\n ;; indentation level.\n (goto-char start)\n (while (re-search-forward re end-marker t)\n (goto-char (match-beginning arrow-match-pos))\n (just-one-space) ; adjust whitespace\n (setq arrow-positions (cons (point) arrow-positions))\n (setq most-indent (max most-indent (erlang-column-number))))\n (set-marker end-marker nil) ; free the marker\n ;; Pass 2: Insert extra padding so that all arrow indentation is\n ;; equal. This is done last-to-first by buffer position, so that\n ;; inserting spaces before one arrow doesn't change the\n ;; positions of the next ones.\n (mapc (lambda (arrow-pos)\n (goto-char arrow-pos)\n (let* ((pad (- most-indent (erlang-column-number))))\n (when (> pad 0)\n (insert-char ?\\ pad))))\n arrow-positions))))\n\n(defun erlang-column-number ()\n \"Return the column number of the current position in the buffer.\nTab characters are counted by their visual width.\"\n (string-width (buffer-substring (line-beginning-position) (point))))\n\n(defun erlang-current-defun ()\n \"`add-log-current-defun-function' for Erlang.\"\n (save-excursion\n (erlang-beginning-of-function)\n (if (looking-at \"[a-z0-9_]+\")\n (match-string 0))))\n\n(defconst erlang-unload-hook\n (list (lambda ()\n (ad-unadvise 'Man-notify-when-ready)\n (ad-unadvise 'set-visited-file-name))))\n\n;; The end...\n\n(provide 'erlang)\n\n(run-hooks 'erlang-load-hook)\n\n;; Local variables:\n;; coding: utf-8\n;; indent-tabs-mode: nil\n;; End:\n\n;;; erlang.el ends here\n","avg_line_length":37.7748616601,"max_line_length":121,"alphanum_fraction":0.5926730452} {"size":10493,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":";;; line-num.el --- Display line numbers in left-margin of buffer.\n;;\n;; Filename: line-num.el\n;; Description: Display line numbers in left-margin of buffer.\n;; Author: (Darryl Okahata) darrylo@hpsrdmo, Drew Adams\n;; Maintainer: Drew Adams (concat \"drew.adams\" \"@\" \"oracle\" \".com\")\n;; Copyright (C) 1999-2017, Drew Adams, all rights reserved.\n;; Copyright (C) 1989, Hewlett-Packard, all rights reserved.\n;; Created: Wed Mar 31 16:18:24 1999\n;; Version: 0\n;; Package-Requires: ()\n;;; Last-Updated: Tue Mar 7 08:38:38 2017 (-0800)\n;; By: dradams\n;; Update #: 222\n;; URL: https:\/\/www.emacswiki.org\/emacs\/download\/line-num.el\n;; Doc URL: http:\/\/emacswiki.org\/LineNumbers\n;; Keywords: local\n;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x, 25.x\n;;\n;; Features that might be required by this library:\n;;\n;; None\n;;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\n;;; Commentary:\n;;\n;; Display line numbers in left-margin of buffer.\n;;\n;; New functions defined here:\n;;\n;; `display-line-numbers', `toggle-line-numbers-display',\n;; `turn-on-line-numbers-display', `turn-off-line-numbers-display'.\n;;\n;; NOTE: `setnu.el' now provides similar, but generally better,\n;; functionality.\n;;\n;; Original author was Darryl Okahata darrylo@hpsrdmo: The copy on\n;; which the current (Adams) modifications were made was obtained from\n;; Rick Kunin (rickk@sperdk).\n;;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\n;;; Change Log:\n;;\n;; 2004\/11\/26 dadams\n;; Replaced decf with setq...1+.\n;; turn-off-line-numbers-display: Error if not displaying line #s.\n;; Removed calls to `fit-frame' (and require of fit-frame.el).\n;; 2000\/11\/01 dadams\n;; 1. Added: toggle-line-numbers-display, turn-on-line-numbers-display,\n;; turn-off-line-numbers-display.\n;; 2. Added global vars: displaying-line-numbers-p,\n;; display-line-numbers-format-string, display-line-numbers-first-line,\n;; display-line-numbers-count, display-line-numbers-buffer-name,\n;; display-line-numbers-modified-p.\n;; 1999\/04\/14 dadams\n;; Commented out assignment to unused free var: insert-end.\n;;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 2, or (at your option)\n;; any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program; see the file COPYING. If not, write to\n;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n;; Floor, Boston, MA 02110-1301, USA.\n;;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\n;;; Code:\n\n;;>> Problem: Tabs at beginning of lines\n\n;;;;;;;;;;;;;\n\n\n;;;###autoload\n(defun display-line-numbers ()\n \"Temporarily display line numbers in left margin of current buffer.\"\n (interactive)\n (or (eq (current-buffer) (window-buffer (selected-window)))\n (error \"Current buffer, %s, is not the selected window's buffer\"\n (buffer-name)))\n (let ((buffer-read-only nil)\n (modified (buffer-modified-p))\n (name buffer-file-name)\n (point (point-marker))\n format-string\n line-number\n (count 0)\n nlines\n first-line)\n (save-restriction\n (widen)\n (save-excursion\n (setq first-line (window-start (selected-window)))\n (goto-char first-line)\n (setq line-number (1+ (count-lines (point-min) (point))))\n (move-to-window-line -1)\n (beginning-of-line)\n (setq nlines (count-lines first-line (point)))\n (let ((max (+ line-number nlines)))\n (setq format-string (cond ((< max 100) \"%2d \")\n ((< max 1000) \"%3d \")\n ((< max 10000) \"%4d \")\n (t \"%7d \"))))))\n (save-excursion\n (unwind-protect\n (progn\n (goto-char first-line)\n ;; defeat file locking... don't try this at home, kids!\n (setq buffer-file-name nil)\n (while (<= count nlines)\n (insert-before-markers (format format-string line-number))\n ;;;(setq insert-end (point)) THIS VAR IS FREE - AND UNUSED!\n (setq line-number (1+ line-number))\n (setq count (1+ count))\n (forward-line 1))\n (set-window-start (selected-window) first-line)\n (goto-char point)\n (set-buffer-modified-p modified)\n (message \"<<< Press SPACE to continue >>>\")\n (let ((char (read-char)))\n (or (eql char ?\\ )\n (setq unread-command-events (list char))))\n )\n (goto-char first-line)\n (let ((n (1+ (- (aref format-string 1) ?0))))\n (while (> count 0)\n (setq count (1- count))\n (delete-char n)\n (forward-line 1)))\n (setq buffer-file-name name)\n (set-buffer-modified-p modified)))))\n\n;;;-----------------------------------------------------------------\n\n(defvar displaying-line-numbers-p nil)\n(make-variable-buffer-local 'displaying-line-numbers-p)\n(defvar display-line-numbers-format-string nil)\n(make-variable-buffer-local 'display-line-numbers-format-string)\n(defvar display-line-numbers-first-line nil)\n(make-variable-buffer-local 'display-line-numbers-first-line)\n(defvar display-line-numbers-count 0)\n(make-variable-buffer-local 'display-line-numbers-count)\n(defvar display-line-numbers-buffer-name nil)\n(make-variable-buffer-local 'display-line-numbers-buffer-name)\n(defvar display-line-numbers-modified-p nil)\n(make-variable-buffer-local 'display-line-numbers-modified-p)\n\n;;;###autoload\n(defun toggle-line-numbers-display (arg)\n \"Display\/clear line numbers in left margin of current buffer.\nWith prefix ARG, just number lines in current window, not all lines in\nbuffer.\"\n (interactive \"P\")\n (if displaying-line-numbers-p\n (turn-off-line-numbers-display)\n (turn-on-line-numbers-display arg)))\n\n;;;###autoload\n(defun turn-on-line-numbers-display (arg)\n \"Display line numbers in left margin of current buffer.\nWith prefix ARG, just number lines in current window, not all lines in\nbuffer.\"\n (interactive \"P\")\n (or (eq (current-buffer) (window-buffer (selected-window)))\n (error \"Current buffer, %s, is not the selected window's buffer\"\n (buffer-name)))\n (let ((buffer-read-only nil)\n (point (point-marker))\n line-number\n nlines)\n (setq display-line-numbers-buffer-name buffer-file-name)\n (setq display-line-numbers-modified-p (buffer-modified-p))\n (save-restriction\n (widen)\n (save-excursion\n (setq display-line-numbers-first-line\n (if arg\n (window-start (selected-window))\n (point-min)))\n (goto-char display-line-numbers-first-line)\n (setq line-number (1+ (count-lines (point-min) (point))))\n (if arg\n (move-to-window-line -1)\n (goto-char (point-max)))\n (beginning-of-line)\n (setq nlines (count-lines display-line-numbers-first-line (point)))\n (let ((max (+ line-number nlines)))\n (setq display-line-numbers-format-string (cond ((< max 100) \"%2d \")\n ((< max 1000) \"%3d \")\n ((< max 10000) \"%4d \")\n (t \"%7d \"))))))\n (save-excursion\n (condition-case nil\n (progn\n (goto-char display-line-numbers-first-line)\n (setq buffer-file-name nil) ; To prevent saving with line numbers etc.\n (setq displaying-line-numbers-p t)\n (while (<= display-line-numbers-count nlines)\n (insert-before-markers\n (format display-line-numbers-format-string line-number))\n (setq line-number (1+ line-number))\n (setq display-line-numbers-count (1+ display-line-numbers-count))\n (forward-line 1))\n (when arg\n (set-window-start (selected-window) display-line-numbers-first-line))\n (goto-char point)\n (set-buffer-modified-p display-line-numbers-modified-p))\n (error\n (progn\n (goto-char display-line-numbers-first-line)\n (let ((n (1+ (- (aref display-line-numbers-format-string 1) ?0))))\n (while (> display-line-numbers-count 0)\n (setq display-line-numbers-count (1- display-line-numbers-count))\n (delete-char n)\n (forward-line 1)))\n (setq buffer-file-name display-line-numbers-buffer-name)\n (set-buffer-modified-p display-line-numbers-modified-p)\n (setq displaying-line-numbers-p nil))))))\n (let ((curr-line (count-lines (window-start) (point))))\n (when (> curr-line 0) (setq curr-line (1+ curr-line)))\n (recenter curr-line)))\n\n;;;###autoload\n(defun turn-off-line-numbers-display ()\n \"Clear displayed line numbers from left margin of current buffer.\"\n (interactive)\n (unless (eq (current-buffer) (window-buffer (selected-window)))\n (error \"Current buffer, `%s', is not the selected window's buffer\"\n (buffer-name)))\n (unless displaying-line-numbers-p\n (error \"Not displaying line numbers in buffer `%s'\" (buffer-name)))\n (let ((buffer-read-only nil))\n (save-excursion\n (when (boundp 'display-line-numbers-buffer-name)\n (setq buffer-file-name display-line-numbers-buffer-name))\n (goto-char display-line-numbers-first-line)\n (let ((n (1+ (- (aref display-line-numbers-format-string 1) ?0))))\n (while (> display-line-numbers-count 0)\n (setq display-line-numbers-count (1- display-line-numbers-count))\n (delete-char n)\n (forward-line 1)))\n (when (boundp 'display-line-numbers-modified-p)\n (set-buffer-modified-p display-line-numbers-modified-p))\n (setq displaying-line-numbers-p nil))))\n\n\n;;;;;;;;;;;;;;;;;;;;;;;\n\n(provide 'line-num)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; line-num.el ends here\n","avg_line_length":39.5962264151,"max_line_length":83,"alphanum_fraction":0.5897264843} {"size":293,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":"(use-package dashboard\n :config\n (dashboard-setup-startup-hook)\n (setq dashboard-items '((recents . 8)\n (bookmarks . 5)\n (projects . 5)\n (agenda . 5)\n (registers . 5))))\n\n(provide 'init-dashboard)\n","avg_line_length":26.6363636364,"max_line_length":42,"alphanum_fraction":0.4505119454} {"size":11181,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; vnvni.el --- Quail package for Vietnamese by VNI method\n\n;; Copyright (C) 2001-2015 Free Software Foundation, Inc.\n\n;; Author: Werner Lemberg \n;; Nguyen Thai Ngoc Duy \n;; Keywords: multilingual, input method, Vietnamese\n\n;; This file is part of GNU Emacs.\n\n;; GNU Emacs is free software: you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; GNU Emacs is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs. If not, see .\n\n;;; Commentary:\n\n;; There are two commonly-used input methods for Vietnamese: Telex\n;; (implemented in vntelex.el) and VNI (implemented in this file,\n;; which was based on vntelex.el).\n\n;;; Code:\n\n(require 'quail)\n\n\n(quail-define-package\n \"vietnamese-vni\" ; NAME\n \"Vietnamese\" ; LANGUAGE\n \"VV\" ; TITLE\n t ; GUIDANCE\n \"Vietnamese VNI input method\n\nDiacritics:\n\n effect postfix examples\n ------------------------------\n circumflex 6 a6 -> \u00e2\n breve 8 a8 -> \u0103\n horn 7 o7 -> \u01a1\n\n acute 1 a1 -> \u00e1\n grave 2 a2 -> \u00e0\n hook above 3 a3 -> \u1ea3\n tilde 4 a4 -> \u00e3\n dot below 5 a5 -> \u1ea1\n\n d bar 9 d9 -> \u0111\n\nCombinations:\n\n A82 -> \u1eb0, o74 -> \u1ee1, etc.\n\nDoubling the postfix (but not in combinations) separates the letter\nand postfix: E66 -> E6, a55 -> a5, etc.\n\" ; DOCSTRING\n nil ; TRANSLATION-KEYS\n t ; FORGET-LAST-SELECTION\n nil ; DETERMINISTIC\n nil ; KBD-TRANSLATE\n nil ; SHOW-LAYOUT\n nil ; CREATE-DECODE-MAP\n nil ; MAXIMUM-SHORTEST\n nil ; OVERLAY-PLIST\n nil ; UPDATE-TRANSLATION-FUNCTION\n nil ; CONVERSION-KEYS\n t) ; SIMPLE\n\n(quail-define-rules\n (\"a2\" ?\u00e0)\t; LATIN SMALL LETTER A WITH GRAVE\n (\"A2\" ?\u00c0)\t; LATIN CAPITAL LETTER A WITH GRAVE\n (\"a1\" ?\u00e1)\t; LATIN SMALL LETTER A WITH ACUTE\n (\"A1\" ?\u00c1)\t; LATIN CAPITAL LETTER A WITH ACUTE\n (\"a6\" ?\u00e2)\t; LATIN SMALL LETTER A WITH CIRCUMFLEX\n (\"A6\" ?\u00c2)\t; LATIN CAPITAL LETTER A WITH CIRCUMFLEX\n (\"a4\" ?\u00e3)\t; LATIN SMALL LETTER A WITH TILDE\n (\"A4\" ?\u00c3)\t; LATIN CAPITAL LETTER A WITH TILDE\n (\"e2\" ?\u00e8)\t; LATIN SMALL LETTER E WITH GRAVE\n (\"E2\" ?\u00c8)\t; LATIN CAPITAL LETTER E WITH GRAVE\n (\"e1\" ?\u00e9)\t; LATIN SMALL LETTER E WITH ACUTE\n (\"E1\" ?\u00c9)\t; LATIN CAPITAL LETTER E WITH ACUTE\n (\"e6\" ?\u00ea)\t; LATIN SMALL LETTER E WITH CIRCUMFLEX\n (\"E6\" ?\u00ca)\t; LATIN CAPITAL LETTER E WITH CIRCUMFLEX\n (\"i2\" ?\u00ec)\t; LATIN SMALL LETTER I WITH GRAVE\n (\"I2\" ?\u00cc)\t; LATIN CAPITAL LETTER I WITH GRAVE\n (\"i1\" ?\u00ed)\t; LATIN SMALL LETTER I WITH ACUTE\n (\"I1\" ?\u00cd)\t; LATIN CAPITAL LETTER I WITH ACUTE\n (\"o2\" ?\u00f2)\t; LATIN SMALL LETTER O WITH GRAVE\n (\"O2\" ?\u00d2)\t; LATIN CAPITAL LETTER O WITH GRAVE\n (\"o1\" ?\u00f3)\t; LATIN SMALL LETTER O WITH ACUTE\n (\"O1\" ?\u00d3)\t; LATIN CAPITAL LETTER O WITH ACUTE\n (\"o6\" ?\u00f4)\t; LATIN SMALL LETTER O WITH CIRCUMFLEX\n (\"O6\" ?\u00d4)\t; LATIN CAPITAL LETTER O WITH CIRCUMFLEX\n (\"o4\" ?\u00f5)\t; LATIN SMALL LETTER O WITH TILDE\n (\"O4\" ?\u00d5)\t; LATIN CAPITAL LETTER O WITH TILDE\n (\"u2\" ?\u00f9)\t; LATIN SMALL LETTER U WITH GRAVE\n (\"U2\" ?\u00d9)\t; LATIN CAPITAL LETTER U WITH GRAVE\n (\"u1\" ?\u00fa)\t; LATIN SMALL LETTER U WITH ACUTE\n (\"U1\" ?\u00da)\t; LATIN CAPITAL LETTER U WITH ACUTE\n (\"y1\" ?\u00fd)\t; LATIN SMALL LETTER Y WITH ACUTE\n (\"Y1\" ?\u00dd)\t; LATIN CAPITAL LETTER Y WITH ACUTE\n (\"a8\" ?\u0103)\t; LATIN SMALL LETTER A WITH BREVE\n (\"A8\" ?\u0102)\t; LATIN CAPITAL LETTER A WITH BREVE\n (\"i4\" ?\u0129)\t; LATIN SMALL LETTER I WITH TILDE\n (\"I4\" ?\u0128)\t; LATIN CAPITAL LETTER I WITH TILDE\n (\"u4\" ?\u0169)\t; LATIN SMALL LETTER U WITH TILDE\n (\"U4\" ?\u0168)\t; LATIN CAPITAL LETTER U WITH TILDE\n (\"o7\" ?\u01a1)\t; LATIN SMALL LETTER O WITH HORN\n (\"O7\" ?\u01a0)\t; LATIN CAPITAL LETTER O WITH HORN\n (\"u7\" ?\u01b0)\t; LATIN SMALL LETTER U WITH HORN\n (\"U7\" ?\u01af)\t; LATIN CAPITAL LETTER U WITH HORN\n (\"a5\" ?\u1ea1)\t; LATIN SMALL LETTER A WITH DOT BELOW\n (\"A5\" ?\u1ea0)\t; LATIN CAPITAL LETTER A WITH DOT BELOW\n (\"a3\" ?\u1ea3)\t; LATIN SMALL LETTER A WITH HOOK ABOVE\n (\"A3\" ?\u1ea2)\t; LATIN CAPITAL LETTER A WITH HOOK ABOVE\n (\"a61\" ?\u1ea5)\t; LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE\n (\"A61\" ?\u1ea4)\t; LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE\n (\"a62\" ?\u1ea7)\t; LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE\n (\"A62\" ?\u1ea6)\t; LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE\n (\"a63\" ?\u1ea9)\t; LATIN SMALL LETTER A WITH CIRCUMFLEX AND HO6K ABOVE\n (\"A63\" ?\u1ea8)\t; LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HO6K ABOVE\n (\"a64\" ?\u1eab)\t; LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE\n (\"A64\" ?\u1eaa)\t; LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE\n (\"a65\" ?\u1ead)\t; LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW\n (\"A65\" ?\u1eac)\t; LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW\n (\"a81\" ?\u1eaf)\t; LATIN SMALL LETTER A WITH BREVE AND ACUTE\n (\"A81\" ?\u1eae)\t; LATIN CAPITAL LETTER A WITH BREVE AND ACUTE\n (\"a82\" ?\u1eb1)\t; LATIN SMALL LETTER A WITH BREVE AND GRAVE\n (\"A82\" ?\u1eb0)\t; LATIN CAPITAL LETTER A WITH BREVE AND GRAVE\n (\"a83\" ?\u1eb3)\t; LATIN SMALL LETTER A WITH BREVE AND HO6K ABOVE\n (\"A83\" ?\u1eb2)\t; LATIN CAPITAL LETTER A WITH BREVE AND HO6K ABOVE\n (\"a84\" ?\u1eb5)\t; LATIN SMALL LETTER A WITH BREVE AND TILDE\n (\"A84\" ?\u1eb4)\t; LATIN CAPITAL LETTER A WITH BREVE AND TILDE\n (\"a85\" ?\u1eb7)\t; LATIN SMALL LETTER A WITH BREVE AND DOT BELOW\n (\"A85\" ?\u1eb6)\t; LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW\n (\"e5\" ?\u1eb9)\t; LATIN SMALL LETTER E WITH DOT BELOW\n (\"E5\" ?\u1eb8)\t; LATIN CAPITAL LETTER E WITH DOT BELOW\n (\"e3\" ?\u1ebb)\t; LATIN SMALL LETTER E WITH HO6K ABOVE\n (\"E3\" ?\u1eba)\t; LATIN CAPITAL LETTER E WITH HO6K ABOVE\n (\"e4\" ?\u1ebd)\t; LATIN SMALL LETTER E WITH TILDE\n (\"E4\" ?\u1ebc)\t; LATIN CAPITAL LETTER E WITH TILDE\n (\"e61\" ?\u1ebf)\t; LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE\n (\"E61\" ?\u1ebe)\t; LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE\n (\"e62\" ?\u1ec1)\t; LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE\n (\"E62\" ?\u1ec0)\t; LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE\n (\"e63\" ?\u1ec3)\t; LATIN SMALL LETTER E WITH CIRCUMFLEX AND HO6K ABOVE\n (\"E63\" ?\u1ec2)\t; LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HO6K ABOVE\n (\"e64\" ?\u1ec5)\t; LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE\n (\"E64\" ?\u1ec4)\t; LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE\n (\"e65\" ?\u1ec7)\t; LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW\n (\"E65\" ?\u1ec6)\t; LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW\n (\"i3\" ?\u1ec9)\t; LATIN SMALL LETTER I WITH HO6K ABOVE\n (\"I3\" ?\u1ec8)\t; LATIN CAPITAL LETTER I WITH HO6K ABOVE\n (\"i5\" ?\u1ecb)\t; LATIN SMALL LETTER I WITH DOT BELOW\n (\"I5\" ?\u1eca)\t; LATIN CAPITAL LETTER I WITH DOT BELOW\n (\"o5\" ?\u1ecd)\t; LATIN SMALL LETTER O WITH DOT BELOW\n (\"O5\" ?\u1ecc)\t; LATIN CAPITAL LETTER O WITH DOT BELOW\n (\"o3\" ?\u1ecf)\t; LATIN SMALL LETTER O WITH HO6K ABOVE\n (\"O3\" ?\u1ece)\t; LATIN CAPITAL LETTER O WITH HO6K ABOVE\n (\"o61\" ?\u1ed1)\t; LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE\n (\"O61\" ?\u1ed0)\t; LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE\n (\"o62\" ?\u1ed3)\t; LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE\n (\"O62\" ?\u1ed2)\t; LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE\n (\"o63\" ?\u1ed5)\t; LATIN SMALL LETTER O WITH CIRCUMFLEX AND HO6K ABOVE\n (\"O63\" ?\u1ed4)\t; LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HO6K ABOVE\n (\"o64\" ?\u1ed7)\t; LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE\n (\"O64\" ?\u1ed6)\t; LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE\n (\"o65\" ?\u1ed9)\t; LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELO7\n (\"O65\" ?\u1ed8)\t; LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELO7\n (\"o71\" ?\u1edb)\t; LATIN SMALL LETTER O WITH HORN AND ACUTE\n (\"O71\" ?\u1eda)\t; LATIN CAPITAL LETTER O WITH HORN AND ACUTE\n (\"o72\" ?\u1edd)\t; LATIN SMALL LETTER O WITH HORN AND GRAVE\n (\"O72\" ?\u1edc)\t; LATIN CAPITAL LETTER O WITH HORN AND GRAVE\n (\"o73\" ?\u1edf)\t; LATIN SMALL LETTER O WITH HORN AND HO6K ABOVE\n (\"O73\" ?\u1ede)\t; LATIN CAPITAL LETTER O WITH HORN AND HO6K ABOVE\n (\"o74\" ?\u1ee1)\t; LATIN SMALL LETTER O WITH HORN AND TILDE\n (\"O74\" ?\u1ee0)\t; LATIN CAPITAL LETTER O WITH HORN AND TILDE\n (\"o75\" ?\u1ee3)\t; LATIN SMALL LETTER O WITH HORN AND DOT BELO7\n (\"O75\" ?\u1ee2)\t; LATIN CAPITAL LETTER O WITH HORN AND DOT BELO7\n (\"u5\" ?\u1ee5)\t; LATIN SMALL LETTER U WITH DOT BELO7\n (\"U5\" ?\u1ee4)\t; LATIN CAPITAL LETTER U WITH DOT BELO7\n (\"u3\" ?\u1ee7)\t; LATIN SMALL LETTER U WITH HO6K ABOVE\n (\"U3\" ?\u1ee6)\t; LATIN CAPITAL LETTER U WITH HO6K ABOVE\n (\"u71\" ?\u1ee9)\t; LATIN SMALL LETTER U WITH HORN AND ACUTE\n (\"U71\" ?\u1ee8)\t; LATIN CAPITAL LETTER U WITH HORN AND ACUTE\n (\"u72\" ?\u1eeb)\t; LATIN SMALL LETTER U WITH HORN AND GRAVE\n (\"U72\" ?\u1eea)\t; LATIN CAPITAL LETTER U WITH HORN AND GRAVE\n (\"u73\" ?\u1eed)\t; LATIN SMALL LETTER U WITH HORN AND HO6K ABOVE\n (\"U73\" ?\u1eec)\t; LATIN CAPITAL LETTER U WITH HORN AND HO6K ABOVE\n (\"u74\" ?\u1eef)\t; LATIN SMALL LETTER U WITH HORN AND TILDE\n (\"U74\" ?\u1eee)\t; LATIN CAPITAL LETTER U WITH HORN AND TILDE\n (\"u75\" ?\u1ef1)\t; LATIN SMALL LETTER U WITH HORN AND DOT BELO7\n (\"U75\" ?\u1ef0)\t; LATIN CAPITAL LETTER U WITH HORN AND DOT BELO7\n (\"y2\" ?\u1ef3)\t; LATIN SMALL LETTER Y WITH GRAVE\n (\"Y2\" ?\u1ef2)\t; LATIN CAPITAL LETTER Y WITH GRAVE\n (\"y5\" ?\u1ef5)\t; LATIN SMALL LETTER Y WITH DOT BELO7\n (\"Y5\" ?\u1ef4)\t; LATIN CAPITAL LETTER Y WITH DOT BELO7\n (\"y3\" ?\u1ef7)\t; LATIN SMALL LETTER Y WITH HO6K ABOVE\n (\"Y3\" ?\u1ef6)\t; LATIN CAPITAL LETTER Y WITH HO6K ABOVE\n (\"y4\" ?\u1ef9)\t; LATIN SMALL LETTER Y WITH TILDE\n (\"Y4\" ?\u1ef8)\t; LATIN CAPITAL LETTER Y WITH TILDE\n (\"d9\" ?\u0111)\t; LATIN SMALL LETTER D WITH STROKE\n (\"D9\" ?\u0110)\t; LATIN CAPITAL LETTER D WITH STROKE\n;(\"$$\" ?\u20ab)\t; U+20AB DONG SIGN (#### check)\n\n (\"a22\" [\"a22\"])\n (\"A22\" [\"A2\"])\n (\"a11\" [\"a1\"])\n (\"A11\" [\"A1\"])\n (\"a66\"' [\"a6\"])\n (\"A66\"' [\"A6\"])\n (\"a44\" [\"a4\"])\n (\"A44\" [\"A4\"])\n (\"e22\" [\"e2\"])\n (\"E22\" [\"E2\"])\n (\"e11\" [\"e1\"])\n (\"E11\" [\"E1\"])\n (\"e66\" [\"e6\"])\n (\"E66\" [\"E6\"])\n (\"i22\" [\"i2\"])\n (\"I22\" [\"I2\"])\n (\"i11\" [\"i1\"])\n (\"I11\" [\"I1\"])\n (\"o22\" [\"o2\"])\n (\"O22\" [\"O2\"])\n (\"o11\" [\"o1\"])\n (\"O11\" [\"O1\"])\n (\"o66\" [\"o6\"])\n (\"O66\" [\"O6\"])\n (\"o44\" [\"o4\"])\n (\"O44\" [\"O4\"])\n (\"u22\" [\"u2\"])\n (\"U22\" [\"U2\"])\n (\"u11\" [\"u1\"])\n (\"U11\" [\"U1\"])\n (\"y11\" [\"y1\"])\n (\"Y11\" [\"Y1\"])\n (\"a88\" [\"a8\"])\n (\"A88\" [\"A8\"])\n (\"i44\" [\"i4\"])\n (\"I44\" [\"I4\"])\n (\"u44\" [\"u4\"])\n (\"U44\" [\"u4\"])\n (\"o77\" [\"o7\"])\n (\"O77\" [\"O7\"])\n (\"u77\" [\"u7\"])\n (\"U77\" [\"U7\"])\n (\"a55\" [\"a5\"])\n (\"A55\" [\"A5\"])\n (\"a33\" [\"a3\"])\n (\"A33\" [\"A3\"])\n (\"e55\" [\"e5\"])\n (\"E55\" [\"E5\"])\n (\"e33\" [\"e3\"])\n (\"E33\" [\"E3\"])\n (\"e44\" [\"e4\"])\n (\"E44\" [\"E4\"])\n (\"i33\" [\"i3\"])\n (\"I33\" [\"I3\"])\n (\"i55\" [\"i5\"])\n (\"I55\" [\"I5\"])\n (\"o55\" [\"o5\"])\n (\"O55\" [\"O5\"])\n (\"o33\" [\"o3\"])\n (\"O33\" [\"O3\"])\n (\"u55\" [\"u5\"])\n (\"U55\" [\"U5\"])\n (\"u33\" [\"u3\"])\n (\"U33\" [\"U3\"])\n (\"y22\" [\"y2\"])\n (\"Y22\" [\"Y2\"])\n (\"y55\" [\"y5\"])\n (\"Y55\" [\"Y5\"])\n (\"y33\" [\"y3\"])\n (\"Y33\" [\"Y3\"])\n (\"y44\" [\"y4\"])\n (\"Y44\" [\"Y4\"])\n (\"d9\" [\"d9\"])\n (\"D99\" [\"D9\"])\n;(\"$$$\" [\"$$\"])\n\n ;; escape from composition\n (\"\\\\1\" ?1)\n (\"\\\\2\" ?2)\n (\"\\\\3\" ?3)\n (\"\\\\4\" ?4)\n (\"\\\\5\" ?5)\n (\"\\\\6\" ?6)\n (\"\\\\7\" ?7)\n (\"\\\\8\" ?8)\n (\"\\\\9\" ?9)\n (\"\\\\\\\\\" ?\\\\)) ; literal backslash\n\n\n;; Local Variables:\n;; coding: utf-8\n;; End:\n","avg_line_length":36.5392156863,"max_line_length":71,"alphanum_fraction":0.6011984617} {"size":18743,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; zoom-frm.el --- Commands to zoom frame font size.\n;;\n;; Filename: zoom-frm.el\n;; Description: Commands to zoom frame font size.\n;; Author: Drew Adams\n;; Maintainer: Drew Adams (concat \"drew.adams\" \"@\" \"oracle\" \".com\")\n;; Copyright (C) 2005-2014, Drew Adams, all rights reserved.\n;; Created: Fri Jan 07 10:24:35 2005\n;; Version: 20140101.56\n;; X-Original-Version: 0\n;; Package-Requires: ((frame-fns \"0\") (frame-cmds \"0\"))\n;; Last-Updated: Tue Dec 31 16:52:22 2013 (-0800)\n;; By: dradams\n;; Update #: 320\n;; URL: http:\/\/www.emacswiki.org\/zoom-frm.el\n;; Doc URL: http:\/\/emacswiki.org\/SetFonts\n;; Keywords: frames, extensions, convenience\n;; Compatibility: GNU Emacs: 20.x, 21.x, 22.x, 23.x, 24.x\n;;\n;; Features that might be required by this library:\n;;\n;; `avoid', `frame-cmds', `frame-fns', `misc-fns', `strings',\n;; `thingatpt', `thingatpt+'.\n;;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\n;;; Commentary:\n;;\n;; Commands to zoom into and out of text. They zoom a frame or a\n;; buffer, so that the text appears larger or smaller.\n;;\n;; Commands `zoom-in', `zoom-out', and `zoom-in\/out' do both kinds of\n;; zooming. They can behave like command `text-scale-adjust',\n;; zooming a buffer wherever it is displayed, or they can zoom an\n;; entire single frame (all of its windows). Hit `C-u' at any time\n;; while using these commands to toggle between buffer and frame\n;; zooming.\n;;\n;; Because it is a more general replacement for `text-scale-adjust',\n;; I suggest you bind `zoom-in\/out' to the keys bound by default to\n;; `text-scale-adjust': `C-x C-+', `C-x C-=', `C-x C--', and `C-x\n;; C-0'.\n;;\n;; It is also handy to use a mouse button or wheel for zooming, hence\n;; the mouse binding suggestions. For example, binding `zoom-in' and\n;; `zoom-out' to mouse wheel events gives you the zooming effect you\n;; are perhaps used to in a Web browser.\n;;\n;; User option `zoom-frame\/buffer' determines which kind of zooming\n;; (frame or buffer) is used by default. You can customize this\n;; option, but (in Emacs 23 or later) you can also toggle it just by\n;; providing a prefix arg (`C-u') to `zoom-in\/out', `zoom-in', or\n;; `zoom-out'.\n;;\n;; Note about saving changes made dynamically using the commands\n;; defined here:\n;;\n;; Some of the commands defined here change frame properties. You\n;; can save any changes you have made, by using Customize. To\n;; visit a Customize buffer of all unsaved changes you have made,\n;; use command `customize-customized'.\n;;\n;; Frame parameter changes, such as font size, can be saved for\n;; future use by all frames or all frames of a certain kind. For\n;; that, you must change the frame parameters of the correponding\n;; frame-alist variable.\n;;\n;; There is no single variable for saving changes to parameters of\n;; the current frame. Instead, there are several different\n;; frame-alist variables, which you can use to define different\n;; kinds of frames. These include: `default-frame-alist',\n;; `initial-frame-alist', and `special-display-frame-alist'. The\n;; complete list of such frame alist variables is available using\n;; function `frame-alist-var-names', defined in library\n;; `frame-cmds.el'.\n;;\n;; Example: Suppose you change the font size of a frame and want to\n;; make that the default font size for new frames in the future.\n;; You will need to update the value of variable\n;; `default-frame-alist' to use the `font' parameter setting of the\n;; changed frame.\n;;\n;; You can easily copy one or all parameter values from any given\n;; frame to any frame alist (such as `default-frame-alist'), by\n;; using the commands `set-frame-alist-parameter-from-frame' and\n;; `set-all-frame-alist-parameters-from-frame'. Those commands are\n;; defined in library `frame-cmds.el'.\n;;\n;;\n;; Commands defined here:\n;;\n;; `toggle-zoom-frame', `zoom-all-frames-in',\n;; `zoom-all-frames-out', `zoom-frm-in', `zoom-frm-out',\n;; `zoom-frm-unzoom', `zoom-in', `zoom-in\/out' (Emacs 23+),\n;; `zoom-out'.\n;;\n;;\n;; User options (variables) defined here:\n;;\n;; `frame-zoom-font-difference', `zoom-frame\/buffer' (Emacs 23+).\n;;\n;;\n;; Put this in your init file (`~\/.emacs'): (require 'zoom-frm)\n;;\n;; Suggested key bindings:\n;;\n;; Emacs 23 and later:\n;;\n;; (define-key ctl-x-map [(control ?+)] 'zoom-in\/out)\n;; (define-key ctl-x-map [(control ?-)] 'zoom-in\/out)\n;; (define-key ctl-x-map [(control ?=)] 'zoom-in\/out)\n;; (define-key ctl-x-map [(control ?0)] 'zoom-in\/out)\n;;\n;; Any Emacs version:\n;;\n;; (global-set-key (if (boundp 'mouse-wheel-down-event) ; Emacs 22+\n;; (vector (list 'control\n;; mouse-wheel-down-event))\n;; [C-mouse-wheel]) ; Emacs 20, 21\n;; 'zoom-in)\n;; (when (boundp 'mouse-wheel-up-event) ; Emacs 22+\n;; (global-set-key (vector (list 'control mouse-wheel-up-event))\n;; 'zoom-out))\n;;\n;; (global-set-key [S-mouse-1] 'zoom-in)\n;; (global-set-key [C-S-mouse-1] 'zoom-out)\n;; ;; Get rid of `mouse-set-font' or `mouse-appearance-menu':\n;; (global-set-key [S-down-mouse-1] nil)\n;;\n;; The first two of the mouse bindings mean that in Emacs 22 or later\n;; you can hold the Control key and rotate the mouse wheel to zoom in\n;; and out, just as you might do in a Web browser.\n;;\n;; (In Emacs 20 and 21, Control plus mouse wheeling zooms in, but to\n;; zoom out you need to use `C--' before wheeling with Control. This\n;; is because Emacs 20 and 21 do not have separate events for the\n;; mouse wheel directions, and it is the prefix arg, not the wheel\n;; direction, that determines the effect.)\n;;\n;;\n;; See also these files for other frame commands:\n;;\n;; `autofit-frame.el' - Automatically fit each frame to its\n;; selected window. Uses `fit-frame.el'.\n;;\n;; `fit-frame.el' - 1) Fit a frame to its selected window.\n;; 2) Incrementally resize a frame.\n;;\n;; `doremi-frm.el' - Incrementally adjust frame properties\n;; using arrow keys and\/or mouse wheel.\n;;\n;; `frame-cmds.el' - Miscellaneous frame and window commands.\n;;\n;; `thumb-frm.el' - Shrink frames to a thumbnail size and\n;; restore them again.\n;;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\n;;; Change Log:\n;;\n;; 2013\/12\/31 dadams\n;; zoom-in\/out: Use set-transient-map, if defined.\n;; 2013\/09\/\/29 dadams\n;; zoom-in\/out: Only for Emacs 24.3+ (needs set-temporary-overlay-map).\n;; 2013\/09\/13 dadams\n;; Added: zoom-all-frames-in, zoom-all-frames-out.\n;; 2013\/04\/21 dadams\n;; Added: zoom-in\/out.\n;; 2011\/01\/04 dadams\n;; Added autoload cookies for defgroup and defcustom.\n;; 2010\/07\/06 dadams\n;; zoom-(in|out): Put doc strings before interactive spec. Thx to Yidong Chong.\n;; 2009\/06\/11 dadams\n;; Added buffer zooming, for Emacs 23.\n;; Added zoom-(in|out), group zoom, zoom-frame\/buffer.\n;; 2006\/01\/07 dadams\n;; Added :link for sending bug report.\n;; 2006\/01\/06 dadams\n;; frame-zoom-font-difference: Changed :group to Frame-Commands. Added :link.\n;; 2005\/01\/18 dadams\n;; Changed default value of frame-zoom-font-difference.\n;; Added Note on saving changes.\n;;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 2, or (at your option)\n;; any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program; see the file COPYING. If not, write to\n;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth\n;; Floor, Boston, MA 02110-1301, USA.\n;;\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\n;;; Code:\n\n(require 'frame-cmds) ;; enlarge-font\n\n\n(defvar zoom-frame\/buffer) ;; Defined here for Emacs 22+.\n\n;;;;;;;;;;;;;;;;;;;;;;;;\n\n\n;;; USER OPTIONS (VARIABLES) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n;;;###autoload\n(defgroup zoom nil\n \"Zoom a frame or buffer.\"\n :group 'frames :group 'Frame-Commands ; Defined in `frame-cmds.el'.\n :link `(url-link :tag \"Send Bug Report\"\n ,(concat \"mailto:\" \"drew.adams\" \"@\" \"oracle\" \".com?subject=\\\nzoom-frm.el bug: \\\n&body=Describe bug here, starting with `emacs -q'. \\\nDon't forget to mention your Emacs and library versions.\"))\n :link '(url-link :tag \"Other Libraries by Drew\"\n \"http:\/\/www.emacswiki.org\/DrewsElispLibraries\")\n :link '(url-link :tag \"Download\"\n \"http:\/\/www.emacswiki.org\/emacs-en\/download\/zoom-frm.el\")\n :link '(url-link :tag \"Description\"\n \"http:\/\/www.emacswiki.org\/SetFonts#ChangingFontSize\")\n :link '(emacs-commentary-link :tag \"Commentary\" \"zoom-frm\"))\n\n;;;###autoload\n(defcustom frame-zoom-font-difference 1\n \"*Number of points to change the frame font size when zooming.\nThis applies to commands `zoom-in\/out', `zoom-in', `zoom-out',\n`zoom-frm-in', and `zoom-frm-out' when zooming a frame.\n\nThe absolute value of the value must be less than the current font\nsize for the frame, because the new font size cannot be less than one\npoint.\"\n :type 'integer :group 'zoom)\n\n(when (> emacs-major-version 22)\n (defcustom zoom-frame\/buffer 'frame\n \"*What to zoom: current frame or current buffer.\nSee command `zoom-in\/out', `zoom-in', or `zoom-out'.\"\n :type '(choice (const :tag \"Zoom frame\" frame) (const :tag \"Zoom buffer\" buffer))\n :group 'zoom))\n\n\n;;; FUNCTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(unless (> emacs-major-version 22) (defalias 'zoom-in 'zoom-frm-in))\n;;;###autoload\n(defun zoom-frm-in (&optional frame flip)\n \"Zoom FRAME in by `frame-zoom-font-difference', making text larger.\nIf `frame-zoom-font-difference' is negative, make text smaller.\nWith prefix argument FLIP, reverse the direction:\nif `frame-zoom-font-difference' is positive, then make text smaller.\nThis is equal but opposite to `zoom-frm-out'.\"\n (interactive (list (selected-frame) current-prefix-arg))\n (setq frame (or frame (selected-frame)))\n (let ((zoom-factor (frame-parameter frame 'zoomed))\n (increment (if flip (- frame-zoom-font-difference) frame-zoom-font-difference)))\n (unless zoom-factor (setq zoom-factor 0))\n (setq zoom-factor (+ zoom-factor increment))\n (enlarge-font increment frame)\n (modify-frame-parameters frame (list (cons 'zoomed zoom-factor)))))\n\n(unless (> emacs-major-version 22) (defalias 'zoom-out 'zoom-frm-out))\n;;;###autoload\n(defun zoom-frm-out (&optional frame flip)\n \"Zoom FRAME out by `frame-zoom-font-difference', making text smaller.\nIf `frame-zoom-font-difference' is negative, make text larger.\nWith prefix argument FLIP, reverse the direction:\nif `frame-zoom-font-difference' is positive, then make text larger.\nThis is equal but opposite to `zoom-frm-in'.\"\n (interactive (list (selected-frame) current-prefix-arg))\n (setq frame (or frame (selected-frame)))\n (let ((frame-zoom-font-difference (- frame-zoom-font-difference)))\n (zoom-frm-in frame flip)))\n\n;;;###autoload\n(defun zoom-frm-unzoom (&optional frame)\n \"Cancel zoom of FRAME.\"\n (interactive)\n (setq frame (or frame (selected-frame)))\n (let ((zoom-factor (frame-parameter frame 'zoomed)))\n (if (not zoom-factor)\n (error \"Frame is not zoomed\")\n (enlarge-font (- zoom-factor) frame)\n (modify-frame-parameters frame '((zoomed))))))\n\n;;;###autoload\n(defun toggle-zoom-frame (&optional frame)\n \"Alternately zoom\/unzoom FRAME by `frame-zoom-font-difference'.\"\n (interactive)\n (setq frame (or frame (selected-frame)))\n (if (frame-parameter frame 'zoomed)\n (zoom-frm-unzoom frame)\n (zoom-frm-in frame)))\n\n(when (> emacs-major-version 22)\n (defun zoom-in (arg)\n \"Zoom current frame or buffer in.\nWith a prefix arg, toggle between zooming frame and zooming buffer.\nFrame zooming uses command `zoom-frm-in'.\nBuffer zooming uses command `text-scale-increase'.\"\n (interactive \"P\")\n (when arg\n (setq zoom-frame\/buffer (if (eq zoom-frame\/buffer 'frame) 'buffer 'frame)))\n (if (eq zoom-frame\/buffer 'frame)\n (zoom-frm-in)\n (with-current-buffer\n (if (string-match \"mouse\" (format \"%S\" (event-basic-type\n last-command-event)))\n (window-buffer (posn-window (event-start last-command-event)))\n (current-buffer))\n (text-scale-increase 1))))\n\n (defun zoom-out (arg)\n \"Zoom current frame or buffer out.\nWith a prefix arg, toggle between zooming frame and zooming buffer.\nFrame zooming uses command `zoom-frm-out'.\nBuffer zooming uses command `text-scale-decrease'.\"\n (interactive \"P\")\n (when arg\n (setq zoom-frame\/buffer (if (eq zoom-frame\/buffer 'frame) 'buffer 'frame)))\n (if (eq zoom-frame\/buffer 'frame)\n (zoom-frm-out)\n (with-current-buffer\n (if (string-match \"mouse\" (format \"%S\" (event-basic-type\n last-command-event)))\n (window-buffer (posn-window (event-start last-command-event)))\n (current-buffer))\n (text-scale-decrease 1))))\n\n (when (or (fboundp 'set-transient-map) ; Emacs 24.4+\n (fboundp 'set-temporary-overlay-map)) ; Emacs 24.3\n \n (defun zoom-in\/out (arg)\n \"Zoom current frame or buffer in or out.\nA prefix arg determines the behavior, as follows:\n none : Use 1 as the zoom amount.\n plain `C-u': Toggle between zooming frame and zooming buffer.\n 0 : Unzoom: reset size to the default.\n other : Use the numeric value as the zoom amount.\n\nSimilar to the behavior of command `text-scale-adjust', you can\ncontinue to use any of the keys `+', `-', `0', and `C-u' repeatedly.\nThe zoom amount from the initial key sequence is used each time.\n\nExample: `C-3 C-x C-- C-- C-- C--' zooms out 4 times with a zoom\namount of 3 each time.\n\nThe zoom amount for frame zooming is a point-size increment\/decrement.\nThe zoom amount for buffer zooming is a number of text-scaling steps.\n\nFrame zooming uses command `zoom-frm-in'.\nBuffer zooming uses command `text-scale-increase'.\n\nUser option `zoom-frame\/buffer' determines the default zoom type:\nframe or buffer. If the option value is `buffer' and you never use\nplain `C-u' with this command then it acts like `text-scale-adjust'.\"\n (interactive \"P\")\n (when (or (equal arg '(4)) (eq ?\\025 last-command-event)) ; `C-u'\n (setq zoom-frame\/buffer (if (eq zoom-frame\/buffer 'frame) 'buffer 'frame)\n arg 1)\n (message \"Zooming %sS from now on\" (upcase (symbol-name zoom-frame\/buffer)))\n (sit-for 1)) \n (let* ((ev last-command-event)\n (echo-keystrokes nil)\n (base (event-basic-type ev))\n (step (if (or (equal arg '(4)) (eq ?\\025 last-command-event)) ; C-u\n 'C-U-WAS-USED\n (setq arg (prefix-numeric-value arg))\n (case base\n ((?+ ?=) arg)\n (?- (- arg))\n (?0 0)\n (t arg)))))\n (message (if (eq step 0)\n \"Reset to default size. Use +\/- to zoom in\/out\"\n \"Use +\/- to zoom in\/out, 0 to reset (unzoom)\"))\n (unless (eq step 'C-U-WAS-USED)\n (if (eq zoom-frame\/buffer 'frame)\n (if (eq step 0)\n (zoom-frm-unzoom)\n (let ((frame-zoom-font-difference step)) (zoom-frm-in)))\n (with-current-buffer\n (if (string-match \"mouse\" (format \"%S\" (event-basic-type last-command-event)))\n (window-buffer (posn-window (event-start last-command-event)))\n (current-buffer))\n (text-scale-increase step))))\n (let ((fun (if (fboundp 'set-transient-map)\n #'set-transient-map\n #'set-temporary-overlay-map)))\n (funcall fun\n (let ((map (make-sparse-keymap)))\n (dolist (mods '(() (control)))\n (dolist (key '(?- ?+ ?= ?0)) ; The `=' key is often unshifted `+' key.\n (define-key map (vector (append mods (list key)))\n `(lambda () (interactive) (zoom-in\/out ',arg)))))\n (define-key map \"\\C-u\" `(lambda () (interactive) (zoom-in\/out ',arg)))\n map)))))))\n\n;; These are not so useful, but some people might like them.\n(when (fboundp 'set-face-attribute) ; Emacs 22+\n (defun zoom-all-frames-in (&optional flip)\n \"Zoom all frames in by `frame-zoom-font-difference', making text larger.\nIf `frame-zoom-font-difference' is negative, make text smaller.\nWith prefix argument FLIP, reverse the direction:\nif `frame-zoom-font-difference' is positive, then make text smaller.\nThis is equal but opposite to `zoom-all-frames-out'.\nNote: This zooming is unaffected by `zoom-frm-unzoom'.\"\n (interactive \"P\")\n (let ((increment (if flip (- frame-zoom-font-difference) frame-zoom-font-difference)))\n (set-face-attribute 'default nil\n :height (+ (* 10 increment)\n (face-attribute 'default :height nil 'default)))))\n\n (defun zoom-all-frames-out (&optional flip)\n \"Zoom all frames out by `frame-zoom-font-difference', making text smaller.\nIf `frame-zoom-font-difference' is negative, make text larger.\nWith prefix argument FLIP, reverse the direction:\nif `frame-zoom-font-difference' is positive, then make text larger.\nThis is equal but opposite to `zoom-frm-in'.\nNote: This zooming is unaffected by `zoom-frm-unzoom'.\"\n (interactive \"P\")\n (let ((increment (if flip frame-zoom-font-difference (- frame-zoom-font-difference))))\n (set-face-attribute 'default nil\n :height (+ (* 10 increment)\n (face-attribute 'default :height nil 'default))))))\n\n;;;;;;;;;;;;;;;;;;;;;;;;;\n\n(provide 'zoom-frm)\n\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; zoom-frm.el ends here\n","avg_line_length":42.5011337868,"max_line_length":94,"alphanum_fraction":0.6132956304} {"size":5317,"ext":"el","lang":"Emacs Lisp","max_stars_count":14.0,"content":";;; wombat-theme.el --- Custom face theme for Emacs -*-coding: utf-8 -*-\n;;; Note: This theme has been customized and thus differs from the original.\n\n;; Copyright (C) 2011-2013 Free Software Foundation, Inc.\n\n;; Author: Kristoffer Gr\u00f6nlund \n\n;; This file is part of GNU Emacs.\n\n;; GNU Emacs is free software: you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; GNU Emacs is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs. If not, see .\n\n;;; Code:\n\n(deftheme wombat-custom\n \"Medium-contrast faces with a dark gray background.\nAdapted, with permission, from a Vim color scheme by Lars H. Nielsen.\nBasic, Font Lock, Isearch, Gnus, Message, and Ansi-Color faces\nare included.\")\n\n(let ((class '((class color) (min-colors 89))))\n (custom-theme-set-faces\n 'wombat-custom\n `(default ((,class (:background \"#242424\" :foreground \"#f6f3e8\"))))\n `(cursor ((,class (:background \"#656565\"))))\n ;; Highlighting faces\n `(fringe ((,class (:background \"#303030\"))))\n `(highlight ((,class (:background \"#090909\"))))\n `(region ((,class (:background \"#444444\" :foreground \"#f6f3e8\"))))\n `(secondary-selection ((,class (:background \"#333366\" :foreground \"#f6f3e8\"))))\n `(isearch ((,class (:background \"#343434\" :foreground \"#857b6f\"))))\n `(lazy-highlight ((,class (:background \"#384048\" :foreground \"#a0a8b0\"))))\n ;; Mode line faces\n `(mode-line ((,class (:background \"#444444\" :foreground \"#f6f3e8\" :box nil))))\n `(mode-line-inactive ((,class (:background \"#444444\" :foreground \"#857b6f\"))))\n ;; Escape and prompt faces\n `(minibuffer-prompt ((,class (:foreground \"#e5786d\"))))\n `(escape-glyph ((,class (:foreground \"#ddaa6f\" :weight bold))))\n ;; Font lock faces\n `(font-lock-builtin-face ((,class (:foreground \"#e5786d\"))))\n `(font-lock-comment-face ((,class (:foreground \"#99968b\"))))\n `(font-lock-constant-face ((,class (:foreground \"#e5786d\"))))\n `(font-lock-function-name-face ((,class (:foreground \"#cae682\"))))\n `(font-lock-keyword-face ((,class (:foreground \"#8ac6f2\" :weight bold))))\n `(font-lock-string-face ((,class (:foreground \"#95e454\"))))\n `(font-lock-type-face ((,class (:foreground \"#92a65e\" :weight bold))))\n `(font-lock-variable-name-face ((,class (:foreground \"#cae682\"))))\n `(font-lock-warning-face ((,class (:foreground \"#ccaa8f\"))))\n ;; Button and link faces\n `(link ((,class (:foreground \"#8ac6f2\" :underline t))))\n `(link-visited ((,class (:foreground \"#e5786d\" :underline t))))\n `(button ((,class (:background \"#333333\" :foreground \"#f6f3e8\"))))\n `(header-line ((,class (:background \"#303030\" :foreground \"#e7f6da\"))))\n ;; Gnus faces\n `(gnus-group-news-1 ((,class (:weight bold :foreground \"#95e454\"))))\n `(gnus-group-news-1-low ((,class (:foreground \"#95e454\"))))\n `(gnus-group-news-2 ((,class (:weight bold :foreground \"#cae682\"))))\n `(gnus-group-news-2-low ((,class (:foreground \"#cae682\"))))\n `(gnus-group-news-3 ((,class (:weight bold :foreground \"#ccaa8f\"))))\n `(gnus-group-news-3-low ((,class (:foreground \"#ccaa8f\"))))\n `(gnus-group-news-4 ((,class (:weight bold :foreground \"#99968b\"))))\n `(gnus-group-news-4-low ((,class (:foreground \"#99968b\"))))\n `(gnus-group-news-5 ((,class (:weight bold :foreground \"#cae682\"))))\n `(gnus-group-news-5-low ((,class (:foreground \"#cae682\"))))\n `(gnus-group-news-low ((,class (:foreground \"#99968b\"))))\n `(gnus-group-mail-1 ((,class (:weight bold :foreground \"#95e454\"))))\n `(gnus-group-mail-1-low ((,class (:foreground \"#95e454\"))))\n `(gnus-group-mail-2 ((,class (:weight bold :foreground \"#cae682\"))))\n `(gnus-group-mail-2-low ((,class (:foreground \"#cae682\"))))\n `(gnus-group-mail-3 ((,class (:weight bold :foreground \"#ccaa8f\"))))\n `(gnus-group-mail-3-low ((,class (:foreground \"#ccaa8f\"))))\n `(gnus-group-mail-low ((,class (:foreground \"#99968b\"))))\n `(gnus-header-content ((,class (:foreground \"#8ac6f2\"))))\n `(gnus-header-from ((,class (:weight bold :foreground \"#95e454\"))))\n `(gnus-header-subject ((,class (:foreground \"#cae682\"))))\n `(gnus-header-name ((,class (:foreground \"#8ac6f2\"))))\n `(gnus-header-newsgroups ((,class (:foreground \"#cae682\"))))\n ;; Message faces\n `(message-header-name ((,class (:foreground \"#8ac6f2\" :weight bold))))\n `(message-header-cc ((,class (:foreground \"#95e454\"))))\n `(message-header-other ((,class (:foreground \"#95e454\"))))\n `(message-header-subject ((,class (:foreground \"#cae682\"))))\n `(message-header-to ((,class (:foreground \"#cae682\"))))\n `(message-cited-text ((,class (:foreground \"#99968b\"))))\n `(message-separator ((,class (:foreground \"#e5786d\" :weight bold))))))\n\n(custom-theme-set-variables\n 'wombat-custom\n '(ansi-color-names-vector [\"#242424\" \"#e5786d\" \"#95e454\" \"#cae682\"\n\t\t\t \"#8ac6f2\" \"#333366\" \"#ccaa8f\" \"#f6f3e8\"]))\n\n(provide-theme 'wombat-custom)\n\n;;; wombat-custom-theme.el ends here\n","avg_line_length":50.6380952381,"max_line_length":82,"alphanum_fraction":0.6496144442} {"size":233,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":"(define-package \"with-editor\" \"20150701.1246\" \"Use the Emacsclient as $EDITOR\"\n '((emacs \"24.4\")\n (dash \"2.10.0\"))\n :url \"https:\/\/github.com\/magit\/magit\" :keywords\n '(\"tools\"))\n;; Local Variables:\n;; no-byte-compile: t\n;; End:\n","avg_line_length":25.8888888889,"max_line_length":78,"alphanum_fraction":0.6309012876} {"size":218,"ext":"el","lang":"Emacs Lisp","max_stars_count":1.0,"content":"(define-package \"swiper\" \"20160205.1224\" \"Isearch with an overview. Oh, man!\"\n '((emacs \"24.1\"))\n :url \"https:\/\/github.com\/abo-abo\/swiper\" :keywords\n '(\"matching\"))\n;; Local Variables:\n;; no-byte-compile: t\n;; End:\n","avg_line_length":27.25,"max_line_length":77,"alphanum_fraction":0.6467889908} {"size":8866,"ext":"el","lang":"Emacs Lisp","max_stars_count":42.0,"content":";;; multiple-cursors.el --- Multiple cursors for emacs.\n\n;; Copyright (C) 2012-2016 Magnar Sveen\n\n;; Author: Magnar Sveen \n;; Version: 1.4.0\n;; Keywords: editing cursors\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Commentary:\n\n;; Multiple cursors for Emacs. This is some pretty crazy functionality, so yes,\n;; there are kinks. Don't be afraid tho, I've been using it since 2011 with\n;; great success and much merriment.\n\n;; ## Basic usage\n\n;; Start out with:\n\n;; (require 'multiple-cursors)\n\n;; Then you have to set up your keybindings - multiple-cursors doesn't presume to\n;; know how you'd like them laid out. Here are some examples:\n\n;; When you have an active region that spans multiple lines, the following will\n;; add a cursor to each line:\n\n;; (global-set-key (kbd \"C-S-c C-S-c\") 'mc\/edit-lines)\n\n;; When you want to add multiple cursors not based on continuous lines, but based on\n;; keywords in the buffer, use:\n\n;; (global-set-key (kbd \"C->\") 'mc\/mark-next-like-this)\n;; (global-set-key (kbd \"C-<\") 'mc\/mark-previous-like-this)\n;; (global-set-key (kbd \"C-c C-<\") 'mc\/mark-all-like-this)\n\n;; First mark the word, then add more cursors.\n\n;; To get out of multiple-cursors-mode, press `` or `C-g`. The latter will\n;; first disable multiple regions before disabling multiple cursors. If you want to\n;; insert a newline in multiple-cursors-mode, use `C-j`.\n\n;; ## Video\n\n;; You can [watch an intro to multiple-cursors at Emacs Rocks](http:\/\/emacsrocks.com\/e13.html).\n\n;; ## Command overview\n\n;; ### Mark one more occurrence\n\n;; - `mc\/mark-next-like-this`: Adds a cursor and region at the next part of the buffer forwards that matches the current region.\n;; - `mc\/mark-next-like-this-word`: Adds a cursor and region at the next part of the buffer forwards that matches the current region, if no region is selected it selects the word at the point.\n;; - `mc\/mark-next-like-this-symbol`: Adds a cursor and region at the next part of the buffer forwards that matches the current region, if no region is selected it selects the symbol at the point.\n;; - `mc\/mark-next-word-like-this`: Like `mc\/mark-next-like-this` but only for whole words.\n;; - `mc\/mark-next-symbol-like-this`: Like `mc\/mark-next-like-this` but only for whole symbols.\n;; - `mc\/mark-previous-like-this`: Adds a cursor and region at the next part of the buffer backwards that matches the current region.\n;; - `mc\/mark-previous-word-like-this`: Like `mc\/mark-previous-like-this` but only for whole words.\n;; - `mc\/mark-previous-symbol-like-this`: Like `mc\/mark-previous-like-this` but only for whole symbols.\n;; - `mc\/mark-more-like-this-extended`: Use arrow keys to quickly mark\/skip next\/previous occurances.\n;; - `mc\/add-cursor-on-click`: Bind to a mouse event to add cursors by clicking. See tips-section.\n\n;; ### Mark many occurrences\n\n;; - `mc\/mark-all-like-this`: Marks all parts of the buffer that matches the current region.\n;; - `mc\/mark-all-words-like-this`: Like `mc\/mark-all-like-this` but only for whole words.\n;; - `mc\/mark-all-symbols-like-this`: Like `mc\/mark-all-like-this` but only for whole symbols.\n;; - `mc\/mark-all-in-region`: Prompts for a string to match in the region, adding cursors to all of them.\n;; - `mc\/mark-all-like-this-in-defun`: Marks all parts of the current defun that matches the current region.\n;; - `mc\/mark-all-words-like-this-in-defun`: Like `mc\/mark-all-like-this-in-defun` but only for whole words.\n;; - `mc\/mark-all-symbols-like-this-in-defun`: Like `mc\/mark-all-like-this-in-defun` but only for whole symbols.\n;; - `mc\/mark-all-like-this-dwim`: Tries to be smart about marking everything you want. Can be pressed multiple times.\n\n;; ### Special\n\n;; - `set-rectangular-region-anchor`: Think of this one as `set-mark` except you're marking a rectangular region.\n;; - `mc\/mark-sgml-tag-pair`: Mark the current opening and closing tag.\n;; - `mc\/insert-numbers`: Insert increasing numbers for each cursor, top to bottom.\n;; - `mc\/insert-letters`: Insert increasing letters for each cursor, top to bottom.\n;; - `mc\/sort-regions`: Sort the marked regions alphabetically.\n;; - `mc\/reverse-regions`: Reverse the order of the marked regions.\n\n;; ## Tips and tricks\n\n;; - To get out of multiple-cursors-mode, press `` or `C-g`. The latter will\n;; first disable multiple regions before disabling multiple cursors. If you want to\n;; insert a newline in multiple-cursors-mode, use `C-j`.\n;;\n;; - Sometimes you end up with cursors outside of your view. You can\n;; scroll the screen to center on each cursor with `C-v` and `M-v`.\n;;\n;; - Try pressing `mc\/mark-next-like-this` with no region selected. It will just add a cursor\n;; on the next line.\n;;\n;; - Try pressing `mc\/mark-next-like-this-word` or\n;; `mc\/mark-next-like-this-symbol` with no region selected. It will\n;; mark the symbol and add a cursor at the next occurance\n;;\n;; - Try pressing `mc\/mark-all-like-this-dwim` on a tagname in html-mode.\n;;\n;; - Notice that the number of cursors active can be seen in the modeline.\n;;\n;; - If you get out of multiple-cursors-mode and yank - it will yank only\n;; from the kill-ring of main cursor. To yank from the kill-rings of\n;; every cursor use yank-rectangle, normally found at C-x r y.\n;;\n;; - You can use `mc\/reverse-regions` with nothing selected and just one cursor.\n;; It will then flip the sexp at point and the one below it.\n;;\n;; - If you would like to keep the global bindings clean, and get custom keybindings\n;; when the region is active, you can try [region-bindings-mode](https:\/\/github.com\/fgallina\/region-bindings-mode).\n;;\n;; BTW, I highly recommend adding `mc\/mark-next-like-this` to a key binding that's\n;; right next to the key for `er\/expand-region`.\n\n;; ### Binding mouse events\n\n;; To override a mouse event, you will likely have to also unbind the\n;; `down-mouse` part of the event. Like this:\n;;\n;; (global-unset-key (kbd \"M-\"))\n;; (global-set-key (kbd \"M-\") 'mc\/add-cursor-on-click)\n;;\n;; Or you can do like me and find an unused, but less convenient, binding:\n;;\n;; (global-set-key (kbd \"C-S-\") 'mc\/add-cursor-on-click)\n\n;; ## Unknown commands\n\n;; Multiple-cursors uses two lists of commands to know what to do: the run-once list\n;; and the run-for-all list. It comes with a set of defaults, but it would be beyond silly\n;; to try and include all the known Emacs commands.\n\n;; So that's why multiple-cursors occasionally asks what to do about a command. It will\n;; then remember your choice by saving it in `~\/.emacs.d\/.mc-lists.el`. You can change\n;; the location with:\n\n;; (setq mc\/list-file \"\/my\/preferred\/file\")\n\n;; ## Known limitations\n\n;; * isearch-forward and isearch-backward aren't supported with multiple cursors.\n;; You should feel free to add a simplified version that can work with it.\n;; * Commands run with `M-x` won't be repeated for all cursors.\n;; * All key bindings that refer to lambdas are always run for all cursors. If you\n;; need to limit it, you will have to give it a name.\n;; * Redo might screw with your cursors. Undo works very well.\n\n;; ## Contribute\n\n;; Yes, please do. There's a suite of tests, so remember to add tests for your\n;; specific feature, or I might break it later.\n\n;; You'll find the repo at:\n\n;; https:\/\/github.com\/magnars\/multiple-cursors.el\n\n;; To fetch the test dependencies:\n\n;; $ cd \/path\/to\/multiple-cursors\n;; $ git submodule update --init\n\n;; Run the tests with:\n\n;; $ .\/util\/ecukes\/ecukes --graphical\n\n;; ## Contributors\n\n;; * [Takafumi Arakaki](https:\/\/github.com\/tkf) made .mc-lists.el diff friendly\n;; * [Marco Baringer](https:\/\/github.com\/segv) contributed looping to mc\/cycle and adding cursors without region for mark-more.\n;; * [Ivan Andrus](https:\/\/github.com\/gvol) added showing number of cursors in mode-line\n;; * [Fuco](https:\/\/github.com\/Fuco1) added the first version of `mc\/mark-all-like-this-dwim`\n\n;; Thanks!\n\n;;; Code:\n\n(require 'mc-edit-lines)\n(require 'mc-cycle-cursors)\n(require 'mc-mark-more)\n(require 'mc-mark-pop)\n(require 'rectangular-region-mode)\n(require 'mc-separate-operations)\n(require 'mc-hide-unmatched-lines-mode)\n\n(provide 'multiple-cursors)\n\n;;; multiple-cursors.el ends here\n","avg_line_length":44.33,"max_line_length":198,"alphanum_fraction":0.7090006767} {"size":1534,"ext":"el","lang":"Emacs Lisp","max_stars_count":10.0,"content":"(eval-and-compile\n (require 'slime))\n\n(define-slime-contrib slime-media\n \"Display things other than text in SLIME buffers\"\n (:authors \"Christophe Rhodes \")\n (:license \"GPL\")\n (:slime-dependencies slime-repl)\n (:swank-dependencies swank-media)\n (:on-load\n (add-hook 'slime-event-hooks 'slime-dispatch-media-event)))\n\n(defun slime-media-decode-image (image)\n (mapcar (lambda (image)\n\t (if (plist-get image :data)\n\t\t(plist-put image :data (base64-decode-string (plist-get image :data)))\n\t image))\n\t image))\n\n(defun slime-dispatch-media-event (event)\n (slime-dcase event\n ((:write-image image string)\n (let ((img (or (find-image (slime-media-decode-image image))\n (create-image image))))\n (slime-media-insert-image img string))\n t)\n ((:popup-buffer bufname string mode)\n (slime-with-popup-buffer (bufname :connection t :package t)\n (when mode (funcall mode))\n (princ string)\n (goto-char (point-min)))\n t)\n (t nil)))\n\n(defun slime-media-insert-image (image string &optional bol)\n (with-current-buffer (slime-output-buffer)\n (let ((marker (slime-repl-output-target-marker :repl-result)))\n (goto-char marker)\n (slime-propertize-region `(face slime-repl-result-face\n rear-nonsticky (face))\n (insert-image image string))\n ;; Move the input-start marker after the REPL result.\n (set-marker marker (point)))\n (slime-repl-show-maximum-output)))\n\n(provide 'slime-media)\n","avg_line_length":32.6382978723,"max_line_length":72,"alphanum_fraction":0.6434159061} {"size":1262,"ext":"el","lang":"Emacs Lisp","max_stars_count":6.0,"content":";;; placeins.el --- AUCTeX style for `placeins.sty'\n\n;; Copyright (C) 2013 Free Software Foundation, Inc.\n\n;; Author: Mads Jensen \n;; Maintainer: auctex-devel@gnu.org\n;; Keywords: tex\n\n;; This file is part of AUCTeX.\n\n;; AUCTeX is free software; you can redistribute it and\/or modify it\n;; under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; AUCTeX is distributed in the hope that it will be useful, but\n;; WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n;; General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with AUCTeX; see the file COPYING. If not, write to the Free\n;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n;; 02110-1301, USA.\n\n;;; Commentary:\n\n;; This file adds support for `placeins.sty'\n\n;;; Code:\n\n(TeX-add-style-hook\n \"placeins\"\n (lambda ()\n (TeX-add-symbols\n '(\"FloatBarrier\" 0)))\n LaTeX-dialect)\n\n(defvar LaTeX-placeins-package-options \n '(\"section\" \"above\" \"below\" \"verbose\")\n \"Package options for placeins.\")\n\n;; placeins.el ends here\n","avg_line_length":28.6818181818,"max_line_length":70,"alphanum_fraction":0.7179080824} {"size":108,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(define-package \"browse-kill-ring\" \"20150104.1237\" \"interactively insert items from kill-ring\" (quote nil))\n","avg_line_length":54.0,"max_line_length":107,"alphanum_fraction":0.7685185185} {"size":15002,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; lsp-treemacs-themes.el --- LSP treemacs themes -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2020 Eric Dallo\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n;;\n;; This file is not part of GNU Emacs.\n;;\n;;; Commentary:\n;;\n;; LSP treemacs themes\n;;\n;;; Code:\n\n(require 'treemacs)\n(require 'treemacs-themes)\n\n(defcustom lsp-treemacs-theme \"Default\"\n \"The `lsp-treemacs' theme.\"\n :type 'string\n :group 'lsp-treemacs)\n\n(treemacs-modify-theme \"Default\"\n :extends \"Default\"\n :icon-directory (f-join (f-dirname (or load-file-name buffer-file-name)) \"icons\/vscode\")\n :config\n (progn\n (treemacs-create-icon :file \"BooleanData.png\" :extensions (boolean-data) :fallback \"-\")\n (treemacs-create-icon :file \"ColorPalette.png\" :extensions (color-palette) :fallback \"-\")\n (treemacs-create-icon :file \"Document.png\" :extensions (document) :fallback \"-\")\n (treemacs-create-icon :file \"Enumerator.png\" :extensions (enumerator) :fallback \"-\")\n (treemacs-create-icon :file \"EnumItem.png\" :extensions (enumitem) :fallback \"-\")\n (treemacs-create-icon :file \"Indexer.png\" :extensions (indexer) :fallback \"-\")\n (treemacs-create-icon :file \"IntelliSenseKeyword.png\" :extensions (intellisense-keyword) :fallback \"-\")\n (treemacs-create-icon :file \"LocalVariable.png\" :extensions (localvariable) :fallback \"-\")\n (treemacs-create-icon :file \"Numeric.png\" :extensions (numeric) :fallback \"-\")\n (treemacs-create-icon :file \"Operator.png\" :extensions (operator) :fallback \"-\")\n (treemacs-create-icon :file \"Template.png\" :extensions (template) :fallback \"-\")\n (treemacs-create-icon :file \"collapsed.png\" :extensions (collapsed) :fallback \"-\")\n (treemacs-create-icon :file \"expanded.png\" :extensions (expanded) :fallback \"-\")\n (treemacs-create-icon :file \"classfile.png\" :extensions (classfile) :fallback \"-\")\n (treemacs-create-icon :file \"default_folder_opened.png\" :extensions (default-folder-opened) :fallback \"-\")\n (treemacs-create-icon :file \"default_folder.png\" :extensions (default-folder) :fallback \"-\")\n (treemacs-create-icon :file \"default_root_folder_opened.png\" :extensions (default-root-folder-opened) :fallback \"-\")\n (treemacs-create-icon :file \"default_root_folder.png\" :extensions (default-root-folder) :fallback \"-\")\n (treemacs-create-icon :file \"file_type_class.png\" :extensions (\"class\") :fallback \"-\")\n (treemacs-create-icon :file \"file_type_jar.png\" :extensions (file-type-jar) :fallback \"-\")\n (treemacs-create-icon :file \"file_type_flutter.png\" :extensions (flutter) :fallback \"-\")\n (treemacs-create-icon :file \"folder-open.png\" :extensions (folder-open) :fallback \"-\")\n (treemacs-create-icon :file \"folder.png\" :extensions (folder) :fallback \"-\")\n (treemacs-create-icon :file \"folder_type_component_opened.png\" :extensions (folder-type-component-opened) :fallback \"-\")\n (treemacs-create-icon :file \"folder_type_component.png\" :extensions (folder-type-component) :fallback \"-\")\n (treemacs-create-icon :file \"folder_type_library_opened.png\" :extensions (folder-type-library-opened) :fallback \"-\")\n (treemacs-create-icon :file \"folder_type_library.png\" :extensions (folder-type-library) :fallback \"-\")\n (treemacs-create-icon :file \"folder_type_maven_opened.png\" :extensions (folder-type-maven-opened) :fallback \"-\")\n (treemacs-create-icon :file \"folder_type_maven.png\" :extensions (folder-type-maven) :fallback \"-\")\n (treemacs-create-icon :file \"folder_type_package_opened.png\" :extensions (folder-type-package-opened) :fallback \"-\")\n (treemacs-create-icon :file \"folder_type_package.png\" :extensions (folder-type-package) :fallback \"-\")\n (treemacs-create-icon :file \"icon-create.png\" :extensions (icon-create) :fallback \"-\")\n (treemacs-create-icon :file \"icon-flat.png\" :extensions (icon-flat) :fallback \"-\")\n (treemacs-create-icon :file \"icon-hierarchical.png\" :extensions (icon-hierarchical) :fallback \"-\")\n (treemacs-create-icon :file \"icon-link.png\" :extensions (icon-link) :fallback \"-\")\n (treemacs-create-icon :file \"icon-refresh.png\" :extensions (icon-refresh) :fallback \"-\")\n (treemacs-create-icon :file \"icon-unlink.png\" :extensions (icon-unlink) :fallback \"-\")\n (treemacs-create-icon :file \"jar.png\" :extensions (jar) :fallback \"-\")\n (treemacs-create-icon :file \"library.png\" :extensions (library) :fallback \"-\")\n (treemacs-create-icon :file \"packagefolder-open.png\" :extensions (packagefolder-open) :fallback \"-\")\n (treemacs-create-icon :file \"packagefolder.png\" :extensions (packagefolder) :fallback \"-\")\n (treemacs-create-icon :file \"package.png\" :extensions (package) :fallback \"-\")\n (treemacs-create-icon :file \"project.png\" :extensions (java-project) :fallback \"-\")\n\n (treemacs-create-icon :file \"symbol-array.png\" :extensions (array) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-boolean.png\" :extensions (boolean) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-class.png\" :extensions (class) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-color.png\" :extensions (color) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-constant.png\" :extensions (constant) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-enumerator-member.png\" :extensions (enum-member) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-enumerator.png\" :extensions (enum) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-event.png\" :extensions (event) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-field.png\" :extensions (field) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-interface.png\" :extensions (interface) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-key.png\" :extensions (key) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-keyword.png\" :extensions (keyword) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-method.png\" :extensions (method) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-misc.png\" :extensions (misc) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-namespace.png\" :extensions (namespace) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-namespace.png\" :extensions (module) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-numeric.png\" :extensions (numeric) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-operator.png\" :extensions (operator) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-parameter.png\" :extensions (parameter) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-property.png\" :extensions (property) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-ruler.png\" :extensions (ruler) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-snippet.png\" :extensions (snippet) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-string.png\" :extensions (string) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-structure.png\" :extensions (struct) :fallback \"-\")\n (treemacs-create-icon :file \"symbol-variable.png\" :extensions (variable) :fallback \"-\")))\n\n(treemacs-create-theme \"Eclipse\"\n :extends \"Default\"\n :icon-directory (f-join (f-dirname (or load-file-name buffer-file-name)) \"icons\/eclipse\")\n :config\n (progn\n (treemacs-create-icon :file \"vscode\/Namespace.png\" :extensions (namespace) :fallback \"-\")\n (treemacs-create-icon :file \"text.png\" :extensions (text) :fallback \"-\")\n (treemacs-create-icon :file \"method.png\" :extensions (method) :fallback \"-\")\n (treemacs-create-icon :file \"function.png\" :extensions (function) :fallback \"-\")\n (treemacs-create-icon :file \"constructor.png\" :extensions (constructor) :fallback \"-\")\n (treemacs-create-icon :file \"field.png\" :extensions (field) :fallback \"-\")\n (treemacs-create-icon :file \"variable.png\" :extensions (variable) :fallback \"-\")\n (treemacs-create-icon :file \"class.png\" :extensions (class) :fallback \"-\")\n (treemacs-create-icon :file \"interface.png\" :extensions (interface) :fallback \"-\")\n (treemacs-create-icon :file \"module.png\" :extensions (module) :fallback \"-\")\n (treemacs-create-icon :file \"property.png\" :extensions (property) :fallback \"-\")\n (treemacs-create-icon :file \"unit.png\" :extensions (unit) :fallback \"-\")\n (treemacs-create-icon :file \"value.png\" :extensions (value) :fallback \"-\")\n (treemacs-create-icon :file \"enum.png\" :extensions (enum) :fallback \"-\")\n (treemacs-create-icon :file \"keyword.png\" :extensions (keyword) :fallback \"-\")\n (treemacs-create-icon :file \"snippet.png\" :extensions (snippet) :fallback \"-\")\n (treemacs-create-icon :file \"color.png\" :extensions (color) :fallback \"-\")\n (treemacs-create-icon :file \"file.png\" :extensions (file) :fallback \"-\")\n (treemacs-create-icon :file \"reference.png\" :extensions (reference) :fallback \"-\")\n (treemacs-create-icon :file \"folder.png\" :extensions (folder) :fallback \"-\")\n (treemacs-create-icon :file \"enummember.png\" :extensions (enum-member) :fallback \"-\")\n (treemacs-create-icon :file \"constant.png\" :extensions (constant) :fallback \"-\")\n (treemacs-create-icon :file \"struct.png\" :extensions (struct) :fallback \"-\")\n (treemacs-create-icon :file \"event.png\" :extensions (event) :fallback \"-\")\n (treemacs-create-icon :file \"operator.png\" :extensions (operator) :fallback \"-\")\n (treemacs-create-icon :file \"typeparameter.png\" :extensions (type-parameter) :fallback \"-\")\n (treemacs-create-icon :file \"template.png\" :extensions (template) :fallback \"-\")))\n\n(treemacs-create-theme \"Netbeans\"\n :extends \"Default\"\n :icon-directory (f-join (f-dirname (or load-file-name buffer-file-name)) \"icons\/netbeans\")\n :config\n (progn\n (treemacs-create-icon :file \"vscode\/Namespace.png\" :extensions (namespace) :fallback \"-\")\n (treemacs-create-icon :file \"text.png\" :extensions (text) :fallback \"-\")\n (treemacs-create-icon :file \"method.png\" :extensions (method) :fallback \"-\")\n (treemacs-create-icon :file \"function.png\" :extensions (function) :fallback \"-\")\n (treemacs-create-icon :file \"constructor.png\" :extensions (constructor) :fallback \"-\")\n (treemacs-create-icon :file \"field.png\" :extensions (field) :fallback \"-\")\n (treemacs-create-icon :file \"variable.gif\" :extensions (variable) :fallback \"-\")\n (treemacs-create-icon :file \"class.png\" :extensions (class) :fallback \"-\")\n (treemacs-create-icon :file \"interface.png\" :extensions (interface) :fallback \"-\")\n (treemacs-create-icon :file \"module.png\" :extensions (module) :fallback \"-\")\n (treemacs-create-icon :file \"property.png\" :extensions (property) :fallback \"-\")\n (treemacs-create-icon :file \"unit.png\" :extensions (unit) :fallback \"-\")\n (treemacs-create-icon :file \"value.png\" :extensions (value) :fallback \"-\")\n (treemacs-create-icon :file \"enum.png\" :extensions (enum) :fallback \"-\")\n (treemacs-create-icon :file \"keyword.png\" :extensions (keyword) :fallback \"-\")\n (treemacs-create-icon :file \"snippet.png\" :extensions (snippet) :fallback \"-\")\n (treemacs-create-icon :file \"color.png\" :extensions (color) :fallback \"-\")\n (treemacs-create-icon :file \"file.png\" :extensions (file) :fallback \"-\")\n (treemacs-create-icon :file \"reference.png\" :extensions (reference) :fallback \"-\")\n (treemacs-create-icon :file \"folder.png\" :extensions (folder) :fallback \"-\")\n (treemacs-create-icon :file \"enummember.png\" :extensions (enum-member) :fallback \"-\")\n (treemacs-create-icon :file \"constant.png\" :extensions (constant) :fallback \"-\")\n (treemacs-create-icon :file \"struct.png\" :extensions (struct) :fallback \"-\")\n (treemacs-create-icon :file \"event.png\" :extensions (event) :fallback \"-\")\n (treemacs-create-icon :file \"operator.png\" :extensions (operator) :fallback \"-\")\n (treemacs-create-icon :file \"typeparameter.png\" :extensions (type-parameter) :fallback \"-\")\n (treemacs-create-icon :file \"template.png\" :extensions (template) :fallback \"-\")))\n\n(treemacs-create-theme \"Idea\"\n :extends \"Default\"\n :icon-directory (f-join (f-dirname (or load-file-name buffer-file-name)) \"icons\/idea\")\n :config\n (progn\n (treemacs-create-icon :file \"vscode\/template.png\" :extensions (template) :fallback \"-\")\n (treemacs-create-icon :file \"package.png\" :extensions (unknown) :fallback \"-\")\n ;; (treemacs-create-icon :file \"misc.png\" :extensions (text) :fallback \"-\")\n (treemacs-create-icon :file \"method.png\" :extensions (method) :fallback \"-\")\n (treemacs-create-icon :file \"method.png\" :extensions (function) :fallback \"-\")\n (treemacs-create-icon :file \"method.png\" :extensions (constructor) :fallback \"-\")\n (treemacs-create-icon :file \"field.png\" :extensions (field) :fallback \"-\")\n (treemacs-create-icon :file \"field.png\" :extensions (variable) :fallback \"-\")\n (treemacs-create-icon :file \"class.png\" :extensions (class) :fallback \"-\")\n (treemacs-create-icon :file \"interface.png\" :extensions (interface) :fallback \"-\")\n (treemacs-create-icon :file \"package.png\" :extensions (module) :fallback \"-\")\n (treemacs-create-icon :file \"property.png\" :extensions (property) :fallback \"-\")\n ;; (treemacs-create-icon :file \"misc.png\" :extensions (unit) :fallback \"-\")\n (treemacs-create-icon :file \"field.png\" :extensions (value) :fallback \"-\")\n (treemacs-create-icon :file \"enum.png\" :extensions (enum) :fallback \"-\")\n ;; (treemacs-create-icon :file \"misc.png\" :extensions (keyword) :fallback \"-\")\n (treemacs-create-icon :file \"snippet.png\" :extensions (snippet) :fallback \"-\")\n ;; (treemacs-create-icon :file \"misc.png\" :extensions (color) :fallback \"-\")\n (treemacs-create-icon :file \"ppFile.png\" :extensions (file) :fallback \"-\")\n (treemacs-create-icon :file \"misc.png\" :extensions (reference) :fallback \"-\")\n (treemacs-create-icon :file \"ppFile.png\" :extensions (folder) :fallback \"-\")\n (treemacs-create-icon :file \"enum.png\" :extensions (enumMember) :fallback \"-\")\n (treemacs-create-icon :file \"field.png\" :extensions (constant) :fallback \"-\")\n (treemacs-create-icon :file \"class.png\" :extensions (struct) :fallback \"-\")\n (treemacs-create-icon :file \"Event.png\" :extensions (event) :fallback \"-\")\n (treemacs-create-icon :file \"Misc.png\" :extensions (operator) :fallback \"-\")\n ;; (treemacs-create-icon :file \"Misc.png\" :extensions (operator) :fallback \"-\")\n (treemacs-create-icon :file \"Class.png\" :extensions (typeParameter) :fallback \"-\")\n (treemacs-create-icon :file \"Template.png\" :extensions (template) :fallback \"-\")))\n\n(provide 'lsp-treemacs-themes)\n;;; lsp-treemacs-themes.el ends here\n","avg_line_length":70.7641509434,"max_line_length":124,"alphanum_fraction":0.6977069724} {"size":1608,"ext":"el","lang":"Emacs Lisp","max_stars_count":10.0,"content":"; This Emacs Lisp file defines a C indentation style that closely\n; follows most aspects of the one that is used throughout SSLeay,\n; and hence in OpenSSL.\n; \n; This definition is for the \"CC mode\" package, which is the default\n; mode for editing C source files in Emacs 20, not for the older\n; c-mode.el (which was the default in less recent releaes of Emacs 19).\n;\n; Copy the definition in your .emacs file or use M-x eval-buffer.\n; To activate this indentation style, visit a C file, type\n; M-x c-set-style (or C-c . for short), and enter \"eay\".\n; To toggle the auto-newline feature of CC mode, type C-c C-a.\n;\n; Apparently statement blocks that are not introduced by a statement\n; such as \"if\" and that are not the body of a function cannot\n; be handled too well by CC mode with this indentation style,\n; so you have to indent them manually (you can use C-q tab).\n; \n; For suggesting improvements, please send e-mail to bodo@openssl.org.\n\n(c-add-style \"eay\"\n\t '((c-basic-offset . 8)\n\t (c-comment-only-line-offset . 0)\n\t (c-hanging-braces-alist)\n\t (c-offsets-alist\t. ((defun-open . +)\n\t\t\t\t (defun-block-intro . 0)\n\t\t\t\t (class-open . +)\n\t\t\t\t (class-close . +)\n\t\t\t\t (block-open . 0)\n\t\t\t\t (block-close . 0)\n\t\t\t\t (substatement-open . +)\n\t\t\t\t (statement . 0)\n\t\t\t\t (statement-block-intro . 0)\n\t\t\t\t (statement-case-open . +)\n\t\t\t\t (statement-case-intro . +)\n\t\t\t\t (case-label . -)\n\t\t\t\t (label . -)\n\t\t\t\t (arglist-cont-nonempty . +)\n\t\t\t\t (topmost-intro . -)\n\t\t\t\t (brace-list-close . 0)\n\t\t\t\t (brace-list-intro . 0)\n\t\t\t\t (brace-list-open . +)\n\t\t\t\t ))))\n\n","avg_line_length":35.7333333333,"max_line_length":71,"alphanum_fraction":0.6312189055} {"size":541,"ext":"el","lang":"Emacs Lisp","max_stars_count":1.0,"content":";; -*- no-byte-compile: t; -*-\n;;; lang\/web\/packages.el\n\n;; +html.el\n(package! emmet-mode)\n(package! haml-mode)\n(package! pug-mode)\n(package! slim-mode)\n(when (package! web-mode)\n (when (featurep! :completion company)\n (package! company-web)))\n\n;; +css.el\n(package! css-mode :built-in t)\n(package! less-css-mode :built-in t)\n\n(package! sass-mode)\n(package! stylus-mode)\n(package! sws-mode)\n(package! rainbow-mode)\n(when (featurep! :completion ivy)\n (package! counsel-css))\n(when (featurep! :completion helm)\n (package! helm-css-scss))\n","avg_line_length":21.64,"max_line_length":39,"alphanum_fraction":0.6728280961} {"size":3534,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; evil-matchit-simple.el --- simple match plugin of evil-matchit\n\n;; Copyright (C) 2014-2019 Chen Bin \n\n\n;; Author: Chen Bin \n\n;; This file is not part of GNU Emacs.\n\n;;; License:\n\n;; This file is part of evil-matchit\n;;\n;; evil-matchit is free software: you can redistribute it and\/or\n;; modify it under the terms of the GNU General Public License as published\n;; by the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n;;\n;; evil-matchit is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n;;\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n\n;;; Code:\n\n(require 'evil-matchit-sdk)\n\n(defun evilmi--simple-find-open-brace (cur-line)\n \"Find open brace from CUR-LINE.\"\n (if evilmi-debug (message \"evilmi--simple-find-open-brace called => cur-line=%s (point)=%d\" cur-line (point)))\n (let (rlt)\n (cond\n\n ;; code \"(function(...) { ...\"\n ;; code \"} else {\"\n ;; css-mode use characters \".:-\"\n ((or (string-match-p \"^[ \\t]*[\\(\\}]?[.:_a-zA-Z0-9-]+.*{ *\\\\(\\\/\\\/.*\\\\)?$\" cur-line)\n (string-match-p \"^[ \\t]*[\\(\\}]?[.:_a-zA-Z0-9-]+.*{ *\\\\(\\\/\\*[^\/]*\\*\\\/\\\\)?$\" cur-line))\n (setq rlt 1))\n\n ;; code \"} if (...) {\"\n ;; code \"} else (...) {\"\n ((and (string-match-p \"^[ \\t]*[\\}]? \\\\(if\\\\|el[a-z]*\\\\) *.*{ *?$\" cur-line)\n (not (eq (following-char) ?})))\n (setq rlt 1))\n\n ;; next line is \"{\"\n (t\n (save-excursion\n (forward-line)\n (setq cur-line (evilmi-sdk-curline))\n (if (string-match-p \"^[ \\t]*{ *$\" cur-line)\n (setq rlt 2)))))\n\n rlt))\n\n;;;###autoload\n(defun evilmi-simple-get-tag ()\n \"Get current tag in simple language.\"\n (let* (forward-line-num\n ;; Only handle open tag\n (tmp (evilmi--get-char-under-cursor))\n (ch (if tmp (car tmp)))\n rlt)\n\n (if evilmi-debug (message \"evilmi-simple-get-tag called => ch=%s (point)=%d\" ch (point)))\n\n (cond\n ;; In evil-visual-state, the (preceding-char) is actually the character under cursor\n ((not (evilmi--char-is-simple ch))\n (when (setq forward-line-num (evilmi--simple-find-open-brace (evilmi-sdk-curline)))\n (setq rlt (list (line-beginning-position)))\n ;; need handle case \"if () \\n { ... }\".\n ;; move cursor over \"{\", prepare for `evil-jump-item'\n (forward-line (1- forward-line-num))\n (search-forward \"{\" nil nil)\n (backward-char)))\n (t\n ;; use evil's own evilmi--simple-jump\n (setq rlt (list (point)))))\n\n (if (and evilmi-debug rlt) (message \"evilmi-simple-get-tag called rlt=%s\" rlt))\n rlt))\n\n;;;###autoload\n(defun evilmi-simple-jump (rlt NUM)\n \"Jump from current tag to matching tag in simple language.\"\n (when rlt\n (if evilmi-debug (message \"evilmi-simple-jump called (point)=%d\" (point)))\n\n ;; In latex-mode `scan-sexps' does NOT work properly between \"[]\"\n ;; so we have to fallback to evil's API.\n (if (memq major-mode '(latex-mode))\n (evil-jump-item)\n (evilmi--simple-jump))\n\n ;; hack for javascript\n (if (string-match-p \"^[ \\t]*})\\\\((.*)\\\\)?\\; *$\"\n (evilmi-sdk-curline))\n (line-end-position)\n (1+ (point)))))\n\n(provide 'evil-matchit-simple)\n","avg_line_length":32.7222222222,"max_line_length":112,"alphanum_fraction":0.5854555744} {"size":3334,"ext":"el","lang":"Emacs Lisp","max_stars_count":42.0,"content":";;; dap-cpptools.el --- Debug Adapter Protocol mode for cpptools -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2020 Ivan Yonchovski\n\n;; Author: Ivan Yonchovski \n;; Keywords: language, tools\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Commentary:\n\n;; Adapter for https:\/\/github.com\/microsoft\/vscode-cpptools\n\n;;; Code:\n\n(require 'dap-mode)\n(require 'dap-utils)\n\n(defcustom dap-cpptools-debug-path (expand-file-name \"vscode\/cpptools\" dap-utils-extension-path)\n \"The path to go vscode extension.\"\n :group 'dap-cpptools\n :type 'string)\n\n(defcustom dap-cpptools-download-url\n (format \"https:\/\/github.com\/microsoft\/vscode-cpptools\/releases\/download\/0.29.0\/cpptools-%s.vsix\"\n (alist-get system-type\n '((windows-nt . \"win32\")\n (darwin . \"osx\")\n (gnu\/linux . \"linux\"))))\n \"The download url.\"\n :group 'dap-cpptools\n :type 'string)\n\n(defcustom dap-cpptools-debug-program\n `(,(concat dap-cpptools-debug-path\n (if (eq system-type 'windows-nt)\n \"\/extension\/debugAdapters\/bin\/OpenDebugAD7.exe\"\n \"\/extension\/debugAdapters\/OpenDebugAD7\")))\n \"The path to the go debugger.\"\n :group 'dap-cpptools\n :type '(repeat string))\n\n(defun dap-cpptools-setup (&optional forced)\n \"Downloading ms-vscode.cpptools to path specified.\nWith prefix, FORCED to redownload the extension.\"\n (interactive \"P\")\n (unless (and (not forced) (file-exists-p dap-cpptools-debug-path))\n (dap-utils--get-extension dap-cpptools-download-url dap-cpptools-debug-path)\n (let* ((adapter-binary (cl-first dap-cpptools-debug-program))\n (mono (f-join (f-parent adapter-binary) \"mono.linux-x86_64\")))\n (set-file-modes adapter-binary #o0700)\n (when (f-exists? mono)\n (set-file-modes mono #o0700)))\n\n (message \"%s: Downloading done!\" \"dap-cpptools\")))\n\n(defun dap-cpptools--populate-args (conf)\n \"Populate auto arguments.\"\n (-> conf\n (dap--put-if-absent :dap-server-path dap-cpptools-debug-program)\n (dap--put-if-absent :request \"launch\")\n (dap--put-if-absent :type \"cppdbg\")\n (dap--put-if-absent :environment [])))\n\n(dap-register-debug-provider \"cppdbg\" #'dap-cpptools--populate-args)\n\n(dap-register-debug-template \"cpptools::Run Configuration\"\n (list :type \"cppdbg\"\n :request \"launch\"\n :name \"cpptools::Run Configuration\"\n :MIMode \"gdb\"\n :program \"${workspaceFolder}\/ replace with your binary\"\n :cwd \"${workspaceFolder}\"))\n\n(provide 'dap-cpptools)\n;;; dap-cpptools.el ends here\n","avg_line_length":37.8863636364,"max_line_length":98,"alphanum_fraction":0.6424715057} {"size":1516,"ext":"el","lang":"Emacs Lisp","max_stars_count":44.0,"content":"(require 'mmm-auto)\n(setq mmm-global-mode 'maybe)\n\n(mmm-add-classes\n '((bistro-sh\n :submode sh-mode\n :face mmm-declaration-submode-face\n :front \"[%sh[ \\t\\n]*{|\"\n :back \"|}\")\n (bistro-bash\n :submode sh-mode\n :face mmm-declaration-submode-face\n :front \"[%bash[ \\t\\n]*{|\"\n :back \"|}\")\n (bistro-R\n :submode ess-mode\n :face mmm-declaration-submode-face\n :front \"[%R[ \\t\\n]*{|\"\n :back \"|}\")\n (bistro-perl\n :submode perl-mode\n :face mmm-declaration-submode-face\n :front \"[%perl[ \\t\\n]*{|\"\n :back \"|}\")\n (bistro-ocaml\n :submode tuareg-mode\n :face mmm-declaration-submode-face\n :front \"[%ocaml[ \\t\\n]*{|\"\n :back \"|}\")\n (bistro-ocamlscript\n :submode tuareg-mode\n :face mmm-declaration-submode-face\n :front \"[%ocamlscript[ \\t\\n]*{|\"\n :back \"|}\")\n (bistro-python\n :submode python-mode\n :face mmm-declaration-submode-face\n :front \"[%python[ \\t\\n]*{|\"\n :back \"|}\")))\n\n(mmm-add-mode-ext-class 'tuareg-mode nil 'bistro-sh)\n(mmm-add-mode-ext-class 'tuareg-mode nil 'bistro-bash)\n(mmm-add-mode-ext-class 'tuareg-mode nil 'bistro-ocaml)\n(mmm-add-mode-ext-class 'tuareg-mode nil 'bistro-ocamlscript)\n(mmm-add-mode-ext-class 'tuareg-mode nil 'bistro-python)\n(mmm-add-mode-ext-class 'tuareg-mode nil 'bistro-R)\n(mmm-add-mode-ext-class 'tuareg-mode nil 'bistro-perl)\n\n","avg_line_length":30.9387755102,"max_line_length":61,"alphanum_fraction":0.5507915567} {"size":3625,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";; -*- lexical-binding: t -*-\n\n(require 'ert)\n(require 'f)\n\n(let ((rustic-dir (f-parent (f-dirname (f-this-file)))))\n (add-to-list 'load-path rustic-dir))\n(require 'rustic)\n(custom-set-variables '(indent-tabs-mode nil))\n\n;; don't start LSP server for every test\n(setq rustic-lsp-setup-p nil)\n\n;; variable doesn't exist in noninteractive emacs sessions\n(when noninteractive\n (defvar org-babel-temporary-directory\n (or (and (boundp 'org-babel-temporary-directory)\n\t (file-exists-p org-babel-temporary-directory)\n\t org-babel-temporary-directory)\n\t (make-temp-file \"babel-\" t))\n \"Directory to hold temporary files created to execute code blocks.\nUsed by `org-babel-temp-file'. This directory will be removed on\nEmacs shutdown.\")\n\n (defun remove-temporary-babel-directory ()\n (when (and (boundp 'org-babel-temporary-directory)\n\t (file-exists-p org-babel-temporary-directory))\n (delete-directory org-babel-temporary-directory t)))\n\n (add-hook 'kill-emacs-hook 'remove-temporary-babel-directory))\n\n(defsubst rustic-compare-code-after-manip (_original _point-pos _manip-func expected got)\n (equal expected got))\n\n(defun rustic-test-manip-code (original point-pos manip-func expected)\n (with-temp-buffer\n (rustic-mode)\n (insert original)\n (goto-char point-pos)\n (funcall manip-func)\n (should (rustic-compare-code-after-manip\n original point-pos manip-func expected (buffer-string)))))\n\n;; TODO: rename\n(defun rustic-test-count-error-helper (string)\n (let* ((buffer (get-buffer-create \"b\"))\n (dir (rustic-babel-generate-project t))\n (src (concat dir \"\/src\"))\n (file (expand-file-name \"main.rs\" src))\n (buffer-save-without-query t)\n (rustic-format-trigger nil))\n (with-current-buffer buffer\n (write-file file)\n (insert \"#[allow(non_snake_case)]\")\n (insert string)\n (save-buffer))\n dir))\n\n(defmacro rustic-test-silence (messages &rest body)\n `(cl-letf* (((symbol-function 'm)\n (symbol-function #'message))\n ((symbol-function #'message)\n\t (lambda (format-string &rest args)\n\t (unless (member format-string ,messages)\n\t (apply 'm format-string args)))))\n ,@body))\n\n(defun test-indent (indented &optional deindented)\n (let ((deindented\n (or deindented\n (replace-regexp-in-string \"^[[:blank:]]*\" \" \" indented))))\n (rustic-test-manip-code\n deindented\n 1\n (lambda ()\n (rustic-test-silence\n '(\"%s %s\" ; \"Indenting...\" progress-reporter-do-update\n \"%sdone\") ; \"Indenting...done\" progress-reporter-done\n (indent-region 1 (+ 1 (buffer-size)))))\n indented)))\n\n(defun rustic-test-group-str-by-face (str)\n \"Fontify `STR' in rust-mode and group it by face, returning a\nlist of substrings of `STR' each followed by its face.\"\n (cl-loop with fontified = (rustic-test-fontify-string str)\n for start = 0 then end\n while start\n for end = (next-single-property-change start 'face fontified)\n for prop = (get-text-property start 'face fontified)\n for text = (substring-no-properties fontified start end)\n if prop\n append (list text prop)))\n\n(defun rustic-test-font-lock (source face-groups)\n \"Test that `SOURCE' fontifies to the expected `FACE-GROUPS'\"\n (should (equal (rustic-test-group-str-by-face source)\n face-groups)))\n\n(defun rustic-test-fontify-string (str)\n (with-temp-buffer\n (rustic-mode)\n (insert str)\n (font-lock-ensure)\n (font-lock-flush)\n (buffer-string)))\n","avg_line_length":34.1981132075,"max_line_length":89,"alphanum_fraction":0.6435862069} {"size":56811,"ext":"el","lang":"Emacs Lisp","max_stars_count":1.0,"content":";; -*- Emacs-Lisp -*-\n\n(require 'cl)\n(require 'pp)\n\n(eval-and-compile (setq load-path (cons \"..\" (cons \".\" load-path))))\n(provide 'edsio)\n(eval-and-compile (setq load-path (cdr (cdr load-path))))\n\n;; Turn of assertions in compiled code.\n(eval-and-compile\n (setq cl-optimize-speed 3)\n (setq cl-optimize-safety 1)\n )\n\n;; Begin\n\n(defconst *definition-state* nil\n \"List of all the names of variables containing state from the\ndefinition file so that operations may be performed on everything in\nthe definition file.\")\n(defconst *definition-attrs* nil\n \"List of attributes for sharing indices.\")\n(defconst *all-objects* nil)\n(defconst *output-files* nil\n \"List of lists (NAME BUFFER) used during output of headers.\")\n(defconst *output-prefix* nil\n \"Prefix used for outputing header files.\")\n(defconst *cpp-extension* \"c\")\n\n;; This defines several functions and one macro. The indirection makes\n;; it a little bit confusing to read. It defines the macro DEFDNAME,\n;; a function DEFDNAME*, MAKE-DNAME, and a setter and getter for each arg.\n(eval-and-compile\n(defmacro attr-index (attr)\n `(- (length *definition-attrs*) (length (memq ,attr *definition-attrs*))))\n\n(defmacro defastmacro(dtype args attrs)\n \"Defines a macro named DEFDTYPE for defining various AST properties.\"\n (let ((def-macr (intern (format \"def%s\" dtype)))\n\t(def-func (intern (format \"def%s*\" dtype)))\n\t(make-func (intern (format \"make-%s\" dtype)))\n\t(state (intern (format \"*%s-defs*\" dtype)))\n\t(exprs nil))\n (if (not *definition-attrs*)\n\t(setq *definition-attrs* '(menunode menuline)))\n (let ((fields (append args attrs)))\n (while fields\n\t(if (not (memq (car fields) *definition-attrs*))\n\t (setq *definition-attrs* (append *definition-attrs* (list (car fields)))))\n\t(setq fields (cdr fields))\n\t)\n )\n ;; Add it to *definition-state*\n (setq *definition-state* (cons state *definition-state*))\n ;; DEFCONST it\n (setq exprs (cons (list 'defconst state (quote nil)) exprs))\n ;; DEFMACRO DEFDTYPE\n (setq exprs (cons (list 'defmacro\n\t\t\t def-macr\n\t\t\t args\n\t\t\t (append (list 'list (list 'quote def-func))\n\t\t\t\t (mapcar (function (lambda (x)\n\t\t\t\t\t\t\t(list 'list (list 'quote 'quote) x)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t )\n\t\t\t\t\t args)\n\t\t\t\t )\n\t\t\t )\n\t\t exprs\n\t\t )\n\t )\n ;; DEFUN DEFDTYPE*\n (setq exprs (cons (list 'defun\n\t\t\t def-func\n\t\t\t args\n\t\t\t (list 'setq\n\t\t\t\t state\n\t\t\t\t (list 'cons\n\t\t\t\t\t(cons make-func args)\n\t\t\t\t\tstate\n\t\t\t\t\t)\n\t\t\t\t )\n\t\t\t )\n\t\t exprs\n\t\t )\n\t )\n ;; MAKE-DTYPE\n (setq exprs (cons (list 'defun\n\t\t\t make-func\n\t\t\t args\n\t\t\t (list 'let (list (list 'it (list 'make-vector (length *definition-attrs*) nil)))\n\t\t\t\t (if args\n\t\t\t\t (cons 'progn (mapcar\n\t\t\t\t\t\t (function\n\t\t\t\t\t\t (lambda (x)\n\t\t\t\t\t\t (list 'aset 'it (attr-index x) x)\n\t\t\t\t\t\t )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t args\n\t\t\t\t\t\t )\n\t\t\t\t\t )\n\t\t\t\t )\n\t\t\t\t (if attrs\n\t\t\t\t (cons 'progn (mapcar\n\t\t\t\t\t\t (function\n\t\t\t\t\t\t (lambda (x)\n\t\t\t\t\t\t (list 'aset 'it (attr-index x) nil)\n\t\t\t\t\t\t )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t attrs\n\t\t\t\t\t\t )\n\t\t\t\t\t )\n\t\t\t\t )\n\t\t\t\t (if (memq 'menu args)\n\t\t\t\t (list 'progn\n\t\t\t\t\t (list 'aset 'it (attr-index 'menunode) (list 'function (intern (format \"%s-menunode\" dtype))))\n\t\t\t\t\t (list 'aset 'it (attr-index 'menuline) (list 'function (intern (format \"%s-menuline\" dtype))))\n\t\t\t\t\t )\n\t\t\t\t )\n\t\t\t\t (list 'cons (list 'quote dtype) 'it)\n\t\t\t\t )\n\t\t\t )\n\t\t exprs\n\t\t )\n\t )\n ;; Add the fake arguments:\n (if (memq 'menu args)\n\t(setq attrs (append (list 'menunode 'menuline) attrs)))\n (setq args (append args attrs))\n (while args\n (let* ((thearg (car args))\n\t (arg-set (intern (format \"%s-%s-set\" dtype thearg)))\n\t (arg-get (intern (format \"%s-%s-get\" dtype thearg))))\n\t;; DTYPE-ARG-GET\n\t(setq exprs (cons (list 'defmacro\n\t\t\t\t(intern (format \"%s-%s-get\" dtype thearg))\n\t\t\t\t'(obj)\n\t\t\t\t(list 'list\n\t\t\t\t (list 'quote 'aref)\n\t\t\t\t (list 'list (list 'quote 'cdr) 'obj)\n\t\t\t\t (attr-index thearg))\n\t\t\t\t)\n\t\t\t exprs\n\t\t\t )\n\t )\n\t;; DTYPE-ARG-SET\n\t(setq exprs (cons (list 'defmacro\n\t\t\t\t(intern (format \"%s-%s-set\" dtype thearg))\n\t\t\t\t'(obj val)\n\t\t\t\t(list 'list\n\t\t\t\t (list 'quote 'aset)\n\t\t\t\t (list 'list (list 'quote 'cdr) 'obj)\n\t\t\t\t (attr-index thearg)\n\t\t\t\t 'val)\n\t\t\t\t)\n\t\t\t exprs\n\t\t\t )\n\t )\n\t)\n (setq args (cdr args))\n )\n ;; To see what it's generating uncomment the next 2 lines.\n ;;(setq message-log-max t)\n ;;(mapcar (function pp) exprs)\n (cons 'progn exprs)\n )\n )\n\n\n;; This is, as the name suggests, really bogus. Basically, each DEFASTMACRO\n;; call adds to the list *definition-state*. To compile it, however, it has\n;; to be done at compile time, so this macro gets evaluated when being compiled\n;; and clears the list. Then the DEFASTMACRO calls are made, and then DEFCDS\n;; is called to define CLEAR-DEFINITION-STATE which resets the list to the\n;; compile-time computed value of *definition-state*, it would otherwise be\n;; empty when running compiled code.\n(defmacro bogus ()\n (setq *definition-state* nil)\n (setq *definition-attrs* nil)\n )\n\n (bogus)\n\n;; Each DEFASTMACRO statement defines a directive for the definition\n;; file along with it's argument names.\n(defastmacro sertype (name number fields transients) ())\n(defastmacro module (name id header pheader) ())\n(defastmacro import (name) (prefix))\n\n(defastmacro event (name level uargs sargs desc) ())\n(defastmacro etype (name ctype) ())\n\n(defastmacro prophost (name letter ctype persist) (proptypes))\n(defastmacro prophosttype (host type) ())\n\n(defmacro defcds ()\n (let ((exprs nil))\n (setq exprs (list (list 'defun 'clear-definition-state nil\n\t\t\t '(setq *all-objects* nil)\n\t\t\t (list 'setq '*definition-state* (list 'quote *definition-state*))\n\t\t\t (list 'setq '*definition-attrs* (list 'quote *definition-attrs*))\n\t\t\t '(mapcar (function (lambda (x) (set x nil))) *definition-state*)\n\t\t\t )\n\n\t\t )\n\t )\n (mapcar\n (function\n (lambda (x)\n\t(setq exprs (cons (list 'defmacro\n\t\t\t\t(intern (format \"obj-%s-get\" x))\n\t\t\t\t'(obj)\n\t\t\t\t(list 'list\n\t\t\t\t (list 'quote 'aref)\n\t\t\t\t (list 'list (list 'quote 'cdr) 'obj)\n\t\t\t\t (attr-index x))\n\t\t\t\t)\n\t\t\t exprs\n\t\t\t )\n\t )\n\t(setq exprs (cons (list 'defmacro\n\t\t\t\t(intern (format \"obj-%s-set\" x))\n\t\t\t\t'(obj val)\n\t\t\t\t(list 'list\n\t\t\t\t (list 'quote 'aset)\n\t\t\t\t (list 'list (list 'quote 'cdr) 'obj)\n\t\t\t\t (attr-index x)\n\t\t\t\t 'val)\n\t\t\t\t)\n\t\t\t exprs\n\t\t\t )\n\t )\n\t(let ((get (intern (format \"obj-%s-get\" x))))\n\t (setq exprs (cons (list 'defun\n\t\t\t\t (intern (format \"obj-%s-eq\" x))\n\t\t\t\t '(val olist)\n\t\t\t\t `(let ((ret nil))\n\t\t\t\t (while (and (not ret) olist)\n\t\t\t\t (if (eq val (,get (car olist)))\n\t\t\t\t\t (setq ret (car olist))\n\t\t\t\t\t )\n\t\t\t\t (setq olist (cdr olist))\n\t\t\t\t )\n\t\t\t\t ret\n\t\t\t\t )\n\t\t\t\t )\n\t\t\t exprs\n\t\t\t )\n\t\t)\n\t )\n\t)\n )\n *definition-attrs*\n )\n ;;(setq message-log-max t)\n ;;(mapcar (function pp) exprs)\n (cons 'progn exprs)\n )\n )\n\n(defcds)\n)\n;; Entry Points\n\n(defun generate-ser-noargs ()\n (interactive)\n (generate-ser \"edsio.ser\" \"edsio\")\n )\n\n(defun generate-ser (input-file output-prefix)\n ;(interactive \"finput: \\nsoutput: \\nsid: \")\n (let ((make-backup-files nil)\n\t(executing-kbd-macro t))\n (clear-definition-state)\n\n (do-it input-file output-prefix)\n )\n )\n\n(defconst *library-id* nil\n \"Identifier of this library.\")\n\n(defconst *library-header* nil\n \"Header of this library.\")\n(defconst *library-pheader* nil\n \"Header of this library.\")\n\n(defconst *prefix-with-library-header* t)\n\n(defun load-defs(file)\n (load-file file)\n (setq *import-defs* (reverse *import-defs*))\n (setq *module-defs* (reverse *module-defs*))\n (setq *sertype-defs* (reverse *sertype-defs*))\n\n (setq *event-defs* (reverse *event-defs*))\n (setq *etype-defs* (reverse *etype-defs*))\n\n (setq *prophost-defs* (reverse *prophost-defs*))\n (setq *prophosttype-defs* (reverse *prophosttype-defs*))\n )\n\n(defconst *header-typedef-marker* nil)\n(defconst *source-init-marker* nil)\n(defconst *source-top-marker* nil)\n\n(defun do-it (input-file output-prefix)\n (setq *output-files* nil)\n (setq *output-prefix* output-prefix)\n\n (load-defs input-file)\n\n (if (not *module-defs*)\n (error \"no defmodule in %s\" input-file))\n\n (if (> (length *module-defs*) 1)\n (error \"too many defmodules in %s\" input-file))\n\n (setq *library-id* (module-id-get (car *module-defs*)))\n (setq *library-header* (module-header-get (car *module-defs*)))\n (setq *library-pheader* (module-pheader-get (car *module-defs*)))\n\n (when (not *library-header*)\n (setq *prefix-with-library-header* nil)\n (setq *library-header* (format \"%s_edsio.h\" *output-prefix*))\n )\n\n (if (or (<= *library-id* 0)\n\t (>= *library-id* 256))\n (error \"Library-id is out of range\"))\n\n (if (> (length *sertype-defs*) 24)\n (error \"no more than 24 types\"))\n\n (unwind-protect\n (progn\n\n\t(output-header-file \"_edsio\")\n\n\t(read-imports)\n\n\t(insert \"\/* Initialize this library. *\/\\n\\n\")\n\t(insert \"gboolean \" *output-prefix* \"_edsio_init (void);\\n\\n\")\n\n\t(insert \"\/* Types defined here. *\/\\n\\n\")\n\t(setq *header-typedef-marker* (point-marker))\n\n\t(insert \"\/* Functions declared here. *\/\\n\\n\")\n\n\t(output-source-file \"_edsio\")\n\n\t(insert \"#include \\\"\" *library-header* \"\\\"\\n\\n\")\n\t(insert \"#include \\n\\n\")\n\n\t(if *library-pheader*\n\t (insert \"#include \\\"\" *library-pheader* \"\\\"\\n\\n\"))\n\n\t(insert \"\/* Declarations. *\/\\n\\n\")\n\t(setq *source-top-marker* (point-marker))\n\n\t(insert \"\\n\")\n\n\t(insert \"\/* initialize this library. *\/\\n\\n\")\n\t(insert \"gboolean\\n\" *output-prefix* \"_edsio_init (void)\\n{\\n\")\n\t(insert \" static gboolean once = FALSE;\\n\")\n\t(insert \" static gboolean result = FALSE;\\n\")\n\t(insert \" if (once) return result;\\n\")\n\t(insert \" once = TRUE;\\n\")\n\n\t(setq *source-init-marker* (point-marker))\n\n\t(insert (format \" edsio_library_register (%d, \\\"%s\\\");\\n\" *library-id* *output-prefix*))\n\t(insert \" result = TRUE;\\n\")\n\t(insert \" return TRUE;\\n\")\n\t(insert \"};\\n\\n\")\n\n \t(if *prophosttype-defs*\n \t (generate-properties))\n\n \t(if *sertype-defs*\n \t (generate-code))\n\n \t(if *event-defs*\n \t (generate-events))\n\n;\t(message \"source file:\\n%s\" (buffer-string))\n\n\t(mapcar (function (lambda (x) (output-finish-file x))) *output-files*)\n\t)\n (mapcar (function (lambda (x) (kill-buffer (cadr x)))) *output-files*)\n )\n )\n\n(defvar *all-sertype-defs* nil)\n(defvar *all-prophost-defs* nil)\n(defvar *all-etype-defs* nil)\n\n(defun read-imports ()\n\n (setq *all-sertype-defs* *sertype-defs*)\n (setq *all-etype-defs* *etype-defs*)\n (setq *all-prophost-defs* *prophost-defs*)\n\n (let ((mods *module-defs*)\n\t(imps0 *import-defs*)\n\t(imps *import-defs*)\n\t(types *sertype-defs*)\n\t(events *event-defs*)\n\t(etypes *etype-defs*)\n\t(phosts *prophost-defs*)\n\t(phts *prophosttype-defs*)\n\t)\n\n (while imps\n (clear-definition-state)\n\n (load-defs (import-name-get (car imps)))\n\n (setq *all-sertype-defs* (append *all-sertype-defs* *sertype-defs*))\n (setq *all-etype-defs* (append *all-etype-defs* *etype-defs*))\n (setq *all-prophost-defs* (append *all-prophost-defs* *prophost-defs*))\n\n (import-prefix-set (car imps) (module-name-get (car *module-defs*)))\n\n (when (or *sertype-defs* *event-defs*)\n\t(output-header-file \"_edsio\")\n\t(insert (format \"#include \\\"%s_edsio.h\\\"\\n\\n\" (import-prefix-get (car imps))))\n\t)\n\n (setq imps (cdr imps))\n )\n\n (setq *module-defs* mods)\n (setq *import-defs* imps0)\n (setq *sertype-defs* types)\n (setq *event-defs* events)\n (setq *etype-defs* etypes)\n (setq *prophost-defs* phosts)\n (setq *prophosttype-defs* phts)\n )\n )\n\n\n(defun output-header-file (name)\n (output-file (format \"%s.h\" name) 'c-header *output-prefix*))\n\n(defun output-source-file (name)\n (output-file (format \"%s.%s\" name *cpp-extension*) 'c *output-prefix*))\n\n(defun output-source-include-file (name)\n (output-file (format \"%s.%si\" name *cpp-extension*) 'c *output-prefix*))\n\n(defun output-plain-file (name)\n (output-file (format \"%s\" name) 'plain \"\"))\n\n(defun output-file (name type prefix)\n (let* ((name (format \"%s%s\" prefix name))\n\t (it (assoc name *output-files*)))\n (if it\n\t(set-buffer (cadr it))\n (let ((nbuf (get-buffer-create (generate-new-buffer-name name))))\n\t(setq *output-files* (cons (list name nbuf type) *output-files*))\n\t(set-buffer nbuf)\n\t)\n )\n )\n )\n\n(defun output-finish-file (file)\n (let ((name (car file))\n\t(buf (cadr file))\n\t(type (caddr file)))\n (set-buffer buf)\n ;(message \"printing %s: %s\" file (buffer-string))\n (cond ((eq type 'c)\n\t (output-to-c name nil))\n\t ((eq type 'c-header)\n\t (output-to-c name t))\n\t )\n (write-file-if-different buf name)\n )\n )\n\n(defun output-to-c (name is-header)\n (goto-char (point-min))\n (insert \"\/* -*-Mode: C;-*-\n * Copyright (C) 1997, 1998, 1999 Josh MacDonald\n *\n * This program is free software; you can redistribute it and\/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n *\n * Author: Josh MacDonald \n *\n * This file was AUTOMATICALLY GENERATED using:\n *\n * $Id: edsio.el,v 1.1 2004\/01\/05 18:54:23 icculus Exp $\n *\/\n\n\")\n\n (if is-header\n (let ((cppname (string-replace-regexp (upcase name) \"[-.\/]\" \"_\")))\n\t(insert \"#include \\\"edsio.h\\\"\\n\\n\")\n\n\t(if *prefix-with-library-header*\n\t (insert \"#include \\\"\" *library-header* \"\\\"\\n\\n\"))\n\n\t(insert \"#ifndef _\" cppname \"_\\n\")\n\t(insert \"#define _\" cppname \"_\\n\\n\")\n\t(insert \"#ifdef __cplusplus\\n\")\n\t(insert \"extern \\\"C\\\" {\\n\")\n\t(insert \"#endif\\n\\n\")\n\t(goto-char (point-max))\n\t(insert \"#ifdef __cplusplus\\n\")\n\t(insert \"}\\n\")\n\t(insert \"#endif\\n\")\n\t(insert \"\\n#endif \/* _\" cppname \"_ *\/\\n\\n\")\n\t)\n )\n )\n\n(defun string-replace-regexp (str regexp to-string)\n \"Result of replacing all occurrences in STR of REGEXP by TO-STRING. The\nreplacement is as for replace-regexp.\"\n (let ((work (get-buffer-create \"*string-tmp*\")))\n (save-excursion\n (set-buffer work)\n (erase-buffer)\n (insert str)\n (beginning-of-buffer)\n (while (re-search-forward regexp nil t)\n\t(replace-match to-string nil nil))\n (buffer-string))))\n\n(defun write-file-if-different (buf filename)\n (save-excursion\n (if (not (file-exists-p filename))\n\t(write-file filename)\n (set-buffer buf)\n (let ((old (get-buffer-create (generate-new-buffer-name filename)))\n\t (bmin (point-min))\n\t (bmax (point-max)))\n\t(unwind-protect\n\t (progn\n\t (set-buffer old)\n\t (insert-file filename)\n\t (let ((omin (point-min))\n\t\t (omax (point-max))\n\t\t (case-fold-search nil))\n\t\t(if (= 0 (compare-buffer-substrings old omin omax buf bmin bmax))\n\t\t (message \"Output file %s is unchanged.\" filename)\n\t\t (set-buffer buf)\n\t\t (write-file filename)\n\t\t )\n\t\t)\n\t )\n\t (kill-buffer old)\n\t )\n\t)\n )\n )\n )\n\n\n(defun format-comlist (func l)\n (let ((x \"\"))\n (while l\n (setq x (concat x (funcall func (car l))))\n (if (cdr l)\n\t (setq x (concat x \", \")))\n (setq l (cdr l))\n )\n x\n )\n )\n\n(defun format-semilist (func l)\n (let ((x \"\"))\n (while l\n (setq x (concat x (funcall func (car l))))\n (if (cdr l)\n\t (setq x (concat x \"; \")))\n (setq l (cdr l))\n )\n x\n )\n )\n\n(defun format-numbered-comlist (func l)\n (let ((x \"\")\n\t(n 0))\n (while l\n (setq x (concat x (funcall func (car l) n)))\n (setq n (+ n 1))\n (if (cdr l)\n\t (setq x (concat x \", \")))\n (setq l (cdr l))\n )\n x\n )\n )\n\n(defun capitalize1(s)\n (let ((work (get-buffer-create \"*string-tmp*\")))\n (save-excursion\n (set-buffer work)\n (erase-buffer)\n (insert (format \"%s\" s))\n (upcase-region (point-min) (+ (point-min) 1))\n (buffer-substring-no-properties (point-min) (point-max))\n )\n )\n )\n\n(defun upcase-string (s)\n (let ((work (get-buffer-create \"*string-tmp*\")))\n (save-excursion\n (set-buffer work)\n (erase-buffer)\n (insert (format \"%s\" s))\n (upcase-region (point-min) (point-max))\n (buffer-substring-no-properties (point-min) (point-max))\n )\n )\n )\n\n(defun downcase-string (s)\n (let ((work (get-buffer-create \"*string-tmp*\")))\n (save-excursion\n (set-buffer work)\n (erase-buffer)\n (insert (format \"%s\" s))\n (downcase-region (point-min) (point-max))\n (buffer-substring-no-properties (point-min) (point-max))\n )\n )\n )\n\n;; HERE IT IS\n\n(defun generate-code ()\n\n (let ((all-codes nil))\n (mapcar\n (function\n (lambda (st)\n\t(let ((x (sertype-number-get st)))\n\t (cond ((member x all-codes)\n\t\t (error \"serial type number %d defined twice\" x))\n\t\t((> x 24)\n\t\t (error \"serial type value %d too high\" x))\n\t\t((< x 0)\n\t\t (error \"serial type value %d too low\" x))\n\t\t(t (setq all-codes (cons x all-codes))))))\n )\n *sertype-defs*)\n )\n\n (output-header-file \"_edsio\")\n\n (insert \"\/* Serial Types *\/\\n\\n\")\n (insert (format \"enum _Serial%sType {\\n\" (capitalize1 *output-prefix*)))\n (insert (format-comlist\n\t (function\n\t (lambda (x)\n\t (format \"\\n ST_%s = (1<<(%d+EDSIO_LIBRARY_OFFSET_BITS))+%d\" (sertype-name-get x) (sertype-number-get x) *library-id*))) *sertype-defs*))\n (insert \"\\n};\\n\\n\")\n\n (insert \"\\n\\n\")\n\n (output-source-file \"_edsio\")\n\n (save-excursion\n (goto-char *source-top-marker*)\n\n (insert \"static void print_spaces (guint n) { int i; for (i = 0; i < n; i += 1) g_print (\\\" \\\"); }\\n\\n\")\n )\n\n (mapcar (function generate-code-entry) *sertype-defs*)\n\n )\n\n(defun generate-code-entry (entry)\n (let ((ent-upcase (sertype-name-get entry))\n\t(ent-downcase (downcase-string (sertype-name-get entry))))\n\n (output-header-file \"_edsio\")\n\n ;; The typedef, structure, and declarations.\n\n (save-excursion\n (goto-char *header-typedef-marker*)\n (insert (format \"typedef struct _Serial%s Serial%s;\\n\" ent-upcase ent-upcase))\n )\n\n (insert (format \"\/* %s Structure\\n *\/\\n\\n\" ent-upcase))\n\n (insert (format \"struct _Serial%s {\\n\" ent-upcase))\n\n (apply (function insert)\n\t (mapcar (function\n\t\t (lambda (x)\n\t\t (format \" %s;\\n\" x)))\n\t\t (entry-typename-pairs entry nil)))\n\n (apply (function insert)\n\t (mapcar (function\n\t\t (lambda (x)\n\t\t (format \" %s;\\n\" x)))\n\t\t (sertype-transients-get entry)))\n\n (insert \"};\\n\\n\")\n\n (insert (format \"void serializeio_print_%s_obj (Serial%s* obj, guint indent_spaces);\\n\\n\" ent-downcase ent-upcase))\n\n (insert (format \"gboolean unserialize_%s (SerialSource *source, Serial%s**);\\n\" ent-downcase ent-upcase))\n (insert (format \"gboolean unserialize_%s_internal (SerialSource *source, Serial%s** );\\n\" ent-downcase ent-upcase))\n (insert (format \"gboolean unserialize_%s_internal_noalloc (SerialSource *source, Serial%s* );\\n\" ent-downcase ent-upcase))\n (insert (format \"gboolean serialize_%s (SerialSink *sink%s);\\n\" ent-downcase (entry-arglist t entry)))\n (insert (format \"gboolean serialize_%s_obj (SerialSink *sink, const Serial%s* obj);\\n\" ent-downcase ent-upcase))\n (insert (format \"gboolean serialize_%s_internal (SerialSink *sink%s);\\n\" ent-downcase (entry-arglist t entry)))\n (insert (format \"gboolean serialize_%s_obj_internal (SerialSink *sink, Serial%s* obj);\\n\" ent-downcase ent-upcase))\n (insert (format \"guint serializeio_count_%s (%s);\\n\" ent-downcase (entry-arglist nil entry)))\n (insert (format \"guint serializeio_count_%s_obj (Serial%s const* obj);\\n\" ent-downcase ent-upcase))\n (insert (format \"\\n\"))\n\n (output-source-file \"_edsio\")\n\n ;; The init entry\n\n (save-excursion\n (goto-char *source-init-marker*)\n (insert (format \" serializeio_initialize_type (\\\"ST_%s\\\", ST_%s, &unserialize_%s_internal, &serialize_%s_obj_internal, &serializeio_count_%s_obj, &serializeio_print_%s_obj);\\n\" ent-upcase ent-upcase ent-downcase ent-downcase ent-downcase ent-downcase))\n )\n\n ;; Count code\n\n (insert (format \"\/* %s Count\\n *\/\\n\\n\" ent-upcase))\n\n (insert (format \"guint\\nserializeio_count_%s (%s) {\\n\" ent-downcase (entry-arglist nil entry)))\n (insert (format \" guint size = sizeof (Serial%s);\\n\" ent-upcase))\n (apply (function insert)\n\t (mapcar (function (lambda (x) (concat\n\t\t\t\t\t (format \" ALIGN_8 (size);\\n\")\n\t\t\t\t\t (entry-count-field entry x (format \"%s\" (car x)) \" \" t))))\n\t\t (sertype-fields-get entry)))\n (insert (format \" ALIGN_8 (size);\\n\"))\n (insert (format \" return size;\\n\"))\n (insert (format \"}\\n\\n\"))\n\n ;; Count Object code\n\n (insert (format \"guint\\nserializeio_count_%s_obj (Serial%s const* obj) {\\n\" ent-downcase ent-upcase))\n (insert (format \" return serializeio_count_%s (%s);\\n\" ent-downcase (entry-plist t nil \"obj->\" entry)))\n (insert (format \"}\\n\\n\"))\n\n ;; Print object code\n\n (insert (format \"\/* %s Print\\n *\/\\n\\n\" ent-upcase))\n\n (insert (format \"void\\nserializeio_print_%s_obj (Serial%s* obj, guint indent_spaces) {\\n\" ent-downcase ent-upcase))\n (insert (format \" print_spaces (indent_spaces);\\n\"))\n\n (insert (format \" g_print (\\\"[ST_%s]\\\\n\\\");\\n\" ent-upcase))\n\n (apply (function insert)\n\t (mapcar (function (lambda (x) (entry-print-field entry x (format \"obj->%s\" (car x)) \" \" t)))\n\t\t (sertype-fields-get entry)))\n\n (insert (format \"}\\n\\n\"))\n\n ;; Print internal code\n\n ;; Serialize code\n\n (insert (format \"\/* %s Serialize\\n *\/\\n\\n\" ent-upcase))\n\n (insert (format \"gboolean\\nserialize_%s_internal (SerialSink *sink%s)\\n\" ent-downcase (entry-arglist t entry)))\n (insert (format \"{\\n\"))\n\n (apply (function insert)\n\t (mapcar (function (lambda (x) (entry-serialize-field entry x (format \"%s\" (car x)) \" \" t)))\n\t\t (sertype-fields-get entry)))\n\n (insert (format \" return TRUE;\\n\"))\n (if (sertype-fields-get entry)\n\t(insert (format \"bail:\\n return FALSE;\\n\")))\n (insert (format \"}\\n\\n\"))\n\n ;; Internal Serialize Object code\n\n (insert (format \"gboolean\\nserialize_%s_obj_internal (SerialSink *sink, Serial%s* obj)\\n\" ent-downcase ent-upcase))\n (insert (format \"{\\n\"))\n (insert (format \" return serialize_%s_internal (sink%s);\\n\" ent-downcase (entry-plist t t \"obj->\" entry)))\n (insert (format \"}\\n\\n\"))\n\n ;; External Serialize code\n\n (insert (format \"gboolean\\nserialize_%s (SerialSink *sink%s)\\n\" ent-downcase (entry-arglist t entry)))\n (insert (format \"{\\n\"))\n\n (insert (format \" if (! (* sink->sink_type) (sink, ST_%s, serializeio_count_%s (%s), TRUE)) goto bail;\\n\" ent-upcase ent-downcase (entry-plist nil nil \"\" entry)))\n\n (insert (format \" if (! serialize_%s_internal (sink%s)) goto bail;\\n\" ent-downcase (entry-plist nil t \"\" entry)))\n (insert (format \" if (sink->sink_quantum && ! sink->sink_quantum (sink)) goto bail;\\n\"))\n\n (insert (format \" return TRUE;\\n\"))\n (insert (format \"bail:\\n\"))\n (insert (format \" return FALSE;\\n\"))\n (insert (format \"}\\n\\n\"))\n\n ;; External serialize_obj\n\n (insert (format \"gboolean\\nserialize_%s_obj (SerialSink *sink, const Serial%s* obj) {\\n\\n\" ent-downcase ent-upcase))\n (insert (format \" return serialize_%s (sink%s);\\n\" ent-downcase (entry-plist t t \"obj->\" entry)))\n (insert (format \"}\\n\\n\"))\n\n ;; Unserialize code\n\n (insert (format \"\/* %s Unserialize\\n *\/\\n\\n\" ent-upcase))\n\n (insert (format \"gboolean\\nunserialize_%s_internal_noalloc (SerialSource *source, Serial%s* result)\\n\" ent-downcase ent-upcase))\n (insert (format \"{\\n\"))\n\n (apply (function insert)\n\t (mapcar (function (lambda (x) (entry-unserialize-field entry x (format \"result->%s\" (car x)) \" \")))\n\t\t (sertype-fields-get entry)))\n\n (insert (format \" return TRUE;\\n\"))\n (if (sertype-fields-get entry)\n\t(insert (format \"bail:\\n return FALSE;\\n\")))\n (insert (format \"}\\n\\n\"))\n\n\n (insert (format \"gboolean\\nunserialize_%s_internal (SerialSource *source, Serial%s** result)\\n\" ent-downcase ent-upcase))\n (insert (format \"{\\n\"))\n\n (insert (format \" Serial%s* unser;\\n\" ent-upcase))\n (insert (format \" (*result) = NULL;\\n\"))\n (insert (format \" unser = serializeio_source_alloc (source, sizeof (Serial%s));\\n\" ent-upcase))\n (insert (format \" if (! unser) goto bail;\\n\"))\n\n (insert (format \" if (! unserialize_%s_internal_noalloc (source, unser)) goto bail;\\n\" ent-downcase))\n\n (insert (format \" (*result) = unser;\\n\"))\n (insert (format \" return TRUE;\\n\"))\n (insert (format \"bail:\\n\"))\n (insert (format \" return FALSE;\\n\"))\n (insert (format \"}\\n\\n\"))\n\n ;; External unserialize\n\n (insert (format \"gboolean\\nunserialize_%s (SerialSource *source, Serial%s** result)\\n\" ent-downcase ent-upcase))\n (insert (format \"{\\n\"))\n\n (insert (format \" if ( (* source->source_type) (source, TRUE) != ST_%s) goto bail;\\n\" ent-upcase))\n\n (insert (format \" if (! unserialize_%s_internal (source, result)) goto bail;\\n\" ent-downcase))\n\n (insert (format \" if (! serializeio_source_object_received (source)) goto bail;\\n\"))\n\n (insert (format \" return TRUE;\\n\"))\n (insert (format \"bail:\\n\"))\n (insert (format \" return FALSE;\\n\"))\n\n (insert (format \"}\\n\\n\"))\n\n )\n )\n\n(defun entry-typename-pairs (entry is-param)\n (let ((pairs nil)\n\t(fields (sertype-fields-get entry)))\n (while fields\n (let ((field (car fields)))\n\t(when (or (equal (cadr field) 'bytes)\n\t\t (and (consp (cadr field)) (equal (caadr field) 'array)))\n\t (setq pairs (cons (format \"guint32 %s_len\" (car field)) pairs))\n\t )\n\t(when (equal (cadr field) 'object)\n\t (setq pairs (cons (format \"guint32 %s_type\" (car field)) pairs))\n\t )\n\t(setq pairs (cons (field-decl field is-param) pairs))\n\t)\n (setq fields (cdr fields))\n )\n (nreverse pairs)\n )\n )\n\n(defun entry-param-names (prefix entry need_pbr)\n (let ((pairs nil)\n\t(fields (sertype-fields-get entry)))\n (while fields\n (let ((field (car fields)))\n\t(when (or (equal (cadr field) 'bytes)\n\t\t (and (consp (cadr field)) (equal (caadr field) 'array)))\n\t (setq pairs (cons (format \"%s%s_len\" prefix (car field)) pairs))\n\t )\n\t(when (equal (cadr field) 'object)\n\t (setq pairs (cons (format \"%s%s_type\" prefix (car field)) pairs))\n\t )\n\t(setq pairs (cons (format \"%s%s%s\" (if (and need_pbr (needs-ref field)) \"&\" \"\") prefix (car field)) pairs))\n\t)\n (setq fields (cdr fields))\n )\n (nreverse pairs)\n )\n )\n\n(defun field-ctype (field)\n (cond ((equal (cadr field) 'string)\n\t \"const gchar*\")\n\t((equal (cadr field) 'uint)\n\t \"guint32\")\n\t((equal (cadr field) 'uint32)\n\t \"guint32\")\n\t((equal (cadr field) 'uint16)\n\t \"guint16\")\n\t((equal (cadr field) 'uint8)\n\t \"guint8\")\n\t((equal (cadr field) 'boolean)\n\t \"gboolean\")\n\t((equal (cadr field) 'bytes)\n\t \"const guint8*\")\n\t((equal (cadr field) 'object)\n\t \"void*\")\n\t((member (cadr field) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n\t (format \"Serial%s\" (cadr field)))\n\t((equal (car (cadr field)) 'bytes)\n\t \"const guint8*\")\n\t((member (car (cadr field)) '(array ptr))\n\t (concat (field-ctype (cadr field)) \"*\"))\n\t(t (error \"unrecognized field type: %s\" (cadr field))))\n )\n\n(defun field-decl (field is-param)\n (if (and (consp (cadr field))\n\t (equal (car (cadr field)) 'bytes))\n (format \"%sguint8 %s[%d]\" (if is-param \"const \" \"\") (car field) (cadr (cadr field)))\n ;(message \"foo %s %s\" field (member (cadr field) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*)))\n (format \"%s %s\"\n\t (cond ((member (cadr field) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n\t\t (format \"Serial%s%s\" (cadr field) (if is-param \" const*\" \"\")))\n\t\t ((equal (cadr field) 'string)\n\t\t \"const gchar*\")\n\t\t ((equal (cadr field) 'uint)\n\t\t \"guint32\")\n\t\t ((equal (cadr field) 'uint32)\n\t\t \"guint32\")\n\t\t ((equal (cadr field) 'uint16)\n\t\t \"guint16\")\n\t\t ((equal (cadr field) 'uint8)\n\t\t \"guint8\")\n\t\t ((equal (cadr field) 'boolean)\n\t\t \"gboolean\")\n\t\t ((equal (cadr field) 'bytes)\n\t\t \"const guint8*\")\n\t\t ((equal (cadr field) 'object)\n\t\t \"void*\")\n\t\t ((member (car (cadr field)) '(array ptr))\n\t\t (concat (field-ctype (cadr field)) (if is-param \" const*\" \"*\")))\n\t\t (t (error \"unrecognized field type: %s\" (cadr field))))\n\t (car field)))\n )\n\n(defun entry-arglist (need_first entry)\n (concat\n (if (and need_first (sertype-fields-get entry)) \", \" \"\")\n (format-comlist (function (lambda (x) x)) (entry-typename-pairs entry t))))\n\n(defun needs-ref (field)\n (member (cadr field) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n )\n\n(defun entry-plist (need_pbr need_first prefix entry)\n (concat\n (if (and need_first (sertype-fields-get entry)) \", \" \"\")\n (format-comlist (function (lambda (x) (format \"%s\" x)))\n\t\t (entry-param-names prefix entry need_pbr))))\n\n(defun entry-unserialize-field (entry field name prefix)\n (cond ((equal (cadr field) 'uint)\n\t (format \"%sif (! (* source->next_uint) (source, &%s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'uint32)\n\t (format \"%sif (! (* source->next_uint32) (source, &%s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'uint16)\n\t (format \"%sif (! (* source->next_uint16) (source, &%s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'uint8)\n\t (format \"%sif (! (* source->next_uint8) (source, &%s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'boolean)\n\t (format \"%sif (! (* source->next_bool) (source, &%s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'string)\n\t (format \"%sif (! (* source->next_string) (source, &%s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'bytes)\n\t (format \"%sif (! (* source->next_bytes) (source, &%s, &%s_len)) goto bail;\\n\" prefix name name))\n\t((equal (cadr field) 'object)\n\t (format \"%sif (! serializeio_unserialize_generic_internal (source, &%s_type, &%s, FALSE)) goto bail;\\n\" prefix name name))\n\t((member (cadr field) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n\t (format \"%sif (! unserialize_%s_internal_noalloc (source, &%s)) goto bail;\\n\" prefix (downcase-string (cadr field)) name))\n\t((and (equal (car (cadr field)) 'ptr)\n\t (member (cadr (cadr field)) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*)))\n\t (format \"%sif (! unserialize_%s_internal (source, &%s)) goto bail;\\n\" prefix (downcase-string (cadr (cadr field))) name))\n\t((equal (car (cadr field)) 'bytes)\n\t (format \"%sif (! (* source->next_bytes_known) (source, %s, %d)) goto bail;\\n\" prefix name (cadr (cadr field))))\n\t((equal (car (cadr field)) 'array)\n\t (format \"%s{\n%s gint i;\n%s if (! (* source->next_uint) (source, &%s_len)) goto bail;\n%s if (! (%s = serializeio_source_alloc (source, sizeof (%s) * %s_len))) goto bail;\n%s for (i = 0; i < %s_len; i += 1)\n%s {\n%s%s }\n%s}\n\"\n\t\t prefix\n\t\t prefix prefix\n\t\t name\n\t\t prefix\n\t\t name\n\t\t (field-ctype (cadr field))\n\t\t name\n\t\t prefix\n\t\t name\n\t\t prefix\n\t\t prefix\n\t\t (entry-unserialize-field entry (cadr field) (concat \"(\" name \"[i])\") (concat prefix \" \"))\n\t\t prefix\n\t\t ))\n\t(t (error \"unrecognized field type: %s\" (cadr field)))))\n\n\n(defun entry-serialize-field (entry field name prefix is-param)\n (cond ((equal (cadr field) 'uint)\n\t (format \"%sif (! (* sink->next_uint) (sink, %s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'uint16)\n\t (format \"%sif (! (* sink->next_uint16) (sink, %s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'uint8)\n\t (format \"%sif (! (* sink->next_uint8) (sink, %s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'uint32)\n\t (format \"%sif (! (* sink->next_uint32) (sink, %s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'boolean)\n\t (format \"%sif (! (* sink->next_bool) (sink, %s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'string)\n\t (format \"%sif (! (* sink->next_string) (sink, %s)) goto bail;\\n\" prefix name))\n\t((equal (cadr field) 'bytes)\n\t (format \"%sif (! (* sink->next_bytes) (sink, %s, %s_len)) goto bail;\\n\" prefix name name))\n\t((equal (cadr field) 'object)\n\t (format \"%sif (! serializeio_serialize_generic_internal (sink, %s_type, %s, FALSE)) goto bail;\\n\" prefix name name))\n\t((member (cadr field) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n\t (format \"%sif (! serialize_%s_internal (sink%s)) goto bail;\\n\" prefix (downcase-string (cadr field))\n\t\t (entry-plist t t (concat name (if is-param \"->\" \".\")) (obj-name-eq (cadr field) *all-sertype-defs*))))\n\t((and (equal (car (cadr field)) 'ptr)\n\t (member (cadr (cadr field)) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*)))\n\t (format \"%sif (! serialize_%s_internal (sink%s)) goto bail;\\n\" prefix (downcase-string (cadr (cadr field)))\n\t\t (entry-plist t t (concat name \"->\") (obj-name-eq (cadr (cadr field)) *all-sertype-defs*))))\n\t((equal (car (cadr field)) 'bytes)\n\t (format \"%sif (! (* sink->next_bytes_known) (sink, %s, %d)) goto bail;\\n\" prefix name (cadr (cadr field))))\n\t((equal (car (cadr field)) 'array)\n\t (format \"%s{\n%s gint i;\n%s if (! (* sink->next_uint) (sink, %s_len)) goto bail;\n%s for (i = 0; i < %s_len; i += 1)\n%s {\n%s%s }\n%s}\n\"\n\t\t prefix prefix prefix\n\t\t name\n\t\t prefix\n\t\t name\n\t\t prefix\n\t\t prefix\n\t\t (entry-serialize-field entry (cadr field) (array-index name (cadr field)) (concat prefix \" \") nil)\n\t\t prefix\n\t\t ))\n\t(t (error \"unrecognized field type: %s\" (cadr field)))))\n\n(defun array-index (name field)\n ;(concat \"(\" (if (needs-ref field) \"&\" \"\") name \"[i])\")\n (concat \"(\" name \"[i])\")\n )\n\n(defun entry-count-field (entry field name prefix is-param)\n (cond ((equal (cadr field) 'uint)\n\t ;(format \"%ssize += sizeof (guint32);\\n\" prefix)\n\t \"\"\n\t )\n\t((equal (cadr field) 'uint32)\n\t ;(format \"%ssize += sizeof (guint32);\\n\" prefix)\n\t \"\"\n\t )\n\t((equal (cadr field) 'uint16)\n\t ;(format \"%ssize += sizeof (guint16);\\n\" prefix)\n\t \"\"\n\t )\n\t((equal (cadr field) 'uint8)\n\t ;(format \"%ssize += sizeof (guint8);\\n\" prefix)\n\t \"\"\n\t )\n\t((equal (cadr field) 'boolean)\n\t ;(format \"%ssize += sizeof (gboolean);\\n\" prefix)\n\t \"\"\n\t )\n\t((equal (cadr field) 'string)\n\t (format \"%ssize += strlen (%s) + 1;\\n\" prefix name)\n\t )\n\t((equal (cadr field) 'bytes)\n\t (format \"%ssize += %s_len;\\n\" prefix name)\n\t )\n\t((equal (cadr field) 'object)\n\t (format \"%ssize += serializeio_generic_count (%s_type, %s);\\n\" prefix name name)\n\t )\n\t((member (cadr field) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n \t (format \"%ssize += serializeio_count_%s_obj (%s%s) - sizeof (Serial%s);\\n\"\n\t\t prefix\n\t\t (downcase-string (cadr field))\n\t\t (if is-param \"\" \"& \")\n\t\t name\n\t\t (cadr field)\n \t\t )\n\t )\n\t((and (equal (car (cadr field)) 'ptr)\n\t (member (cadr (cadr field)) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*)))\n \t (format \"%ssize += serializeio_count_%s_obj (%s);\\n\" prefix (downcase-string (cadr (cadr field))) name)\n\t )\n\t((equal (car (cadr field)) 'bytes)\n\t ;(format \"%ssize += 0;\\n\" prefix (cadr (cadr field)))\n\t \"\"\n\t )\n\t((equal (car (cadr field)) 'array)\n\t (format \"%s{\n%s gint i;\n%s for (i = 0; i < %s_len; i += 1)\n%s {\n%s%s }\n%s}\n\"\n\t\t prefix prefix prefix\n\t\t name\n\t\t prefix\n\t\t prefix\n\t\t (entry-count-array-field entry (cadr field) (array-index name (cadr field)) (concat prefix \" \") nil)\n\t\t prefix\n\t\t ))\n\t(t (error \"unrecognized field type: %s\" (cadr field)))))\n\n(defun entry-count-array-field (entry field name prefix is-param)\n (cond ((equal (cadr field) 'uint)\n\t (format \"%ssize += sizeof (guint32);\\n\" prefix)\n\t )\n\t((equal (cadr field) 'uint32)\n\t (format \"%ssize += sizeof (guint32);\\n\" prefix)\n\t )\n\t((equal (cadr field) 'uint16)\n\t (format \"%ssize += sizeof (guint16);\\n\" prefix)\n\t )\n\t((equal (cadr field) 'uint8)\n\t (format \"%ssize += sizeof (guint8);\\n\" prefix)\n\t )\n\t((equal (cadr field) 'boolean)\n\t (format \"%ssize += sizeof (gboolean);\\n\" prefix)\n\t )\n\t((equal (cadr field) 'string)\n\t (format \"%ssize += strlen (%s) + 1 + sizeof (void*);\\n\" prefix name)\n\t )\n\t((equal (cadr field) 'bytes)\n\t (error \"can't do that: bytes1\")\n\t )\n\t((equal (cadr field) 'object)\n\t (error \"can't do that: object\")\n\t )\n\t((member (cadr field) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n \t (format \"%ssize += serializeio_count_%s_obj (%s%s);\\n\"\n\t\t prefix\n\t\t (downcase-string (cadr field))\n\t\t (if is-param \"\" \"& \")\n\t\t name\n\t\t (cadr field)\n \t\t )\n\t )\n\t((and (equal (car (cadr field)) 'ptr)\n\t (member (cadr (cadr field)) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*)))\n \t (format \"%ssize += serializeio_count_%s_obj (%s) + sizeof (void*);\\n\" prefix (downcase-string (cadr (cadr field))) name)\n\t )\n\t((equal (car (cadr field)) 'bytes)\n\t (error \"can't do that: bytes2\")\n\t )\n\t((equal (car (cadr field)) 'array)\n\t (error \"can't do that: array\")\n\t )\n\t(t (error \"unrecognized field type: %s\" (cadr field)))))\n\n(defun entry-print-field (entry field name prefix is-param)\n (concat\n (format \"%sprint_spaces (indent_spaces);\\n\" prefix)\n (if is-param (format \"%sg_print (\\\"%s = \\\");\\n\" prefix (car field)) \"\")\n (cond ((equal (cadr field) 'uint)\n\t (format \"%sg_print (\\\"%%d\\\\n\\\", %s);\\n\" prefix name))\n\t ((equal (cadr field) 'uint32)\n\t (format \"%sg_print (\\\"%%d\\\\n\\\", %s);\\n\" prefix name))\n\t ((equal (cadr field) 'uint16)\n\t (format \"%sg_print (\\\"%%d\\\\n\\\", %s);\\n\" prefix name))\n\t ((equal (cadr field) 'uint8)\n\t (format \"%sg_print (\\\"%%d\\\\n\\\", %s);\\n\" prefix name))\n\t ((equal (cadr field) 'boolean)\n\t (format \"%sg_print (\\\"%%s\\\\n\\\", %s ? \\\"true\\\" : \\\"false\\\");\\n\" prefix name))\n\t ((equal (cadr field) 'string)\n\t (format \"%sg_print (\\\"%%s\\\\n\\\", %s);\\n\" prefix name))\n\t ((equal (cadr field) 'bytes)\n\t (format \"%sserializeio_print_bytes (%s, %s_len);\\n\" prefix name name))\n\t ((equal (cadr field) 'object)\n\t (concat\n \t (if is-param (format \"%sg_print (\\\"{\\\\n\\\");\\n\" prefix) \"\")\n\t (format \"%sserializeio_generic_print (%s_type, %s, indent_spaces + 2);\\n\" prefix name name)\n\t (format \"%sprint_spaces (indent_spaces);\\n;\\n\" prefix)\n\t (if is-param (format \"%sg_print (\\\"}\\\\n\\\");\\n\" prefix) \"\")\n\t )\n\t )\n\t ((member (cadr field) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n\t (concat\n\t (if is-param (format \"%sg_print (\\\"{\\\\n\\\");\\n\" prefix) \"\")\n\t (format \"%sserializeio_print_%s_obj (& %s, indent_spaces + 2);\\n\" prefix (downcase-string (cadr field)) name name)\n\t (format \"%sprint_spaces (indent_spaces);\\n;\\n\" prefix)\n\t (if is-param (format \"%sg_print (\\\"}\\\\n\\\");\\n\" prefix) \"\")\n\t )\n\t )\n\t ((and (equal (car (cadr field)) 'ptr)\n\t (member (cadr (cadr field)) (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*)))\n\t (concat\n\t (if is-param (format \"%sg_print (\\\"{\\\\n\\\");\\n\" prefix) \"\")\n\t (format \"%sserializeio_print_%s_obj (%s, indent_spaces + 2);\\n\"\n\t\t prefix (downcase-string (cadr (cadr field))) name name)\n\t (format \"%sprint_spaces (indent_spaces);\\n;\\n\" prefix)\n\t (if is-param (format \"%sg_print (\\\"}\\\\n\\\");\\n\" prefix) \"\")\n\t )\n\t )\n\t ((equal (car (cadr field)) 'bytes)\n\t (format \"%sserializeio_print_bytes (%s, %d);\\n\" prefix name (cadr (cadr field))))\n\t ((equal (car (cadr field)) 'array)\n\t (concat\n\t (if is-param (format \"%sg_print (\\\"{\\\\n\\\");\\n\" prefix) \"\")\n\t (format \"%s{\n%s gint i;\n%s for (i = 0; i < %s_len; i += 1)\n%s {\n%s print_spaces (indent_spaces);\n%s g_print (\\\"%%d:\\n\\\", i);\n%s%s }\n%s}\n\"\n\t\t prefix prefix prefix\n\t\t name\n\t\t prefix\n\t\t prefix\n\t\t prefix\n\t\t prefix\n\t\t (entry-print-field entry (cadr field) (array-index name (cadr field)) (concat prefix \" \") nil)\n\t\t prefix\n\t\t )\n\t (if is-param (format \"%sg_print (\\\"}\\\\n\\\");\\n\" prefix) \"\")))\n\t (t (error \"unrecognized field type: %s\" (cadr field)))))\n )\n\n(defconst *event-id* 0)\n\n(defconst *event-types* nil)\n\n(defun generate-events ()\n (let ((events *event-defs*))\n (while events\n\n (let* ((event (car events))\n\t (uargs (event-uargs-get event))\n\t (sargs (event-sargs-get event))\n\t (type-prefix (intern (apply (function concat)\n\t\t\t\t\t (append (mapcar (function (lambda (x) (capitalize1 (cadr x)))) uargs)\n\t\t\t\t\t\t (mapcar (function (lambda (x) (capitalize1 x))) sargs)))))\n\t (capprefix (capitalize1 *output-prefix*)))\n\n\t(if (and (not uargs) (not sargs))\n\t (setq type-prefix \"Void\"))\n\n\t(when (not (member type-prefix *event-types*))\n\t (setq *event-types* (cons type-prefix *event-types*))\n\n\t (output-header-file \"_edsio\")\n\n\t (save-excursion\n\t (goto-char *header-typedef-marker*)\n\n\t (insert (format \"\/* %s%sEventCode.\\n *\/\\n\\n\" capprefix type-prefix))\n\n\t (insert (format \"typedef struct _%s%sEventCode %s%sEventCode;\\n\" capprefix type-prefix capprefix type-prefix))\n\t (insert (format \"struct _%s%sEventCode { gint code; };\\n\\n\" capprefix type-prefix))\n\n\t (insert (format \"typedef struct _%s%sEvent %s%sEvent;\\n\" capprefix type-prefix capprefix type-prefix))\n\t (insert (format \"struct _%s%sEvent { gint code; const char* srcfile; guint srcline;%s%s };\\n\\n\" capprefix type-prefix (event-struct-entries event) (event-struct-sys-entries event)))\n\t )\n\n\t (insert (format \"void %s_generate_%s_event_internal (%s%sEventCode code, const char* srcfile, gint srcline%s);\\n\"\n\t\t\t *output-prefix*\n\t\t\t (downcase-string type-prefix)\n\t\t\t capprefix\n\t\t\t type-prefix\n\t\t\t (event-uargs-plist uargs t)\n\t\t\t ))\n\t (insert (format \"#define %s_generate_%s_event(ecode%s) %s_generate_%s_event_internal((ecode),__FILE__,__LINE__%s)\\n\\n\"\n\t\t\t *output-prefix*\n\t\t\t (downcase-string type-prefix)\n\t\t\t (event-uargs-alist uargs t)\n\t\t\t *output-prefix*\n\t\t\t (downcase-string type-prefix)\n\t\t\t (event-uargs-mlist uargs t)))\n\n\t (output-source-file \"_edsio\")\n\n\t (insert (format \"void\\n%s_generate_%s_event_internal (%s%sEventCode _code, const char* _srcfile, gint _srcline%s)\\n\"\n\t\t\t *output-prefix*\n\t\t\t (downcase-string type-prefix)\n\t\t\t capprefix\n\t\t\t type-prefix\n\t\t\t (event-uargs-plist uargs t)\n\t\t\t ))\n\t (insert (format \"{\\n\"))\n\t (insert (format \" %s%sEvent *_e = g_new0 (%s%sEvent, 1);\\n\" capprefix type-prefix capprefix type-prefix))\n\t (insert (format \" _e->code = _code.code;\\n _e->srcline = _srcline;\\n _e->srcfile = _srcfile;\\n\"))\n\t (insert (event-uargs-copy \"_e\" event))\n\t (insert (event-sargs-copy \"_e\" event))\n\t (insert (format \" eventdelivery_event_deliver ((GenericEvent*) _e);\\n\"))\n\t (insert (format \"}\\n\\n\"))\n\n\t ;; Field to string def\n\n\t (unless (equal type-prefix \"Void\")\n\t (save-excursion\n\t (goto-char *source-top-marker*)\n\t (insert (format \"static const char* %s_%s_event_field_to_string (GenericEvent* ev, gint field);\\n\" capprefix type-prefix))\n\t )\n\n\t (insert (format \"const char*\\n%s_%s_event_field_to_string (GenericEvent* ev, gint field)\\n\"\n\t\t\t capprefix type-prefix))\n\t (insert (format \"{\\n\"))\n\n\t (unless (equal type-prefix (intern \"Ssl\"))\n\t (insert (format \" %s%sEvent* it = (%s%sEvent*) ev;\\n\" capprefix type-prefix capprefix type-prefix)))\n\t (insert (format \" switch (field)\\n\"))\n\t (insert (format \" {\\n\"))\n\n\t (let ((uargs (event-uargs-get event))\n\t\t (i 0))\n\t (while uargs\n\t\t(let ((uarg (car uargs)))\n\t\t (insert (format \" case %d: return eventdelivery_%s_to_string (it->%s);\\n\" i (cadr uarg) (car uarg)))\n\t\t )\n\t\t(setq i (+ i 1))\n\t\t(setq uargs (cdr uargs))\n\t\t)\n\t )\n\n\t (if (< 1 (length (event-sargs-get event)))\n\t\t(error \"unhandled case, too many sargs\"))\n\n\t (when (event-sargs-get event)\n\t (let ((sarg (car (event-sargs-get event))))\n\t\t(insert (format \" case %d: \" (length (event-uargs-get event))))\n\n\t\t(if (not (member sarg '(ssl errno)))\n\t\t (error \"what type of sarg is %s\" sarg))\n\n\t\t(if (eq sarg 'errno)\n\t\t (insert (format \"return g_strdup (g_strerror (it->ev_errno));\\n\")))\n\n\t\t(if (eq sarg 'ssl)\n\t\t (insert (format \"return eventdelivery_ssl_errors_to_string ();\\n\")))\n\t\t)\n\t )\n\n\t (insert (format \" default: abort ();\\n\"))\n\t (insert (format \" }\\n\"))\n\n\t (insert (format \"}\\n\\n\"))\n\t )\n\t )\n\n\t(output-header-file \"_edsio\")\n\n\t(insert (format \"extern const %s%sEventCode EC_%s%s;\\n\"\n\t\t\tcapprefix\n\t\t\ttype-prefix\n\t\t\tcapprefix\n\t\t\t(event-name-get event)))\n\n\t(insert (format \"#define EC_%s%sValue ((%d<%s = %s;\\n\" name (car x) (car x))))\n\t\t (event-uargs-get event)))\n )\n\n(defun event-sargs-copy (name event)\n (if (member 'errno (event-sargs-get event))\n (format \" %s->ev_errno = errno;\\n\" name)\n \"\")\n )\n\n(defun event-type-to-ctype (etype)\n (let ((it (obj-name-eq etype *all-etype-defs*)))\n (if (not it)\n\t(message \"no ctype for %s\" etype))\n (etype-ctype-get it)\n )\n )\n\n(defun event-uargs-plist(uargs need_first)\n (concat\n (if (and need_first uargs) \", \" \"\")\n (format-comlist (function (lambda (x) (format \"%s %s\" (event-type-to-ctype (cadr x)) (car x)))) uargs))\n )\n\n(defun event-uargs-alist(uargs need_first)\n (concat\n (if (and need_first uargs) \", \" \"\")\n (format-comlist (function (lambda (x) (format \"%s\" (car x)))) uargs))\n )\n\n(defun event-uargs-mlist(uargs need_first)\n (concat\n (if (and need_first uargs) \", \" \"\")\n (format-comlist (function (lambda (x) (format \"(%s)\" (car x)))) uargs))\n )\n\n(defun fixup-oneline (event oneline)\n (let ((work (get-buffer-create \"*string-tmp2*\")))\n (save-excursion\n (set-buffer work)\n (erase-buffer)\n (insert oneline)\n (beginning-of-buffer)\n\n (while (re-search-forward \"${\\\\(\\\\w+\\\\)}\" nil t)\n\n \t(let* ((it (intern (downcase-string (match-string 1))))\n\t (uargs (event-uargs-get event))\n\t (i 0)\n\t (repl nil))\n\n\t (while uargs\n\n\t (if (eq (car (car uargs)) it)\n\t\t(setq repl (format \"${%d}\" i)))\n\n\t (setq uargs (cdr uargs))\n\t (setq i (+ i 1))\n\t )\n\n\t (when (eq it 'strerror)\n\t (if repl\n\t\t(error \"No wildcards named STRERROR\"))\n\t (setq repl (format \"${%d}\" i))\n\t )\n\n\t (when (eq it 'ssl)\n\t (if repl\n\t\t(error \"No wildcards named SSL\"))\n\t (setq repl (format \"${%d}\" i))\n\t )\n\n\t (if (not repl)\n\t (error \"Illegal wildcard %s in %s\" it oneline))\n\n\t (replace-match repl nil nil)\n \t )\n \t)\n\n (buffer-string)\n )\n )\n )\n\n;; Properties\n\n(defun generate-properties ()\n (let ((cap-prefix (capitalize1 *output-prefix*))\n\t(unique-types nil))\n (output-header-file \"_edsio\")\n\n (insert (format \"\/* Property definitions *\/\\n\\n\"))\n\n ;; Types\n\n (output-source-file \"_edsio\")\n\n (mapcar\n (function\n (lambda (pht)\n\t(let ((type (prophosttype-type-get pht)))\n\t (unless (member type unique-types)\n\t (setq unique-types (cons type unique-types))\n\n\t (save-excursion\n\t (goto-char *source-init-marker*)\n\n\t ;(message \"%s -> %s %s\" type (type-free-func type) (member type (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*)))\n\n\t (insert (format \" edsio_initialize_property_type (\\\"%s\\\", %s, %s, %s, %s, %s);\\n\"\n\t\t\t type\n\t\t\t (type-free-func type)\n\t\t\t (type-gs-func type \"getter\")\n\t\t\t (type-gs-func type \"setter\")\n\t\t\t (type-serialize-func type)\n\t\t\t (type-unserialize-func type)))\n\t )\n\t )\n\t )\n\t)\n )\n *prophosttype-defs*\n )\n\n ;; Host reg\n\n (mapcar\n (function\n (lambda (prophost)\n\t(save-excursion\n\t (goto-char *source-init-marker*)\n\t (insert (format \" edsio_initialize_host_type (\\\"%s\\\", %s, %s, %s, %s, %s);\\n\"\n\t\t\t (prophost-name-get prophost)\n\t\t\t (format \"(PropertyTableFunc) & edsio_%s_property_table\"\n\t\t\t\t (downcase-string (prophost-name-get prophost)))\n\t\t\t (prophost-persist prophost \"source\")\n\t\t\t (prophost-persist prophost \"sink\")\n\t\t\t (prophost-persist prophost \"isset\")\n\t\t\t (prophost-persist prophost \"unset\")\n\t\t\t ))\n\t )\n\t)\n )\n *prophost-defs*)\n\n ;; Compute each distinct (host type) x (prop type)\n\n (mapcar\n (function\n (lambda (prophost)\n\n\t(mapcar\n\t (function\n\t (lambda (prophosttype)\n\n\t (when (equal (prophosttype-host-get prophosttype) (prophost-name-get prophost))\n\n\t (when (not (member (prophosttype-type-get prophosttype) (prophost-proptypes-get prophost)))\n\t\t(prophost-proptypes-set prophost (cons (prophosttype-type-get prophosttype) (prophost-proptypes-get prophost)))\n\t\t)\n\t )))\n\t *prophosttype-defs*\n\t )\n\n\t;; Output the get\/set functions for each property type\n\n\t(mapcar\n\t (function\n\t (lambda (type)\n\n\t (let ((it (property-code-typename type prophost)))\n\n\t ;; Header\n\n\t (output-header-file \"_edsio\")\n\n\t (insert (format \"\/* Property get\/set for %s\/%s\\n *\/\\n\\n\" (prophost-name-get prophost) type))\n\n\t (insert (format \"typedef struct _%s %s;\\n\" it it))\n\n\t (insert (format \"struct _%s { guint32 code; };\\n\\n\" it))\n\n\t (insert (format \"gboolean edsio_new_%s_%s_property (const char* name, guint32 flags, %s* prop);\\n\"\n\t\t\t (downcase-string (prophost-name-get prophost))\n\t\t\t (type-canon-name type)\n\t\t\t it\n\t\t\t ))\n\n\t (insert (format \"gboolean %s_get_%s (%s obj, %s prop%s);\\n\"\n\t\t\t (downcase-string (prophost-name-get prophost))\n\t\t\t (type-canon-name type)\n\t\t\t (prophost-ctype-get prophost)\n\t\t\t it\n\t\t\t (prop-type-to-get-fps type)))\n\n\t (insert (format \"gboolean %s_set_%s (%s obj, %s prop%s);\\n\"\n\t\t\t (downcase-string (prophost-name-get prophost))\n\t\t\t (type-canon-name type)\n\t\t\t (prophost-ctype-get prophost)\n\t\t\t it\n\t\t\t (prop-type-to-set-fps type)))\n\n\t (insert (format \"gboolean %s_unset_%s (%s obj, %s prop);\\n\"\n\t\t\t (downcase-string (prophost-name-get prophost))\n\t\t\t (type-canon-name type)\n\t\t\t (prophost-ctype-get prophost)\n\t\t\t it))\n\n\t (insert (format \"gboolean %s_isset_%s (%s obj, %s prop);\\n\\n\"\n\t\t\t (downcase-string (prophost-name-get prophost))\n\t\t\t (type-canon-name type)\n\t\t\t (prophost-ctype-get prophost)\n\t\t\t it))\n\n\t ;; Source\n\n\t (output-source-file \"_edsio\")\n\n\t (insert (format \"gboolean edsio_new_%s_%s_property (const char* name, guint32 flags, %s* prop)\\n{\\n\"\n\t\t\t (downcase-string (prophost-name-get prophost))\n\t\t\t (type-canon-name type)\n\t\t\t it\n\t\t\t ))\n\t (insert (format \" return edsio_new_property (name, \\\"%s\\\", \\\"%s\\\", flags, (EdsioGenericProperty*) prop);\\n\" (prophost-name-get prophost) type))\n\t (insert (format \"}\\n\\n\"))\n\n\t (insert (format \"gboolean\\n%s_get_%s (%s obj, %s prop%s)\\n{\\n\"\n\t\t\t (downcase-string (prophost-name-get prophost))\n\t\t\t (type-canon-name type)\n\t\t\t (prophost-ctype-get prophost)\n\t\t\t it\n\t\t\t (prop-type-to-get-fps type)))\n\t (insert (format \" EdsioProperty* ep;\\n\"))\n\t (insert (format \" g_return_val_if_fail (obj, FALSE);\\n\"))\n\t (insert (format \" return (* edsio_property_getter (\\\"%s\\\", \\\"%s\\\", prop.code, & ep)) (obj, ep%s);\\n\"\n\t\t\t (prophost-name-get prophost)\n\t\t\t type\n\t\t\t (prop-type-to-args type)\n\t\t\t ))\n\n\t (insert (format \"}\\n\\n\"))\n\n\t (insert (format \"gboolean\\n%s_set_%s (%s obj, %s prop%s)\\n{\\n\"\n\t\t\t (downcase-string (prophost-name-get prophost))\n\t\t\t (type-canon-name type)\n\t\t\t (prophost-ctype-get prophost)\n\t\t\t it\n\t\t\t (prop-type-to-set-fps type)))\n\t (insert (format \" EdsioProperty* ep;\\n\"))\n\t (insert (format \" g_return_val_if_fail (obj, FALSE);\\n\"))\n\t (insert (format \" return (* edsio_property_setter (\\\"%s\\\", \\\"%s\\\", prop.code, & ep)) (obj, ep%s);\\n\"\n\t\t\t (prophost-name-get prophost)\n\t\t\t type\n\t\t\t (prop-type-to-args type)\n\t\t\t ))\n\n\t (insert (format \"}\\n\\n\"))\n\n\t (insert (format \"gboolean\\n%s_unset_%s (%s obj, %s prop)\\n{\\n\"\n\t\t\t (downcase-string (prophost-name-get prophost))\n\t\t\t (type-canon-name type)\n\t\t\t (prophost-ctype-get prophost)\n\t\t\t it))\n\t (insert (format \" g_return_val_if_fail (obj, FALSE);\\n\"))\n\t (insert (format \" return edsio_property_unset (\\\"%s\\\", \\\"%s\\\", prop.code, obj);\\n\"\n\t\t\t (prophost-name-get prophost)\n\t\t\t type\n\t\t\t \"\"\n\t\t\t ))\n\n\t (insert (format \"}\\n\\n\"))\n\n\t (insert (format \"gboolean\\n%s_isset_%s (%s obj, %s prop)\\n{\\n\"\n\t\t\t (downcase-string (prophost-name-get prophost))\n\t\t\t (type-canon-name type)\n\t\t\t (prophost-ctype-get prophost)\n\t\t\t it))\n\t (insert (format \" g_return_val_if_fail (obj, FALSE);\\n\"))\n\t (insert (format \" return edsio_property_isset (\\\"%s\\\", \\\"%s\\\", prop.code, obj);\\n\"\n\t\t\t (prophost-name-get prophost)\n\t\t\t type\n\t\t\t ))\n\n\t (insert (format \"}\\n\\n\"))\n\n\t )\n\t )\n\t )\n\t (prophost-proptypes-get prophost)\n\t )\n\t)\n )\n *all-prophost-defs*\n )\n )\n )\n\n(defun property-code-typename(type prophost)\n (format \"%s%s%sProperty\"\n\t (capitalize1 *output-prefix*)\n\t (prophost-name-get prophost)\n\t (capitalize1 type))\n )\n\n(defun prop-typename-ctypes (type)\n (cond ((equal type 'string)\n\t (list (list 'arg \"const gchar*\")))\n\t((equal type 'uint)\n\t (list (list 'arg \"guint32\")))\n\t((equal type 'uint32)\n\t (list (list 'arg \"guint32\")))\n\t((equal type 'uint16)\n\t (list (list 'arg \"guint16\")))\n\t((equal type 'uint8)\n\t (list (list 'arg \"guint8\")))\n\t((equal type 'boolean)\n\t (list (list 'arg \"gboolean\")))\n\t((equal type 'bytes)\n\t (list (list 'arg \"const guint8*\") (list 'arg_len \"guint32\")))\n\t((equal type 'object)\n\t (list (list 'arg \"void*\") (list 'arg_type \"guint32\")))\n\t((member type (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n\t (list (list 'arg (format \"Serial%s*\" type))))\n\t((equal (car type) 'bytes)\n\t (list (list 'arg \"const guint8*\")))\n\t((equal (car type) 'array)\n\t (list (list 'arg (format \"%s*\" (cadr (car (prop-typename-ctypes (cadr type))))))\n\t (list 'arg_len \"guint32\")))\n\t((equal (car type) 'ptr)\n\t (list (list 'arg (format \"%s*\" (cadr (car (prop-typename-ctypes (cadr type))))))))\n\t(t (error \"unrecognized field type: %s\" type)))\n )\n\n(defun prop-type-to-get-fps (type)\n (concat \", \"\n\t (format-comlist\n\t (function\n\t (lambda (pair)\n\t (format \"%s* %s\" (cadr pair) (car pair))\n\t )\n\t )\n\t (prop-typename-ctypes type))\n\t )\n )\n\n(defun prop-type-to-set-fps (type)\n (concat \", \"\n\t (format-comlist\n\t (function\n\t (lambda (pair)\n\t (format \"%s %s\" (cadr pair) (car pair))\n\t )\n\t )\n\t (prop-typename-ctypes type))\n\t )\n )\n\n(defun prop-type-to-args (type)\n (concat \", \"\n\t (format-comlist\n\t (function\n\t (lambda (pair)\n\t (format \"%s\" (car pair))\n\t )\n\t )\n\t (prop-typename-ctypes type))\n\t )\n )\n\n(defun type-canon-name (type)\n ; @@@ does not work for (array ...), etc\n (downcase-string type))\n\n(defun type-serialize-func (type)\n (format \"serialize_%s_obj\" (downcase-string type))\n )\n\n(defun type-unserialize-func (type)\n (format \"unserialize_%s\" (downcase-string type))\n )\n\n(defun type-gs-func (type name)\n (if (member type (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n (format \"& edsio_property_vptr_%s\" name)\n (format \"& edsio_property_%s_%s\" type name)))\n\n(defun type-free-func (type)\n (if (member type (mapcar (lambda (x) (sertype-name-get x)) *all-sertype-defs*))\n (format \"& edsio_property_vptr_free\")\n (format \"& edsio_property_%s_free\" type)))\n\n(defun prophost-persist (prophost func)\n (if (prophost-persist-get prophost)\n (format \"(Persist%sFunc) & %s_persist_%s_%s\"\n\t (capitalize1 func)\n\t *output-prefix*\n\t (downcase-string (prophost-name-get prophost))\n\t func)\n \"NULL\"))\n","avg_line_length":30.4453376206,"max_line_length":259,"alphanum_fraction":0.6009047544} {"size":102156,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; dash.el --- A modern list library for Emacs -*- lexical-binding: t -*-\n\n;; Copyright (C) 2012-2016 Free Software Foundation, Inc.\n\n;; Author: Magnar Sveen \n;; Version: 2.15.0\n;; Package-Version: 20190128.1920\n;; Keywords: lists\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Commentary:\n\n;; A modern list api for Emacs.\n;;\n;; See documentation on https:\/\/github.com\/magnars\/dash.el#functions\n;;\n;; **Please note** The lexical binding in this file is not utilised at the\n;; moment. We will take full advantage of lexical binding in an upcoming 3.0\n;; release of Dash. In the meantime, we've added the pragma to avoid a bug that\n;; you can read more about in https:\/\/github.com\/magnars\/dash.el\/issues\/130.\n;;\n\n;;; Code:\n\n(defgroup dash ()\n \"Customize group for dash.el\"\n :group 'lisp\n :prefix \"dash-\")\n\n(defun dash--enable-fontlock (symbol value)\n (when value\n (dash-enable-font-lock))\n (set-default symbol value))\n\n(defcustom dash-enable-fontlock nil\n \"If non-nil, enable fontification of dash functions, macros and\nspecial values.\"\n :type 'boolean\n :set 'dash--enable-fontlock\n :group 'dash)\n\n(defmacro !cons (car cdr)\n \"Destructive: Set CDR to the cons of CAR and CDR.\"\n `(setq ,cdr (cons ,car ,cdr)))\n\n(defmacro !cdr (list)\n \"Destructive: Set LIST to the cdr of LIST.\"\n `(setq ,list (cdr ,list)))\n\n(defmacro --each (list &rest body)\n \"Anaphoric form of `-each'.\"\n (declare (debug (form body))\n (indent 1))\n (let ((l (make-symbol \"list\")))\n `(let ((,l ,list)\n (it-index 0))\n (while ,l\n (let ((it (car ,l)))\n ,@body)\n (setq it-index (1+ it-index))\n (!cdr ,l)))))\n\n(defmacro -doto (eval-initial-value &rest forms)\n \"Eval a form, then insert that form as the 2nd argument to other forms.\nThe EVAL-INITIAL-VALUE form is evaluated once. Its result is\npassed to FORMS, which are then evaluated sequentially. Returns\nthe target form.\"\n (declare (indent 1))\n (let ((retval (make-symbol \"value\")))\n `(let ((,retval ,eval-initial-value))\n ,@(mapcar (lambda (form)\n (if (sequencep form)\n `(,(-first-item form) ,retval ,@(cdr form))\n `(funcall form ,retval)))\n forms)\n ,retval)))\n\n(defmacro --doto (eval-initial-value &rest forms)\n \"Anaphoric form of `-doto'.\nNote: `it' is not required in each form.\"\n (declare (indent 1))\n `(let ((it ,eval-initial-value))\n ,@forms\n it))\n\n(defun -each (list fn)\n \"Call FN with every item in LIST. Return nil, used for side-effects only.\"\n (--each list (funcall fn it)))\n\n(put '-each 'lisp-indent-function 1)\n\n(defalias '--each-indexed '--each)\n\n(defun -each-indexed (list fn)\n \"Call (FN index item) for each item in LIST.\n\nIn the anaphoric form `--each-indexed', the index is exposed as symbol `it-index'.\n\nSee also: `-map-indexed'.\"\n (--each list (funcall fn it-index it)))\n(put '-each-indexed 'lisp-indent-function 1)\n\n(defmacro --each-while (list pred &rest body)\n \"Anaphoric form of `-each-while'.\"\n (declare (debug (form form body))\n (indent 2))\n (let ((l (make-symbol \"list\"))\n (c (make-symbol \"continue\")))\n `(let ((,l ,list)\n (,c t)\n (it-index 0))\n (while (and ,l ,c)\n (let ((it (car ,l)))\n (if (not ,pred) (setq ,c nil) ,@body))\n (setq it-index (1+ it-index))\n (!cdr ,l)))))\n\n(defun -each-while (list pred fn)\n \"Call FN with every item in LIST while (PRED item) is non-nil.\nReturn nil, used for side-effects only.\"\n (--each-while list (funcall pred it) (funcall fn it)))\n\n(put '-each-while 'lisp-indent-function 2)\n\n(defmacro --each-r (list &rest body)\n \"Anaphoric form of `-each-r'.\"\n (declare (debug (form body))\n (indent 1))\n (let ((v (make-symbol \"vector\")))\n ;; Implementation note: building vector is considerably faster\n ;; than building a reversed list (vector takes less memory, so\n ;; there is less GC), plus length comes naturally. In-place\n ;; 'nreverse' would be faster still, but BODY would be able to see\n ;; that, even if modification was reversed before we return.\n `(let* ((,v (vconcat ,list))\n (it-index (length ,v))\n it)\n (while (> it-index 0)\n (setq it-index (1- it-index))\n (setq it (aref ,v it-index))\n ,@body))))\n\n(defun -each-r (list fn)\n \"Call FN with every item in LIST in reversed order.\n Return nil, used for side-effects only.\"\n (--each-r list (funcall fn it)))\n\n(defmacro --each-r-while (list pred &rest body)\n \"Anaphoric form of `-each-r-while'.\"\n (declare (debug (form form body))\n (indent 2))\n (let ((v (make-symbol \"vector\")))\n `(let* ((,v (vconcat ,list))\n (it-index (length ,v))\n it)\n (while (> it-index 0)\n (setq it-index (1- it-index))\n (setq it (aref ,v it-index))\n (if (not ,pred)\n (setq it-index -1)\n ,@body)))))\n\n(defun -each-r-while (list pred fn)\n \"Call FN with every item in reversed LIST while (PRED item) is non-nil.\nReturn nil, used for side-effects only.\"\n (--each-r-while list (funcall pred it) (funcall fn it)))\n\n(defmacro --dotimes (num &rest body)\n \"Repeatedly executes BODY (presumably for side-effects) with symbol `it' bound to integers from 0 through NUM-1.\"\n (declare (debug (form body))\n (indent 1))\n (let ((n (make-symbol \"num\")))\n `(let ((,n ,num)\n (it 0))\n (while (< it ,n)\n ,@body\n (setq it (1+ it))))))\n\n(defun -dotimes (num fn)\n \"Repeatedly calls FN (presumably for side-effects) passing in integers from 0 through NUM-1.\"\n (--dotimes num (funcall fn it)))\n\n(put '-dotimes 'lisp-indent-function 1)\n\n(defun -map (fn list)\n \"Return a new list consisting of the result of applying FN to the items in LIST.\"\n (mapcar fn list))\n\n(defmacro --map (form list)\n \"Anaphoric form of `-map'.\"\n (declare (debug (form form)))\n `(mapcar (lambda (it) ,form) ,list))\n\n(defmacro --reduce-from (form initial-value list)\n \"Anaphoric form of `-reduce-from'.\"\n (declare (debug (form form form)))\n `(let ((acc ,initial-value))\n (--each ,list (setq acc ,form))\n acc))\n\n(defun -reduce-from (fn initial-value list)\n \"Return the result of applying FN to INITIAL-VALUE and the\nfirst item in LIST, then applying FN to that result and the 2nd\nitem, etc. If LIST contains no items, return INITIAL-VALUE and\ndo not call FN.\n\nIn the anaphoric form `--reduce-from', the accumulated value is\nexposed as symbol `acc'.\n\nSee also: `-reduce', `-reduce-r'\"\n (--reduce-from (funcall fn acc it) initial-value list))\n\n(defmacro --reduce (form list)\n \"Anaphoric form of `-reduce'.\"\n (declare (debug (form form)))\n (let ((lv (make-symbol \"list-value\")))\n `(let ((,lv ,list))\n (if ,lv\n (--reduce-from ,form (car ,lv) (cdr ,lv))\n (let (acc it) ,form)))))\n\n(defun -reduce (fn list)\n \"Return the result of applying FN to the first 2 items in LIST,\nthen applying FN to that result and the 3rd item, etc. If LIST\ncontains no items, return the result of calling FN with no\narguments. If LIST contains a single item, return that item\nand do not call FN.\n\nIn the anaphoric form `--reduce', the accumulated value is\nexposed as symbol `acc'.\n\nSee also: `-reduce-from', `-reduce-r'\"\n (if list\n (-reduce-from fn (car list) (cdr list))\n (funcall fn)))\n\n(defmacro --reduce-r-from (form initial-value list)\n \"Anaphoric version of `-reduce-r-from'.\"\n (declare (debug (form form form)))\n `(--reduce-from ,form ,initial-value (reverse ,list)))\n\n(defun -reduce-r-from (fn initial-value list)\n \"Replace conses with FN, nil with INITIAL-VALUE and evaluate\nthe resulting expression. If LIST is empty, INITIAL-VALUE is\nreturned and FN is not called.\n\nNote: this function works the same as `-reduce-from' but the\noperation associates from right instead of from left.\n\nSee also: `-reduce-r', `-reduce'\"\n (--reduce-r-from (funcall fn it acc) initial-value list))\n\n(defmacro --reduce-r (form list)\n \"Anaphoric version of `-reduce-r'.\"\n (declare (debug (form form)))\n `(--reduce ,form (reverse ,list)))\n\n(defun -reduce-r (fn list)\n \"Replace conses with FN and evaluate the resulting expression.\nThe final nil is ignored. If LIST contains no items, return the\nresult of calling FN with no arguments. If LIST contains a single\nitem, return that item and do not call FN.\n\nThe first argument of FN is the new item, the second is the\naccumulated value.\n\nNote: this function works the same as `-reduce' but the operation\nassociates from right instead of from left.\n\nSee also: `-reduce-r-from', `-reduce'\"\n (if list\n (--reduce-r (funcall fn it acc) list)\n (funcall fn)))\n\n(defun -reductions-from (fn init list)\n \"Return a list of the intermediate values of the reduction.\n\nSee `-reduce-from' for explanation of the arguments.\n\nSee also: `-reductions', `-reductions-r', `-reduce-r'\"\n (nreverse (--reduce-from (cons (funcall fn (car acc) it) acc) (list init) list)))\n\n(defun -reductions (fn list)\n \"Return a list of the intermediate values of the reduction.\n\nSee `-reduce' for explanation of the arguments.\n\nSee also: `-reductions-from', `-reductions-r', `-reduce-r'\"\n (and list (-reductions-from fn (car list) (cdr list))))\n\n(defun -reductions-r-from (fn init list)\n \"Return a list of the intermediate values of the reduction.\n\nSee `-reduce-r-from' for explanation of the arguments.\n\nSee also: `-reductions-r', `-reductions', `-reduce'\"\n (--reduce-r-from (cons (funcall fn it (car acc)) acc) (list init) list))\n\n(defun -reductions-r (fn list)\n \"Return a list of the intermediate values of the reduction.\n\nSee `-reduce-r' for explanation of the arguments.\n\nSee also: `-reductions-r-from', `-reductions', `-reduce'\"\n (when list\n (let ((rev (reverse list)))\n (--reduce-from (cons (funcall fn it (car acc)) acc)\n (list (car rev))\n (cdr rev)))))\n\n(defmacro --filter (form list)\n \"Anaphoric form of `-filter'.\n\nSee also: `--remove'.\"\n (declare (debug (form form)))\n (let ((r (make-symbol \"result\")))\n `(let (,r)\n (--each ,list (when ,form (!cons it ,r)))\n (nreverse ,r))))\n\n(defun -filter (pred list)\n \"Return a new list of the items in LIST for which PRED returns a non-nil value.\n\nAlias: `-select'\n\nSee also: `-keep', `-remove'.\"\n (--filter (funcall pred it) list))\n\n(defalias '-select '-filter)\n(defalias '--select '--filter)\n\n(defmacro --remove (form list)\n \"Anaphoric form of `-remove'.\n\nSee also `--filter'.\"\n (declare (debug (form form)))\n `(--filter (not ,form) ,list))\n\n(defun -remove (pred list)\n \"Return a new list of the items in LIST for which PRED returns nil.\n\nAlias: `-reject'\n\nSee also: `-filter'.\"\n (--remove (funcall pred it) list))\n\n(defalias '-reject '-remove)\n(defalias '--reject '--remove)\n\n(defun -remove-first (pred list)\n \"Return a new list with the first item matching PRED removed.\n\nAlias: `-reject-first'\n\nSee also: `-remove', `-map-first'\"\n (let (front)\n (while (and list (not (funcall pred (car list))))\n (push (car list) front)\n (!cdr list))\n (if list\n (-concat (nreverse front) (cdr list))\n (nreverse front))))\n\n(defmacro --remove-first (form list)\n \"Anaphoric form of `-remove-first'.\"\n (declare (debug (form form)))\n `(-remove-first (lambda (it) ,form) ,list))\n\n(defalias '-reject-first '-remove-first)\n(defalias '--reject-first '--remove-first)\n\n(defun -remove-last (pred list)\n \"Return a new list with the last item matching PRED removed.\n\nAlias: `-reject-last'\n\nSee also: `-remove', `-map-last'\"\n (nreverse (-remove-first pred (reverse list))))\n\n(defmacro --remove-last (form list)\n \"Anaphoric form of `-remove-last'.\"\n (declare (debug (form form)))\n `(-remove-last (lambda (it) ,form) ,list))\n\n(defalias '-reject-last '-remove-last)\n(defalias '--reject-last '--remove-last)\n\n(defun -remove-item (item list)\n \"Remove all occurences of ITEM from LIST.\n\nComparison is done with `equal'.\"\n (declare (pure t) (side-effect-free t))\n (--remove (equal it item) list))\n\n(defmacro --keep (form list)\n \"Anaphoric form of `-keep'.\"\n (declare (debug (form form)))\n (let ((r (make-symbol \"result\"))\n (m (make-symbol \"mapped\")))\n `(let (,r)\n (--each ,list (let ((,m ,form)) (when ,m (!cons ,m ,r))))\n (nreverse ,r))))\n\n(defun -keep (fn list)\n \"Return a new list of the non-nil results of applying FN to the items in LIST.\n\nIf you want to select the original items satisfying a predicate use `-filter'.\"\n (--keep (funcall fn it) list))\n\n(defun -non-nil (list)\n \"Return all non-nil elements of LIST.\"\n (declare (pure t) (side-effect-free t))\n (-remove 'null list))\n\n(defmacro --map-indexed (form list)\n \"Anaphoric form of `-map-indexed'.\"\n (declare (debug (form form)))\n (let ((r (make-symbol \"result\")))\n `(let (,r)\n (--each ,list\n (!cons ,form ,r))\n (nreverse ,r))))\n\n(defun -map-indexed (fn list)\n \"Return a new list consisting of the result of (FN index item) for each item in LIST.\n\nIn the anaphoric form `--map-indexed', the index is exposed as symbol `it-index'.\n\nSee also: `-each-indexed'.\"\n (--map-indexed (funcall fn it-index it) list))\n\n(defmacro --map-when (pred rep list)\n \"Anaphoric form of `-map-when'.\"\n (declare (debug (form form form)))\n (let ((r (make-symbol \"result\")))\n `(let (,r)\n (--each ,list (!cons (if ,pred ,rep it) ,r))\n (nreverse ,r))))\n\n(defun -map-when (pred rep list)\n \"Return a new list where the elements in LIST that do not match the PRED function\nare unchanged, and where the elements in LIST that do match the PRED function are mapped\nthrough the REP function.\n\nAlias: `-replace-where'\n\nSee also: `-update-at'\"\n (--map-when (funcall pred it) (funcall rep it) list))\n\n(defalias '-replace-where '-map-when)\n(defalias '--replace-where '--map-when)\n\n(defun -map-first (pred rep list)\n \"Replace first item in LIST satisfying PRED with result of REP called on this item.\n\nSee also: `-map-when', `-replace-first'\"\n (let (front)\n (while (and list (not (funcall pred (car list))))\n (push (car list) front)\n (!cdr list))\n (if list\n (-concat (nreverse front) (cons (funcall rep (car list)) (cdr list)))\n (nreverse front))))\n\n(defmacro --map-first (pred rep list)\n \"Anaphoric form of `-map-first'.\"\n `(-map-first (lambda (it) ,pred) (lambda (it) (ignore it) ,rep) ,list))\n\n(defun -map-last (pred rep list)\n \"Replace last item in LIST satisfying PRED with result of REP called on this item.\n\nSee also: `-map-when', `-replace-last'\"\n (nreverse (-map-first pred rep (reverse list))))\n\n(defmacro --map-last (pred rep list)\n \"Anaphoric form of `-map-last'.\"\n `(-map-last (lambda (it) ,pred) (lambda (it) (ignore it) ,rep) ,list))\n\n(defun -replace (old new list)\n \"Replace all OLD items in LIST with NEW.\n\nElements are compared using `equal'.\n\nSee also: `-replace-at'\"\n (declare (pure t) (side-effect-free t))\n (--map-when (equal it old) new list))\n\n(defun -replace-first (old new list)\n \"Replace the first occurence of OLD with NEW in LIST.\n\nElements are compared using `equal'.\n\nSee also: `-map-first'\"\n (declare (pure t) (side-effect-free t))\n (--map-first (equal old it) new list))\n\n(defun -replace-last (old new list)\n \"Replace the last occurence of OLD with NEW in LIST.\n\nElements are compared using `equal'.\n\nSee also: `-map-last'\"\n (declare (pure t) (side-effect-free t))\n (--map-last (equal old it) new list))\n\n(defmacro --mapcat (form list)\n \"Anaphoric form of `-mapcat'.\"\n (declare (debug (form form)))\n `(apply 'append (--map ,form ,list)))\n\n(defun -mapcat (fn list)\n \"Return the concatenation of the result of mapping FN over LIST.\nThus function FN should return a list.\"\n (--mapcat (funcall fn it) list))\n\n(defun -flatten (l)\n \"Take a nested list L and return its contents as a single, flat list.\n\nNote that because `nil' represents a list of zero elements (an\nempty list), any mention of nil in L will disappear after\nflattening. If you need to preserve nils, consider `-flatten-n'\nor map them to some unique symbol and then map them back.\n\nConses of two atoms are considered \\\"terminals\\\", that is, they\naren't flattened further.\n\nSee also: `-flatten-n'\"\n (declare (pure t) (side-effect-free t))\n (if (and (listp l) (listp (cdr l)))\n (-mapcat '-flatten l)\n (list l)))\n\n(defmacro --iterate (form init n)\n \"Anaphoric version of `-iterate'.\"\n (declare (debug (form form form)))\n `(-iterate (lambda (it) ,form) ,init ,n))\n\n(defun -flatten-n (num list)\n \"Flatten NUM levels of a nested LIST.\n\nSee also: `-flatten'\"\n (declare (pure t) (side-effect-free t))\n (-last-item (--iterate (--mapcat (-list it) it) list (1+ num))))\n\n(defun -concat (&rest lists)\n \"Return a new list with the concatenation of the elements in the supplied LISTS.\"\n (declare (pure t) (side-effect-free t))\n (apply 'append lists))\n\n(defalias '-copy 'copy-sequence\n \"Create a shallow copy of LIST.\n\n\\(fn LIST)\")\n\n(defun -splice (pred fun list)\n \"Splice lists generated by FUN in place of elements matching PRED in LIST.\n\nFUN takes the element matching PRED as input.\n\nThis function can be used as replacement for `,@' in case you\nneed to splice several lists at marked positions (for example\nwith keywords).\n\nSee also: `-splice-list', `-insert-at'\"\n (let (r)\n (--each list\n (if (funcall pred it)\n (let ((new (funcall fun it)))\n (--each new (!cons it r)))\n (!cons it r)))\n (nreverse r)))\n\n(defmacro --splice (pred form list)\n \"Anaphoric form of `-splice'.\"\n `(-splice (lambda (it) ,pred) (lambda (it) ,form) ,list))\n\n(defun -splice-list (pred new-list list)\n \"Splice NEW-LIST in place of elements matching PRED in LIST.\n\nSee also: `-splice', `-insert-at'\"\n (-splice pred (lambda (_) new-list) list))\n\n(defmacro --splice-list (pred new-list list)\n \"Anaphoric form of `-splice-list'.\"\n `(-splice-list (lambda (it) ,pred) ,new-list ,list))\n\n(defun -cons* (&rest args)\n \"Make a new list from the elements of ARGS.\n\nThe last 2 members of ARGS are used as the final cons of the\nresult so if the final member of ARGS is not a list the result is\na dotted list.\"\n (declare (pure t) (side-effect-free t))\n (-reduce-r 'cons args))\n\n(defun -snoc (list elem &rest elements)\n \"Append ELEM to the end of the list.\n\nThis is like `cons', but operates on the end of list.\n\nIf ELEMENTS is non nil, append these to the list as well.\"\n (-concat list (list elem) elements))\n\n(defmacro --first (form list)\n \"Anaphoric form of `-first'.\"\n (declare (debug (form form)))\n (let ((n (make-symbol \"needle\")))\n `(let (,n)\n (--each-while ,list (not ,n)\n (when ,form (setq ,n it)))\n ,n)))\n\n(defun -first (pred list)\n \"Return the first x in LIST where (PRED x) is non-nil, else nil.\n\nTo get the first item in the list no questions asked, use `car'.\n\nAlias: `-find'\"\n (--first (funcall pred it) list))\n\n(defalias '-find '-first)\n(defalias '--find '--first)\n\n(defmacro --some (form list)\n \"Anaphoric form of `-some'.\"\n (declare (debug (form form)))\n (let ((n (make-symbol \"needle\")))\n `(let (,n)\n (--each-while ,list (not ,n)\n (setq ,n ,form))\n ,n)))\n\n(defun -some (pred list)\n \"Return (PRED x) for the first LIST item where (PRED x) is non-nil, else nil.\n\nAlias: `-any'\"\n (--some (funcall pred it) list))\n\n(defalias '-any '-some)\n(defalias '--any '--some)\n\n(defmacro --last (form list)\n \"Anaphoric form of `-last'.\"\n (declare (debug (form form)))\n (let ((n (make-symbol \"needle\")))\n `(let (,n)\n (--each ,list\n (when ,form (setq ,n it)))\n ,n)))\n\n(defun -last (pred list)\n \"Return the last x in LIST where (PRED x) is non-nil, else nil.\"\n (--last (funcall pred it) list))\n\n(defalias '-first-item 'car\n \"Return the first item of LIST, or nil on an empty list.\n\nSee also: `-second-item', `-last-item'.\n\n\\(fn LIST)\")\n\n;; Ensure that calls to `-first-item' are compiled to a single opcode,\n;; just like `car'.\n(put '-first-item 'byte-opcode 'byte-car)\n(put '-first-item 'byte-compile 'byte-compile-one-arg)\n\n(defalias '-second-item 'cadr\n \"Return the second item of LIST, or nil if LIST is too short.\n\nSee also: `-third-item'.\n\n\\(fn LIST)\")\n\n(defalias '-third-item 'caddr\n \"Return the third item of LIST, or nil if LIST is too short.\n\nSee also: `-fourth-item'.\n\n\\(fn LIST)\")\n\n(defun -fourth-item (list)\n \"Return the fourth item of LIST, or nil if LIST is too short.\n\nSee also: `-fifth-item'.\"\n (declare (pure t) (side-effect-free t))\n (car (cdr (cdr (cdr list)))))\n\n(defun -fifth-item (list)\n \"Return the fifth item of LIST, or nil if LIST is too short.\n\nSee also: `-last-item'.\"\n (declare (pure t) (side-effect-free t))\n (car (cdr (cdr (cdr (cdr list))))))\n\n;; TODO: gv was introduced in 24.3, so we can remove the if statement\n;; when support for earlier versions is dropped\n(eval-when-compile\n (require 'cl)\n (if (fboundp 'gv-define-simple-setter)\n (gv-define-simple-setter -first-item setcar)\n (require 'cl)\n (with-no-warnings\n (defsetf -first-item (x) (val) `(setcar ,x ,val)))))\n\n(defun -last-item (list)\n \"Return the last item of LIST, or nil on an empty list.\"\n (declare (pure t) (side-effect-free t))\n (car (last list)))\n\n;; TODO: gv was introduced in 24.3, so we can remove the if statement\n;; when support for earlier versions is dropped\n(eval-when-compile\n (if (fboundp 'gv-define-setter)\n (gv-define-setter -last-item (val x) `(setcar (last ,x) ,val))\n (with-no-warnings\n (defsetf -last-item (x) (val) `(setcar (last ,x) ,val)))))\n\n(defun -butlast (list)\n \"Return a list of all items in list except for the last.\"\n ;; no alias as we don't want magic optional argument\n (declare (pure t) (side-effect-free t))\n (butlast list))\n\n(defmacro --count (pred list)\n \"Anaphoric form of `-count'.\"\n (declare (debug (form form)))\n (let ((r (make-symbol \"result\")))\n `(let ((,r 0))\n (--each ,list (when ,pred (setq ,r (1+ ,r))))\n ,r)))\n\n(defun -count (pred list)\n \"Counts the number of items in LIST where (PRED item) is non-nil.\"\n (--count (funcall pred it) list))\n\n(defun ---truthy? (val)\n (declare (pure t) (side-effect-free t))\n (not (null val)))\n\n(defmacro --any? (form list)\n \"Anaphoric form of `-any?'.\"\n (declare (debug (form form)))\n `(---truthy? (--some ,form ,list)))\n\n(defun -any? (pred list)\n \"Return t if (PRED x) is non-nil for any x in LIST, else nil.\n\nAlias: `-any-p', `-some?', `-some-p'\"\n (--any? (funcall pred it) list))\n\n(defalias '-some? '-any?)\n(defalias '--some? '--any?)\n(defalias '-any-p '-any?)\n(defalias '--any-p '--any?)\n(defalias '-some-p '-any?)\n(defalias '--some-p '--any?)\n\n(defmacro --all? (form list)\n \"Anaphoric form of `-all?'.\"\n (declare (debug (form form)))\n (let ((a (make-symbol \"all\")))\n `(let ((,a t))\n (--each-while ,list ,a (setq ,a ,form))\n (---truthy? ,a))))\n\n(defun -all? (pred list)\n \"Return t if (PRED x) is non-nil for all x in LIST, else nil.\n\nAlias: `-all-p', `-every?', `-every-p'\"\n (--all? (funcall pred it) list))\n\n(defalias '-every? '-all?)\n(defalias '--every? '--all?)\n(defalias '-all-p '-all?)\n(defalias '--all-p '--all?)\n(defalias '-every-p '-all?)\n(defalias '--every-p '--all?)\n\n(defmacro --none? (form list)\n \"Anaphoric form of `-none?'.\"\n (declare (debug (form form)))\n `(--all? (not ,form) ,list))\n\n(defun -none? (pred list)\n \"Return t if (PRED x) is nil for all x in LIST, else nil.\n\nAlias: `-none-p'\"\n (--none? (funcall pred it) list))\n\n(defalias '-none-p '-none?)\n(defalias '--none-p '--none?)\n\n(defmacro --only-some? (form list)\n \"Anaphoric form of `-only-some?'.\"\n (declare (debug (form form)))\n (let ((y (make-symbol \"yes\"))\n (n (make-symbol \"no\")))\n `(let (,y ,n)\n (--each-while ,list (not (and ,y ,n))\n (if ,form (setq ,y t) (setq ,n t)))\n (---truthy? (and ,y ,n)))))\n\n(defun -only-some? (pred list)\n \"Return `t` if at least one item of LIST matches PRED and at least one item of LIST does not match PRED.\nReturn `nil` both if all items match the predicate or if none of the items match the predicate.\n\nAlias: `-only-some-p'\"\n (--only-some? (funcall pred it) list))\n\n(defalias '-only-some-p '-only-some?)\n(defalias '--only-some-p '--only-some?)\n\n(defun -slice (list from &optional to step)\n \"Return copy of LIST, starting from index FROM to index TO.\n\nFROM or TO may be negative. These values are then interpreted\nmodulo the length of the list.\n\nIf STEP is a number, only each STEPth item in the resulting\nsection is returned. Defaults to 1.\"\n (declare (pure t) (side-effect-free t))\n (let ((length (length list))\n (new-list nil))\n ;; to defaults to the end of the list\n (setq to (or to length))\n (setq step (or step 1))\n ;; handle negative indices\n (when (< from 0)\n (setq from (mod from length)))\n (when (< to 0)\n (setq to (mod to length)))\n\n ;; iterate through the list, keeping the elements we want\n (--each-while list (< it-index to)\n (when (and (>= it-index from)\n (= (mod (- from it-index) step) 0))\n (push it new-list)))\n (nreverse new-list)))\n\n(defun -take (n list)\n \"Return a new list of the first N items in LIST, or all items if there are fewer than N.\n\nSee also: `-take-last'\"\n (declare (pure t) (side-effect-free t))\n (let (result)\n (--dotimes n\n (when list\n (!cons (car list) result)\n (!cdr list)))\n (nreverse result)))\n\n(defun -take-last (n list)\n \"Return the last N items of LIST in order.\n\nSee also: `-take'\"\n (declare (pure t) (side-effect-free t))\n (copy-sequence (last list n)))\n\n(defalias '-drop 'nthcdr\n \"Return the tail of LIST without the first N items.\n\nSee also: `-drop-last'\n\n\\(fn N LIST)\")\n\n(defun -drop-last (n list)\n \"Remove the last N items of LIST and return a copy.\n\nSee also: `-drop'\"\n ;; No alias because we don't want magic optional argument\n (declare (pure t) (side-effect-free t))\n (butlast list n))\n\n(defmacro --take-while (form list)\n \"Anaphoric form of `-take-while'.\"\n (declare (debug (form form)))\n (let ((r (make-symbol \"result\")))\n `(let (,r)\n (--each-while ,list ,form (!cons it ,r))\n (nreverse ,r))))\n\n(defun -take-while (pred list)\n \"Return a new list of successive items from LIST while (PRED item) returns a non-nil value.\"\n (--take-while (funcall pred it) list))\n\n(defmacro --drop-while (form list)\n \"Anaphoric form of `-drop-while'.\"\n (declare (debug (form form)))\n (let ((l (make-symbol \"list\")))\n `(let ((,l ,list))\n (while (and ,l (let ((it (car ,l))) ,form))\n (!cdr ,l))\n ,l)))\n\n(defun -drop-while (pred list)\n \"Return the tail of LIST starting from the first item for which (PRED item) returns nil.\"\n (--drop-while (funcall pred it) list))\n\n(defun -split-at (n list)\n \"Return a list of ((-take N LIST) (-drop N LIST)), in no more than one pass through the list.\"\n (declare (pure t) (side-effect-free t))\n (let (result)\n (--dotimes n\n (when list\n (!cons (car list) result)\n (!cdr list)))\n (list (nreverse result) list)))\n\n(defun -rotate (n list)\n \"Rotate LIST N places to the right. With N negative, rotate to the left.\nThe time complexity is O(n).\"\n (declare (pure t) (side-effect-free t))\n (if (> n 0)\n (append (last list n) (butlast list n))\n (append (-drop (- n) list) (-take (- n) list))))\n\n(defun -insert-at (n x list)\n \"Return a list with X inserted into LIST at position N.\n\nSee also: `-splice', `-splice-list'\"\n (declare (pure t) (side-effect-free t))\n (let ((split-list (-split-at n list)))\n (nconc (car split-list) (cons x (cadr split-list)))))\n\n(defun -replace-at (n x list)\n \"Return a list with element at Nth position in LIST replaced with X.\n\nSee also: `-replace'\"\n (declare (pure t) (side-effect-free t))\n (let ((split-list (-split-at n list)))\n (nconc (car split-list) (cons x (cdr (cadr split-list))))))\n\n(defun -update-at (n func list)\n \"Return a list with element at Nth position in LIST replaced with `(func (nth n list))`.\n\nSee also: `-map-when'\"\n (let ((split-list (-split-at n list)))\n (nconc (car split-list) (cons (funcall func (car (cadr split-list))) (cdr (cadr split-list))))))\n\n(defmacro --update-at (n form list)\n \"Anaphoric version of `-update-at'.\"\n (declare (debug (form form form)))\n `(-update-at ,n (lambda (it) ,form) ,list))\n\n(defun -remove-at (n list)\n \"Return a list with element at Nth position in LIST removed.\n\nSee also: `-remove-at-indices', `-remove'\"\n (declare (pure t) (side-effect-free t))\n (-remove-at-indices (list n) list))\n\n(defun -remove-at-indices (indices list)\n \"Return a list whose elements are elements from LIST without\nelements selected as `(nth i list)` for all i\nfrom INDICES.\n\nSee also: `-remove-at', `-remove'\"\n (declare (pure t) (side-effect-free t))\n (let* ((indices (-sort '< indices))\n (diffs (cons (car indices) (-map '1- (-zip-with '- (cdr indices) indices))))\n r)\n (--each diffs\n (let ((split (-split-at it list)))\n (!cons (car split) r)\n (setq list (cdr (cadr split)))))\n (!cons list r)\n (apply '-concat (nreverse r))))\n\n(defmacro --split-with (pred list)\n \"Anaphoric form of `-split-with'.\"\n (declare (debug (form form)))\n (let ((l (make-symbol \"list\"))\n (r (make-symbol \"result\"))\n (c (make-symbol \"continue\")))\n `(let ((,l ,list)\n (,r nil)\n (,c t))\n (while (and ,l ,c)\n (let ((it (car ,l)))\n (if (not ,pred)\n (setq ,c nil)\n (!cons it ,r)\n (!cdr ,l))))\n (list (nreverse ,r) ,l))))\n\n(defun -split-with (pred list)\n \"Return a list of ((-take-while PRED LIST) (-drop-while PRED LIST)), in no more than one pass through the list.\"\n (--split-with (funcall pred it) list))\n\n(defmacro -split-on (item list)\n \"Split the LIST each time ITEM is found.\n\nUnlike `-partition-by', the ITEM is discarded from the results.\nEmpty lists are also removed from the result.\n\nComparison is done by `equal'.\n\nSee also `-split-when'\"\n (declare (debug (form form)))\n `(-split-when (lambda (it) (equal it ,item)) ,list))\n\n(defmacro --split-when (form list)\n \"Anaphoric version of `-split-when'.\"\n (declare (debug (form form)))\n `(-split-when (lambda (it) ,form) ,list))\n\n(defun -split-when (fn list)\n \"Split the LIST on each element where FN returns non-nil.\n\nUnlike `-partition-by', the \\\"matched\\\" element is discarded from\nthe results. Empty lists are also removed from the result.\n\nThis function can be thought of as a generalization of\n`split-string'.\"\n (let (r s)\n (while list\n (if (not (funcall fn (car list)))\n (push (car list) s)\n (when s (push (nreverse s) r))\n (setq s nil))\n (!cdr list))\n (when s (push (nreverse s) r))\n (nreverse r)))\n\n(defmacro --separate (form list)\n \"Anaphoric form of `-separate'.\"\n (declare (debug (form form)))\n (let ((y (make-symbol \"yes\"))\n (n (make-symbol \"no\")))\n `(let (,y ,n)\n (--each ,list (if ,form (!cons it ,y) (!cons it ,n)))\n (list (nreverse ,y) (nreverse ,n)))))\n\n(defun -separate (pred list)\n \"Return a list of ((-filter PRED LIST) (-remove PRED LIST)), in one pass through the list.\"\n (--separate (funcall pred it) list))\n\n(defun ---partition-all-in-steps-reversed (n step list)\n \"Private: Used by -partition-all-in-steps and -partition-in-steps.\"\n (when (< step 1)\n (error \"Step must be a positive number, or you're looking at some juicy infinite loops.\"))\n (let ((result nil))\n (while list\n (!cons (-take n list) result)\n (setq list (-drop step list)))\n result))\n\n(defun -partition-all-in-steps (n step list)\n \"Return a new list with the items in LIST grouped into N-sized sublists at offsets STEP apart.\nThe last groups may contain less than N items.\"\n (declare (pure t) (side-effect-free t))\n (nreverse (---partition-all-in-steps-reversed n step list)))\n\n(defun -partition-in-steps (n step list)\n \"Return a new list with the items in LIST grouped into N-sized sublists at offsets STEP apart.\nIf there are not enough items to make the last group N-sized,\nthose items are discarded.\"\n (declare (pure t) (side-effect-free t))\n (let ((result (---partition-all-in-steps-reversed n step list)))\n (while (and result (< (length (car result)) n))\n (!cdr result))\n (nreverse result)))\n\n(defun -partition-all (n list)\n \"Return a new list with the items in LIST grouped into N-sized sublists.\nThe last group may contain less than N items.\"\n (declare (pure t) (side-effect-free t))\n (-partition-all-in-steps n n list))\n\n(defun -partition (n list)\n \"Return a new list with the items in LIST grouped into N-sized sublists.\nIf there are not enough items to make the last group N-sized,\nthose items are discarded.\"\n (declare (pure t) (side-effect-free t))\n (-partition-in-steps n n list))\n\n(defmacro --partition-by (form list)\n \"Anaphoric form of `-partition-by'.\"\n (declare (debug (form form)))\n (let ((r (make-symbol \"result\"))\n (s (make-symbol \"sublist\"))\n (v (make-symbol \"value\"))\n (n (make-symbol \"new-value\"))\n (l (make-symbol \"list\")))\n `(let ((,l ,list))\n (when ,l\n (let* ((,r nil)\n (it (car ,l))\n (,s (list it))\n (,v ,form)\n (,l (cdr ,l)))\n (while ,l\n (let* ((it (car ,l))\n (,n ,form))\n (unless (equal ,v ,n)\n (!cons (nreverse ,s) ,r)\n (setq ,s nil)\n (setq ,v ,n))\n (!cons it ,s)\n (!cdr ,l)))\n (!cons (nreverse ,s) ,r)\n (nreverse ,r))))))\n\n(defun -partition-by (fn list)\n \"Apply FN to each item in LIST, splitting it each time FN returns a new value.\"\n (--partition-by (funcall fn it) list))\n\n(defmacro --partition-by-header (form list)\n \"Anaphoric form of `-partition-by-header'.\"\n (declare (debug (form form)))\n (let ((r (make-symbol \"result\"))\n (s (make-symbol \"sublist\"))\n (h (make-symbol \"header-value\"))\n (b (make-symbol \"seen-body?\"))\n (n (make-symbol \"new-value\"))\n (l (make-symbol \"list\")))\n `(let ((,l ,list))\n (when ,l\n (let* ((,r nil)\n (it (car ,l))\n (,s (list it))\n (,h ,form)\n (,b nil)\n (,l (cdr ,l)))\n (while ,l\n (let* ((it (car ,l))\n (,n ,form))\n (if (equal ,h ,n)\n (when ,b\n (!cons (nreverse ,s) ,r)\n (setq ,s nil)\n (setq ,b nil))\n (setq ,b t))\n (!cons it ,s)\n (!cdr ,l)))\n (!cons (nreverse ,s) ,r)\n (nreverse ,r))))))\n\n(defun -partition-by-header (fn list)\n \"Apply FN to the first item in LIST. That is the header\nvalue. Apply FN to each item in LIST, splitting it each time FN\nreturns the header value, but only after seeing at least one\nother value (the body).\"\n (--partition-by-header (funcall fn it) list))\n\n(defun -partition-after-pred (pred list)\n \"Partition directly after each time PRED is true on an element of LIST.\"\n (when list\n (let ((rest (-partition-after-pred pred\n (cdr list))))\n (if (funcall pred (car list))\n ;;split after (car list)\n (cons (list (car list))\n rest)\n\n ;;don't split after (car list)\n (cons (cons (car list)\n (car rest))\n (cdr rest))))))\n\n(defun -partition-before-pred (pred list)\n \"Partition directly before each time PRED is true on an element of LIST.\"\n (nreverse (-map #'reverse\n (-partition-after-pred pred (reverse list)))))\n\n(defun -partition-after-item (item list)\n \"Partition directly after each time ITEM appears in LIST.\"\n (-partition-after-pred (lambda (ele) (equal ele item))\n list))\n\n(defun -partition-before-item (item list)\n \"Partition directly before each time ITEM appears in LIST.\"\n (-partition-before-pred (lambda (ele) (equal ele item))\n list))\n\n(defmacro --group-by (form list)\n \"Anaphoric form of `-group-by'.\"\n (declare (debug t))\n (let ((n (make-symbol \"n\"))\n (k (make-symbol \"k\"))\n (grp (make-symbol \"grp\")))\n `(nreverse\n (-map\n (lambda (,n)\n (cons (car ,n)\n (nreverse (cdr ,n))))\n (--reduce-from\n (let* ((,k (,@form))\n (,grp (assoc ,k acc)))\n (if ,grp\n (setcdr ,grp (cons it (cdr ,grp)))\n (push\n (list ,k it)\n acc))\n acc)\n nil ,list)))))\n\n(defun -group-by (fn list)\n \"Separate LIST into an alist whose keys are FN applied to the\nelements of LIST. Keys are compared by `equal'.\"\n (--group-by (funcall fn it) list))\n\n(defun -interpose (sep list)\n \"Return a new list of all elements in LIST separated by SEP.\"\n (declare (pure t) (side-effect-free t))\n (let (result)\n (when list\n (!cons (car list) result)\n (!cdr list))\n (while list\n (setq result (cons (car list) (cons sep result)))\n (!cdr list))\n (nreverse result)))\n\n(defun -interleave (&rest lists)\n \"Return a new list of the first item in each list, then the second etc.\"\n (declare (pure t) (side-effect-free t))\n (when lists\n (let (result)\n (while (-none? 'null lists)\n (--each lists (!cons (car it) result))\n (setq lists (-map 'cdr lists)))\n (nreverse result))))\n\n(defmacro --zip-with (form list1 list2)\n \"Anaphoric form of `-zip-with'.\n\nThe elements in list1 are bound as symbol `it', the elements in list2 as symbol `other'.\"\n (declare (debug (form form form)))\n (let ((r (make-symbol \"result\"))\n (l1 (make-symbol \"list1\"))\n (l2 (make-symbol \"list2\")))\n `(let ((,r nil)\n (,l1 ,list1)\n (,l2 ,list2))\n (while (and ,l1 ,l2)\n (let ((it (car ,l1))\n (other (car ,l2)))\n (!cons ,form ,r)\n (!cdr ,l1)\n (!cdr ,l2)))\n (nreverse ,r))))\n\n(defun -zip-with (fn list1 list2)\n \"Zip the two lists LIST1 and LIST2 using a function FN. This\nfunction is applied pairwise taking as first argument element of\nLIST1 and as second argument element of LIST2 at corresponding\nposition.\n\nThe anaphoric form `--zip-with' binds the elements from LIST1 as symbol `it',\nand the elements from LIST2 as symbol `other'.\"\n (--zip-with (funcall fn it other) list1 list2))\n\n(defun -zip (&rest lists)\n \"Zip LISTS together. Group the head of each list, followed by the\nsecond elements of each list, and so on. The lengths of the returned\ngroupings are equal to the length of the shortest input list.\n\nIf two lists are provided as arguments, return the groupings as a list\nof cons cells. Otherwise, return the groupings as a list of lists.\n\nPlease note! This distinction is being removed in an upcoming 3.0\nrelease of Dash. If you rely on this behavior, use -zip-pair instead.\"\n (declare (pure t) (side-effect-free t))\n (when lists\n (let (results)\n (while (-none? 'null lists)\n (setq results (cons (mapcar 'car lists) results))\n (setq lists (mapcar 'cdr lists)))\n (setq results (nreverse results))\n (if (= (length lists) 2)\n ;; to support backward compatability, return\n ;; a cons cell if two lists were provided\n (--map (cons (car it) (cadr it)) results)\n results))))\n\n(defalias '-zip-pair '-zip)\n\n(defun -zip-fill (fill-value &rest lists)\n \"Zip LISTS, with FILL-VALUE padded onto the shorter lists. The\nlengths of the returned groupings are equal to the length of the\nlongest input list.\"\n (declare (pure t) (side-effect-free t))\n (apply '-zip (apply '-pad (cons fill-value lists))))\n\n(defun -unzip (lists)\n \"Unzip LISTS.\n\nThis works just like `-zip' but takes a list of lists instead of\na variable number of arguments, such that\n\n (-unzip (-zip L1 L2 L3 ...))\n\nis identity (given that the lists are the same length).\n\nSee also: `-zip'\"\n (apply '-zip lists))\n\n(defun -cycle (list)\n \"Return an infinite copy of LIST that will cycle through the\nelements and repeat from the beginning.\"\n (declare (pure t) (side-effect-free t))\n (let ((newlist (-map 'identity list)))\n (nconc newlist newlist)))\n\n(defun -pad (fill-value &rest lists)\n \"Appends FILL-VALUE to the end of each list in LISTS such that they\nwill all have the same length.\"\n (let* ((annotations (-annotate 'length lists))\n (n (-max (-map 'car annotations))))\n (--map (append (cdr it) (-repeat (- n (car it)) fill-value)) annotations)))\n\n(defun -annotate (fn list)\n \"Return a list of cons cells where each cell is FN applied to each\nelement of LIST paired with the unmodified element of LIST.\"\n (-zip (-map fn list) list))\n\n(defmacro --annotate (form list)\n \"Anaphoric version of `-annotate'.\"\n (declare (debug (form form)))\n `(-annotate (lambda (it) ,form) ,list))\n\n(defun dash--table-carry (lists restore-lists &optional re)\n \"Helper for `-table' and `-table-flat'.\n\nIf a list overflows, carry to the right and reset the list.\"\n (while (not (or (car lists)\n (equal lists '(nil))))\n (setcar lists (car restore-lists))\n (pop (cadr lists))\n (!cdr lists)\n (!cdr restore-lists)\n (when re\n (push (nreverse (car re)) (cadr re))\n (setcar re nil)\n (!cdr re))))\n\n(defun -table (fn &rest lists)\n \"Compute outer product of LISTS using function FN.\n\nThe function FN should have the same arity as the number of\nsupplied lists.\n\nThe outer product is computed by applying fn to all possible\ncombinations created by taking one element from each list in\norder. The dimension of the result is (length lists).\n\nSee also: `-table-flat'\"\n (let ((restore-lists (copy-sequence lists))\n (last-list (last lists))\n (re (make-list (length lists) nil)))\n (while (car last-list)\n (let ((item (apply fn (-map 'car lists))))\n (push item (car re))\n (setcar lists (cdar lists)) ;; silence byte compiler\n (dash--table-carry lists restore-lists re)))\n (nreverse (car (last re)))))\n\n(defun -table-flat (fn &rest lists)\n \"Compute flat outer product of LISTS using function FN.\n\nThe function FN should have the same arity as the number of\nsupplied lists.\n\nThe outer product is computed by applying fn to all possible\ncombinations created by taking one element from each list in\norder. The results are flattened, ignoring the tensor structure\nof the result. This is equivalent to calling:\n\n (-flatten-n (1- (length lists)) (apply \\\\='-table fn lists))\n\nbut the implementation here is much more efficient.\n\nSee also: `-flatten-n', `-table'\"\n (let ((restore-lists (copy-sequence lists))\n (last-list (last lists))\n re)\n (while (car last-list)\n (let ((item (apply fn (-map 'car lists))))\n (push item re)\n (setcar lists (cdar lists)) ;; silence byte compiler\n (dash--table-carry lists restore-lists)))\n (nreverse re)))\n\n(defun -partial (fn &rest args)\n \"Take a function FN and fewer than the normal arguments to FN,\nand return a fn that takes a variable number of additional ARGS.\nWhen called, the returned function calls FN with ARGS first and\nthen additional args.\"\n (apply 'apply-partially fn args))\n\n(defun -elem-index (elem list)\n \"Return the index of the first element in the given LIST which\nis equal to the query element ELEM, or nil if there is no\nsuch element.\"\n (declare (pure t) (side-effect-free t))\n (car (-elem-indices elem list)))\n\n(defun -elem-indices (elem list)\n \"Return the indices of all elements in LIST equal to the query\nelement ELEM, in ascending order.\"\n (declare (pure t) (side-effect-free t))\n (-find-indices (-partial 'equal elem) list))\n\n(defun -find-indices (pred list)\n \"Return the indices of all elements in LIST satisfying the\npredicate PRED, in ascending order.\"\n (apply 'append (--map-indexed (when (funcall pred it) (list it-index)) list)))\n\n(defmacro --find-indices (form list)\n \"Anaphoric version of `-find-indices'.\"\n (declare (debug (form form)))\n `(-find-indices (lambda (it) ,form) ,list))\n\n(defun -find-index (pred list)\n \"Take a predicate PRED and a LIST and return the index of the\nfirst element in the list satisfying the predicate, or nil if\nthere is no such element.\n\nSee also `-first'.\"\n (car (-find-indices pred list)))\n\n(defmacro --find-index (form list)\n \"Anaphoric version of `-find-index'.\"\n (declare (debug (form form)))\n `(-find-index (lambda (it) ,form) ,list))\n\n(defun -find-last-index (pred list)\n \"Take a predicate PRED and a LIST and return the index of the\nlast element in the list satisfying the predicate, or nil if\nthere is no such element.\n\nSee also `-last'.\"\n (-last-item (-find-indices pred list)))\n\n(defmacro --find-last-index (form list)\n \"Anaphoric version of `-find-last-index'.\"\n `(-find-last-index (lambda (it) ,form) ,list))\n\n(defun -select-by-indices (indices list)\n \"Return a list whose elements are elements from LIST selected\nas `(nth i list)` for all i from INDICES.\"\n (declare (pure t) (side-effect-free t))\n (let (r)\n (--each indices\n (!cons (nth it list) r))\n (nreverse r)))\n\n(defun -select-columns (columns table)\n \"Select COLUMNS from TABLE.\n\nTABLE is a list of lists where each element represents one row.\nIt is assumed each row has the same length.\n\nEach row is transformed such that only the specified COLUMNS are\nselected.\n\nSee also: `-select-column', `-select-by-indices'\"\n (declare (pure t) (side-effect-free t))\n (--map (-select-by-indices columns it) table))\n\n(defun -select-column (column table)\n \"Select COLUMN from TABLE.\n\nTABLE is a list of lists where each element represents one row.\nIt is assumed each row has the same length.\n\nThe single selected column is returned as a list.\n\nSee also: `-select-columns', `-select-by-indices'\"\n (declare (pure t) (side-effect-free t))\n (--mapcat (-select-by-indices (list column) it) table))\n\n(defmacro -> (x &optional form &rest more)\n \"Thread the expr through the forms. Insert X as the second item\nin the first form, making a list of it if it is not a list\nalready. If there are more forms, insert the first form as the\nsecond item in second form, etc.\"\n (declare (debug (form &rest [&or symbolp (sexp &rest form)])))\n (cond\n ((null form) x)\n ((null more) (if (listp form)\n `(,(car form) ,x ,@(cdr form))\n (list form x)))\n (:else `(-> (-> ,x ,form) ,@more))))\n\n(defmacro ->> (x &optional form &rest more)\n \"Thread the expr through the forms. Insert X as the last item\nin the first form, making a list of it if it is not a list\nalready. If there are more forms, insert the first form as the\nlast item in second form, etc.\"\n (declare (debug ->))\n (cond\n ((null form) x)\n ((null more) (if (listp form)\n `(,@form ,x)\n (list form x)))\n (:else `(->> (->> ,x ,form) ,@more))))\n\n(defmacro --> (x &rest forms)\n \"Starting with the value of X, thread each expression through FORMS.\n\nInsert X at the position signified by the symbol `it' in the first\nform. If there are more forms, insert the first form at the position\nsignified by `it' in in second form, etc.\"\n (declare (debug (form body)))\n `(-as-> ,x it ,@forms))\n\n(defmacro -as-> (value variable &rest forms)\n \"Starting with VALUE, thread VARIABLE through FORMS.\n\nIn the first form, bind VARIABLE to VALUE. In the second form, bind\nVARIABLE to the result of the first form, and so forth.\"\n (declare (debug (form symbolp body)))\n (if (null forms)\n `,value\n `(let ((,variable ,value))\n (-as-> ,(if (symbolp (car forms))\n (list (car forms) variable)\n (car forms))\n ,variable\n ,@(cdr forms)))))\n\n(defmacro -some-> (x &optional form &rest more)\n \"When expr is non-nil, thread it through the first form (via `->'),\nand when that result is non-nil, through the next form, etc.\"\n (declare (debug ->))\n (if (null form) x\n (let ((result (make-symbol \"result\")))\n `(-some-> (-when-let (,result ,x)\n (-> ,result ,form))\n ,@more))))\n\n(defmacro -some->> (x &optional form &rest more)\n \"When expr is non-nil, thread it through the first form (via `->>'),\nand when that result is non-nil, through the next form, etc.\"\n (declare (debug ->))\n (if (null form) x\n (let ((result (make-symbol \"result\")))\n `(-some->> (-when-let (,result ,x)\n (->> ,result ,form))\n ,@more))))\n\n(defmacro -some--> (x &optional form &rest more)\n \"When expr in non-nil, thread it through the first form (via `-->'),\nand when that result is non-nil, through the next form, etc.\"\n (declare (debug ->))\n (if (null form) x\n (let ((result (make-symbol \"result\")))\n `(-some--> (-when-let (,result ,x)\n (--> ,result ,form))\n ,@more))))\n\n(defun -grade-up (comparator list)\n \"Grade elements of LIST using COMPARATOR relation, yielding a\npermutation vector such that applying this permutation to LIST\nsorts it in ascending order.\"\n ;; ugly hack to \"fix\" lack of lexical scope\n (let ((comp `(lambda (it other) (funcall ',comparator (car it) (car other)))))\n (->> (--map-indexed (cons it it-index) list)\n (-sort comp)\n (-map 'cdr))))\n\n(defun -grade-down (comparator list)\n \"Grade elements of LIST using COMPARATOR relation, yielding a\npermutation vector such that applying this permutation to LIST\nsorts it in descending order.\"\n ;; ugly hack to \"fix\" lack of lexical scope\n (let ((comp `(lambda (it other) (funcall ',comparator (car other) (car it)))))\n (->> (--map-indexed (cons it it-index) list)\n (-sort comp)\n (-map 'cdr))))\n\n(defvar dash--source-counter 0\n \"Monotonic counter for generated symbols.\")\n\n(defun dash--match-make-source-symbol ()\n \"Generate a new dash-source symbol.\n\nAll returned symbols are guaranteed to be unique.\"\n (prog1 (make-symbol (format \"--dash-source-%d--\" dash--source-counter))\n (setq dash--source-counter (1+ dash--source-counter))))\n\n(defun dash--match-ignore-place-p (symbol)\n \"Return non-nil if SYMBOL is a symbol and starts with _.\"\n (and (symbolp symbol)\n (eq (aref (symbol-name symbol) 0) ?_)))\n\n(defun dash--match-cons-skip-cdr (skip-cdr source)\n \"Helper function generating idiomatic shifting code.\"\n (cond\n ((= skip-cdr 0)\n `(pop ,source))\n (t\n `(prog1 ,(dash--match-cons-get-car skip-cdr source)\n (setq ,source ,(dash--match-cons-get-cdr (1+ skip-cdr) source))))))\n\n(defun dash--match-cons-get-car (skip-cdr source)\n \"Helper function generating idiomatic code to get nth car.\"\n (cond\n ((= skip-cdr 0)\n `(car ,source))\n ((= skip-cdr 1)\n `(cadr ,source))\n (t\n `(nth ,skip-cdr ,source))))\n\n(defun dash--match-cons-get-cdr (skip-cdr source)\n \"Helper function generating idiomatic code to get nth cdr.\"\n (cond\n ((= skip-cdr 0)\n source)\n ((= skip-cdr 1)\n `(cdr ,source))\n (t\n `(nthcdr ,skip-cdr ,source))))\n\n(defun dash--match-cons (match-form source)\n \"Setup a cons matching environment and call the real matcher.\"\n (let ((s (dash--match-make-source-symbol))\n (n 0)\n (m match-form))\n (while (and (consp m)\n (dash--match-ignore-place-p (car m)))\n (setq n (1+ n)) (!cdr m))\n (cond\n ;; when we only have one pattern in the list, we don't have to\n ;; create a temporary binding (--dash-source--) for the source\n ;; and just use the input directly\n ((and (consp m)\n (not (cdr m)))\n (dash--match (car m) (dash--match-cons-get-car n source)))\n ;; handle other special types\n ((> n 0)\n (dash--match m (dash--match-cons-get-cdr n source)))\n ;; this is the only entry-point for dash--match-cons-1, that's\n ;; why we can't simply use the above branch, it would produce\n ;; infinite recursion\n (t\n (cons (list s source) (dash--match-cons-1 match-form s))))))\n\n(defun dash--match-cons-1 (match-form source &optional props)\n \"Match MATCH-FORM against SOURCE.\n\nMATCH-FORM is a proper or improper list. Each element of\nMATCH-FORM is either a symbol, which gets bound to the respective\nvalue in source or another match form which gets destructured\nrecursively.\n\nIf the cdr of last cons cell in the list is `nil', matching stops\nthere.\n\nSOURCE is a proper or improper list.\"\n (let ((skip-cdr (or (plist-get props :skip-cdr) 0)))\n (cond\n ((consp match-form)\n (cond\n ((cdr match-form)\n (cond\n ((and (symbolp (car match-form))\n (memq (car match-form) '(&keys &plist &alist &hash)))\n (dash--match-kv (dash--match-kv-normalize-match-form match-form) (dash--match-cons-get-cdr skip-cdr source)))\n ((dash--match-ignore-place-p (car match-form))\n (dash--match-cons-1 (cdr match-form) source\n (plist-put props :skip-cdr (1+ skip-cdr))))\n (t\n (-concat (dash--match (car match-form) (dash--match-cons-skip-cdr skip-cdr source))\n (dash--match-cons-1 (cdr match-form) source)))))\n (t ;; Last matching place, no need for shift\n (dash--match (car match-form) (dash--match-cons-get-car skip-cdr source)))))\n ((eq match-form nil)\n nil)\n (t ;; Handle improper lists. Last matching place, no need for shift\n (dash--match match-form (dash--match-cons-get-cdr skip-cdr source))))))\n\n(defun dash--vector-tail (seq start)\n \"Return the tail of SEQ starting at START.\"\n (cond\n ((vectorp seq)\n (let* ((re-length (- (length seq) start))\n (re (make-vector re-length 0)))\n (--dotimes re-length (aset re it (aref seq (+ it start))))\n re))\n ((stringp seq)\n (substring seq start))))\n\n(defun dash--match-vector (match-form source)\n \"Setup a vector matching environment and call the real matcher.\"\n (let ((s (dash--match-make-source-symbol)))\n (cond\n ;; don't bind `s' if we only have one sub-pattern\n ((= (length match-form) 1)\n (dash--match (aref match-form 0) `(aref ,source 0)))\n ;; if the source is a symbol, we don't need to re-bind it\n ((symbolp source)\n (dash--match-vector-1 match-form source))\n ;; don't bind `s' if we only have one sub-pattern which is not ignored\n ((let* ((ignored-places (mapcar 'dash--match-ignore-place-p match-form))\n (ignored-places-n (length (-remove 'null ignored-places))))\n (when (= ignored-places-n (1- (length match-form)))\n (let ((n (-find-index 'null ignored-places)))\n (dash--match (aref match-form n) `(aref ,source ,n))))))\n (t\n (cons (list s source) (dash--match-vector-1 match-form s))))))\n\n(defun dash--match-vector-1 (match-form source)\n \"Match MATCH-FORM against SOURCE.\n\nMATCH-FORM is a vector. Each element of MATCH-FORM is either a\nsymbol, which gets bound to the respective value in source or\nanother match form which gets destructured recursively.\n\nIf second-from-last place in MATCH-FORM is the symbol &rest, the\nnext element of the MATCH-FORM is matched against the tail of\nSOURCE, starting at index of the &rest symbol. This is\nconceptually the same as the (head . tail) match for improper\nlists, where dot plays the role of &rest.\n\nSOURCE is a vector.\n\nIf the MATCH-FORM vector is shorter than SOURCE vector, only\nthe (length MATCH-FORM) places are bound, the rest of the SOURCE\nis discarded.\"\n (let ((i 0)\n (l (length match-form))\n (re))\n (while (< i l)\n (let ((m (aref match-form i)))\n (push (cond\n ((and (symbolp m)\n (eq m '&rest))\n (prog1 (dash--match\n (aref match-form (1+ i))\n `(dash--vector-tail ,source ,i))\n (setq i l)))\n ((and (symbolp m)\n ;; do not match symbols starting with _\n (not (eq (aref (symbol-name m) 0) ?_)))\n (list (list m `(aref ,source ,i))))\n ((not (symbolp m))\n (dash--match m `(aref ,source ,i))))\n re)\n (setq i (1+ i))))\n (-flatten-n 1 (nreverse re))))\n\n(defun dash--match-kv-normalize-match-form (pattern)\n \"Normalize kv PATTERN.\n\nThis method normalizes PATTERN to the format expected by\n`dash--match-kv'. See `-let' for the specification.\"\n (let ((normalized (list (car pattern)))\n (skip nil)\n (fill-placeholder (make-symbol \"--dash-fill-placeholder--\")))\n (-each (apply '-zip (-pad fill-placeholder (cdr pattern) (cddr pattern)))\n (lambda (pair)\n (let ((current (car pair))\n (next (cdr pair)))\n (if skip\n (setq skip nil)\n (if (or (eq fill-placeholder next)\n (not (or (and (symbolp next)\n (not (keywordp next))\n (not (eq next t))\n (not (eq next nil)))\n (and (consp next)\n (not (eq (car next) 'quote)))\n (vectorp next))))\n (progn\n (cond\n ((keywordp current)\n (push current normalized)\n (push (intern (substring (symbol-name current) 1)) normalized))\n ((stringp current)\n (push current normalized)\n (push (intern current) normalized))\n ((and (consp current)\n (eq (car current) 'quote))\n (push current normalized)\n (push (cadr current) normalized))\n (t (error \"-let: found key `%s' in kv destructuring but its pattern `%s' is invalid and can not be derived from the key\" current next)))\n (setq skip nil))\n (push current normalized)\n (push next normalized)\n (setq skip t))))))\n (nreverse normalized)))\n\n(defun dash--match-kv (match-form source)\n \"Setup a kv matching environment and call the real matcher.\n\nkv can be any key-value store, such as plist, alist or hash-table.\"\n (let ((s (dash--match-make-source-symbol)))\n (cond\n ;; don't bind `s' if we only have one sub-pattern (&type key val)\n ((= (length match-form) 3)\n (dash--match-kv-1 (cdr match-form) source (car match-form)))\n ;; if the source is a symbol, we don't need to re-bind it\n ((symbolp source)\n (dash--match-kv-1 (cdr match-form) source (car match-form)))\n (t\n (cons (list s source) (dash--match-kv-1 (cdr match-form) s (car match-form)))))))\n\n(defun dash--match-kv-1 (match-form source type)\n \"Match MATCH-FORM against SOURCE of type TYPE.\n\nMATCH-FORM is a proper list of the form (key1 place1 ... keyN\nplaceN). Each placeK is either a symbol, which gets bound to the\nvalue of keyK retrieved from the key-value store, or another\nmatch form which gets destructured recursively.\n\nSOURCE is a key-value store of type TYPE, which can be a plist,\nan alist or a hash table.\n\nTYPE is a token specifying the type of the key-value store.\nValid values are &plist, &alist and &hash.\"\n (-flatten-n 1 (-map\n (lambda (kv)\n (let* ((k (car kv))\n (v (cadr kv))\n (getter (cond\n ((or (eq type '&plist) (eq type '&keys))\n `(plist-get ,source ,k))\n ((eq type '&alist)\n `(cdr (assoc ,k ,source)))\n ((eq type '&hash)\n `(gethash ,k ,source)))))\n (cond\n ((symbolp v)\n (list (list v getter)))\n (t (dash--match v getter)))))\n (-partition 2 match-form))))\n\n(defun dash--match-symbol (match-form source)\n \"Bind a symbol.\n\nThis works just like `let', there is no destructuring.\"\n (list (list match-form source)))\n\n(defun dash--match (match-form source)\n \"Match MATCH-FORM against SOURCE.\n\nThis function tests the MATCH-FORM and dispatches to specific\nmatchers based on the type of the expression.\n\nKey-value stores are disambiguated by placing a token &plist,\n&alist or &hash as a first item in the MATCH-FORM.\"\n (cond\n ((symbolp match-form)\n (dash--match-symbol match-form source))\n ((consp match-form)\n (cond\n ;; Handle the \"x &as\" bindings first.\n ((and (consp (cdr match-form))\n (symbolp (car match-form))\n (eq '&as (cadr match-form)))\n (let ((s (car match-form)))\n (cons (list s source)\n (dash--match (cddr match-form) s))))\n ((memq (car match-form) '(&keys &plist &alist &hash))\n (dash--match-kv (dash--match-kv-normalize-match-form match-form) source))\n (t (dash--match-cons match-form source))))\n ((vectorp match-form)\n ;; We support the &as binding in vectors too\n (cond\n ((and (> (length match-form) 2)\n (symbolp (aref match-form 0))\n (eq '&as (aref match-form 1)))\n (let ((s (aref match-form 0)))\n (cons (list s source)\n (dash--match (dash--vector-tail match-form 2) s))))\n (t (dash--match-vector match-form source))))))\n\n(defun dash--normalize-let-varlist (varlist)\n \"Normalize VARLIST so that every binding is a list.\n\n`let' allows specifying a binding which is not a list but simply\nthe place which is then automatically bound to nil, such that all\nthree of the following are identical and evaluate to nil.\n\n (let (a) a)\n (let ((a)) a)\n (let ((a nil)) a)\n\nThis function normalizes all of these to the last form.\"\n (--map (if (consp it) it (list it nil)) varlist))\n\n(defmacro -let* (varlist &rest body)\n \"Bind variables according to VARLIST then eval BODY.\n\nVARLIST is a list of lists of the form (PATTERN SOURCE). Each\nPATTERN is matched against the SOURCE structurally. SOURCE is\nonly evaluated once for each PATTERN.\n\nEach SOURCE can refer to the symbols already bound by this\nVARLIST. This is useful if you want to destructure SOURCE\nrecursively but also want to name the intermediate structures.\n\nSee `-let' for the list of all possible patterns.\"\n (declare (debug ((&rest [&or (sexp form) sexp]) body))\n (indent 1))\n (let* ((varlist (dash--normalize-let-varlist varlist))\n (bindings (--mapcat (dash--match (car it) (cadr it)) varlist)))\n `(let* ,bindings\n ,@body)))\n\n(defmacro -let (varlist &rest body)\n \"Bind variables according to VARLIST then eval BODY.\n\nVARLIST is a list of lists of the form (PATTERN SOURCE). Each\nPATTERN is matched against the SOURCE \\\"structurally\\\". SOURCE\nis only evaluated once for each PATTERN. Each PATTERN is matched\nrecursively, and can therefore contain sub-patterns which are\nmatched against corresponding sub-expressions of SOURCE.\n\nAll the SOURCEs are evalled before any symbols are\nbound (i.e. \\\"in parallel\\\").\n\nIf VARLIST only contains one (PATTERN SOURCE) element, you can\noptionally specify it using a vector and discarding the\nouter-most parens. Thus\n\n (-let ((PATTERN SOURCE)) ..)\n\nbecomes\n\n (-let [PATTERN SOURCE] ..).\n\n`-let' uses a convention of not binding places (symbols) starting\nwith _ whenever it's possible. You can use this to skip over\nentries you don't care about. However, this is not *always*\npossible (as a result of implementation) and these symbols might\nget bound to undefined values.\n\nFollowing is the overview of supported patterns. Remember that\npatterns can be matched recursively, so every a, b, aK in the\nfollowing can be a matching construct and not necessarily a\nsymbol\/variable.\n\nSymbol:\n\n a - bind the SOURCE to A. This is just like regular `let'.\n\nConses and lists:\n\n (a) - bind `car' of cons\/list to A\n\n (a . b) - bind car of cons to A and `cdr' to B\n\n (a b) - bind car of list to A and `cadr' to B\n\n (a1 a2 a3 ...) - bind 0th car of list to A1, 1st to A2, 2nd to A3 ...\n\n (a1 a2 a3 ... aN . rest) - as above, but bind the Nth cdr to REST.\n\nVectors:\n\n [a] - bind 0th element of a non-list sequence to A (works with\n vectors, strings, bit arrays...)\n\n [a1 a2 a3 ...] - bind 0th element of non-list sequence to A0, 1st to\n A1, 2nd to A2, ...\n If the PATTERN is shorter than SOURCE, the values at\n places not in PATTERN are ignored.\n If the PATTERN is longer than SOURCE, an `error' is\n thrown.\n\n [a1 a2 a3 ... &rest rest] - as above, but bind the rest of\n the sequence to REST. This is\n conceptually the same as improper list\n matching (a1 a2 ... aN . rest)\n\nKey\/value stores:\n\n (&plist key0 a0 ... keyN aN) - bind value mapped by keyK in the\n SOURCE plist to aK. If the\n value is not found, aK is nil.\n Uses `plist-get' to fetch values.\n\n (&alist key0 a0 ... keyN aN) - bind value mapped by keyK in the\n SOURCE alist to aK. If the\n value is not found, aK is nil.\n Uses `assoc' to fetch values.\n\n (&hash key0 a0 ... keyN aN) - bind value mapped by keyK in the\n SOURCE hash table to aK. If the\n value is not found, aK is nil.\n Uses `gethash' to fetch values.\n\nFurther, special keyword &keys supports \\\"inline\\\" matching of\nplist-like key-value pairs, similarly to &keys keyword of\n`cl-defun'.\n\n (a1 a2 ... aN &keys key1 b1 ... keyN bK)\n\nThis binds N values from the list to a1 ... aN, then interprets\nthe cdr as a plist (see key\/value matching above).\n\nA shorthand notation for kv-destructuring exists which allows the\npatterns be optionally left out and derived from the key name in\nthe following fashion:\n\n- a key :foo is converted into `foo' pattern,\n- a key 'bar is converted into `bar' pattern,\n- a key \\\"baz\\\" is converted into `baz' pattern.\n\nThat is, the entire value under the key is bound to the derived\nvariable without any further destructuring.\n\nThis is possible only when the form following the key is not a\nvalid pattern (i.e. not a symbol, a cons cell or a vector).\nOtherwise the matching proceeds as usual and in case of an\ninvalid spec fails with an error.\n\nThus the patterns are normalized as follows:\n\n ;; derive all the missing patterns\n (&plist :foo 'bar \\\"baz\\\") => (&plist :foo foo 'bar bar \\\"baz\\\" baz)\n\n ;; we can specify some but not others\n (&plist :foo 'bar explicit-bar) => (&plist :foo foo 'bar explicit-bar)\n\n ;; nothing happens, we store :foo in x\n (&plist :foo x) => (&plist :foo x)\n\n ;; nothing happens, we match recursively\n (&plist :foo (a b c)) => (&plist :foo (a b c))\n\nYou can name the source using the syntax SYMBOL &as PATTERN.\nThis syntax works with lists (proper or improper), vectors and\nall types of maps.\n\n (list &as a b c) (list 1 2 3)\n\nbinds A to 1, B to 2, C to 3 and LIST to (1 2 3).\n\nSimilarly:\n\n (bounds &as beg . end) (cons 1 2)\n\nbinds BEG to 1, END to 2 and BOUNDS to (1 . 2).\n\n (items &as first . rest) (list 1 2 3)\n\nbinds FIRST to 1, REST to (2 3) and ITEMS to (1 2 3)\n\n [vect &as _ b c] [1 2 3]\n\nbinds B to 2, C to 3 and VECT to [1 2 3] (_ avoids binding as usual).\n\n (plist &as &plist :b b) (list :a 1 :b 2 :c 3)\n\nbinds B to 2 and PLIST to (:a 1 :b 2 :c 3). Same for &alist and &hash.\n\nThis is especially useful when we want to capture the result of a\ncomputation and destructure at the same time. Consider the\nform (function-returning-complex-structure) returning a list of\ntwo vectors with two items each. We want to capture this entire\nresult and pass it to another computation, but at the same time\nwe want to get the second item from each vector. We can achieve\nit with pattern\n\n (result &as [_ a] [_ b]) (function-returning-complex-structure)\n\nNote: Clojure programmers may know this feature as the \\\":as\nbinding\\\". The difference is that we put the &as at the front\nbecause we need to support improper list binding.\"\n (declare (debug ([&or (&rest [&or (sexp form) sexp])\n (vector [&rest [sexp form]])]\n body))\n (indent 1))\n (if (vectorp varlist)\n `(let* ,(dash--match (aref varlist 0) (aref varlist 1))\n ,@body)\n (let* ((varlist (dash--normalize-let-varlist varlist))\n (inputs (--map-indexed (list (make-symbol (format \"input%d\" it-index)) (cadr it)) varlist))\n (new-varlist (--map (list (caar it) (cadr it)) (-zip varlist inputs))))\n `(let ,inputs\n (-let* ,new-varlist ,@body)))))\n\n(defmacro -lambda (match-form &rest body)\n \"Return a lambda which destructures its input as MATCH-FORM and executes BODY.\n\nNote that you have to enclose the MATCH-FORM in a pair of parens,\nsuch that:\n\n (-lambda (x) body)\n (-lambda (x y ...) body)\n\nhas the usual semantics of `lambda'. Furthermore, these get\ntranslated into normal lambda, so there is no performance\npenalty.\n\nSee `-let' for the description of destructuring mechanism.\"\n (declare (doc-string 2) (indent defun)\n (debug (&define sexp\n [&optional stringp]\n [&optional (\"interactive\" interactive)]\n def-body)))\n (cond\n ((not (consp match-form))\n (signal 'wrong-type-argument \"match-form must be a list\"))\n ;; no destructuring, so just return regular lambda to make things faster\n ((-all? 'symbolp match-form)\n `(lambda ,match-form ,@body))\n (t\n (let* ((inputs (--map-indexed (list it (make-symbol (format \"input%d\" it-index))) match-form)))\n ;; TODO: because inputs to the lambda are evaluated only once,\n ;; -let* need not to create the extra bindings to ensure that.\n ;; We should find a way to optimize that. Not critical however.\n `(lambda ,(--map (cadr it) inputs)\n (-let* ,inputs ,@body))))))\n\n(defmacro -setq (&rest forms)\n \"Bind each MATCH-FORM to the value of its VAL.\n\nMATCH-FORM destructuring is done according to the rules of `-let'.\n\nThis macro allows you to bind multiple variables by destructuring\nthe value, so for example:\n\n (-setq (a b) x\n (&plist :c c) plist)\n\nexpands roughly speaking to the following code\n\n (setq a (car x)\n b (cadr x)\n c (plist-get plist :c))\n\nCare is taken to only evaluate each VAL once so that in case of\nmultiple assignments it does not cause unexpected side effects.\n\n\\(fn [MATCH-FORM VAL]...)\"\n (declare (debug (&rest sexp form))\n (indent 1))\n (when (= (mod (length forms) 2) 1)\n (error \"Odd number of arguments\"))\n (let* ((forms-and-sources\n ;; First get all the necessary mappings with all the\n ;; intermediate bindings.\n (-map (lambda (x) (dash--match (car x) (cadr x)))\n (-partition 2 forms)))\n ;; To preserve the logic of dynamic scoping we must ensure\n ;; that we `setq' the variables outside of the `let*' form\n ;; which holds the destructured intermediate values. For\n ;; this we generate for each variable a placeholder which is\n ;; bound to (lexically) the result of the destructuring.\n ;; Then outside of the helper `let*' form we bind all the\n ;; original variables to their respective placeholders.\n ;; TODO: There is a lot of room for possible optimization,\n ;; for start playing with `special-variable-p' to eliminate\n ;; unnecessary re-binding.\n (variables-to-placeholders\n (-mapcat\n (lambda (bindings)\n (-map\n (lambda (binding)\n (let ((var (car binding)))\n (list var (make-symbol (concat \"--dash-binding-\" (symbol-name var) \"--\")))))\n (--filter (not (string-prefix-p \"--\" (symbol-name (car it)))) bindings)))\n forms-and-sources)))\n `(let ,(-map 'cadr variables-to-placeholders)\n (let* ,(-flatten-n 1 forms-and-sources)\n (setq ,@(-flatten (-map 'reverse variables-to-placeholders))))\n (setq ,@(-flatten variables-to-placeholders)))))\n\n(defmacro -if-let* (vars-vals then &rest else)\n \"If all VALS evaluate to true, bind them to their corresponding\nVARS and do THEN, otherwise do ELSE. VARS-VALS should be a list\nof (VAR VAL) pairs.\n\nNote: binding is done according to `-let*'. VALS are evaluated\nsequentially, and evaluation stops after the first nil VAL is\nencountered.\"\n (declare (debug ((&rest (sexp form)) form body))\n (indent 2))\n (->> vars-vals\n (--mapcat (dash--match (car it) (cadr it)))\n (--reduce-r-from\n (let ((var (car it))\n (val (cadr it)))\n `(let ((,var ,val))\n (if ,var ,acc ,@else)))\n then)))\n\n(defmacro -if-let (var-val then &rest else)\n \"If VAL evaluates to non-nil, bind it to VAR and do THEN,\notherwise do ELSE.\n\nNote: binding is done according to `-let'.\n\n\\(fn (VAR VAL) THEN &rest ELSE)\"\n (declare (debug ((sexp form) form body))\n (indent 2))\n `(-if-let* (,var-val) ,then ,@else))\n\n(defmacro --if-let (val then &rest else)\n \"If VAL evaluates to non-nil, bind it to symbol `it' and do THEN,\notherwise do ELSE.\"\n (declare (debug (form form body))\n (indent 2))\n `(-if-let (it ,val) ,then ,@else))\n\n(defmacro -when-let* (vars-vals &rest body)\n \"If all VALS evaluate to true, bind them to their corresponding\nVARS and execute body. VARS-VALS should be a list of (VAR VAL)\npairs.\n\nNote: binding is done according to `-let*'. VALS are evaluated\nsequentially, and evaluation stops after the first nil VAL is\nencountered.\"\n (declare (debug ((&rest (sexp form)) body))\n (indent 1))\n `(-if-let* ,vars-vals (progn ,@body)))\n\n(defmacro -when-let (var-val &rest body)\n \"If VAL evaluates to non-nil, bind it to VAR and execute body.\n\nNote: binding is done according to `-let'.\n\n\\(fn (VAR VAL) &rest BODY)\"\n (declare (debug ((sexp form) body))\n (indent 1))\n `(-if-let ,var-val (progn ,@body)))\n\n(defmacro --when-let (val &rest body)\n \"If VAL evaluates to non-nil, bind it to symbol `it' and\nexecute body.\"\n (declare (debug (form body))\n (indent 1))\n `(--if-let ,val (progn ,@body)))\n\n(defvar -compare-fn nil\n \"Tests for equality use this function or `equal' if this is nil.\nIt should only be set using dynamic scope with a let, like:\n\n (let ((-compare-fn #\\\\='=)) (-union numbers1 numbers2 numbers3)\")\n\n(defun -distinct (list)\n \"Return a new list with all duplicates removed.\nThe test for equality is done with `equal',\nor with `-compare-fn' if that's non-nil.\n\nAlias: `-uniq'\"\n (let (result)\n (--each list (unless (-contains? result it) (!cons it result)))\n (nreverse result)))\n\n(defalias '-uniq '-distinct)\n\n(defun -union (list list2)\n \"Return a new list containing the elements of LIST and elements of LIST2 that are not in LIST.\nThe test for equality is done with `equal',\nor with `-compare-fn' if that's non-nil.\"\n ;; We fall back to iteration implementation if the comparison\n ;; function isn't one of `eq', `eql' or `equal'.\n (let* ((result (reverse list))\n ;; TODO: get rid of this dynamic variable, pass it as an\n ;; argument instead.\n (-compare-fn (if (bound-and-true-p -compare-fn)\n -compare-fn\n 'equal)))\n (if (memq -compare-fn '(eq eql equal))\n (let ((ht (make-hash-table :test -compare-fn)))\n (--each list (puthash it t ht))\n (--each list2 (unless (gethash it ht) (!cons it result))))\n (--each list2 (unless (-contains? result it) (!cons it result))))\n (nreverse result)))\n\n(defun -intersection (list list2)\n \"Return a new list containing only the elements that are members of both LIST and LIST2.\nThe test for equality is done with `equal',\nor with `-compare-fn' if that's non-nil.\"\n (--filter (-contains? list2 it) list))\n\n(defun -difference (list list2)\n \"Return a new list with only the members of LIST that are not in LIST2.\nThe test for equality is done with `equal',\nor with `-compare-fn' if that's non-nil.\"\n (--filter (not (-contains? list2 it)) list))\n\n(defun -powerset (list)\n \"Return the power set of LIST.\"\n (if (null list) '(())\n (let ((last (-powerset (cdr list))))\n (append (mapcar (lambda (x) (cons (car list) x)) last)\n last))))\n\n(defun -permutations (list)\n \"Return the permutations of LIST.\"\n (if (null list) '(())\n (apply #'append\n (mapcar (lambda (x)\n (mapcar (lambda (perm) (cons x perm))\n (-permutations (remove x list))))\n list))))\n\n(defun -inits (list)\n \"Return all prefixes of LIST.\"\n (nreverse (-map 'reverse (-tails (nreverse list)))))\n\n(defun -tails (list)\n \"Return all suffixes of LIST\"\n (-reductions-r-from 'cons nil list))\n\n(defun -common-prefix (&rest lists)\n \"Return the longest common prefix of LISTS.\"\n (declare (pure t) (side-effect-free t))\n (--reduce (--take-while (and acc (equal (pop acc) it)) it)\n lists))\n\n(defun -common-suffix (&rest lists)\n \"Return the longest common suffix of LISTS.\"\n (nreverse (apply #'-common-prefix (mapcar #'reverse lists))))\n\n(defun -contains? (list element)\n \"Return non-nil if LIST contains ELEMENT.\n\nThe test for equality is done with `equal', or with `-compare-fn'\nif that's non-nil.\n\nAlias: `-contains-p'\"\n (not\n (null\n (cond\n ((null -compare-fn) (member element list))\n ((eq -compare-fn 'eq) (memq element list))\n ((eq -compare-fn 'eql) (memql element list))\n (t\n (let ((lst list))\n (while (and lst\n (not (funcall -compare-fn element (car lst))))\n (setq lst (cdr lst)))\n lst))))))\n\n(defalias '-contains-p '-contains?)\n\n(defun -same-items? (list list2)\n \"Return true if LIST and LIST2 has the same items.\n\nThe order of the elements in the lists does not matter.\n\nAlias: `-same-items-p'\"\n (let ((length-a (length list))\n (length-b (length list2)))\n (and\n (= length-a length-b)\n (= length-a (length (-intersection list list2))))))\n\n(defalias '-same-items-p '-same-items?)\n\n(defun -is-prefix? (prefix list)\n \"Return non-nil if PREFIX is prefix of LIST.\n\nAlias: `-is-prefix-p'\"\n (declare (pure t) (side-effect-free t))\n (--each-while list (equal (car prefix) it)\n (!cdr prefix))\n (not prefix))\n\n(defun -is-suffix? (suffix list)\n \"Return non-nil if SUFFIX is suffix of LIST.\n\nAlias: `-is-suffix-p'\"\n (declare (pure t) (side-effect-free t))\n (-is-prefix? (reverse suffix) (reverse list)))\n\n(defun -is-infix? (infix list)\n \"Return non-nil if INFIX is infix of LIST.\n\nThis operation runs in O(n^2) time\n\nAlias: `-is-infix-p'\"\n (declare (pure t) (side-effect-free t))\n (let (done)\n (while (and (not done) list)\n (setq done (-is-prefix? infix list))\n (!cdr list))\n done))\n\n(defalias '-is-prefix-p '-is-prefix?)\n(defalias '-is-suffix-p '-is-suffix?)\n(defalias '-is-infix-p '-is-infix?)\n\n(defun -sort (comparator list)\n \"Sort LIST, stably, comparing elements using COMPARATOR.\nReturn the sorted list. LIST is NOT modified by side effects.\nCOMPARATOR is called with two elements of LIST, and should return non-nil\nif the first element should sort before the second.\"\n (sort (copy-sequence list) comparator))\n\n(defmacro --sort (form list)\n \"Anaphoric form of `-sort'.\"\n (declare (debug (form form)))\n `(-sort (lambda (it other) ,form) ,list))\n\n(defun -list (&rest args)\n \"Return a list with ARGS.\n\nIf first item of ARGS is already a list, simply return ARGS. If\nnot, return a list with ARGS as elements.\"\n (declare (pure t) (side-effect-free t))\n (let ((arg (car args)))\n (if (listp arg) arg args)))\n\n(defun -repeat (n x)\n \"Return a list with X repeated N times.\nReturn nil if N is less than 1.\"\n (declare (pure t) (side-effect-free t))\n (let (ret)\n (--dotimes n (!cons x ret))\n ret))\n\n(defun -sum (list)\n \"Return the sum of LIST.\"\n (declare (pure t) (side-effect-free t))\n (apply '+ list))\n\n(defun -running-sum (list)\n \"Return a list with running sums of items in LIST.\n\nLIST must be non-empty.\"\n (declare (pure t) (side-effect-free t))\n (unless (consp list)\n (error \"LIST must be non-empty\"))\n (-reductions '+ list))\n\n(defun -product (list)\n \"Return the product of LIST.\"\n (declare (pure t) (side-effect-free t))\n (apply '* list))\n\n(defun -running-product (list)\n \"Return a list with running products of items in LIST.\n\nLIST must be non-empty.\"\n (declare (pure t) (side-effect-free t))\n (unless (consp list)\n (error \"LIST must be non-empty\"))\n (-reductions '* list))\n\n(defun -max (list)\n \"Return the largest value from LIST of numbers or markers.\"\n (declare (pure t) (side-effect-free t))\n (apply 'max list))\n\n(defun -min (list)\n \"Return the smallest value from LIST of numbers or markers.\"\n (declare (pure t) (side-effect-free t))\n (apply 'min list))\n\n(defun -max-by (comparator list)\n \"Take a comparison function COMPARATOR and a LIST and return\nthe greatest element of the list by the comparison function.\n\nSee also combinator `-on' which can transform the values before\ncomparing them.\"\n (--reduce (if (funcall comparator it acc) it acc) list))\n\n(defun -min-by (comparator list)\n \"Take a comparison function COMPARATOR and a LIST and return\nthe least element of the list by the comparison function.\n\nSee also combinator `-on' which can transform the values before\ncomparing them.\"\n (--reduce (if (funcall comparator it acc) acc it) list))\n\n(defmacro --max-by (form list)\n \"Anaphoric version of `-max-by'.\n\nThe items for the comparator form are exposed as \\\"it\\\" and \\\"other\\\".\"\n (declare (debug (form form)))\n `(-max-by (lambda (it other) ,form) ,list))\n\n(defmacro --min-by (form list)\n \"Anaphoric version of `-min-by'.\n\nThe items for the comparator form are exposed as \\\"it\\\" and \\\"other\\\".\"\n (declare (debug (form form)))\n `(-min-by (lambda (it other) ,form) ,list))\n\n(defun -iterate (fun init n)\n \"Return a list of iterated applications of FUN to INIT.\n\nThis means a list of form:\n\n (init (fun init) (fun (fun init)) ...)\n\nN is the length of the returned list.\"\n (if (= n 0) nil\n (let ((r (list init)))\n (--dotimes (1- n)\n (push (funcall fun (car r)) r))\n (nreverse r))))\n\n(defun -fix (fn list)\n \"Compute the (least) fixpoint of FN with initial input LIST.\n\nFN is called at least once, results are compared with `equal'.\"\n (let ((re (funcall fn list)))\n (while (not (equal list re))\n (setq list re)\n (setq re (funcall fn re)))\n re))\n\n(defmacro --fix (form list)\n \"Anaphoric form of `-fix'.\"\n `(-fix (lambda (it) ,form) ,list))\n\n(defun -unfold (fun seed)\n \"Build a list from SEED using FUN.\n\nThis is \\\"dual\\\" operation to `-reduce-r': while -reduce-r\nconsumes a list to produce a single value, `-unfold' takes a\nseed value and builds a (potentially infinite!) list.\n\nFUN should return `nil' to stop the generating process, or a\ncons (A . B), where A will be prepended to the result and B is\nthe new seed.\"\n (let ((last (funcall fun seed)) r)\n (while last\n (push (car last) r)\n (setq last (funcall fun (cdr last))))\n (nreverse r)))\n\n(defmacro --unfold (form seed)\n \"Anaphoric version of `-unfold'.\"\n (declare (debug (form form)))\n `(-unfold (lambda (it) ,form) ,seed))\n\n(defun -cons-pair? (con)\n \"Return non-nil if CON is true cons pair.\nThat is (A . B) where B is not a list.\"\n (declare (pure t) (side-effect-free t))\n (and (listp con)\n (not (listp (cdr con)))))\n\n(defun -cons-to-list (con)\n \"Convert a cons pair to a list with `car' and `cdr' of the pair respectively.\"\n (declare (pure t) (side-effect-free t))\n (list (car con) (cdr con)))\n\n(defun -value-to-list (val)\n \"Convert a value to a list.\n\nIf the value is a cons pair, make a list with two elements, `car'\nand `cdr' of the pair respectively.\n\nIf the value is anything else, wrap it in a list.\"\n (declare (pure t) (side-effect-free t))\n (cond\n ((-cons-pair? val) (-cons-to-list val))\n (t (list val))))\n\n(defun -tree-mapreduce-from (fn folder init-value tree)\n \"Apply FN to each element of TREE, and make a list of the results.\nIf elements of TREE are lists themselves, apply FN recursively to\nelements of these nested lists.\n\nThen reduce the resulting lists using FOLDER and initial value\nINIT-VALUE. See `-reduce-r-from'.\n\nThis is the same as calling `-tree-reduce-from' after `-tree-map'\nbut is twice as fast as it only traverse the structure once.\"\n (cond\n ((not tree) nil)\n ((-cons-pair? tree) (funcall fn tree))\n ((listp tree)\n (-reduce-r-from folder init-value (mapcar (lambda (x) (-tree-mapreduce-from fn folder init-value x)) tree)))\n (t (funcall fn tree))))\n\n(defmacro --tree-mapreduce-from (form folder init-value tree)\n \"Anaphoric form of `-tree-mapreduce-from'.\"\n (declare (debug (form form form form)))\n `(-tree-mapreduce-from (lambda (it) ,form) (lambda (it acc) ,folder) ,init-value ,tree))\n\n(defun -tree-mapreduce (fn folder tree)\n \"Apply FN to each element of TREE, and make a list of the results.\nIf elements of TREE are lists themselves, apply FN recursively to\nelements of these nested lists.\n\nThen reduce the resulting lists using FOLDER and initial value\nINIT-VALUE. See `-reduce-r-from'.\n\nThis is the same as calling `-tree-reduce' after `-tree-map'\nbut is twice as fast as it only traverse the structure once.\"\n (cond\n ((not tree) nil)\n ((-cons-pair? tree) (funcall fn tree))\n ((listp tree)\n (-reduce-r folder (mapcar (lambda (x) (-tree-mapreduce fn folder x)) tree)))\n (t (funcall fn tree))))\n\n(defmacro --tree-mapreduce (form folder tree)\n \"Anaphoric form of `-tree-mapreduce'.\"\n (declare (debug (form form form)))\n `(-tree-mapreduce (lambda (it) ,form) (lambda (it acc) ,folder) ,tree))\n\n(defun -tree-map (fn tree)\n \"Apply FN to each element of TREE while preserving the tree structure.\"\n (cond\n ((not tree) nil)\n ((-cons-pair? tree) (funcall fn tree))\n ((listp tree)\n (mapcar (lambda (x) (-tree-map fn x)) tree))\n (t (funcall fn tree))))\n\n(defmacro --tree-map (form tree)\n \"Anaphoric form of `-tree-map'.\"\n (declare (debug (form form)))\n `(-tree-map (lambda (it) ,form) ,tree))\n\n(defun -tree-reduce-from (fn init-value tree)\n \"Use FN to reduce elements of list TREE.\nIf elements of TREE are lists themselves, apply the reduction recursively.\n\nFN is first applied to INIT-VALUE and first element of the list,\nthen on this result and second element from the list etc.\n\nThe initial value is ignored on cons pairs as they always contain\ntwo elements.\"\n (cond\n ((not tree) nil)\n ((-cons-pair? tree) tree)\n ((listp tree)\n (-reduce-r-from fn init-value (mapcar (lambda (x) (-tree-reduce-from fn init-value x)) tree)))\n (t tree)))\n\n(defmacro --tree-reduce-from (form init-value tree)\n \"Anaphoric form of `-tree-reduce-from'.\"\n (declare (debug (form form form)))\n `(-tree-reduce-from (lambda (it acc) ,form) ,init-value ,tree))\n\n(defun -tree-reduce (fn tree)\n \"Use FN to reduce elements of list TREE.\nIf elements of TREE are lists themselves, apply the reduction recursively.\n\nFN is first applied to first element of the list and second\nelement, then on this result and third element from the list etc.\n\nSee `-reduce-r' for how exactly are lists of zero or one element handled.\"\n (cond\n ((not tree) nil)\n ((-cons-pair? tree) tree)\n ((listp tree)\n (-reduce-r fn (mapcar (lambda (x) (-tree-reduce fn x)) tree)))\n (t tree)))\n\n(defmacro --tree-reduce (form tree)\n \"Anaphoric form of `-tree-reduce'.\"\n (declare (debug (form form)))\n `(-tree-reduce (lambda (it acc) ,form) ,tree))\n\n(defun -tree-map-nodes (pred fun tree)\n \"Call FUN on each node of TREE that satisfies PRED.\n\nIf PRED returns nil, continue descending down this node. If PRED\nreturns non-nil, apply FUN to this node and do not descend\nfurther.\"\n (if (funcall pred tree)\n (funcall fun tree)\n (if (and (listp tree)\n (not (-cons-pair? tree)))\n (-map (lambda (x) (-tree-map-nodes pred fun x)) tree)\n tree)))\n\n(defmacro --tree-map-nodes (pred form tree)\n \"Anaphoric form of `-tree-map-nodes'.\"\n `(-tree-map-nodes (lambda (it) ,pred) (lambda (it) ,form) ,tree))\n\n(defun -tree-seq (branch children tree)\n \"Return a sequence of the nodes in TREE, in depth-first search order.\n\nBRANCH is a predicate of one argument that returns non-nil if the\npassed argument is a branch, that is, a node that can have children.\n\nCHILDREN is a function of one argument that returns the children\nof the passed branch node.\n\nNon-branch nodes are simply copied.\"\n (cons tree\n (when (funcall branch tree)\n (-mapcat (lambda (x) (-tree-seq branch children x))\n (funcall children tree)))))\n\n(defmacro --tree-seq (branch children tree)\n \"Anaphoric form of `-tree-seq'.\"\n `(-tree-seq (lambda (it) ,branch) (lambda (it) ,children) ,tree))\n\n(defun -clone (list)\n \"Create a deep copy of LIST.\nThe new list has the same elements and structure but all cons are\nreplaced with new ones. This is useful when you need to clone a\nstructure such as plist or alist.\"\n (declare (pure t) (side-effect-free t))\n (-tree-map 'identity list))\n\n(defun dash-enable-font-lock ()\n \"Add syntax highlighting to dash functions, macros and magic values.\"\n (eval-after-load 'lisp-mode\n '(progn\n (let ((new-keywords '(\n \"!cons\"\n \"!cdr\"\n \"-each\"\n \"--each\"\n \"-each-indexed\"\n \"--each-indexed\"\n \"-each-while\"\n \"--each-while\"\n \"-doto\"\n \"-dotimes\"\n \"--dotimes\"\n \"-map\"\n \"--map\"\n \"-reduce-from\"\n \"--reduce-from\"\n \"-reduce\"\n \"--reduce\"\n \"-reduce-r-from\"\n \"--reduce-r-from\"\n \"-reduce-r\"\n \"--reduce-r\"\n \"-reductions-from\"\n \"-reductions-r-from\"\n \"-reductions\"\n \"-reductions-r\"\n \"-filter\"\n \"--filter\"\n \"-select\"\n \"--select\"\n \"-remove\"\n \"--remove\"\n \"-reject\"\n \"--reject\"\n \"-remove-first\"\n \"--remove-first\"\n \"-reject-first\"\n \"--reject-first\"\n \"-remove-last\"\n \"--remove-last\"\n \"-reject-last\"\n \"--reject-last\"\n \"-remove-item\"\n \"-non-nil\"\n \"-keep\"\n \"--keep\"\n \"-map-indexed\"\n \"--map-indexed\"\n \"-splice\"\n \"--splice\"\n \"-splice-list\"\n \"--splice-list\"\n \"-map-when\"\n \"--map-when\"\n \"-replace-where\"\n \"--replace-where\"\n \"-map-first\"\n \"--map-first\"\n \"-map-last\"\n \"--map-last\"\n \"-replace\"\n \"-replace-first\"\n \"-replace-last\"\n \"-flatten\"\n \"-flatten-n\"\n \"-concat\"\n \"-mapcat\"\n \"--mapcat\"\n \"-copy\"\n \"-cons*\"\n \"-snoc\"\n \"-first\"\n \"--first\"\n \"-find\"\n \"--find\"\n \"-some\"\n \"--some\"\n \"-any\"\n \"--any\"\n \"-last\"\n \"--last\"\n \"-first-item\"\n \"-second-item\"\n \"-third-item\"\n \"-fourth-item\"\n \"-fifth-item\"\n \"-last-item\"\n \"-butlast\"\n \"-count\"\n \"--count\"\n \"-any?\"\n \"--any?\"\n \"-some?\"\n \"--some?\"\n \"-any-p\"\n \"--any-p\"\n \"-some-p\"\n \"--some-p\"\n \"-some->\"\n \"-some->>\"\n \"-some-->\"\n \"-all?\"\n \"-all-p\"\n \"--all?\"\n \"--all-p\"\n \"-every?\"\n \"--every?\"\n \"-all-p\"\n \"--all-p\"\n \"-every-p\"\n \"--every-p\"\n \"-none?\"\n \"--none?\"\n \"-none-p\"\n \"--none-p\"\n \"-only-some?\"\n \"--only-some?\"\n \"-only-some-p\"\n \"--only-some-p\"\n \"-slice\"\n \"-take\"\n \"-drop\"\n \"-drop-last\"\n \"-take-last\"\n \"-take-while\"\n \"--take-while\"\n \"-drop-while\"\n \"--drop-while\"\n \"-split-at\"\n \"-rotate\"\n \"-insert-at\"\n \"-replace-at\"\n \"-update-at\"\n \"--update-at\"\n \"-remove-at\"\n \"-remove-at-indices\"\n \"-split-with\"\n \"--split-with\"\n \"-split-on\"\n \"-split-when\"\n \"--split-when\"\n \"-separate\"\n \"--separate\"\n \"-partition-all-in-steps\"\n \"-partition-in-steps\"\n \"-partition-all\"\n \"-partition\"\n \"-partition-after-item\"\n \"-partition-after-pred\"\n \"-partition-before-item\"\n \"-partition-before-pred\"\n \"-partition-by\"\n \"--partition-by\"\n \"-partition-by-header\"\n \"--partition-by-header\"\n \"-group-by\"\n \"--group-by\"\n \"-interpose\"\n \"-interleave\"\n \"-unzip\"\n \"-zip-with\"\n \"--zip-with\"\n \"-zip\"\n \"-zip-fill\"\n \"-zip-pair\"\n \"-cycle\"\n \"-pad\"\n \"-annotate\"\n \"--annotate\"\n \"-table\"\n \"-table-flat\"\n \"-partial\"\n \"-elem-index\"\n \"-elem-indices\"\n \"-find-indices\"\n \"--find-indices\"\n \"-find-index\"\n \"--find-index\"\n \"-find-last-index\"\n \"--find-last-index\"\n \"-select-by-indices\"\n \"-select-columns\"\n \"-select-column\"\n \"-grade-up\"\n \"-grade-down\"\n \"->\"\n \"->>\"\n \"-->\"\n \"-as->\"\n \"-when-let\"\n \"-when-let*\"\n \"--when-let\"\n \"-if-let\"\n \"-if-let*\"\n \"--if-let\"\n \"-let*\"\n \"-let\"\n \"-lambda\"\n \"-distinct\"\n \"-uniq\"\n \"-union\"\n \"-intersection\"\n \"-difference\"\n \"-powerset\"\n \"-permutations\"\n \"-inits\"\n \"-tails\"\n \"-common-prefix\"\n \"-common-suffix\"\n \"-contains?\"\n \"-contains-p\"\n \"-same-items?\"\n \"-same-items-p\"\n \"-is-prefix-p\"\n \"-is-prefix?\"\n \"-is-suffix-p\"\n \"-is-suffix?\"\n \"-is-infix-p\"\n \"-is-infix?\"\n \"-sort\"\n \"--sort\"\n \"-list\"\n \"-repeat\"\n \"-sum\"\n \"-running-sum\"\n \"-product\"\n \"-running-product\"\n \"-max\"\n \"-min\"\n \"-max-by\"\n \"--max-by\"\n \"-min-by\"\n \"--min-by\"\n \"-iterate\"\n \"--iterate\"\n \"-fix\"\n \"--fix\"\n \"-unfold\"\n \"--unfold\"\n \"-cons-pair?\"\n \"-cons-to-list\"\n \"-value-to-list\"\n \"-tree-mapreduce-from\"\n \"--tree-mapreduce-from\"\n \"-tree-mapreduce\"\n \"--tree-mapreduce\"\n \"-tree-map\"\n \"--tree-map\"\n \"-tree-reduce-from\"\n \"--tree-reduce-from\"\n \"-tree-reduce\"\n \"--tree-reduce\"\n \"-tree-seq\"\n \"--tree-seq\"\n \"-tree-map-nodes\"\n \"--tree-map-nodes\"\n \"-clone\"\n \"-rpartial\"\n \"-juxt\"\n \"-applify\"\n \"-on\"\n \"-flip\"\n \"-const\"\n \"-cut\"\n \"-orfn\"\n \"-andfn\"\n \"-iteratefn\"\n \"-fixfn\"\n \"-prodfn\"\n ))\n (special-variables '(\n \"it\"\n \"it-index\"\n \"acc\"\n \"other\"\n )))\n (font-lock-add-keywords 'emacs-lisp-mode `((,(concat \"\\\\_<\" (regexp-opt special-variables 'paren) \"\\\\_>\")\n 1 font-lock-variable-name-face)) 'append)\n (font-lock-add-keywords 'emacs-lisp-mode `((,(concat \"(\\\\s-*\" (regexp-opt new-keywords 'paren) \"\\\\_>\")\n 1 font-lock-keyword-face)) 'append))\n (--each (buffer-list)\n (with-current-buffer it\n (when (and (eq major-mode 'emacs-lisp-mode)\n (boundp 'font-lock-mode)\n font-lock-mode)\n (font-lock-refresh-defaults)))))))\n\n(provide 'dash)\n;;; dash.el ends here\n","avg_line_length":34.0293137908,"max_line_length":155,"alphanum_fraction":0.574944203} {"size":208,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; ui\/treemacs\/doctor.el -*- lexical-binding: t; -*-\n\n(assert! (and (not (featurep! :tools lsp +eglot))\n (featurep! +lsp))\n \"+lsp flag is not supported with eglot, only with lsp-mode.\")\n","avg_line_length":34.6666666667,"max_line_length":70,"alphanum_fraction":0.5865384615} {"size":9109,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; emacsql-tests.el --- tests for emacsql -*- lexical-binding: t; -*-\n\n;;; Code:\n\n(require 'ert)\n(require 'emacsql)\n\n(ert-deftest emacsql-escape-identifier ()\n (should-error (emacsql-escape-identifier \"foo\"))\n (should (string= (emacsql-escape-identifier 'foo) \"foo\"))\n (should (string= (emacsql-escape-identifier 'a\\ b) \"\\\"a\\\\ b\\\"\"))\n (should (string= (emacsql-escape-identifier '$foo) \"\\\"$foo\\\"\"))\n (should (string= (emacsql-escape-identifier 'select) \"\\\"select\\\"\"))\n (should-error (emacsql-escape-identifier 10))\n (should-error (emacsql-escape-identifier nil))\n (should (string= (emacsql-escape-identifier 'person-id) \"person_id\"))\n (should (string= (emacsql-escape-identifier\n 'people:person-id) \"people.person_id\"))\n (should (string= (emacsql-escape-identifier 'foo$) \"foo$\"))\n (should (string= (emacsql-escape-identifier 'foo:bar) \"foo.bar\")))\n\n(ert-deftest emacsql-escape-scalar ()\n (should (string= (emacsql-escape-scalar 'foo) \"'foo'\"))\n (should (string= (emacsql-escape-scalar \"foo\") \"'\\\"foo\\\"'\"))\n (should (string= (emacsql-escape-scalar :foo) \"':foo'\"))\n (should (string= (emacsql-escape-scalar [1 2 3]) \"'[1 2 3]'\"))\n (should (string= (emacsql-escape-scalar '(a b c)) \"'(a b c)'\"))\n (should (string= (emacsql-escape-scalar nil) \"NULL\")))\n\n(ert-deftest emacsql-escape-vector ()\n (should (string= (emacsql-escape-vector [1 2 3]) \"(1, 2, 3)\"))\n (should (string= (emacsql-escape-vector '([1 2 3])) \"(1, 2, 3)\"))\n (should (string= (emacsql-escape-vector '([1 2 3] [4 5 6]))\n \"(1, 2, 3), (4, 5, 6)\")))\n\n(ert-deftest emacsql-escape-raw ()\n (should (string= (emacsql-escape-raw \"\/var\/emacsql\") \"'\/var\/emacsql'\"))\n (should (string= (emacsql-escape-raw \"a b c\") \"'a b c'\"))\n (should (string= (emacsql-escape-raw \"a 'b' c\") \"'a ''b'' c'\"))\n (should (string= (emacsql-escape-raw nil) \"NULL\")))\n\n(ert-deftest emacsql-schema ()\n (should (string= (emacsql-prepare-schema [a]) \"a &NONE\"))\n (should (string= (emacsql-prepare-schema [a b c])\n \"a &NONE, b &NONE, c &NONE\"))\n (should (string= (emacsql-prepare-schema [a (b)])\n \"a &NONE, b &NONE\"))\n (should (string= (emacsql-prepare-schema [a (b float)])\n \"a &NONE, b &REAL\"))\n (should (string= (emacsql-prepare-schema\n [a (b float :primary-key :unique)])\n \"a &NONE, b &REAL PRIMARY KEY UNIQUE\"))\n (should (string= (emacsql-prepare-schema [(a integer) (b float)])\n \"a &INTEGER, b &REAL\")))\n\n(ert-deftest emacsql-param ()\n (should (equal (emacsql-param 'a) nil))\n (should (equal (emacsql-param 0) nil))\n (should (equal (emacsql-param \"\") nil))\n (should (equal (emacsql-param '$) nil))\n (should (equal (emacsql-param '$1) nil))\n (should (equal (emacsql-param '$s5) '(4 . :scalar)))\n (should (equal (emacsql-param '$v10) '(9 . :vector)))\n (should (equal (emacsql-param '$r2) '(1 . :raw)))\n (should (equal (emacsql-param '$a) nil))\n (should (equal (emacsql-param '$i10) '(9 . :identifier))))\n\n(defun emacsql-tests-query (query args result)\n \"Check that QUERY outputs RESULT for ARGS.\"\n (should (string= (apply #'emacsql-compile nil query args)\n result)))\n\n(defmacro emacsql-tests-with-queries (&rest queries)\n \"Thread `emacsql-tests-query' through QUERIES.\"\n (declare (indent 0))\n (cons 'progn (mapcar (lambda (q) (cons 'emacsql-tests-query q)) queries)))\n\n(ert-deftest emacsql-select ()\n (emacsql-tests-with-queries\n ([:select [$i1 name] :from $i2] '(id people)\n \"SELECT id, name FROM people;\")\n ([:select * :from employees] '()\n \"SELECT * FROM employees;\")\n ([:select * :from employees :where (< salary 50000)] '()\n \"SELECT * FROM employees WHERE salary < 50000;\")\n ([:select * :from people :where (in name $v1)] '([FOO BAR])\n \"SELECT * FROM people WHERE name IN ('FOO', 'BAR');\")\n ;; Sub queries\n ([:select name :from [:select * :from $i1]] '(people)\n \"SELECT name FROM (SELECT * FROM people);\")\n ([:select name :from [people (as accounts a)]] '()\n \"SELECT name FROM people, accounts AS a;\")\n ([:select p:name :from [(as [:select * :from people] p)]] '()\n \"SELECT p.name FROM (SELECT * FROM people) AS p;\")))\n\n(ert-deftest emacsql-attach ()\n (emacsql-tests-with-queries\n ([:attach $r1 :as $i2] '(\"\/var\/foo.db\" foo)\n \"ATTACH '\/var\/foo.db' AS foo;\")\n ([:detach $i1] '(foo)\n \"DETACH foo;\")))\n\n(ert-deftest emacsql-create-table ()\n (emacsql-tests-with-queries\n ([:create-table foo ([a b c])] ()\n \"CREATE TABLE foo (a &NONE, b &NONE, c &NONE);\")\n ([:create-temporary-table :if-not-exists x ([y])] '()\n \"CREATE TEMPORARY TABLE IF NOT EXISTS x (y &NONE);\")\n ([:create-table foo ([(a :default 10)])] '()\n \"CREATE TABLE foo (a &NONE DEFAULT 10);\")\n ([:create-table foo ([(a :primary-key :not-null) b])] '()\n \"CREATE TABLE foo (a &NONE PRIMARY KEY NOT NULL, b &NONE);\")\n ([:create-table foo ([a (b :check (< b 10))])] '()\n \"CREATE TABLE foo (a &NONE, b &NONE CHECK (b < 10));\")\n ([:create-table foo $S1] '([a b (c :primary-key)])\n \"CREATE TABLE foo (a &NONE, b &NONE, c &NONE PRIMARY KEY);\")\n ([:create-table foo ([a b (c :default \"FOO\")])] '()\n \"CREATE TABLE foo (a &NONE, b &NONE, c &NONE DEFAULT '\\\"FOO\\\"');\")\n ;; From select\n ([:create-table $i1 :as [:select name :from $i2]] '(names people)\n \"CREATE TABLE names AS (SELECT name FROM people);\")\n ;; Table constraints\n ([:create-table foo ([a b c] (:primary-key [a c]))] '()\n \"CREATE TABLE foo (a &NONE, b &NONE, c &NONE, PRIMARY KEY (a, c));\")\n ([:create-table foo ([a b c] (:unique [a b c]))] '()\n \"CREATE TABLE foo (a &NONE, b &NONE, c &NONE, UNIQUE (a, b, c));\")\n ([:create-table foo ([a b] (:check (< a b)))] '()\n \"CREATE TABLE foo (a &NONE, b &NONE, CHECK (a < b));\")\n ([:create-table foo ([a b c]\n (:foreign-key [a b] :references bar [aa bb]\n :on-delete :cascade))] '()\n (concat \"CREATE TABLE foo (a &NONE, b &NONE, c &NONE, FOREIGN KEY (a, b) \"\n \"REFERENCES bar (aa, bb) ON DELETE CASCADE);\"))\n ;; Template\n ([:create-table $i1 $S2] '(foo [alpha beta delta])\n \"CREATE TABLE foo (alpha &NONE, beta &NONE, delta &NONE);\")\n ;; Drop table\n ([:drop-table $i1] '(foo)\n \"DROP TABLE foo;\")))\n\n(ert-deftest emacsql-update ()\n (emacsql-tests-with-queries\n ([:update people :set (= id $s1)] '(10)\n \"UPDATE people SET id = 10;\")))\n\n(ert-deftest emacsql-insert ()\n (emacsql-tests-with-queries\n ([:insert :into foo :values [nil $s1]] '(10.1)\n \"INSERT INTO foo VALUES (NULL, 10.1);\")\n ([:insert :into foo [a b] :values $v1] '([1 2])\n \"INSERT INTO foo (a, b) VALUES (1, 2);\")\n ([:replace :into $i1 :values $v2] '(bar ([1 2] [3 4]))\n \"REPLACE INTO bar VALUES (1, 2), (3, 4);\")))\n\n(ert-deftest emacsql-order-by ()\n (emacsql-tests-with-queries\n ([:order-by foo] '()\n \"ORDER BY foo;\")\n ([:order-by [$i1]] '(bar)\n \"ORDER BY bar;\")\n ([:order-by (- foo)] '()\n \"ORDER BY -(foo);\")\n ([:order-by [(asc a) (desc (\/ b 2))]] '()\n \"ORDER BY a ASC, b \/ 2 DESC;\")))\n\n(ert-deftest emacsql-limit ()\n (emacsql-tests-with-queries\n ([:limit 10] '()\n \"LIMIT 10;\")\n ([:limit $s1] '(11)\n \"LIMIT 11;\")\n ([:limit [12]] '()\n \"LIMIT 12;\")\n ([:limit [2 10]] '()\n \"LIMIT 2, 10;\")\n ([:limit [$s1 $s2]] '(4 30)\n \"LIMIT 4, 30;\")))\n\n(ert-deftest emacsql-quoting ()\n (emacsql-tests-with-queries\n ([:where (= name 'foo)] '()\n \"WHERE name = 'foo';\")\n ([:where (= name '$s1)] '(qux)\n \"WHERE name = 'qux';\")))\n\n(ert-deftest emacsql-expr ()\n (emacsql-tests-with-queries\n ([:where (and a b)] '()\n \"WHERE a AND b;\")\n ([:where (or a $i1)] '(b)\n \"WHERE a OR b;\")\n ([:where (and $i1 $i2 $i3)] '(a b c)\n \"WHERE a AND b AND c;\")\n ([:where (is foo (not nil))] '()\n \"WHERE foo IS NOT NULL;\")\n ([:where (= attrib :name)] '()\n \"WHERE attrib = ':name';\")))\n\n(ert-deftest emacsql-transaction ()\n (emacsql-tests-with-queries\n ([:begin :transaction] '()\n \"BEGIN TRANSACTION;\")\n ([:begin :immediate] '()\n \"BEGIN IMMEDIATE;\")\n ([:rollback] '()\n \"ROLLBACK;\")\n ([:commit] '()\n \"COMMIT;\")))\n\n(ert-deftest emacsql-alter-table ()\n (emacsql-tests-with-queries\n ([:alter-table foo :rename-to bar] '()\n \"ALTER TABLE foo RENAME TO bar;\")\n ([:alter-table $i1 :rename-to $i2] '(alpha beta)\n \"ALTER TABLE alpha RENAME TO beta;\")\n ([:alter-table foo :add-column size :integer :not-null] '()\n \"ALTER TABLE foo ADD COLUMN size INTEGER NOT NULL;\")))\n\n(ert-deftest emacsql-funcall ()\n (emacsql-tests-with-queries\n ([:select (funcall count x)] '()\n \"SELECT count(x);\")\n ([:select (funcall count *)] '()\n \"SELECT count(*);\")\n ([:select (funcall group-concat x y)] '()\n \"SELECT group_concat(x, y);\")\n ([:select (funcall foobar :distinct x y)] '()\n \"SELECT foobar(':distinct', x, y);\")\n ([:select (funcall count :distinct x)] '()\n \"SELECT count(DISTINCT x);\")))\n\n(provide 'emacsql-compiler-tests)\n\n;;; emacsql-tests.el ends here\n","avg_line_length":38.7617021277,"max_line_length":80,"alphanum_fraction":0.5706444176} {"size":27402,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; cider-autoloads.el --- automatically extracted autoloads\n;;\n;;; Code:\n\n(add-to-list 'load-path (directory-file-name\n (or (file-name-directory #$) (car load-path))))\n\n\f\n;;;### (autoloads nil \"cider\" \"cider.el\" (0 0 0 0))\n;;; Generated autoloads from cider.el\n\n(autoload 'cider-version \"cider\" \"\\\nDisplay CIDER's version.\n\n\\(fn)\" t nil)\n (autoload 'cider-start-map \"cider\" \"CIDER jack-in and connect keymap.\" t 'keymap)\n\n(autoload 'cider-jack-in-clj \"cider\" \"\\\nStart an nREPL server for the current project and connect to it.\nPARAMS is a plist optionally containing :project-dir and :jack-in-cmd.\nWith the prefix argument, allow editing of the jack in command; with a\ndouble prefix prompt for all these parameters.\n\n\\(fn PARAMS)\" t nil)\n\n(autoload 'cider-jack-in-cljs \"cider\" \"\\\nStart an nREPL server for the current project and connect to it.\nPARAMS is a plist optionally containing :project-dir, :jack-in-cmd and\n:cljs-repl-type (e.g. Node, Figwheel, etc). With the prefix argument,\nallow editing of the jack in command; with a double prefix prompt for all\nthese parameters.\n\n\\(fn PARAMS)\" t nil)\n\n(autoload 'cider-jack-in-clj&cljs \"cider\" \"\\\nStart an nREPL server and connect with clj and cljs REPLs.\nPARAMS is a plist optionally containing :project-dir, :jack-in-cmd and\n:cljs-repl-type (e.g. Node, Figwheel, etc). With the prefix argument,\nallow for editing of the jack in command; with a double prefix prompt for\nall these parameters. When SOFT-CLJS-START is non-nil, start cljs REPL\nonly when the ClojureScript dependencies are met.\n\n\\(fn &optional PARAMS SOFT-CLJS-START)\" t nil)\n\n(autoload 'cider-connect-sibling-clj \"cider\" \"\\\nCreate a Clojure REPL with the same server as OTHER-REPL.\nPARAMS is for consistency with other connection commands and is currently\nignored. OTHER-REPL defaults to `cider-current-repl' and in programs can\nalso be a server buffer, in which case a new session with a REPL for that\nserver is created.\n\n\\(fn PARAMS &optional OTHER-REPL)\" t nil)\n\n(autoload 'cider-connect-sibling-cljs \"cider\" \"\\\nCreate a ClojureScript REPL with the same server as OTHER-REPL.\nPARAMS is a plist optionally containing :cljs-repl-type (e.g. Node,\nFigwheel, etc). All other parameters are inferred from the OTHER-REPL.\nOTHER-REPL defaults to `cider-current-repl' but in programs can also be a\nserver buffer, in which case a new session for that server is created.\n\n\\(fn PARAMS &optional OTHER-REPL)\" t nil)\n\n(autoload 'cider-connect-clj \"cider\" \"\\\nInitialize a Clojure connection to an nREPL server.\nPARAMS is a plist optionally containing :host, :port and :project-dir. On\nprefix argument, prompt for all the parameters.\n\n\\(fn &optional PARAMS)\" t nil)\n\n(autoload 'cider-connect-cljs \"cider\" \"\\\nInitialize a ClojureScript connection to an nREPL server.\nPARAMS is a plist optionally containing :host, :port, :project-dir and\n:cljs-repl-type (e.g. Node, Figwheel, etc). On prefix, prompt for all the\nparameters regardless of their supplied or default values.\n\n\\(fn &optional PARAMS)\" t nil)\n\n(autoload 'cider-connect-clj&cljs \"cider\" \"\\\nInitialize a Clojure and ClojureScript connection to an nREPL server.\nPARAMS is a plist optionally containing :host, :port, :project-dir and\n:cljs-repl-type (e.g. Node, Figwheel, etc). When SOFT-CLJS-START is\nnon-nil, don't start if ClojureScript requirements are not met.\n\n\\(fn PARAMS &optional SOFT-CLJS-START)\" t nil)\n\n(autoload 'cider \"cider\" \"\\\nStart a connection of any type interactively.\n\n\\(fn)\" t nil)\n\n(defalias 'cider-jack-in #'cider-jack-in-clj)\n\n(defalias 'cider-jack-in-clojure #'cider-jack-in-clj)\n\n(defalias 'cider-jack-in-clojurescript #'cider-jack-in-cljs)\n\n(defalias 'cider-connect #'cider-connect-clj)\n\n(defalias 'cider-connect-clojure #'cider-connect-clj)\n\n(defalias 'cider-connect-clojurescript #'cider-connect-cljs)\n\n(defalias 'cider-connect-sibling-clojure #'cider-connect-sibling-clj)\n\n(defalias 'cider-connect-sibling-clojurescript #'cider-connect-sibling-cljs)\n\n(with-eval-after-load 'clojure-mode (define-key clojure-mode-map (kbd \"C-c M-x\") #'cider) (define-key clojure-mode-map (kbd \"C-c M-j\") #'cider-jack-in-clj) (define-key clojure-mode-map (kbd \"C-c M-J\") #'cider-jack-in-cljs) (define-key clojure-mode-map (kbd \"C-c M-c\") #'cider-connect-clj) (define-key clojure-mode-map (kbd \"C-c M-C\") #'cider-connect-cljs) (define-key clojure-mode-map (kbd \"C-c C-x\") 'cider-start-map) (define-key clojure-mode-map (kbd \"C-c C-s\") 'sesman-map) (require 'sesman) (sesman-install-menu clojure-mode-map) (add-hook 'clojure-mode-hook (lambda nil (setq-local sesman-system 'CIDER))))\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-apropos\" \"cider-apropos.el\" (0 0 0 0))\n;;; Generated autoloads from cider-apropos.el\n\n(autoload 'cider-apropos \"cider-apropos\" \"\\\nShow all symbols whose names match QUERY, a regular expression.\nQUERY can also be a list of space-separated words (e.g. take while) which\nwill be converted to a regular expression (like take.+while) automatically\nbehind the scenes. The search may be limited to the namespace NS, and may\noptionally search doc strings (based on DOCS-P), include private vars\n\\(based on PRIVATES-P), and be case-sensitive (based on CASE-SENSITIVE-P).\n\n\\(fn QUERY &optional NS DOCS-P PRIVATES-P CASE-SENSITIVE-P)\" t nil)\n\n(autoload 'cider-apropos-documentation \"cider-apropos\" \"\\\nShortcut for (cider-apropos nil t).\n\n\\(fn)\" t nil)\n\n(autoload 'cider-apropos-select \"cider-apropos\" \"\\\nSimilar to `cider-apropos', but presents the results in a completing read.\nShow all symbols whose names match QUERY, a regular expression.\nQUERY can also be a list of space-separated words (e.g. take while) which\nwill be converted to a regular expression (like take.+while) automatically\nbehind the scenes. The search may be limited to the namespace NS, and may\noptionally search doc strings (based on DOCS-P), include private vars\n\\(based on PRIVATES-P), and be case-sensitive (based on CASE-SENSITIVE-P).\n\n\\(fn QUERY &optional NS DOCS-P PRIVATES-P CASE-SENSITIVE-P)\" t nil)\n\n(autoload 'cider-apropos-documentation-select \"cider-apropos\" \"\\\nShortcut for (cider-apropos-select nil t).\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-apropos\" '(\"cider-\" \"apropos-special-form\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-browse-ns\" \"cider-browse-ns.el\" (0 0\n;;;;;; 0 0))\n;;; Generated autoloads from cider-browse-ns.el\n\n(autoload 'cider-browse-ns \"cider-browse-ns\" \"\\\nList all NAMESPACE's vars in BUFFER.\n\n\\(fn NAMESPACE)\" t nil)\n\n(autoload 'cider-browse-ns-all \"cider-browse-ns\" \"\\\nList all loaded namespaces in BUFFER.\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-browse-ns\" '(\"cider-browse-ns-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-browse-spec\" \"cider-browse-spec.el\"\n;;;;;; (0 0 0 0))\n;;; Generated autoloads from cider-browse-spec.el\n\n(autoload 'cider-browse-spec \"cider-browse-spec\" \"\\\nBrowse SPEC definition.\n\n\\(fn SPEC)\" t nil)\n\n(autoload 'cider-browse-spec-all \"cider-browse-spec\" \"\\\nOpen list of specs in a popup buffer.\n\nWith a prefix argument ARG, prompts for a regexp to filter specs.\nNo filter applied if the regexp is the empty string.\n\n\\(fn &optional ARG)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-browse-spec\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-cheatsheet\" \"cider-cheatsheet.el\" (0\n;;;;;; 0 0 0))\n;;; Generated autoloads from cider-cheatsheet.el\n\n(autoload 'cider-cheatsheet \"cider-cheatsheet\" \"\\\nNavigate `cider-cheatsheet-hierarchy' with `completing-read'.\n\nWhen you make it to a Clojure var its doc buffer gets displayed.\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-cheatsheet\" '(\"cider-cheatsheet-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-classpath\" \"cider-classpath.el\" (0 0\n;;;;;; 0 0))\n;;; Generated autoloads from cider-classpath.el\n\n(autoload 'cider-classpath \"cider-classpath\" \"\\\nList all classpath entries.\n\n\\(fn)\" t nil)\n\n(autoload 'cider-open-classpath-entry \"cider-classpath\" \"\\\nOpen a classpath entry.\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-classpath\" '(\"cider-classpath-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-client\" \"cider-client.el\" (0 0 0 0))\n;;; Generated autoloads from cider-client.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-client\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-common\" \"cider-common.el\" (0 0 0 0))\n;;; Generated autoloads from cider-common.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-common\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-completion\" \"cider-completion.el\" (0\n;;;;;; 0 0 0))\n;;; Generated autoloads from cider-completion.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-completion\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-connection\" \"cider-connection.el\" (0\n;;;;;; 0 0 0))\n;;; Generated autoloads from cider-connection.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-connection\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-debug\" \"cider-debug.el\" (0 0 0 0))\n;;; Generated autoloads from cider-debug.el\n\n(autoload 'cider-debug-defun-at-point \"cider-debug\" \"\\\nInstrument the \\\"top-level\\\" expression at point.\nIf it is a defn, dispatch the instrumented definition. Otherwise,\nimmediately evaluate the instrumented expression.\n\nWhile debugged code is being evaluated, the user is taken through the\nsource code and displayed the value of various expressions. At each step,\na number of keys will be prompted to the user.\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-debug\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-doc\" \"cider-doc.el\" (0 0 0 0))\n;;; Generated autoloads from cider-doc.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-doc\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-eldoc\" \"cider-eldoc.el\" (0 0 0 0))\n;;; Generated autoloads from cider-eldoc.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-eldoc\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-eval\" \"cider-eval.el\" (0 0 0 0))\n;;; Generated autoloads from cider-eval.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-eval\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-find\" \"cider-find.el\" (0 0 0 0))\n;;; Generated autoloads from cider-find.el\n\n(autoload 'cider-find-var \"cider-find\" \"\\\nFind definition for VAR at LINE.\nPrompt according to prefix ARG and `cider-prompt-for-symbol'.\nA single or double prefix argument inverts the meaning of\n`cider-prompt-for-symbol'. A prefix of `-` or a double prefix argument causes\nthe results to be displayed in a different window. The default value is\nthing at point.\n\n\\(fn &optional ARG VAR LINE)\" t nil)\n\n(autoload 'cider-find-dwim-at-mouse \"cider-find\" \"\\\nFind and display variable or resource at mouse EVENT.\n\n\\(fn EVENT)\" t nil)\n\n(autoload 'cider-find-dwim \"cider-find\" \"\\\nFind and display the SYMBOL-FILE at point.\nSYMBOL-FILE could be a var or a resource. If thing at point is empty then\nshow dired on project. If var is not found, try to jump to resource of the\nsame name. When called interactively, a prompt is given according to the\nvariable `cider-prompt-for-symbol'. A single or double prefix argument\ninverts the meaning. A prefix of `-' or a double prefix argument causes\nthe results to be displayed in a different window. A default value of thing\nat point is given when prompted.\n\n\\(fn SYMBOL-FILE)\" t nil)\n\n(autoload 'cider-find-resource \"cider-find\" \"\\\nFind the resource at PATH.\nPrompt for input as indicated by the variable `cider-prompt-for-symbol'.\nA single or double prefix argument inverts the meaning of\n`cider-prompt-for-symbol'. A prefix argument of `-` or a double prefix\nargument causes the results to be displayed in other window. The default\nvalue is thing at point.\n\n\\(fn PATH)\" t nil)\n\n(autoload 'cider-find-ns \"cider-find\" \"\\\nFind the file containing NS.\nA prefix ARG of `-` or a double prefix argument causes\nthe results to be displayed in a different window.\n\n\\(fn &optional ARG NS)\" t nil)\n\n(autoload 'cider-find-keyword \"cider-find\" \"\\\nFind the namespace of the keyword at point and its first occurrence there.\n\nFor instance - if the keyword at point is \\\":cider.demo\/keyword\\\", this command\nwould find the namespace \\\"cider.demo\\\" and afterwards find the first mention\nof \\\"::keyword\\\" there.\n\nPrompt according to prefix ARG and `cider-prompt-for-symbol'.\nA single or double prefix argument inverts the meaning of\n`cider-prompt-for-symbol'. A prefix of `-` or a double prefix argument causes\nthe results to be displayed in a different window. The default value is\nthing at point.\n\n\\(fn &optional ARG)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-find\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-format\" \"cider-format.el\" (0 0 0 0))\n;;; Generated autoloads from cider-format.el\n\n(autoload 'cider-format-region \"cider-format\" \"\\\nFormat the Clojure code in the current region.\nSTART and END represent the region's boundaries.\n\n\\(fn START END)\" t nil)\n\n(autoload 'cider-format-defun \"cider-format\" \"\\\nFormat the code in the current defun.\n\n\\(fn)\" t nil)\n\n(autoload 'cider-format-buffer \"cider-format\" \"\\\nFormat the Clojure code in the current buffer.\n\n\\(fn)\" t nil)\n\n(autoload 'cider-format-edn-buffer \"cider-format\" \"\\\nFormat the EDN data in the current buffer.\n\n\\(fn)\" t nil)\n\n(autoload 'cider-format-edn-region \"cider-format\" \"\\\nFormat the EDN data in the current region.\nSTART and END represent the region's boundaries.\n\n\\(fn START END)\" t nil)\n\n(autoload 'cider-format-edn-last-sexp \"cider-format\" \"\\\nFormat the EDN data of the last sexp.\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-format\" '(\"cider--format-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-grimoire\" \"cider-grimoire.el\" (0 0 0\n;;;;;; 0))\n;;; Generated autoloads from cider-grimoire.el\n\n(autoload 'cider-grimoire-web \"cider-grimoire\" \"\\\nOpen grimoire documentation in the default web browser.\n\nPrompts for the symbol to use, or uses the symbol at point, depending on\nthe value of `cider-prompt-for-symbol'. With prefix arg ARG, does the\nopposite of what that option dictates.\n\n\\(fn &optional ARG)\" t nil)\n\n(autoload 'cider-grimoire \"cider-grimoire\" \"\\\nOpen grimoire documentation in a popup buffer.\n\nPrompts for the symbol to use, or uses the symbol at point, depending on\nthe value of `cider-prompt-for-symbol'. With prefix arg ARG, does the\nopposite of what that option dictates.\n\n\\(fn &optional ARG)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-grimoire\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-inspector\" \"cider-inspector.el\" (0 0\n;;;;;; 0 0))\n;;; Generated autoloads from cider-inspector.el\n\n(autoload 'cider-inspect-last-sexp \"cider-inspector\" \"\\\nInspect the result of the the expression preceding point.\n\n\\(fn)\" t nil)\n\n(autoload 'cider-inspect-defun-at-point \"cider-inspector\" \"\\\nInspect the result of the \\\"top-level\\\" expression at point.\n\n\\(fn)\" t nil)\n\n(autoload 'cider-inspect-last-result \"cider-inspector\" \"\\\nInspect the most recent eval result.\n\n\\(fn)\" t nil)\n\n(autoload 'cider-inspect \"cider-inspector\" \"\\\nInspect the result of the preceding sexp.\n\nWith a prefix argument ARG it inspects the result of the \\\"top-level\\\" form.\nWith a second prefix argument it prompts for an expression to eval and inspect.\n\n\\(fn &optional ARG)\" t nil)\n\n(autoload 'cider-inspect-expr \"cider-inspector\" \"\\\nEvaluate EXPR in NS and inspect its value.\nInteractively, EXPR is read from the minibuffer, and NS the\ncurrent buffer's namespace.\n\n\\(fn EXPR NS)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-inspector\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-macroexpansion\" \"cider-macroexpansion.el\"\n;;;;;; (0 0 0 0))\n;;; Generated autoloads from cider-macroexpansion.el\n\n(autoload 'cider-macroexpand-1 \"cider-macroexpansion\" \"\\\nInvoke \\\\=`macroexpand-1\\\\=` on the expression preceding point.\nIf invoked with a PREFIX argument, use \\\\=`macroexpand\\\\=` instead of\n\\\\=`macroexpand-1\\\\=`.\n\n\\(fn &optional PREFIX)\" t nil)\n\n(autoload 'cider-macroexpand-all \"cider-macroexpansion\" \"\\\nInvoke \\\\=`macroexpand-all\\\\=` on the expression preceding point.\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-macroexpansion\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-mode\" \"cider-mode.el\" (0 0 0 0))\n;;; Generated autoloads from cider-mode.el\n\n(defvar cider-mode-line '(:eval (format \" cider[%s]\" (cider--modeline-info))) \"\\\nMode line lighter for cider mode.\n\nThe value of this variable is a mode line template as in\n`mode-line-format'. See Info Node `(elisp)Mode Line Format' for details\nabout mode line templates.\n\nCustomize this variable to change how cider mode displays its status in the\nmode line. The default value displays the current connection. Set this\nvariable to nil to disable the mode line entirely.\")\n\n(custom-autoload 'cider-mode-line \"cider-mode\" t)\n\n(with-eval-after-load 'clojure-mode (easy-menu-define cider-clojure-mode-menu-open clojure-mode-map \"Menu for Clojure mode.\\n This is displayed in `clojure-mode' buffers, if `cider-mode' is not active.\" `(\"CIDER\" :visible (not cider-mode) [\"Start a Clojure REPL\" cider-jack-in-clj :help \"Starts an nREPL server and connects a Clojure REPL to it.\"] [\"Connect to a Clojure REPL\" cider-connect-clj :help \"Connects to a REPL that's already running.\"] [\"Start a ClojureScript REPL\" cider-jack-in-cljs :help \"Starts an nREPL server and connects a ClojureScript REPL to it.\"] [\"Connect to a ClojureScript REPL\" cider-connect-cljs :help \"Connects to a ClojureScript REPL that's already running.\"] [\"Start a Clojure REPL, and a ClojureScript REPL\" cider-jack-in-clj&cljs :help \"Starts an nREPL server, connects a Clojure REPL to it, and then a ClojureScript REPL.\"] \"--\" [\"View manual online\" cider-view-manual])))\n\n(autoload 'cider-mode \"cider-mode\" \"\\\nMinor mode for REPL interaction from a Clojure buffer.\n\n\\\\{cider-mode-map}\n\n\\(fn &optional ARG)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-mode\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-ns\" \"cider-ns.el\" (0 0 0 0))\n;;; Generated autoloads from cider-ns.el\n\n(autoload 'cider-ns-reload \"cider-ns\" \"\\\nSend a (require 'ns :reload) to the REPL.\n\nWith an argument PROMPT, it prompts for a namespace name. This is the\nClojure out of the box reloading experience and does not rely on\norg.clojure\/tools.namespace. See Commentary of this file for a longer list\nof differences. From the Clojure doc: \\\":reload forces loading of all the\nidentified libs even if they are already loaded\\\".\n\n\\(fn &optional PROMPT)\" t nil)\n\n(autoload 'cider-ns-reload-all \"cider-ns\" \"\\\nSend a (require 'ns :reload-all) to the REPL.\n\nWith an argument PROMPT, it prompts for a namespace name. This is the\nClojure out of the box reloading experience and does not rely on\norg.clojure\/tools.namespace. See Commentary of this file for a longer list\nof differences. From the Clojure doc: \\\":reload-all implies :reload and\nalso forces loading of all libs that the identified libs directly or\nindirectly load via require\\\".\n\n\\(fn &optional PROMPT)\" t nil)\n\n(autoload 'cider-ns-refresh \"cider-ns\" \"\\\nReload modified and unloaded namespaces on the classpath.\n\nWith a single prefix argument, or if MODE is `refresh-all', reload all\nnamespaces on the classpath unconditionally.\n\nWith a double prefix argument, or if MODE is `clear', clear the state of\nthe namespace tracker before reloading. This is useful for recovering from\nsome classes of error (for example, those caused by circular dependencies)\nthat a normal reload would not otherwise recover from. The trade-off of\nclearing is that stale code from any deleted files may not be completely\nunloaded.\n\nWith a negative prefix argument, or if MODE is `inhibit-fns', prevent any\nrefresh functions (defined in `cider-ns-refresh-before-fn' and\n`cider-ns-refresh-after-fn') from being invoked.\n\n\\(fn &optional MODE)\" t nil)\n\n(define-obsolete-function-alias 'cider-refresh 'cider-ns-refresh \"0.18\")\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-ns\" '(\"cider-ns-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-overlays\" \"cider-overlays.el\" (0 0 0\n;;;;;; 0))\n;;; Generated autoloads from cider-overlays.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-overlays\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-popup\" \"cider-popup.el\" (0 0 0 0))\n;;; Generated autoloads from cider-popup.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-popup\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-profile\" \"cider-profile.el\" (0 0 0 0))\n;;; Generated autoloads from cider-profile.el\n\n(autoload 'cider-profile-samples \"cider-profile\" \"\\\nDisplays current max-sample-count.\nIf optional QUERY is specified, set max-sample-count and display new value.\n\n\\(fn &optional QUERY)\" t nil)\n\n(autoload 'cider-profile-var-profiled-p \"cider-profile\" \"\\\nDisplays the profiling status of var under point.\nPrompts for var if none under point or QUERY is present.\n\n\\(fn QUERY)\" t nil)\n\n(autoload 'cider-profile-ns-toggle \"cider-profile\" \"\\\nToggle profiling for the ns associated with optional QUERY.\n\nIf optional argument QUERY is non-nil, prompt for ns. Otherwise use\ncurrent ns.\n\n\\(fn &optional QUERY)\" t nil)\n\n(autoload 'cider-profile-toggle \"cider-profile\" \"\\\nToggle profiling for the given QUERY.\nDefaults to the symbol at point.\nWith prefix arg or no symbol at point, prompts for a var.\n\n\\(fn QUERY)\" t nil)\n\n(autoload 'cider-profile-summary \"cider-profile\" \"\\\nDisplay a summary of currently collected profile data.\n\n\\(fn)\" t nil)\n\n(autoload 'cider-profile-var-summary \"cider-profile\" \"\\\nDisplay profile data for var under point QUERY.\nDefaults to the symbol at point. With prefix arg or no symbol at point,\nprompts for a var.\n\n\\(fn QUERY)\" t nil)\n\n(autoload 'cider-profile-clear \"cider-profile\" \"\\\nClear any collected profile data.\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-profile\" '(\"cider-profile-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-repl\" \"cider-repl.el\" (0 0 0 0))\n;;; Generated autoloads from cider-repl.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-repl\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-repl-history\" \"cider-repl-history.el\"\n;;;;;; (0 0 0 0))\n;;; Generated autoloads from cider-repl-history.el\n\n(autoload 'cider-repl-history \"cider-repl-history\" \"\\\nDisplay items in the CIDER command history in another buffer.\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-repl-history\" '(\"cider-repl-history-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-resolve\" \"cider-resolve.el\" (0 0 0 0))\n;;; Generated autoloads from cider-resolve.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-resolve\" '(\"cider-resolve-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-scratch\" \"cider-scratch.el\" (0 0 0 0))\n;;; Generated autoloads from cider-scratch.el\n\n(autoload 'cider-scratch \"cider-scratch\" \"\\\nGo to the scratch buffer named `cider-scratch-buffer-name'.\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-scratch\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-selector\" \"cider-selector.el\" (0 0 0\n;;;;;; 0))\n;;; Generated autoloads from cider-selector.el\n\n(autoload 'cider-selector \"cider-selector\" \"\\\nSelect a new buffer by type, indicated by a single character.\nThe user is prompted for a single character indicating the method by\nwhich to choose a new buffer. The `?' character describes then\navailable methods. OTHER-WINDOW provides an optional target.\nSee `def-cider-selector-method' for defining new methods.\n\n\\(fn &optional OTHER-WINDOW)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-selector\" '(\"??\" \"?c\" \"?e\" \"?q\" \"?r\" \"?m\" \"?x\" \"?p\" \"?d\" \"?s\" \"def-cider-selector-method\" \"cider-selector-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-stacktrace\" \"cider-stacktrace.el\" (0\n;;;;;; 0 0 0))\n;;; Generated autoloads from cider-stacktrace.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-stacktrace\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-test\" \"cider-test.el\" (0 0 0 0))\n;;; Generated autoloads from cider-test.el\n\n(defvar cider-auto-test-mode nil \"\\\nNon-nil if Cider-Auto-Test mode is enabled.\nSee the `cider-auto-test-mode' command\nfor a description of this minor mode.\nSetting this variable directly does not take effect;\neither customize it (see the info node `Easy Customization')\nor call the function `cider-auto-test-mode'.\")\n\n(custom-autoload 'cider-auto-test-mode \"cider-test\" nil)\n\n(autoload 'cider-auto-test-mode \"cider-test\" \"\\\nToggle automatic testing of Clojure files.\n\nWhen enabled this reruns tests every time a Clojure file is loaded.\nOnly runs tests corresponding to the loaded file's namespace and does\nnothing if no tests are defined or if the file failed to load.\n\n\\(fn &optional ARG)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-test\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-tracing\" \"cider-tracing.el\" (0 0 0 0))\n;;; Generated autoloads from cider-tracing.el\n\n(autoload 'cider-toggle-trace-var \"cider-tracing\" \"\\\nToggle var tracing.\nPrompts for the symbol to use, or uses the symbol at point, depending on\nthe value of `cider-prompt-for-symbol'. With prefix arg ARG, does the\nopposite of what that option dictates.\n\n\\(fn ARG)\" t nil)\n\n(autoload 'cider-toggle-trace-ns \"cider-tracing\" \"\\\nToggle ns tracing.\nDefaults to the current ns. With prefix arg QUERY, prompts for a ns.\n\n\\(fn QUERY)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-tracing\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"cider-util\" \"cider-util.el\" (0 0 0 0))\n;;; Generated autoloads from cider-util.el\n\n(autoload 'cider-view-manual \"cider-util\" \"\\\nView the manual in your default browser.\n\n\\(fn)\" t nil)\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"cider-util\" '(\"cider-\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"nrepl-client\" \"nrepl-client.el\" (0 0 0 0))\n;;; Generated autoloads from nrepl-client.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"nrepl-client\" '(\"nrepl-\" \"cider-enlighten-mode\")))\n\n;;;***\n\f\n;;;### (autoloads nil \"nrepl-dict\" \"nrepl-dict.el\" (0 0 0 0))\n;;; Generated autoloads from nrepl-dict.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"nrepl-dict\" '(\"nrepl-\")))\n\n;;;***\n\f\n;;;### (autoloads nil nil (\"cider-compat.el\" \"cider-pkg.el\") (0 0\n;;;;;; 0 0))\n\n;;;***\n\f\n;; Local Variables:\n;; version-control: never\n;; no-byte-compile: t\n;; no-update-autoloads: t\n;; coding: utf-8\n;; End:\n;;; cider-autoloads.el ends here\n","avg_line_length":35.3118556701,"max_line_length":906,"alphanum_fraction":0.7225020072} {"size":4550,"ext":"el","lang":"Emacs Lisp","max_stars_count":11.0,"content":";;; geiser.el --- GNU Emacs and Scheme talk to each other\n\n;; Copyright (C) 2009, 2010, 2011, 2012, 2013, 2015, 2018 Jose Antonio Ortega Ruiz\n;; URL: http:\/\/www.nongnu.org\/geiser\/\n\n;; This program is free software; you can redistribute it and\/or\n;; modify it under the terms of the Modified BSD License. You should\n;; have received a copy of the license along with this program. If\n;; not, see .\n\n\f\n;; Autoloads and basic setup for geiser.\n\n;;; Locations:\n\n;;;###autoload\n(defconst geiser-elisp-dir (file-name-directory load-file-name)\n \"Directory containing Geiser's Elisp files.\")\n\n;;;###autoload\n(defconst geiser-scheme-dir\n (let ((d (expand-file-name \".\/scheme\/\" geiser-elisp-dir)))\n (if (file-directory-p d)\n d\n (expand-file-name \"..\/scheme\/\" geiser-elisp-dir)))\n \"Directory containing Geiser's Scheme files.\")\n\n;;;###autoload\n(add-to-list 'load-path (directory-file-name geiser-elisp-dir))\n\n\f\n;;; Autoloads:\n\n;;;###autoload\n(autoload 'geiser-version \"geiser-version\" \"Echo Geiser's version.\" t)\n\n;;;###autoload\n(autoload 'geiser-unload \"geiser-reload\" \"Unload all Geiser code.\" t)\n\n;;;###autoload\n(autoload 'geiser-reload \"geiser-reload\" \"Reload Geiser code.\" t)\n\n;;;###autoload\n(autoload 'geiser \"geiser-repl\"\n \"Start a Geiser REPL, or switch to a running one.\" t)\n\n;;;###autoload\n(autoload 'run-geiser \"geiser-repl\" \"Start a Geiser REPL.\" t)\n\n;;;###autoload\n(autoload 'geiser-connect \"geiser-repl\"\n \"Start a Geiser REPL connected to a remote server.\" t)\n\n;;;###autoload\n(autoload 'geiser-connect-local \"geiser-repl\"\n \"Start a Geiser REPL connected to a remote server over a Unix-domain socket.\"\n t)\n\n;;;###autoload\n(autoload 'switch-to-geiser \"geiser-repl\"\n \"Switch to a running one Geiser REPL.\" t)\n\n;;;###autoload\n(autoload 'run-chez \"geiser-chez\" \"Start a Geiser Chez REPL.\" t)\n\n;;;###autoload\n(autoload 'switch-to-chez \"geiser-chez\"\n \"Start a Geiser Chez REPL, or switch to a running one.\" t)\n\n;;;###autoload\n(autoload 'run-guile \"geiser-guile\" \"Start a Geiser Guile REPL.\" t)\n\n;;;###autoload\n(autoload 'switch-to-guile \"geiser-guile\"\n \"Start a Geiser Guile REPL, or switch to a running one.\" t)\n\n;;;###autoload\n(autoload 'connect-to-guile \"geiser-guile\"\n \"Connect to a remote Geiser Guile REPL.\" t)\n\n;;;###autoload\n(autoload 'run-racket \"geiser-racket\" \"Start a Geiser Racket REPL.\" t)\n\n;;;###autoload\n(autoload 'run-gracket \"geiser-racket\" \"Start a Geiser GRacket REPL.\" t)\n\n;;;###autoload\n(autoload 'switch-to-racket \"geiser-racket\"\n \"Start a Geiser Racket REPL, or switch to a running one.\" t)\n\n;;;###autoload\n(autoload 'connect-to-racket \"geiser-racket\"\n \"Connect to a remote Geiser Racket REPL.\" t)\n\n;;;###autoload\n(autoload 'run-chicken \"geiser-chicken\" \"Start a Geiser Chicken REPL.\" t)\n\n;;;###autoload\n(autoload 'switch-to-chicken \"geiser-chicken\"\n \"Start a Geiser Chicken REPL, or switch to a running one.\" t)\n\n;;;###autoload\n(autoload 'connect-to-chicken \"geiser-chicken\"\n \"Connect to a remote Geiser Chicken REPL.\" t)\n\n;;;###autoload\n(autoload 'run-mit \"geiser-mit\" \"Start a Geiser MIT\/GNU Scheme REPL.\" t)\n\n;;;###autoload\n(autoload 'switch-to-mit \"geiser-mit\"\n \"Start a Geiser MIT\/GNU Scheme REPL, or switch to a running one.\" t)\n\n;;;###autoload\n(autoload 'run-chibi \"geiser-chibi\" \"Start a Geiser Chibi Scheme REPL.\" t)\n\n;;;###autoload\n(autoload 'switch-to-chibi \"geiser-chibi\"\n \"Start a Geiser Chibi Scheme REPL, or switch to a running one.\" t)\n\n;;;###autoload\n(autoload 'geiser-mode \"geiser-mode\"\n \"Minor mode adding Geiser REPL interaction to Scheme buffers.\" t)\n\n;;;###autoload\n(autoload 'turn-on-geiser-mode \"geiser-mode\"\n \"Enable Geiser's mode (useful in Scheme buffers).\" t)\n\n;;;###autoload\n(autoload 'turn-off-geiser-mode \"geiser-mode\"\n \"Disable Geiser's mode (useful in Scheme buffers).\" t)\n\n;;;###autoload\n(autoload 'geiser-mode--maybe-activate \"geiser-mode\")\n\n;;;###autoload\n(mapc (lambda (group)\n (custom-add-load group (symbol-name group))\n (custom-add-load 'geiser (symbol-name group)))\n '(geiser\n geiser-repl\n geiser-autodoc\n geiser-doc\n geiser-debug\n geiser-faces\n geiser-mode\n geiser-guile\n geiser-image\n geiser-racket\n geiser-chicken\n\tgeiser-chez\n\tgeiser-chibi\n\tgeiser-mit\n geiser-implementation\n geiser-xref))\n\n\f\n;;; Setup:\n\n;;;###autoload\n(add-hook 'scheme-mode-hook 'geiser-mode--maybe-activate)\n;;;###autoload\n(add-to-list 'auto-mode-alist '(\"\\\\.rkt\\\\'\" . scheme-mode))\n\n\f\n(provide 'geiser)\n\n;;; geiser.el ends here\n","avg_line_length":27.0833333333,"max_line_length":82,"alphanum_fraction":0.6791208791} {"size":17475,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":";;; kingsajz-theme.el --- kingsajz theme\n\n;; Copyright (C) 2001 by Olgierd \"Kingsajz\" Ziolko\n;; Copyright (C) 2013 by Syohei YOSHIDA\n\n;; Author: Syohei YOSHIDA \n;; URL: https:\/\/github.com\/emacs-jp\/replace-colorthemes\n;; Version: 0.01\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Commentary:\n;;\n;; Port of kingsajz theme from `color-themes'\n\n;;; Code:\n\n(deftheme kingsajz\n \"kingsajz theme\")\n\n(custom-theme-set-faces\n 'kingsajz\n\n '(default ((t (:background \"darkslategrey\" :foreground \"wheat\"))))\n '(mouse ((t (:background \"Grey\"))))\n '(cursor ((t (:background \"LightGray\"))))\n '(border ((t (:background \"black\"))))\n\n '(bbdb-field-name ((t (:foreground \"green\"))))\n '(bg:erc-color-face0 ((t (:background \"White\"))))\n '(bg:erc-color-face1 ((t (:background \"black\"))))\n '(bg:erc-color-face10 ((t (:background \"lightblue1\"))))\n '(bg:erc-color-face11 ((t (:background \"cyan\"))))\n '(bg:erc-color-face12 ((t (:background \"blue\"))))\n '(bg:erc-color-face13 ((t (:background \"deeppink\"))))\n '(bg:erc-color-face14 ((t (:background \"gray50\"))))\n '(bg:erc-color-face15 ((t (:background \"gray90\"))))\n '(bg:erc-color-face2 ((t (:background \"blue4\"))))\n '(bg:erc-color-face3 ((t (:background \"green4\"))))\n '(bg:erc-color-face4 ((t (:background \"red\"))))\n '(bg:erc-color-face5 ((t (:background \"brown\"))))\n '(bg:erc-color-face6 ((t (:background \"purple\"))))\n '(bg:erc-color-face7 ((t (:background \"orange\"))))\n '(bg:erc-color-face8 ((t (:background \"yellow\"))))\n '(bg:erc-color-face9 ((t (:background \"green\"))))\n '(blue ((t (:foreground \"cyan\"))))\n '(bold ((t (:bold t :foreground \"OrangeRed\" :weight bold))))\n '(bold-italic ((t (:italic t :bold t :slant italic :weight bold))))\n '(calendar-today-face ((t (:underline t))))\n '(comint-highlight-input ((t (:bold t :weight bold))))\n '(comint-highlight-prompt ((t (:foreground \"cyan\"))))\n '(cperl-array-face ((t (:foreground \"Yellow\"))))\n '(cperl-hash-face ((t (:foreground \"White\"))))\n '(cperl-nonoverridable-face ((t (:foreground \"SkyBlue\"))))\n '(custom-button-face ((t (:foreground \"MediumSlateBlue\" :underline t))))\n '(custom-button-pressed-face ((t (:background \"lightgrey\" :foreground \"black\" :box (:line-width 2 :style pressed-button)))))\n '(custom-changed-face ((t (:background \"blue\" :foreground \"white\"))))\n '(custom-comment-face ((t (:background \"dim gray\"))))\n '(custom-comment-tag-face ((t (:foreground \"gray80\"))))\n '(custom-documentation-face ((t (:foreground \"Grey\"))))\n '(custom-face-tag-face ((t (:bold t :weight bold :height 1.2))))\n '(custom-group-tag-face ((t (:foreground \"MediumAquamarine\"))))\n '(custom-group-tag-face-1 ((t (:bold t :foreground \"pink\" :weight bold :height 1.2))))\n '(custom-invalid-face ((t (:background \"red\" :foreground \"yellow\"))))\n '(custom-modified-face ((t (:background \"blue\" :foreground \"white\"))))\n '(custom-rogue-face ((t (:background \"black\" :foreground \"pink\"))))\n '(custom-saved-face ((t (:underline t))))\n '(custom-set-face ((t (:background \"white\" :foreground \"blue\"))))\n '(custom-state-face ((t (:foreground \"Coral\"))))\n '(custom-variable-button-face ((t (:underline t))))\n '(custom-variable-tag-face ((t (:foreground \"Aquamarine\"))))\n '(date ((t (:foreground \"green\"))))\n '(diary-face ((t (:bold t :foreground \"IndianRed\" :weight bold))))\n '(dired-face-directory ((t (:bold t :foreground \"sky blue\" :weight bold))))\n '(dired-face-executable ((t (:foreground \"green yellow\"))))\n '(dired-face-flagged ((t (:foreground \"tomato\"))))\n '(dired-face-marked ((t (:foreground \"light salmon\"))))\n '(dired-face-permissions ((t (:foreground \"aquamarine\"))))\n '(erc-action-face ((t (:bold t :weight bold))))\n '(erc-bold-face ((t (:bold t :weight bold))))\n '(erc-default-face ((t (nil))))\n '(erc-direct-msg-face ((t (:foreground \"pale green\"))))\n '(erc-error-face ((t (:bold t :foreground \"IndianRed\" :weight bold))))\n '(erc-highlight-face ((t (:bold t :foreground \"pale green\" :weight bold))))\n '(erc-host-danger-face ((t (:foreground \"red\"))))\n '(erc-input-face ((t (:foreground \"light blue\"))))\n '(erc-inverse-face ((t (:background \"steel blue\"))))\n '(erc-notice-face ((t (:foreground \"light salmon\"))))\n '(erc-pal-face ((t (:foreground \"pale green\"))))\n '(erc-prompt-face ((t (:bold t :foreground \"light blue\" :weight bold))))\n '(erc-underline-face ((t (:underline t))))\n '(eshell-ls-archive-face ((t (:bold t :foreground \"IndianRed\" :weight bold))))\n '(eshell-ls-backup-face ((t (:foreground \"Grey\"))))\n '(eshell-ls-clutter-face ((t (:bold t :foreground \"DimGray\" :weight bold))))\n '(eshell-ls-directory-face ((t (:bold t :foreground \"MediumSlateBlue\" :weight bold))))\n '(eshell-ls-executable-face ((t (:bold t :foreground \"Coral\" :weight bold))))\n '(eshell-ls-missing-face ((t (:bold t :foreground \"black\" :weight bold))))\n '(eshell-ls-picture-face ((t (:foreground \"Violet\"))))\n '(eshell-ls-product-face ((t (:foreground \"LightSalmon\"))))\n '(eshell-ls-readonly-face ((t (:foreground \"Aquamarine\"))))\n '(eshell-ls-special-face ((t (:bold t :foreground \"Gold\" :weight bold))))\n '(eshell-ls-symlink-face ((t (:bold t :foreground \"White\" :weight bold))))\n '(eshell-ls-text-face ((t (:foreground \"medium aquamarine\"))))\n '(eshell-ls-todo-face ((t (:bold t :foreground \"aquamarine\" :weight bold))))\n '(eshell-ls-unreadable-face ((t (:foreground \"DimGray\"))))\n '(eshell-prompt-face ((t (:foreground \"powder blue\"))))\n '(face-1 ((t (:stipple nil :foreground \"royal blue\"))))\n '(face-2 ((t (:stipple nil :foreground \"DeepSkyBlue1\"))))\n '(face-3 ((t (:stipple nil :foreground \"NavajoWhite3\"))))\n '(fg:erc-color-face0 ((t (:foreground \"white\"))))\n '(fg:erc-color-face1 ((t (:foreground \"beige\"))))\n '(fg:erc-color-face10 ((t (:foreground \"pale goldenrod\"))))\n '(fg:erc-color-face11 ((t (:foreground \"light goldenrod yellow\"))))\n '(fg:erc-color-face12 ((t (:foreground \"light yellow\"))))\n '(fg:erc-color-face13 ((t (:foreground \"yellow\"))))\n '(fg:erc-color-face14 ((t (:foreground \"light goldenrod\"))))\n '(fg:erc-color-face15 ((t (:foreground \"lime green\"))))\n '(fg:erc-color-face2 ((t (:foreground \"lemon chiffon\"))))\n '(fg:erc-color-face3 ((t (:foreground \"light cyan\"))))\n '(fg:erc-color-face4 ((t (:foreground \"powder blue\"))))\n '(fg:erc-color-face5 ((t (:foreground \"sky blue\"))))\n '(fg:erc-color-face6 ((t (:foreground \"dark sea green\"))))\n '(fg:erc-color-face7 ((t (:foreground \"pale green\"))))\n '(fg:erc-color-face8 ((t (:foreground \"medium spring green\"))))\n '(fg:erc-color-face9 ((t (:foreground \"khaki\"))))\n\n '(font-lock-builtin-face ((t (:bold t :foreground \"PaleGreen\" :weight bold))))\n '(font-lock-comment-face ((t (:foreground \"White\"))))\n '(font-lock-constant-face ((t (:bold t :foreground \"Aquamarine\" :weight bold))))\n '(font-lock-doc-face ((t (:italic t :slant italic :foreground \"LightSalmon\"))))\n '(font-lock-doc-string-face ((t (:foreground \"LightSalmon\"))))\n '(font-lock-function-name-face ((t (:bold t :foreground \"MediumSlateBlue\" :weight bold))))\n '(font-lock-keyword-face ((t (:foreground \"Salmon\"))))\n '(font-lock-preprocessor-face ((t (:foreground \"Salmon\"))))\n '(font-lock-reference-face ((t (:foreground \"pale green\"))))\n '(font-lock-string-face ((t (:italic t :foreground \"LightSalmon\" :slant italic))))\n '(font-lock-type-face ((t (:bold t :foreground \"YellowGreen\" :weight bold))))\n '(font-lock-variable-name-face ((t (:italic t :bold t :foreground \"Aquamarine\" :slant italic :weight bold))))\n '(font-lock-warning-face ((t (:bold t :foreground \"IndianRed\" :weight bold))))\n '(fringe ((t (:background \"darkslategrey\"))))\n '(gnus-cite-face-1 ((t (:foreground \"DarkGoldenrod3\"))))\n '(gnus-cite-face-10 ((t (nil))))\n '(gnus-cite-face-11 ((t (nil))))\n '(gnus-cite-face-2 ((t (:foreground \"IndianRed3\"))))\n '(gnus-cite-face-3 ((t (:foreground \"tomato\"))))\n '(gnus-cite-face-4 ((t (:foreground \"yellow green\"))))\n '(gnus-cite-face-5 ((t (:foreground \"SteelBlue3\"))))\n '(gnus-cite-face-6 ((t (:foreground \"Azure3\"))))\n '(gnus-cite-face-7 ((t (:foreground \"Azure4\"))))\n '(gnus-cite-face-8 ((t (:foreground \"SpringGreen4\"))))\n '(gnus-cite-face-9 ((t (:foreground \"SlateGray4\"))))\n '(gnus-emphasis-bold ((t (:bold t :foreground \"greenyellow\" :weight bold))))\n '(gnus-emphasis-bold-italic ((t (:italic t :bold t :foreground \"OrangeRed1\" :slant italic :weight bold))))\n '(gnus-emphasis-highlight-words ((t (:background \"black\" :foreground \"khaki\"))))\n '(gnus-emphasis-italic ((t (:italic t :bold t :foreground \"orange\" :slant italic :weight bold))))\n '(gnus-emphasis-underline ((t (:foreground \"greenyellow\" :underline t))))\n '(gnus-emphasis-underline-bold ((t (:bold t :foreground \"khaki\" :underline t :weight bold))))\n '(gnus-emphasis-underline-bold-italic ((t (:italic t :bold t :underline t :slant italic :weight bold))))\n '(gnus-emphasis-underline-italic ((t (:italic t :foreground \"orange\" :underline t :slant italic))))\n '(gnus-group-mail-1-empty-face ((t (:foreground \"Salmon4\"))))\n '(gnus-group-mail-1-face ((t (:bold t :foreground \"firebrick1\" :weight bold))))\n '(gnus-group-mail-2-empty-face ((t (:foreground \"turquoise4\"))))\n '(gnus-group-mail-2-face ((t (:bold t :foreground \"turquoise\" :weight bold))))\n '(gnus-group-mail-3-empty-face ((t (:foreground \"LightCyan4\"))))\n '(gnus-group-mail-3-face ((t (:bold t :foreground \"LightCyan1\" :weight bold))))\n '(gnus-group-mail-low-empty-face ((t (:foreground \"SteelBlue4\"))))\n '(gnus-group-mail-low-face ((t (:bold t :foreground \"SteelBlue2\" :weight bold))))\n '(gnus-group-news-1-empty-face ((t (:foreground \"Salmon4\"))))\n '(gnus-group-news-1-face ((t (:bold t :foreground \"FireBrick1\" :weight bold))))\n '(gnus-group-news-2-empty-face ((t (:foreground \"darkorange3\"))))\n '(gnus-group-news-2-face ((t (:bold t :foreground \"dark orange\" :weight bold))))\n '(gnus-group-news-3-empty-face ((t (:foreground \"turquoise4\"))))\n '(gnus-group-news-3-face ((t (:bold t :foreground \"Aquamarine\" :weight bold))))\n '(gnus-group-news-4-empty-face ((t (:foreground \"SpringGreen4\"))))\n '(gnus-group-news-4-face ((t (:bold t :foreground \"SpringGreen2\" :weight bold))))\n '(gnus-group-news-5-empty-face ((t (:foreground \"OliveDrab4\"))))\n '(gnus-group-news-5-face ((t (:bold t :foreground \"OliveDrab2\" :weight bold))))\n '(gnus-group-news-6-empty-face ((t (:foreground \"DarkGoldenrod4\"))))\n '(gnus-group-news-6-face ((t (:bold t :foreground \"DarkGoldenrod3\" :weight bold))))\n '(gnus-group-news-low-empty-face ((t (:foreground \"wheat4\"))))\n '(gnus-group-news-low-face ((t (:bold t :foreground \"tan4\" :weight bold))))\n '(gnus-header-content-face ((t (:foreground \"LightSkyBlue3\"))))\n '(gnus-header-from-face ((t (:bold t :foreground \"light cyan\" :weight bold))))\n '(gnus-header-name-face ((t (:bold t :foreground \"DodgerBlue1\" :weight bold))))\n '(gnus-header-newsgroups-face ((t (:italic t :bold t :foreground \"LightSkyBlue3\" :slant italic :weight bold))))\n '(gnus-header-subject-face ((t (:bold t :foreground \"light cyan\" :weight bold))))\n '(gnus-signature-face ((t (:italic t :foreground \"salmon\" :slant italic))))\n '(gnus-splash-face ((t (:foreground \"Firebrick1\"))))\n '(gnus-summary-cancelled-face ((t (:background \"black\" :foreground \"yellow\"))))\n '(gnus-summary-high-ancient-face ((t (:bold t :foreground \"MistyRose4\" :weight bold))))\n '(gnus-summary-high-read-face ((t (:bold t :foreground \"tomato3\" :weight bold))))\n '(gnus-summary-high-ticked-face ((t (:bold t :foreground \"coral\" :weight bold))))\n '(gnus-summary-high-unread-face ((t (:italic t :bold t :foreground \"red1\" :slant italic :weight bold))))\n '(gnus-summary-low-ancient-face ((t (:italic t :foreground \"DarkSeaGreen4\" :slant italic))))\n '(gnus-summary-low-read-face ((t (:foreground \"SeaGreen4\"))))\n '(gnus-summary-low-ticked-face ((t (:italic t :foreground \"Green4\" :slant italic))))\n '(gnus-summary-low-unread-face ((t (:italic t :foreground \"green3\" :slant italic))))\n '(gnus-summary-normal-ancient-face ((t (:foreground \"RoyalBlue\"))))\n '(gnus-summary-normal-read-face ((t (:foreground \"khaki4\"))))\n '(gnus-summary-normal-ticked-face ((t (:foreground \"khaki3\"))))\n '(gnus-summary-normal-unread-face ((t (:foreground \"khaki\"))))\n '(gnus-summary-selected-face ((t (:foreground \"gold\" :underline t))))\n '(green ((t (:foreground \"green\"))))\n '(gui-button-face ((t (:foreground \"red\" :background \"black\"))))\n '(gui-element ((t (:bold t :background \"#ffffff\" :foreground \"#000000\" :weight bold))))\n '(header-line ((t (:box (:line-width -1 :style released-button) :background \"grey20\" :foreground \"grey90\" :box nil))))\n '(highlight ((t (:background \"PaleGreen\" :foreground \"DarkGreen\"))))\n '(highline-face ((t (:background \"SeaGreen\"))))\n '(holiday-face ((t (:background \"DimGray\"))))\n '(info-menu-5 ((t (:underline t))))\n '(info-node ((t (:bold t :foreground \"DodgerBlue1\" :underline t :weight bold))))\n '(info-xref ((t (:bold t :foreground \"DodgerBlue3\" :weight bold))))\n '(isearch ((t (:background \"sea green\" :foreground \"black\"))))\n '(isearch-lazy-highlight-face ((t (:background \"paleturquoise4\"))))\n '(italic ((t (:italic t :foreground \"chocolate3\" :slant italic))))\n '(menu ((t (nil))))\n '(message-cited-text-face ((t (:foreground \"White\"))))\n '(message-header-cc-face ((t (:foreground \"light cyan\"))))\n '(message-header-name-face ((t (:foreground \"DodgerBlue1\"))))\n '(message-header-newsgroups-face ((t (:italic t :bold t :foreground \"LightSkyBlue3\" :slant italic :weight bold))))\n '(message-header-other-face ((t (:foreground \"LightSkyBlue3\"))))\n '(message-header-subject-face ((t (:bold t :foreground \"light cyan\" :weight bold))))\n '(message-header-to-face ((t (:bold t :foreground \"light cyan\" :weight bold))))\n '(message-header-xheader-face ((t (:foreground \"DodgerBlue3\"))))\n '(message-mml-face ((t (:foreground \"ForestGreen\"))))\n '(message-separator-face ((t (:background \"cornflower blue\" :foreground \"chocolate\"))))\n '(mode-line ((t (:background \"dark olive green\" :foreground \"wheat\" :box (:line-width -1 :style released-button)))))\n '(mode-line-buffer-id ((t (:bold t :background \"dark olive green\" :foreground \"beige\" :weight bold))))\n '(mode-line-mousable ((t (:bold t :background \"dark olive green\" :foreground \"yellow green\" :weight bold))))\n '(mode-line-mousable-minor-mode ((t (:bold t :background \"dark olive green\" :foreground \"wheat\" :weight bold))))\n '(paren-blink-off ((t (:foreground \"brown\"))))\n '(region ((t (:background \"dark cyan\" :foreground \"cyan\"))))\n '(ruler-mode-column-number-face ((t (:box (:color \"grey76\" :line-width 1 :style released-button) :background \"grey76\" :foreground \"black\"))))\n '(ruler-mode-current-column-face ((t (:bold t :box (:color \"grey76\" :line-width 1 :style released-button) :background \"grey76\" :foreground \"yellow\" :weight bold))))\n '(ruler-mode-default-face ((t (:background \"grey76\" :foreground \"grey64\" :box (:color \"grey76\" :line-width 1 :style released-button)))))\n '(ruler-mode-fill-column-face ((t (:box (:color \"grey76\" :line-width 1 :style released-button) :background \"grey76\" :foreground \"red\"))))\n '(ruler-mode-margins-face ((t (:box (:color \"grey76\" :line-width 1 :style released-button) :foreground \"grey64\" :background \"grey64\"))))\n '(ruler-mode-tab-stop-face ((t (:box (:color \"grey76\" :line-width 1 :style released-button) :background \"grey76\" :foreground \"steelblue\"))))\n '(scroll-bar ((t (nil))))\n '(secondary-selection ((t (:background \"Aquamarine\" :foreground \"SlateBlue\"))))\n '(show-paren-match-face ((t (:bold t :background \"Aquamarine\" :foreground \"steel blue\" :weight bold))))\n '(show-paren-mismatch-face ((t (:background \"Red\" :foreground \"White\"))))\n '(swbuff-current-buffer-face ((t (:bold t :foreground \"red\" :weight bold))))\n '(text-cursor ((t (:background \"Red\" :foreground \"white\"))))\n '(tool-bar ((t (:background \"grey75\" :foreground \"black\" :box (:line-width 1 :style released-button)))))\n '(trailing-whitespace ((t (:background \"red\"))))\n '(underline ((t (:underline t))))\n '(w3m-anchor-face ((t (:bold t :foreground \"DodgerBlue1\" :weight bold))))\n '(w3m-arrived-anchor-face ((t (:bold t :foreground \"DodgerBlue3\" :weight bold))))\n '(w3m-header-line-location-content-face ((t (:background \"dark olive green\" :foreground \"wheat\"))))\n '(w3m-header-line-location-title-face ((t (:background \"dark olive green\" :foreground \"beige\"))))\n '(widget-button-face ((t (:bold t :foreground \"green\" :weight bold))))\n '(widget-button-pressed-face ((t (:foreground \"red\"))))\n '(widget-documentation-face ((t (:foreground \"lime green\"))))\n '(widget-field-face ((t (:foreground \"LightBlue\"))))\n '(widget-inactive-face ((t (:foreground \"DimGray\"))))\n '(widget-single-line-field-face ((t (:foreground \"LightBlue\"))))\n '(woman-bold-face ((t (:bold t :weight bold))))\n '(woman-italic-face ((t (:italic t :foreground \"beige\" :slant italic))))\n '(woman-unknown-face ((t (:foreground \"LightSalmon\"))))\n '(zmacs-region ((t (:background \"dark cyan\" :foreground \"cyan\")))))\n\n;;;###autoload\n(when load-file-name\n (add-to-list 'custom-theme-load-path\n (file-name-as-directory (file-name-directory load-file-name))))\n\n(provide-theme 'kingsajz)\n\n;;; kingsajz-theme.el ends here\n","avg_line_length":61.9680851064,"max_line_length":165,"alphanum_fraction":0.6649499285} {"size":593,"ext":"el","lang":"Emacs Lisp","max_stars_count":1.0,"content":";;; f-autoloads.el --- automatically extracted autoloads\n;;\n;;; Code:\n\n(add-to-list 'load-path (directory-file-name\n (or (file-name-directory #$) (car load-path))))\n\n\f\n;;;### (autoloads nil \"f\" \"f.el\" (0 0 0 0))\n;;; Generated autoloads from f.el\n\n(if (fboundp 'register-definition-prefixes) (register-definition-prefixes \"f\" '(\"f-\")))\n\n;;;***\n\f\n;;;### (autoloads nil nil (\"f-pkg.el\" \"f-shortdoc.el\") (0 0 0 0))\n\n;;;***\n\f\n;; Local Variables:\n;; version-control: never\n;; no-byte-compile: t\n;; no-update-autoloads: t\n;; coding: utf-8\n;; End:\n;;; f-autoloads.el ends here\n","avg_line_length":21.962962963,"max_line_length":87,"alphanum_fraction":0.5952782462} {"size":2965,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; lsp-go.el --- Go support for lsp-mode\n\n;; Copyright (C) 2017 Vibhav Pant \n\n;; Author: Vibhav Pant \n;; Version: 1.0\n;; Package-Version: 20180914.515\n;; Package-Requires: ((lsp-mode \"3.0\"))\n;; Keywords: go, golang\n;; URL: https:\/\/github.com\/emacs-lsp\/lsp-go\n\n(require 'lsp-mode)\n\n(defgroup lsp-go nil\n \"lsp-go settings\"\n :group 'tools)\n\n(defcustom lsp-go-executable-path (executable-find \"go-langserver\")\n \"Path to the go-langserver executable.\"\n :type 'string\n :group 'lsp-go)\n\n(defcustom lsp-go-language-server-flags '(\"-gocodecompletion\")\n \"Extra arguments for the go-langserver.\"\n :type '(repeat string)\n :group 'lsp-go)\n\n(defcustom lsp-go-func-snippet-enabled t\n \"Enable the returning of argument snippets on `func' completions, eg.\n`func(foo string, arg2 bar)'. Requires code completion to be enabled.\"\n :type 'bool\n :group 'lsp-go)\n\n(defcustom lsp-go-gocode-completion-enabled t\n \"Enable code completion feature (using gocode).\"\n :type 'bool\n :group 'lsp-go)\n\n(defcustom lsp-go-format-tool \"goimports\"\n \"The tool to be used for formatting documents. Defaults to `goimports' if nil.\"\n :type '(choice (const :tag \"goimports\" \"goimports\")\n (const :tag \"gofmt\" \"gofmt\"))\n :group 'lsp-go)\n\n(defcustom lsp-go-imports-local-prefix \"\"\n \"The local prefix (comma-separated string) that goimports will use.\"\n :type 'string\n :group 'lsp-go)\n\n(defcustom lsp-go-max-parallelism nil\n \"The maximum number of goroutines that should be used to fulfill requests.\nThis is useful in editor environments where users do not want results ASAP,\nbut rather just semi quickly without eating all of their CPU. When nil,\ndefaults to half of your CPU cores.\"\n :type '(choice integer (const nil \"Half of CPU cores.\"))\n :group 'lsp-go)\n\n(defcustom lsp-go-use-binary-pkg-cache t\n \"Whether or not $GOPATH\/pkg binary .a files should be used.\"\n :type 'bool\n :group 'lsp-go)\n\n(define-inline lsp-go--bool-to-json (val)\n (inline-quote (if ,val t :json-false)))\n\n(defun lsp-go--make-init-options (_)\n `(:funcSnippetEnabled ,(lsp-go--bool-to-json lsp-go-func-snippet-enabled)\n :gocodeCompletionEnabled ,(lsp-go--bool-to-json lsp-go-gocode-completion-enabled)\n :formatTool ,lsp-go-format-tool\n :goimportsLocalPrefix ,lsp-go-imports-local-prefix\n :maxParallelism ,lsp-go-max-parallelism\n :useBinaryPkgCache ,lsp-go-use-binary-pkg-cache))\n\n(lsp-define-stdio-client lsp-go \"go\" #'(lambda () default-directory)\n `(,lsp-go-executable-path\n \"-mode=stdio\"\n ,@lsp-go-language-server-flags)\n :ignore-regexps\n '(\"^langserver-go: reading on stdin, writing on stdout$\")\n :extra-init-params #'lsp-go--make-init-options)\n\n(provide 'lsp-go)\n;;; lsp-go.el ends here\n","avg_line_length":35.2976190476,"max_line_length":105,"alphanum_fraction":0.6495784148} {"size":1993,"ext":"el","lang":"Emacs Lisp","max_stars_count":9.0,"content":";;; +completion.el --- Completion -*- lexical-binding: t; -*-\n;;; Commentary:\n;;; Code:\n\n;;; Company\n\n;; Disable automatic completion start\n(setq company-idle-delay nil\n ;; Number the candidates (use M-1, M-2 etc to select completions).\n company-show-numbers t\n ;; Selecting item last wraps around.\n company-selection-wrap-around t)\n\n(map! :when (featurep! :completion company)\n :after company\n :map company-mode-map\n :i [C-return] #'company-complete-selection)\n\n\n;;; Ivy\n\n;; index\/count format.\n(setq ivy-count-format \"(%d\/%d)\"\n ;; Add file-at-point to the list of candidates.\n counsel-find-file-at-point t\n ;; Separator for kill rings in counsel-yank-pop.\n counsel-yank-pop-separator \"\\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\\n\"\n ;; Use the faster search tool: ripgrep.\n counsel-grep-base-command\n (if (executable-find \"rg\")\n \"rg -S --no-heading --line-number --color never '%s' %s\"\n \"grep -E -n -e %s %s\"))\n\n(after! ivy-prescient\n ;; A list of regex building funcs for each collection func.\n (pushnew! ivy-re-builders-alist\n '(counsel-pt . +ivy-prescient-non-fuzzy)\n '(counsel-grep . +ivy-prescient-non-fuzzy)\n '(counsel-imenu . +ivy-prescient-non-fuzzy)\n '(counsel-projectile-grep . +ivy-prescient-non-fuzzy)\n '(counsel-projectile-rg . +ivy-prescient-non-fuzzy)\n '(counsel-yank-pop . +ivy-prescient-non-fuzzy)\n '(projectile-grep . +ivy-prescient-non-fuzzy)\n '(projectile-ripgrep . +ivy-prescient-non-fuzzy)\n '(swiper-all . +ivy-prescient-non-fuzzy)\n '(lsp-ivy-workspace-symbol . +ivy-prescient-non-fuzzy)\n '(lsp-ivy-global-workspace-symbol . +ivy-prescient-non-fuzzy)\n '(insert-char . +ivy-prescient-non-fuzzy)\n '(counsel-unicode-char . +ivy-prescient-non-fuzzy)))\n\n\n;;; Local Variables:\n;;; byte-compile-warnings: (not free-vars unresolved)\n;;; End:\n;;; +completion.el ends here\n","avg_line_length":35.5892857143,"max_line_length":73,"alphanum_fraction":0.6171600602} {"size":7316,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; ess-font-lock.el -- font-lock color options\n\n;; Copyright (C) 2000--2006 A.J. Rossini, Rich M. Heiberger, Martin\n;;\tMaechler, Kurt Hornik, Rodney Sparapani, and Stephen Eglen.\n\n;; Original Author: Richard M. Heiberger \n;; Created: 06 Feb 2000\n\n;; Keywords: ESS, font-lock\n\n;; This file is part of ESS\n\n;; This file is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 2, or (at your option)\n;; any later version.\n;;\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\t See the\n;; GNU General Public License for more details.\n;;\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs; see the file COPYING.\tIf not, write to\n;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.\n;;\n;; In short: you may use this code any way you like, as long as you\n;; don't charge money for it, remove this notice, or hold anyone liable\n;; for its results.\n\n;;; Commentary:\n\n;; provides syntax highlighting support.\n\n;;; Code:\n\n; Requires and autoloads\n\n(require 'font-lock)\n(require 'paren)\n(if (fboundp 'show-paren-mode) (show-paren-mode 1))\n\n;;; Emacs 20.x notes:\n\n;; font-lock faces are defined in \/emacs\/emacs-20.5\/lisp\/font-lock.el\n;; The font-lock faces are applied to ESS buffers by\n;; ess-mode.el ess-inf.el ess-trns.el ess-cust.el\n;; The keywords for faces are defined in the ess[dl]*.el files.\n;; All faces can be looked at, under Emacs 20.x, with\n;; [menu-bar] [Edit] [Text Properties] [Display Faces}\n\n;;; For XEmacs\n\n;; ... (tony needs to write something here).\n\n(defun ess-font-lock-rmh ()\n \"Set font-lock colors to Richard Heiberger's usual choice.\"\n (interactive)\n\n (set-foreground-color \"Black\")\n (set-background-color \"lightcyan\")\n (set-face-background 'modeline \"lightskyblue\")\n (set-face-foreground 'modeline \"midnightblue\")\n\n (set-face-foreground 'font-lock-comment-face \"Firebrick\")\n (set-face-foreground 'font-lock-function-name-face \"Blue\")\n (set-face-foreground 'font-lock-keyword-face \"Purple\")\n (if (eq font-lock-reference-face 'font-lock-constant-face )\n (set-face-foreground 'font-lock-constant-face \"Brown\")\n (set-face-foreground 'font-lock-reference-face \"Brown\"))\n (set-face-foreground 'font-lock-string-face \"VioletRed\")\n (set-face-foreground 'font-lock-type-face \"Sienna\")\n (set-face-foreground 'font-lock-variable-name-face \"Black\"))\n\n(defun ess-font-lock-blue ()\n \"Set font-lock colors to Richard Heiberger's blue color scheme.\"\n (interactive)\n\n (set-foreground-color \"Black\")\n (set-background-color \"LightBlue\")\n (set-face-foreground 'modeline \"LightBlue\")\n (set-face-background 'modeline \"DarkSlateBlue\")\n\n (set-face-foreground 'font-lock-comment-face \"Firebrick\")\n (set-face-foreground 'font-lock-function-name-face \"Blue\")\n (set-face-foreground 'font-lock-keyword-face \"Purple\")\n (if (eq font-lock-reference-face 'font-lock-constant-face )\n (set-face-foreground 'font-lock-constant-face \"Brown\")\n (set-face-foreground 'font-lock-reference-face \"Brown\"))\n (set-face-foreground 'font-lock-string-face \"VioletRed\")\n (set-face-foreground 'font-lock-type-face \"Sienna\")\n (set-face-foreground 'font-lock-variable-name-face \"Black\"))\n\n(defun ess-font-lock-wheat ()\n \"Set font-lock colors to Richard Heiberger's wheat color scheme.\"\n (interactive)\n\n (set-foreground-color \"Black\")\n (set-background-color \"Wheat\")\n (set-face-foreground 'modeline \"Wheat\")\n (set-face-background 'modeline \"Sienna\")\n\n (set-face-foreground 'font-lock-comment-face \"Firebrick\")\n (set-face-foreground 'font-lock-function-name-face \"Blue\")\n (set-face-foreground 'font-lock-keyword-face \"Purple\")\n (if (eq font-lock-reference-face 'font-lock-constant-face )\n (set-face-foreground 'font-lock-constant-face \"Brown\")\n (set-face-foreground 'font-lock-reference-face \"Brown\"))\n (set-face-foreground 'font-lock-string-face \"VioletRed\")\n (set-face-foreground 'font-lock-type-face \"Sienna\")\n (set-face-foreground 'font-lock-variable-name-face \"Black\"))\n\n\n(defun ess-font-lock-bw ()\n \"Set font-lock colors to Richard Heiberger's black and white color scheme.\"\n (interactive)\n\n (set-foreground-color \"Black\")\n (set-background-color \"white\")\n (set-face-foreground 'modeline \"gray10\")\n (set-face-background 'modeline \"gray90\")\n\n ;; modify-face is an interactive compiled Lisp function in `faces'.\n ;; Sample usage:\n\n ;;(modify-face FACE\t\t\t FOREGROUND BACKGROUND STIPPLE BOLD-P ITALIC-P UNDERLINE-P &optional INVERSE-P FRAME)\n\n (modify-face 'modeline\t\t \"gray10\"\t\"gray90\" nil\t nil\t t\t nil\t )\n (modify-face 'font-lock-comment-face\t \"black\"\t\"white\"\t nil\t nil\t t\t nil\t )\n (modify-face 'font-lock-function-name-face \"black\"\t\"white\"\t nil\t t\t nil\t nil\t )\n (modify-face 'font-lock-keyword-face\t \"black\"\t\"white\"\t nil\t nil\t nil\t t\t )\n (if (eq font-lock-reference-face 'font-lock-constant-face )\n (modify-face 'font-lock-constant-face \"black\" \"white\" nil t nil nil )\n (modify-face 'font-lock-reference-face \"black\"\t\"white\"\t nil\t t\t nil\t nil\t ))\n (modify-face 'font-lock-string-face\t \"black\"\t\"white\"\t nil\t nil\t t\t t\t )\n (modify-face 'font-lock-type-face\t \"black\"\t\"white\"\t nil\t t\t t\t nil\t )\n (modify-face 'font-lock-variable-name-face \"black\"\t\"white\"\t nil\t nil\t nil\t nil\t )\n (modify-face 'font-lock-builtin-face\t \"black\"\t\"white\"\t nil\t t\t nil\t nil\t )\n (modify-face 'font-lock-warning-face\t \"black\"\t\"white\"\t nil\t t\t nil\t nil\t )\n (modify-face 'show-paren-match-face\t \"gray20\"\t\"gray80\" nil\t t\t nil\t nil\t )\n (modify-face 'show-paren-mismatch-face \"white\"\t\"gray40\" nil\t t\t t\t nil\t ))\n\n(defun ess-font-lock-db ()\n \"Set font-lock colors (leave fore-\/back-ground alone) courtesy David Brahm \" \n (interactive)\n (set-face-foreground 'font-lock-comment-face\t \"Firebrick\") ; #... %...\n (set-face-foreground 'font-lock-string-face\t \"SeaGreen\") ; \"...\" \"...\"\n (set-face-foreground 'font-lock-keyword-face\t \"MediumBlue\") ; if\t \\end\n (set-face-foreground 'font-lock-function-name-face \"VioletRed\") ; talk<- {center}\n (set-face-foreground 'font-lock-variable-name-face \"Blue\")\t ; xv\n (set-face-foreground 'font-lock-type-face\t \"Goldenrod\") ; T,F ?\n (if (eq font-lock-reference-face 'font-lock-constant-face )\n (set-face-foreground 'font-lock-constant-face \"Magenta\") ; <-\t {eq1}\n (set-face-foreground 'font-lock-reference-face \"Magenta\"))\n)\n\n(provide 'ess-font-lock)\n\n\f ; Local variables section\n\n;;; This file is automatically placed in Outline minor mode.\n;;; The file is structured as follows:\n;;; Chapters:\t ^L ;\n;;; Sections:\t ;;*;;\n;;; Subsections: ;;;*;;;\n;;; Components:\t defuns, defvars, defconsts\n;;;\t\t Random code beginning with a ;;;;* comment\n;;; Local variables:\n;;; mode: emacs-lisp\n;;; mode: outline-minor\n;;; outline-regexp: \"\\^L\\\\|\\\\`;\\\\|;;\\\\*\\\\|;;;\\\\*\\\\|(def[cvu]\\\\|(setq\\\\|;;;;\\\\*\"\n;;; End:\n\n;;; ess-font-lock.el ends here\n","avg_line_length":41.8057142857,"max_line_length":113,"alphanum_fraction":0.671131766} {"size":1541,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":";;; seq.el --- Sequence manipulation functions -*- lexical-binding: t -*-\n\n;; Copyright (C) 2014-2020 Free Software Foundation, Inc.\n\n;; Author: Nicolas Petton \n;; Keywords: sequences\n;; Version: 2.22\n;; Package: seq\n\n;; Maintainer: emacs-devel@gnu.org\n\n;; This file is part of GNU Emacs.\n\n;; GNU Emacs is free software: you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; GNU Emacs is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs. If not, see .\n\n;;; Commentary:\n\n;; Sequence-manipulation functions that complement basic functions\n;; provided by subr.el.\n;;\n;; All functions are prefixed with \"seq-\".\n;;\n;; All provided functions work on lists, strings and vectors.\n;;\n;; Functions taking a predicate or iterating over a sequence using a\n;; function as argument take the function as their first argument and\n;; the sequence as their second argument. All other functions take\n;; the sequence as their first argument.\n\n;;; Code:\n\n(if (version< emacs-version \"25\")\n (require 'seq-24)\n (require 'seq-25))\n\n(provide 'seq)\n;;; seq.el ends here\n","avg_line_length":31.4489795918,"max_line_length":74,"alphanum_fraction":0.727449708} {"size":129,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; ~\/.doom.d\/config\/org-mode.el -*- lexical-binding: t; -*-\n\n;; Place your org-mode settings here\n\n(setq org-directory \"~\/org\")\n","avg_line_length":21.5,"max_line_length":60,"alphanum_fraction":0.6356589147} {"size":90678,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; rust-mode-tests.el --- ERT tests for rust-mode.el\n\n(require 'rust-mode)\n(require 'ert)\n(require 'cl)\n(require 'imenu)\n\n(setq rust-test-fill-column 32)\n(setq-default indent-tabs-mode nil)\n\n(defun rust-compare-code-after-manip (original point-pos manip-func expected got)\n (equal expected got))\n\n(defun rust-test-explain-bad-manip (original point-pos manip-func expected got)\n (if (equal expected got)\n nil\n (list\n ;; The (goto-char) and (insert) business here is just for\n ;; convenience--after an error, you can copy-paste that into emacs eval to\n ;; insert the bare strings into a buffer\n \"Rust code was manipulated wrong after:\"\n `(insert ,original)\n `(goto-char ,point-pos)\n 'expected `(insert ,expected)\n 'got `(insert ,got)\n (loop for i from 0 to (max (length original) (length expected))\n for oi = (if (< i (length got)) (elt got i))\n for ei = (if (< i (length expected)) (elt expected i))\n while (equal oi ei)\n finally return `(first-difference-at\n (goto-char ,(+ 1 i))\n expected ,(char-to-string ei)\n got ,(char-to-string oi))))))\n(put 'rust-compare-code-after-manip 'ert-explainer\n 'rust-test-explain-bad-manip)\n\n(defun rust-test-manip-code (original point-pos manip-func expected)\n (with-temp-buffer\n (rust-mode)\n (insert original)\n (goto-char point-pos)\n (funcall manip-func)\n (should (rust-compare-code-after-manip\n original point-pos manip-func expected (buffer-string)))))\n\n(defun test-fill-paragraph (unfilled expected &optional start-pos end-pos)\n \"We're going to run through many scenarios here--the point should be able to be anywhere from the start-pos (defaults to 1) through end-pos (defaults to the length of what was passed in) and (fill-paragraph) should return the same result. It should also work with fill-region from start-pos to end-pos.\n\nAlso, the result should be the same regardless of whether the code is at the beginning or end of the file. (If you're not careful, that can make a difference.) So we test each position given above with the passed code at the beginning, the end, neither and both. So we do this a total of 1 + (end-pos - start-pos)*4 times. Oy.\"\n (let* ((start-pos (or start-pos 1))\n (end-pos (or end-pos (length unfilled)))\n (padding \"\\n \\n\")\n (padding-len (length padding)))\n (loop\n for pad-at-beginning from 0 to 1\n do (loop for pad-at-end from 0 to 1\n with padding-beginning = (if (= 0 pad-at-beginning) \"\" padding)\n with padding-end = (if (= 0 pad-at-end) \"\" padding)\n with padding-adjust = (* padding-len pad-at-beginning)\n with padding-beginning = (if (= 0 pad-at-beginning) \"\" padding)\n with padding-end = (if (= 0 pad-at-end) \"\" padding)\n ;; If we're adding space to the beginning, and our start position\n ;; is at the very beginning, we want to test within the added space.\n ;; Otherwise adjust the start and end for the beginning padding.\n with start-pos = (if (= 1 start-pos) 1 (+ padding-adjust start-pos))\n with end-pos = (+ end-pos padding-adjust)\n do (loop for pos from start-pos to end-pos\n do (rust-test-manip-code\n (concat padding-beginning unfilled padding-end)\n pos\n (lambda ()\n (let ((fill-column rust-test-fill-column))\n (fill-paragraph)))\n (concat padding-beginning expected padding-end)))))\n ;; In addition to all the fill-paragraph tests, check that it works using fill-region\n (rust-test-manip-code\n unfilled\n start-pos\n (lambda ()\n (let ((fill-column rust-test-fill-column))\n (fill-region start-pos end-pos)))\n expected)\n ))\n\n(ert-deftest fill-paragraph-top-level-multi-line-style-doc-comment-second-line ()\n (test-fill-paragraph\n \"\/**\n * This is a very very very very very very very long string\n *\/\"\n \"\/**\n * This is a very very very very\n * very very very long string\n *\/\"))\n\n\n(ert-deftest fill-paragraph-top-level-multi-line-style-doc-comment-first-line ()\n (test-fill-paragraph\n \"\/** This is a very very very very very very very long string\n *\/\"\n \"\/** This is a very very very\n * very very very very long\n * string\n *\/\"))\n\n(ert-deftest fill-paragraph-multi-paragraph-multi-line-style-doc-comment ()\n (let\n ((multi-paragraph-unfilled\n \"\/**\n * This is the first really really really really really really really long paragraph\n *\n * This is the second really really really really really really long paragraph\n *\/\"))\n (test-fill-paragraph\n multi-paragraph-unfilled\n \"\/**\n * This is the first really\n * really really really really\n * really really long paragraph\n *\n * This is the second really really really really really really long paragraph\n *\/\"\n 1 89)\n (test-fill-paragraph\n multi-paragraph-unfilled\n \"\/**\n * This is the first really really really really really really really long paragraph\n *\n * This is the second really\n * really really really really\n * really long paragraph\n *\/\"\n 90)))\n\n(ert-deftest fill-paragraph-multi-paragraph-single-line-style-doc-comment ()\n (let\n ((multi-paragraph-unfilled\n \"\/\/\/ This is the first really really really really really really really long paragraph\n\/\/\/\n\/\/\/ This is the second really really really really really really long paragraph\"))\n (test-fill-paragraph\n multi-paragraph-unfilled\n \"\/\/\/ This is the first really\n\/\/\/ really really really really\n\/\/\/ really really long paragraph\n\/\/\/\n\/\/\/ This is the second really really really really really really long paragraph\"\n 1 86)\n (test-fill-paragraph\n multi-paragraph-unfilled\n \"\/\/\/ This is the first really really really really really really really long paragraph\n\/\/\/\n\/\/\/ This is the second really\n\/\/\/ really really really really\n\/\/\/ really long paragraph\"\n 87)))\n\n(ert-deftest fill-paragraph-multi-paragraph-single-line-style-indented ()\n (test-fill-paragraph\n \" \/\/ This is the first really really really really really really really long paragraph\n \/\/\n \/\/ This is the second really really really really really really long paragraph\"\n \" \/\/ This is the first really\n \/\/ really really really\n \/\/ really really really\n \/\/ long paragraph\n \/\/\n \/\/ This is the second really really really really really really long paragraph\" 1 89))\n\n(ert-deftest fill-paragraph-multi-line-style-comment ()\n (test-fill-paragraph\n \"\/* This is a very very very very very very very very long string\n *\/\"\n \"\/* This is a very very very very\n * very very very very long\n * string\n *\/\"))\n\n(ert-deftest fill-paragraph-multi-line-style-inner-doc-comment ()\n (test-fill-paragraph\n \"\/*! This is a very very very very very very very long string\n *\/\"\n \"\/*! This is a very very very\n * very very very very long\n * string\n *\/\"))\n\n(ert-deftest fill-paragraph-single-line-style-inner-doc-comment ()\n (test-fill-paragraph\n \"\/\/! This is a very very very very very very very long string\"\n \"\/\/! This is a very very very\n\/\/! very very very very long\n\/\/! string\"))\n\n(ert-deftest fill-paragraph-prefixless-multi-line-doc-comment ()\n (test-fill-paragraph\n \"\/**\nThis is my summary. Blah blah blah blah blah. Dilly dally dilly dally dilly dally doo.\n\nThis is some more text. Fee fie fo fum. Humpty dumpty sat on a wall.\n*\/\"\n \"\/**\nThis is my summary. Blah blah\nblah blah blah. Dilly dally\ndilly dally dilly dally doo.\n\nThis is some more text. Fee fie fo fum. Humpty dumpty sat on a wall.\n*\/\" 4 90))\n\n(ert-deftest fill-paragraph-with-no-space-after-star-prefix ()\n (test-fill-paragraph\n \"\/**\n *This is a very very very very very very very long string\n *\/\"\n \"\/**\n *This is a very very very very\n *very very very long string\n *\/\"))\n\n(ert-deftest fill-paragraph-single-line-style-with-code-before ()\n (test-fill-paragraph\n \"fn foo() { }\n\/\/\/ This is my comment. This is more of my comment. This is even more.\"\n \"fn foo() { }\n\/\/\/ This is my comment. This is\n\/\/\/ more of my comment. This is\n\/\/\/ even more.\" 14))\n\n(ert-deftest fill-paragraph-single-line-style-with-code-after ()\n (test-fill-paragraph\n \"\/\/\/ This is my comment. This is more of my comment. This is even more.\nfn foo() { }\"\n \"\/\/\/ This is my comment. This is\n\/\/\/ more of my comment. This is\n\/\/\/ even more.\nfn foo() { }\" 1 73))\n\n(ert-deftest fill-paragraph-single-line-style-code-before-and-after ()\n (test-fill-paragraph\n \"fn foo() { }\n\/\/\/ This is my comment. This is more of my comment. This is even more.\nfn bar() { }\"\n \"fn foo() { }\n\/\/\/ This is my comment. This is\n\/\/\/ more of my comment. This is\n\/\/\/ even more.\nfn bar() { }\" 14 85))\n\n(defun test-auto-fill (initial position inserted expected)\n (rust-test-manip-code\n initial\n position\n (lambda ()\n (unwind-protect\n (progn\n (let ((fill-column rust-test-fill-column))\n (auto-fill-mode)\n (goto-char position)\n (insert inserted)\n (syntax-ppss-flush-cache 1)\n (funcall auto-fill-function)))\n (auto-fill-mode t)))\n expected))\n\n(ert-deftest auto-fill-multi-line-doc-comment ()\n (test-auto-fill\n \"\/**\n *\n *\/\"\n 7\n \" This is a very very very very very very very long string\"\n \"\/**\n * This is a very very very very\n * very very very long string\n *\/\"))\n\n(ert-deftest auto-fill-single-line-doc-comment ()\n (test-auto-fill\n \"\/\/\/ This is the first really\n\/\/\/ really really really really\n\/\/\/ really really long paragraph\n\/\/\/\n\/\/\/ \"\n 103\n \"This is the second really really really really really really long paragraph\"\n \"\/\/\/ This is the first really\n\/\/\/ really really really really\n\/\/\/ really really long paragraph\n\/\/\/\n\/\/\/ This is the second really\n\/\/\/ really really really really\n\/\/\/ really long paragraph\"\n ))\n\n(ert-deftest auto-fill-multi-line-prefixless ()\n (test-auto-fill\n \"\/*\n\n *\/\"\n 4\n \"This is a very very very very very very very long string\"\n \"\/*\nThis is a very very very very\nvery very very long string\n *\/\"\n ))\n\n(defun test-indent (indented &optional deindented)\n (let ((deindented (or deindented (replace-regexp-in-string \"^[[:blank:]]*\" \" \" indented))))\n (rust-test-manip-code\n deindented\n 1\n (lambda ()\n (indent-region 1 (+ 1 (buffer-size))))\n indented)))\n\n\n(ert-deftest indent-struct-fields-aligned ()\n (test-indent\n \"\nstruct Foo { bar: i32,\n baz: i32 }\n\nstruct Blah {x:i32,\n y:i32,\n z:String\"))\n\n(ert-deftest indent-doc-comments ()\n (test-indent\n \"\n\/**\n * This is a doc comment\n *\n *\/\n\n\/\/\/ So is this\n\nfn foo() {\n \/*!\n * this is a nested doc comment\n *\/\n \\n \/\/! And so is this\n}\"))\n\n(ert-deftest indent-inside-braces ()\n (test-indent\n \"\n\/\/ struct fields out one level:\nstruct foo {\n a:i32,\n \/\/ comments too\n b:char\n}\n\nfn bar(x:Box) { \/\/ comment here should not affect the next indent\n bla();\n bla();\n}\"))\n\n(ert-deftest indent-top-level ()\n (test-indent\n \"\n\/\/ Everything here is at the top level and should not be indented\n#[attrib]\nmod foo;\n\npub static bar = Quux{a: b()}\n\nuse foo::bar::baz;\n\nfn foo() { }\n\"))\n\n(ert-deftest font-lock-multi-raw-strings-in-a-row ()\n (rust-test-font-lock\n \"\nr\\\"foo\\\\\\\", \\\"bar\\\", r\\\"bar\\\";\nr\\\"foo\\\\.\\\", \\\"bar\\\", r\\\"bar\\\";\nr\\\"foo\\\\..\\\", \\\"bar\\\", r\\\"foo\\\\..\\\\bar\\\";\nr\\\"\\\\\\\", \\\"foo\\\", r\\\"\\\\foo\\\";\nnot_a_string();\n\n\"\n\n (apply 'append (mapcar (lambda (s) (list s 'font-lock-string-face))\n '(\"r\\\"foo\\\\\\\"\" \"\\\"bar\\\"\" \"r\\\"bar\\\"\"\n \"r\\\"foo\\\\.\\\"\" \"\\\"bar\\\"\" \"r\\\"bar\\\"\"\n \"r\\\"foo\\\\..\\\"\" \"\\\"bar\\\"\" \"r\\\"foo\\\\..\\\\bar\\\"\"\n \"r\\\"\\\\\\\"\" \"\\\"foo\\\"\" \"r\\\"\\\\foo\\\"\")))\n ))\n\n(ert-deftest font-lock-raw-string-after-normal-string-ending-in-r ()\n (rust-test-font-lock\n \"\\\"bar\\\" r\\\"foo\\\"\"\n '(\"\\\"bar\\\"\" font-lock-string-face \"r\\\"foo\\\"\" font-lock-string-face)))\n\n(ert-deftest indent-params-no-align ()\n (test-indent\n \"\n\/\/ Indent out one level because no params appear on the first line\nfn xyzzy(\n a:i32,\n b:char) { }\n\nfn abcdef(\n a:i32,\n b:char)\n -> char\n{ }\"))\n\n(ert-deftest indent-params-align ()\n (test-indent\n \"\n\/\/ Align the second line of params to the first\nfn foo(a:i32,\n b:char) { }\n\nfn bar( a:i32,\n b:char)\n -> i32\n{ }\n\nfn baz( a:i32, \/\/ should work with a comment here\n b:char)\n -> i32\n{ }\n\"))\n\n(ert-deftest indent-open-after-arrow ()\n (test-indent\n \"\n\/\/ Indent function body only one level after `-> {`\nfn foo1(a:i32, b:char) -> i32 {\n let body;\n}\n\nfn foo2(a:i32,\n b:char) -> i32 {\n let body;\n}\n\nfn foo3(a:i32,\n b:char)\n -> i32 {\n let body;\n}\n\nfn foo4(a:i32,\n b:char)\n -> i32 where i32:A {\n let body;\n}\n\"))\n\n(ert-deftest indent-return-type-non-visual ()\n (let ((rust-indent-return-type-to-arguments nil))\n(test-indent\n \"\nfn imagine_long_enough_to_wrap_at_arrow(a:i32, b:char)\n -> i32\n{\n let body;\n}\n\")))\n\n(ert-deftest indent-body-after-where ()\n (let ((rust-indent-where-clause t))\n (test-indent\n \"\nfn foo1(a: A, b: B) -> A\n where A: Clone + Default, B: Eq {\n let body;\n Foo {\n bar: 3\n }\n}\n\nfn foo2(a: A, b: B) -> A\n where A: Clone + Default, B: Eq\n{\n let body;\n Foo {\n bar: 3\n }\n}\n\")))\n\n(ert-deftest indent-align-where-clauses-style1a ()\n (let ((rust-indent-where-clause t))\n (test-indent\n \"\nfn foo1a(a: A, b: B, c: C) -> D\n where A: Clone + Default,\n B: Eq,\n C: PartialEq,\n D: PartialEq {\n let body;\n Foo {\n bar: 3\n }\n}\n\")))\n\n(ert-deftest indent-align-where-clauses-style1b ()\n (let ((rust-indent-where-clause t))\n (test-indent\n \"\nfn foo1b(a: A, b: B, c: C) -> D\n where A: Clone + Default,\n B: Eq,\n C: PartialEq,\n D: PartialEq\n{\n let body;\n Foo {\n bar: 3\n }\n}\n\")))\n\n(ert-deftest indent-align-where-clauses-style2a ()\n (test-indent\n \"\nfn foo2a(a: A, b: B, c: C) -> D where A: Clone + Default,\n B: Eq,\n C: PartialEq,\n D: PartialEq {\n let body;\n Foo {\n bar: 3\n }\n}\n\"))\n\n(ert-deftest indent-align-where-clauses-style2b ()\n (test-indent\n \"\nfn foo2b(a: A, b: B, c: C) -> D where A: Clone + Default,\n B: Eq,\n C: PartialEq,\n D: PartialEq\n{\n let body;\n Foo {\n bar: 3\n }\n}\n\"))\n\n(ert-deftest indent-align-where-clauses-style3a ()\n (test-indent\n \"\nfn foo3a(a: A, b: B, c: C) -> D where\n A: Clone + Default,\n B: Eq,\n C: PartialEq,\n D: PartialEq {\n let body;\n Foo {\n bar: 3\n }\n}\n\"))\n\n(ert-deftest indent-align-where-clauses-style3b ()\n (test-indent\n \"\nfn foo3b(a: A, b: B, c: C) -> D where\n A: Clone + Default,\n B: Eq,\n C: PartialEq,\n D: PartialEq\n{\n let body;\n Foo {\n bar: 3\n }\n}\n\"))\n\n(ert-deftest indent-align-where-clauses-style4a ()\n (let ((rust-indent-where-clause nil))\n (test-indent\n \"\nfn foo4a(a: A, b: B, c: C) -> D\nwhere A: Clone + Default,\n B: Eq,\n C: PartialEq,\n D: PartialEq {\n let body;\n Foo {\n bar: 3\n }\n}\n\")))\n\n(ert-deftest indent-align-where-clauses-style4b ()\n (let ((rust-indent-where-clause nil))\n (test-indent\n \"\nfn foo4b(a: A, b: B, c: C) -> D\nwhere A: Clone + Default,\n B: Eq,\n C: PartialEq,\n D: PartialEq\n{\n let body;\n Foo {\n bar: 3\n }\n}\n\")))\n\n(ert-deftest indent-align-where-clauses-impl-example ()\n (let ((rust-indent-where-clause t))\n (test-indent\n \"\nimpl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap\n where K: Eq + Hash + Borrow,\n Q: Eq + Hash,\n S: HashState,\n{\n let body;\n Foo {\n bar: 3\n }\n}\n\")))\n\n(ert-deftest indent-align-where-clauses-first-line ()\n (let ((rust-indent-where-clause t))\n (test-indent\n \"fn foo1(a: A, b: B) -> A\n where A: Clone + Default, B: Eq {\n let body;\n Foo {\n bar: 3\n }\n}\n\")))\n\n(ert-deftest indent-align-where-in-comment1 ()\n (test-indent\n \"\/\/\/ - there must not exist an edge U->V in the graph where:\n#[derive(Clone, PartialEq, Eq)]\npub struct Region { \/\/ <-- this should be flush with left margin!\n entry: BasicBlockIndex,\n leaves: BTreeMap,\n}\n\"))\n\n(ert-deftest indent-align-where-in-comment2 ()\n (let ((rust-indent-where-clause t))\n (test-indent\n \"fn foo(f:F, g:G)\n where F:Send,\n\/\/ where\n G:Sized\n{\n let body;\n}\n\")))\n\n(ert-deftest indent-align-where-in-comment3 ()\n (let ((rust-indent-where-clause t))\n (test-indent\n \"fn foo(f:F, g:G)\n where F:Send,\n\/\/ where F:ThisIsNotActualCode,\n G:Sized\n{\n let body;\n}\n\")))\n\n(ert-deftest indent-square-bracket-alignment ()\n (test-indent\n \"\nfn args_on_the_next_line( \/\/ with a comment\n a:i32,\n b:String) {\n let aaaaaa = [\n 1,\n 2,\n 3];\n let bbbbbbb = [1, 2, 3,\n 4, 5, 6];\n let ccc = [ 10, 9, 8,\n 7, 6, 5];\n}\n\"))\n\n(ert-deftest indent-closing-square-bracket ()\n (test-indent\n \"fn blergh() {\n let list = vec![\n 1,\n 2,\n 3,\n ];\n}\"))\n\n(ert-deftest indent-closing-paren ()\n (test-indent\n \"fn blergh() {\n call(\n a,\n function\n );\n}\"))\n\n(ert-deftest indent-nested-fns ()\n (test-indent\n \"\nfn nexted_fns(a: fn(b:i32,\n c:char)\n -> i32,\n d: i32)\n -> u128\n{\n 0\n}\n\"\n ))\n\n(ert-deftest indent-multi-line-expr ()\n (test-indent\n \"\nfn foo()\n{\n x();\n let a =\n b();\n}\n\"\n ))\n\n(ert-deftest indent-match ()\n (test-indent\n \"\nfn foo() {\n match blah {\n Pattern => stuff(),\n _ => whatever\n }\n}\n\"\n ))\n\n(ert-deftest indent-match-multiline-pattern ()\n (test-indent\n \"\nfn foo() {\n match blah {\n Pattern |\n Pattern2 => {\n hello()\n },\n _ => whatever\n }\n}\n\"\n ))\n\n(ert-deftest indent-indented-match ()\n (test-indent\n \"\nfn foo() {\n let x =\n match blah {\n Pattern |\n Pattern2 => {\n hello()\n },\n _ => whatever\n };\n y();\n}\n\"\n ))\n\n(ert-deftest indent-curly-braces-within-parens ()\n (test-indent\n \"\nfn foo() {\n let x =\n foo(bar(|x| {\n only_one_indent_here();\n }));\n y();\n}\n\"\n ))\n\n(ert-deftest indent-weirdly-indented-block ()\n (rust-test-manip-code\n \"\nfn foo() {\n {\nthis_block_is_over_to_the_left_for_some_reason();\n }\n\n}\n\"\n 16\n #'indent-for-tab-command\n \"\nfn foo() {\n {\n this_block_is_over_to_the_left_for_some_reason();\n }\n\n}\n\"\n ))\n\n(ert-deftest indent-multi-line-attrib ()\n (test-indent\n \"\n#[attrib(\n this,\n that,\n theotherthing)]\nfn function_with_multiline_attribute() {}\n\"\n ))\n\n\n;; Make sure that in effort to cover match patterns we don't mistreat || or expressions\n(ert-deftest indent-nonmatch-or-expression ()\n (test-indent\n \"\nfn foo() {\n let x = foo() ||\n bar();\n}\n\"\n ))\n\n;; Closing braces in single char literals and strings should not confuse the indentation\n(ert-deftest indent-closing-braces-in-char-literals ()\n (test-indent\n \"\nfn foo() {\n { bar('}'); }\n { bar(']'); }\n { bar(')'); }\n}\n\"\n ))\n\n;; This is a test for #103: a comment after the last struct member that does\n;; not have a trailing comma. The comment used to be indented one stop too\n;; far.\n(ert-deftest indent-comment-after-last-struct-member ()\n (test-indent\n \"\nstruct A {\n x: u8\n \/\/ comment\n}\n\nstruct A {\n x: u8\n \/* comment *\/\n}\n\"\n ))\n\n(setq rust-test-motion-string\n \"\nfn fn1(arg: i32) -> bool {\n let x = 5;\n let y = b();\n true\n}\n\nfn fn2(arg: i32) -> bool {\n let x = 5;\n let y = b();\n true\n}\n\npub fn fn3(arg: i32) -> bool {\n let x = 5;\n let y = b();\n true\n}\n\nstruct Foo {\n x: i32\n}\n\"\n rust-test-region-string rust-test-motion-string\n rust-test-indent-motion-string\n \"\nfn blank_line(arg:i32) -> bool {\n\n}\n\nfn indenting_closing_brace() {\n if(true) {\n}\n}\n\nfn indenting_middle_of_line() {\n if(true) {\n push_me_out();\n} else {\n pull_me_back_in();\n}\n}\n\nfn indented_already() {\n\n \/\/ The previous line already has its spaces\n}\n\"\n\n ;; Symbol -> (line column)\n rust-test-positions-alist '((start-of-fn1 (2 0))\n (start-of-fn1-middle-of-line (2 15))\n (middle-of-fn1 (3 7))\n (end-of-fn1 (6 0))\n (between-fn1-fn2 (7 0))\n (start-of-fn2 (8 0))\n (middle-of-fn2 (10 4))\n (before-start-of-fn1 (1 0))\n (after-end-of-fn2 (13 0))\n (beginning-of-fn3 (14 0))\n (middle-of-fn3 (16 4))\n (middle-of-struct (21 10))\n (before-start-of-struct (19 0))\n (after-end-of-struct (23 0))\n (blank-line-indent-start (3 0))\n (blank-line-indent-target (3 4))\n (closing-brace-indent-start (8 1))\n (closing-brace-indent-target (8 5))\n (middle-push-indent-start (13 2))\n (middle-push-indent-target (13 9))\n (after-whitespace-indent-start (13 1))\n (after-whitespace-indent-target (13 8))\n (middle-pull-indent-start (15 19))\n (middle-pull-indent-target (15 12))\n (blank-line-indented-already-bol-start (20 0))\n (blank-line-indented-already-bol-target (20 4))\n (blank-line-indented-already-middle-start (20 2))\n (blank-line-indented-already-middle-target (20 4))\n (nonblank-line-indented-already-bol-start (21 0))\n (nonblank-line-indented-already-bol-target (21 4))\n (nonblank-line-indented-already-middle-start (21 2))\n (nonblank-line-indented-already-middle-target (21 4))))\n\n(defun rust-get-buffer-pos (pos-symbol)\n \"Get buffer position from POS-SYMBOL.\n\nPOS-SYMBOL is a symbol found in `rust-test-positions-alist'.\nConvert the line-column information from that list into a buffer position value.\"\n (interactive \"P\")\n (let* (\n (line-and-column (cadr (assoc pos-symbol rust-test-positions-alist)))\n (line (nth 0 line-and-column))\n (column (nth 1 line-and-column)))\n (save-excursion\n (goto-line line)\n (move-to-column column)\n (point))))\n\n;;; FIXME: Maybe add an ERT explainer function (something that shows the\n;;; surrounding code of the final point, not just the position).\n(defun rust-test-motion (source-code init-pos final-pos manip-func &rest args)\n \"Test that MANIP-FUNC moves point from INIT-POS to FINAL-POS.\n\nIf ARGS are provided, send them to MANIP-FUNC.\n\nINIT-POS, FINAL-POS are position symbols found in `rust-test-positions-alist'.\"\n (with-temp-buffer\n (rust-mode)\n (insert source-code)\n (goto-char (rust-get-buffer-pos init-pos))\n (apply manip-func args)\n (should (equal (point) (rust-get-buffer-pos final-pos)))))\n\n(defun rust-test-region (source-code init-pos reg-beg reg-end manip-func &rest args)\n \"Test that MANIP-FUNC marks region from REG-BEG to REG-END.\n\nINIT-POS is the initial position of point.\nIf ARGS are provided, send them to MANIP-FUNC.\nAll positions are position symbols found in `rust-test-positions-alist'.\"\n (with-temp-buffer\n (rust-mode)\n (insert source-code)\n (goto-char (rust-get-buffer-pos init-pos))\n (apply manip-func args)\n (should (equal (list (region-beginning) (region-end))\n (list (rust-get-buffer-pos reg-beg)\n (rust-get-buffer-pos reg-end))))))\n\n(ert-deftest rust-beginning-of-defun-from-middle-of-fn ()\n (rust-test-motion\n rust-test-motion-string\n 'middle-of-fn1\n 'start-of-fn1\n #'beginning-of-defun))\n\n(ert-deftest rust-beginning-of-defun-from-end ()\n (rust-test-motion\n rust-test-motion-string\n 'end-of-fn1\n 'start-of-fn1\n #'beginning-of-defun))\n\n(ert-deftest rust-beginning-of-defun-before-open-brace ()\n (rust-test-motion\n rust-test-motion-string\n 'start-of-fn1-middle-of-line\n 'start-of-fn1\n #'beginning-of-defun))\n\n(ert-deftest rust-beginning-of-defun-between-fns ()\n (rust-test-motion\n rust-test-motion-string\n 'between-fn1-fn2\n 'start-of-fn1\n #'beginning-of-defun))\n\n(ert-deftest rust-beginning-of-defun-with-arg ()\n (rust-test-motion\n rust-test-motion-string\n 'middle-of-fn2\n 'start-of-fn1\n #'beginning-of-defun 2))\n\n(ert-deftest rust-beginning-of-defun-with-negative-arg ()\n (rust-test-motion\n rust-test-motion-string\n 'middle-of-fn1\n 'beginning-of-fn3\n #'beginning-of-defun -2))\n\n(ert-deftest rust-beginning-of-defun-pub-fn ()\n (rust-test-motion\n rust-test-motion-string\n 'middle-of-fn3\n 'beginning-of-fn3\n #'beginning-of-defun))\n\n(ert-deftest rust-beginning-of-defun-string-comment ()\n (let (fn-1 fn-2 p-1 p-2)\n (with-temp-buffer\n (rust-mode)\n (insert \"fn test1() {\n let s=r#\\\"\nfn test2();\n\\\"#;\")\n (setq p-1 (point))\n (setq fn-1 (1+ p-1))\n (insert \"\nfn test3() {\n \/*\nfn test4();\")\n (setq p-2 (point))\n (insert \"\\n*\/\\n}\\n\")\n (setq fn-2 (point))\n (insert \"fn test5() { }\")\n\n (goto-char p-1)\n (beginning-of-defun)\n (should (eq (point) (point-min)))\n\n (beginning-of-defun -2)\n (should (eq (point) fn-2))\n\n (goto-char p-2)\n (beginning-of-defun)\n (should (eq (point) fn-1))\n\n (beginning-of-defun -1)\n (should (eq (point) fn-2))\n\n (goto-char (point-max))\n (beginning-of-defun 2)\n (should (eq (point) fn-1)))))\n\n(ert-deftest rust-end-of-defun-from-middle-of-fn ()\n (rust-test-motion\n rust-test-motion-string\n 'middle-of-fn1\n 'between-fn1-fn2\n #'end-of-defun))\n\n(ert-deftest rust-end-of-defun-from-beg ()\n (rust-test-motion\n rust-test-motion-string\n 'start-of-fn1\n 'between-fn1-fn2\n #'end-of-defun))\n\n(ert-deftest rust-end-of-defun-before-open-brace ()\n (rust-test-motion\n rust-test-motion-string\n 'start-of-fn1-middle-of-line\n 'between-fn1-fn2\n #'end-of-defun))\n\n(ert-deftest rust-end-of-defun-between-fns ()\n (rust-test-motion\n rust-test-motion-string\n 'between-fn1-fn2\n 'after-end-of-fn2\n #'end-of-defun))\n\n(ert-deftest rust-end-of-defun-with-arg ()\n (rust-test-motion\n rust-test-motion-string\n 'middle-of-fn1\n 'after-end-of-fn2\n #'end-of-defun 2))\n\n(ert-deftest rust-end-of-defun-with-negative-arg ()\n (rust-test-motion\n rust-test-motion-string\n 'middle-of-fn3\n 'between-fn1-fn2\n #'end-of-defun -2))\n\n(ert-deftest rust-mark-defun-from-middle-of-fn ()\n (rust-test-region\n rust-test-region-string\n 'middle-of-fn2\n 'between-fn1-fn2 'after-end-of-fn2\n #'mark-defun))\n\n(ert-deftest rust-mark-defun-from-end ()\n (rust-test-region\n rust-test-region-string\n 'end-of-fn1\n 'before-start-of-fn1 'between-fn1-fn2\n #'mark-defun))\n\n(ert-deftest rust-mark-defun-start-of-defun ()\n (rust-test-region\n rust-test-region-string\n 'start-of-fn2\n 'between-fn1-fn2 'after-end-of-fn2\n #'mark-defun))\n\n(ert-deftest rust-mark-defun-from-middle-of-struct ()\n (rust-test-region\n rust-test-region-string\n 'middle-of-struct\n 'before-start-of-struct 'after-end-of-struct\n #'mark-defun))\n\n(ert-deftest indent-line-blank-line-motion ()\n (rust-test-motion\n rust-test-indent-motion-string\n 'blank-line-indent-start\n 'blank-line-indent-target\n #'indent-for-tab-command))\n\n(ert-deftest indent-line-closing-brace-motion ()\n (rust-test-motion\n rust-test-indent-motion-string\n 'closing-brace-indent-start\n 'closing-brace-indent-target\n #'indent-for-tab-command))\n\n(ert-deftest indent-line-middle-push-motion ()\n (rust-test-motion\n rust-test-indent-motion-string\n 'middle-push-indent-start\n 'middle-push-indent-target\n #'indent-for-tab-command))\n\n(ert-deftest indent-line-after-whitespace-motion ()\n (rust-test-motion\n rust-test-indent-motion-string\n 'after-whitespace-indent-start\n 'after-whitespace-indent-target\n #'indent-for-tab-command))\n\n(ert-deftest indent-line-middle-pull-motion ()\n (rust-test-motion\n rust-test-indent-motion-string\n 'middle-pull-indent-start\n 'middle-pull-indent-target\n #'indent-for-tab-command))\n\n(ert-deftest indent-line-blank-line-indented-already-bol ()\n (rust-test-motion\n rust-test-indent-motion-string\n 'blank-line-indented-already-bol-start\n 'blank-line-indented-already-bol-target\n #'indent-for-tab-command))\n\n(ert-deftest indent-line-blank-line-indented-already-middle ()\n (rust-test-motion\n rust-test-indent-motion-string\n 'blank-line-indented-already-middle-start\n 'blank-line-indented-already-middle-target\n #'indent-for-tab-command))\n\n(ert-deftest indent-line-nonblank-line-indented-already-bol ()\n (rust-test-motion\n rust-test-indent-motion-string\n 'nonblank-line-indented-already-bol-start\n 'nonblank-line-indented-already-bol-target\n #'indent-for-tab-command))\n\n(ert-deftest indent-line-nonblank-line-indented-already-middle ()\n (rust-test-motion\n rust-test-indent-motion-string\n 'nonblank-line-indented-already-middle-start\n 'nonblank-line-indented-already-middle-target\n #'indent-for-tab-command))\n\n(ert-deftest no-stack-overflow-in-rust-rewind-irrelevant ()\n (with-temp-buffer\n (rust-mode)\n (insert \"fn main() {\\n let x = 1;\")\n ;; Insert 150 separate comments on the same line\n (dotimes (i 150)\n (insert \"\/* foo *\/ \"))\n ;; Rewinding from the last commment to the end of the let needs at least\n ;; 150 iterations, but if we limit the stack depth to 100 (this appears to\n ;; be some minimum), a recursive function would overflow, throwing an\n ;; error.\n (let ((max-lisp-eval-depth 100))\n (rust-rewind-irrelevant)\n ;; Only a non-stack overflowing function would make it this far. Also\n ;; check that we rewound till after the ;\n (should (= (char-before) ?\\;)))))\n\n(defun rust-test-fontify-string (str)\n (with-temp-buffer\n (rust-mode)\n (insert str)\n (font-lock-fontify-buffer)\n (buffer-string)))\n\n(defun rust-test-group-str-by-face (str)\n \"Fontify `STR' in rust-mode and group it by face, returning a\nlist of substrings of `STR' each followed by its face.\"\n (loop with fontified = (rust-test-fontify-string str)\n for start = 0 then end\n while start\n for end = (next-single-property-change start 'face fontified)\n for prop = (get-text-property start 'face fontified)\n for text = (substring-no-properties fontified start end)\n if prop\n append (list text prop)))\n\n(defun rust-test-font-lock (source face-groups)\n \"Test that `SOURCE' fontifies to the expected `FACE-GROUPS'\"\n (should (equal (rust-test-group-str-by-face source)\n face-groups)))\n\n(ert-deftest font-lock-attribute-simple ()\n (rust-test-font-lock\n \"#[foo]\"\n '(\"#[foo]\" font-lock-preprocessor-face)))\n\n(ert-deftest font-lock-attribute-inner ()\n (rust-test-font-lock\n \"#![foo]\"\n '(\"#![foo]\" font-lock-preprocessor-face)))\n\n(ert-deftest font-lock-attribute-key-value ()\n (rust-test-font-lock\n \"#[foo = \\\"bar\\\"]\"\n '(\"#[foo = \" font-lock-preprocessor-face\n \"\\\"bar\\\"\" font-lock-string-face\n \"]\" font-lock-preprocessor-face)))\n\n(ert-deftest font-lock-attribute-around-comment ()\n (rust-test-font-lock\n \"#[foo \/* bar *\/]\"\n '(\"#[foo \" font-lock-preprocessor-face\n \"\/* \" font-lock-comment-delimiter-face\n \"bar *\/\" font-lock-comment-face\n \"]\" font-lock-preprocessor-face)))\n\n(ert-deftest font-lock-attribute-inside-string ()\n (rust-test-font-lock\n \"\\\"#[foo]\\\"\"\n '(\"\\\"#[foo]\\\"\" font-lock-string-face)))\n\n(ert-deftest font-lock-attribute-inside-comment ()\n (rust-test-font-lock\n \"\/* #[foo] *\/\"\n '(\"\/* \" font-lock-comment-delimiter-face\n \"#[foo] *\/\" font-lock-comment-face)))\n\n(ert-deftest font-lock-double-quote-character-literal ()\n (rust-test-font-lock\n \"'\\\"'; let\"\n '(\"'\\\"'\" font-lock-string-face\n \"let\" font-lock-keyword-face)))\n\n(ert-deftest font-lock-fn-contains-capital ()\n (rust-test-font-lock\n \"fn foo_Bar() {}\"\n '(\"fn\" font-lock-keyword-face\n \"foo_Bar\" font-lock-function-name-face)))\n\n(ert-deftest font-lock-let-bindings ()\n (rust-test-font-lock\n \"let foo;\"\n '(\"let\" font-lock-keyword-face\n \"foo\" font-lock-variable-name-face))\n (rust-test-font-lock\n \"let ref foo;\"\n '(\"let\" font-lock-keyword-face\n \"ref\" font-lock-keyword-face\n \"foo\" font-lock-variable-name-face))\n (rust-test-font-lock\n \"let mut foo;\"\n '(\"let\" font-lock-keyword-face\n \"mut\" font-lock-keyword-face\n \"foo\" font-lock-variable-name-face))\n (rust-test-font-lock\n \"let foo = 1;\"\n '(\"let\" font-lock-keyword-face\n \"foo\" font-lock-variable-name-face))\n (rust-test-font-lock\n \"let mut foo = 1;\"\n '(\"let\" font-lock-keyword-face\n \"mut\" font-lock-keyword-face\n \"foo\" font-lock-variable-name-face))\n (rust-test-font-lock\n \"fn foo() { let bar = 1; }\"\n '(\"fn\" font-lock-keyword-face\n \"foo\" font-lock-function-name-face\n \"let\" font-lock-keyword-face\n \"bar\" font-lock-variable-name-face))\n (rust-test-font-lock\n \"fn foo() { let mut bar = 1; }\"\n '(\"fn\" font-lock-keyword-face\n \"foo\" font-lock-function-name-face\n \"let\" font-lock-keyword-face\n \"mut\" font-lock-keyword-face\n \"bar\" font-lock-variable-name-face)))\n\n(ert-deftest font-lock-if-let-binding ()\n (rust-test-font-lock\n \"if let Some(var) = some_var { \/* no-op *\/ }\"\n '(\"if\" font-lock-keyword-face\n \"let\" font-lock-keyword-face\n \"Some\" font-lock-type-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face)))\n\n(ert-deftest font-lock-single-quote-character-literal ()\n (rust-test-font-lock\n \"fn main() { let ch = '\\\\''; }\"\n '(\"fn\" font-lock-keyword-face\n \"main\" font-lock-function-name-face\n \"let\" font-lock-keyword-face\n \"ch\" font-lock-variable-name-face\n \"'\\\\''\" font-lock-string-face)))\n\n(ert-deftest font-lock-escaped-double-quote-character-literal ()\n (rust-test-font-lock\n \"fn main() { let ch = '\\\\\\\"'; }\"\n '(\"fn\" font-lock-keyword-face\n \"main\" font-lock-function-name-face\n \"let\" font-lock-keyword-face\n \"ch\" font-lock-variable-name-face\n \"'\\\\\\\"'\" font-lock-string-face)))\n\n(ert-deftest font-lock-escaped-backslash-character-literal ()\n (rust-test-font-lock\n \"fn main() { let ch = '\\\\\\\\'; }\"\n '(\"fn\" font-lock-keyword-face\n \"main\" font-lock-function-name-face\n \"let\" font-lock-keyword-face\n \"ch\" font-lock-variable-name-face\n \"'\\\\\\\\'\" font-lock-string-face)))\n\n(ert-deftest font-lock-hex-escape-character-literal ()\n (rust-test-font-lock\n \"let ch = '\\\\x1f';\"\n '(\"let\" font-lock-keyword-face\n \"ch\" font-lock-variable-name-face\n \"'\\\\x1f'\" font-lock-string-face)))\n\n(ert-deftest font-lock-unicode-escape-character-literal ()\n (rust-test-font-lock\n \"let ch = '\\\\u{1ffff}';\"\n '(\"let\" font-lock-keyword-face\n \"ch\" font-lock-variable-name-face\n \"'\\\\u{1ffff}'\" font-lock-string-face)))\n\n(ert-deftest font-lock-raw-strings-no-hashes ()\n (rust-test-font-lock\n \"r\\\"No hashes\\\";\"\n '(\"r\\\"No hashes\\\"\" font-lock-string-face)))\n\n(ert-deftest font-lock-raw-strings-double-quote ()\n (rust-test-font-lock\n \"fn main() {\n r#\\\"With a double quote (\\\")\\\"#;\n}\n\"\n '(\"fn\" font-lock-keyword-face\n \"main\" font-lock-function-name-face\n \"r#\\\"With a double quote (\\\")\\\"#\" font-lock-string-face)))\n\n(ert-deftest font-lock-raw-strings-two-hashes ()\n (rust-test-font-lock\n \"r##\\\"With two hashes\\\"##;\"\n '(\"r##\\\"With two hashes\\\"##\" font-lock-string-face)))\n\n(ert-deftest font-lock-raw-strings-backslash-at-end ()\n (rust-test-font-lock\n \"r\\\"With a backslash at the end\\\\\\\";\"\n '(\"r\\\"With a backslash at the end\\\\\\\"\" font-lock-string-face)))\n\n(ert-deftest font-lock-two-raw-strings ()\n (rust-test-font-lock\n \"fn main() {\n r\\\"With a backslash at the end\\\\\\\";\n r##\\\"With two hashes\\\"##;\n}\"\n '(\"fn\" font-lock-keyword-face\n \"main\" font-lock-function-name-face\n \"r\\\"With a backslash at the end\\\\\\\"\" font-lock-string-face\n \"r##\\\"With two hashes\\\"##\" font-lock-string-face)))\n\n(ert-deftest font-lock-raw-string-with-inner-hash ()\n (rust-test-font-lock\n \"r##\\\"I've got an octothorpe (#)\\\"##; foo()\"\n '(\"r##\\\"I've got an octothorpe (#)\\\"##\" font-lock-string-face)))\n\n(ert-deftest font-lock-raw-string-with-inner-quote-and-hash ()\n (rust-test-font-lock\n \"not_the_string(); r##\\\"string \\\"# still same string\\\"##; not_the_string()\"\n '(\"r##\\\"string \\\"# still same string\\\"##\" font-lock-string-face)))\n\n(ert-deftest font-lock-string-ending-with-r-not-raw-string ()\n (rust-test-font-lock\n \"fn f() {\n \\\"Er\\\";\n}\n\nfn g() {\n \\\"xs\\\";\n}\"\n '(\"fn\" font-lock-keyword-face\n \"f\" font-lock-function-name-face\n \"\\\"Er\\\"\" font-lock-string-face\n \"fn\" font-lock-keyword-face\n \"g\" font-lock-function-name-face\n \"\\\"xs\\\"\" font-lock-string-face)))\n\n(ert-deftest font-lock-string-ending-with-r-word-boundary ()\n (with-temp-buffer\n (rust-mode)\n (insert \"const foo = \\\"foo bar\\\"\")\n (font-lock-fontify-buffer)\n ;; right-word should move the point to the end of the words.\n (goto-char 14)\n (right-word)\n (should (equal 17 (point)))\n (right-word)\n (should (equal 21 (point)))\n ))\n\n(ert-deftest font-lock-raw-string-trick-ending-followed-by-string-with-quote ()\n (rust-test-font-lock\n \"r\\\"With what looks like the start of a raw string at the end r#\\\";\nnot_a_string();\nr##\\\"With \\\"embedded\\\" quote \\\"##;\"\n '(\"r\\\"With what looks like the start of a raw string at the end r#\\\"\" font-lock-string-face\n \"r##\\\"With \\\"embedded\\\" quote \\\"##\" font-lock-string-face)))\n\n(ert-deftest font-lock-raw-string-starter-inside-raw-string ()\n ;; Check that it won't look for a raw string beginning inside another raw string.\n (rust-test-font-lock\n \"r#\\\"In the first string r\\\" in the first string \\\"#;\nnot_in_a_string();\nr##\\\"In the second string\\\"##;\"\n '(\"r#\\\"In the first string r\\\" in the first string \\\"#\" font-lock-string-face\n \"r##\\\"In the second string\\\"##\" font-lock-string-face)))\n\n(ert-deftest font-lock-raw-string-starter-inside-comment ()\n ;; Check that it won't look for a raw string beginning inside another raw string.\n (rust-test-font-lock\n \"\/\/ r\\\" this is a comment\n\\\"this is a string\\\";\nthis_is_not_a_string();)\"\n '(\"\/\/ \" font-lock-comment-delimiter-face\n \"r\\\" this is a comment\\n\" font-lock-comment-face\n \"\\\"this is a string\\\"\" font-lock-string-face)))\n\n(ert-deftest font-lock-runaway-raw-string ()\n (rust-test-font-lock\n \"const Z = r#\\\"my raw string\\\";\\n\/\/ oops this is still in the string\"\n '(\"const\" font-lock-keyword-face\n \"Z\" font-lock-type-face\n \"r#\\\"my raw string\\\";\\n\/\/ oops this is still in the string\" font-lock-string-face))\n )\n\n(ert-deftest font-lock-recognize-closing-raw-string ()\n (with-temp-buffer\n (rust-mode)\n (insert \"const foo = r##\\\"\n1...............................................50\n1...............................................50\n1...............................................50\n1...............195-->\\\"; let ...................50\n1...............................................50\n1...............................................50\n1...............................................50\n1...............................................50\n1...............................................50\n1......................500......................50\n\\\"#;\n\")\n (font-lock-fontify-buffer)\n (goto-char 530)\n (insert \"#\")\n ;; We have now closed the raw string. Check that the whole string is\n ;; recognized after the change\n (font-lock-after-change-function (1- (point)) (point) 0)\n (should (equal 'font-lock-string-face (get-text-property 195 'face))) ;; The \"let\"\n (should (equal 'font-lock-string-face (get-text-property 500 'face))) ;; The \"500\"\n (should (equal nil (get-text-property 531 'face))) ;; The second \";\"\n ))\n\n;;; Documentation comments\n\n(ert-deftest font-lock-doc-line-comment-parent ()\n (rust-test-font-lock\n \"\/\/! doc\"\n '(\"\/\/! doc\" font-lock-doc-face)))\n\n(ert-deftest font-lock-doc-line-comment-item ()\n (rust-test-font-lock\n \"\/\/\/ doc\"\n '(\"\/\/\/ doc\" font-lock-doc-face)))\n\n(ert-deftest font-lock-nondoc-line ()\n (rust-test-font-lock\n \"\/\/\/\/\/\/ doc\"\n '(\"\/\/\/\/\/\/ \" font-lock-comment-delimiter-face\n \"doc\" font-lock-comment-face)))\n\n(ert-deftest font-lock-doc-line-in-string ()\n (rust-test-font-lock\n \"\\\"\/\/\/ doc\\\"\"\n '(\"\\\"\/\/\/ doc\\\"\" font-lock-string-face))\n\n (rust-test-font-lock\n \"\\\"\/\/! doc\\\"\"\n '(\"\\\"\/\/! doc\\\"\" font-lock-string-face)))\n\n(ert-deftest font-lock-doc-line-in-nested-comment ()\n (rust-test-font-lock\n \"\/* \/\/\/ doc *\/\"\n '(\"\/* \" font-lock-comment-delimiter-face\n \"\/\/\/ doc *\/\" font-lock-comment-face))\n\n (rust-test-font-lock\n \"\/* \/\/! doc *\/\"\n '(\"\/* \" font-lock-comment-delimiter-face\n \"\/\/! doc *\/\" font-lock-comment-face)))\n\n\n(ert-deftest font-lock-doc-block-comment-parent ()\n (rust-test-font-lock\n \"\/*! doc *\/\"\n '(\"\/*! doc *\/\" font-lock-doc-face)))\n\n(ert-deftest font-lock-doc-block-comment-item ()\n (rust-test-font-lock\n \"\/** doc *\/\"\n '(\"\/** doc *\/\" font-lock-doc-face)))\n\n(ert-deftest font-lock-nondoc-block-comment-item ()\n (rust-test-font-lock\n \"\/***** doc *\/\"\n '(\"\/**\" font-lock-comment-delimiter-face\n \"*** doc *\/\" font-lock-comment-face)))\n\n(ert-deftest font-lock-doc-block-in-string ()\n (rust-test-font-lock\n \"\\\"\/** doc *\/\\\"\"\n '(\"\\\"\/** doc *\/\\\"\" font-lock-string-face))\n (rust-test-font-lock\n \"\\\"\/*! doc *\/\\\"\"\n '(\"\\\"\/*! doc *\/\\\"\" font-lock-string-face)))\n\n(ert-deftest font-lock-module-def ()\n (rust-test-font-lock\n \"mod foo;\"\n '(\"mod\" font-lock-keyword-face\n \"foo\" font-lock-constant-face)))\n\n(ert-deftest font-lock-module-use ()\n (rust-test-font-lock\n \"use foo;\"\n '(\"use\" font-lock-keyword-face\n \"foo\" font-lock-constant-face)))\n\n(ert-deftest font-lock-module-path ()\n (rust-test-font-lock\n \"foo::bar\"\n '(\"foo\" font-lock-constant-face)))\n\n(ert-deftest font-lock-submodule-path ()\n (rust-test-font-lock\n \"foo::bar::baz\"\n '(\"foo\" font-lock-constant-face\n \"bar\" font-lock-constant-face)))\n\n(ert-deftest font-lock-type ()\n (rust-test-font-lock\n \"foo::Bar::baz\"\n '(\"foo\" font-lock-constant-face\n \"Bar\" font-lock-type-face)))\n\n(ert-deftest font-lock-type-annotation ()\n \"Ensure type annotations are not confused with modules.\"\n (rust-test-font-lock\n \"parse::();\"\n ;; Only the i32 should have been highlighted.\n '(\"i32\" font-lock-type-face))\n (rust-test-font-lock\n \"foo:: \"\n ;; Only the i32 should have been highlighted.\n '(\"i32\" font-lock-type-face)))\n\n(ert-deftest font-lock-question-mark ()\n \"Ensure question mark operator is highlighted.\"\n (rust-test-font-lock\n \"?\"\n '(\"?\" rust-question-mark-face))\n (rust-test-font-lock\n \"foo\\(\\)?;\"\n '(\"?\" rust-question-mark-face))\n (rust-test-font-lock\n \"foo\\(bar\\(\\)?\\);\"\n '(\"?\" rust-question-mark-face))\n (rust-test-font-lock\n \"\\\"?\\\"\"\n '(\"\\\"?\\\"\" font-lock-string-face))\n (rust-test-font-lock\n \"foo\\(\\\"?\\\"\\);\"\n '(\"\\\"?\\\"\" font-lock-string-face))\n (rust-test-font-lock\n \"\/\/ ?\"\n '(\"\/\/ \" font-lock-comment-delimiter-face\n \"?\" font-lock-comment-face))\n (rust-test-font-lock\n \"\/\/\/ ?\"\n '(\"\/\/\/ ?\" font-lock-doc-face))\n (rust-test-font-lock\n \"foo\\(\\\"?\\\"\\);\"\n '(\"\\\"?\\\"\" font-lock-string-face))\n (rust-test-font-lock\n \"foo\\(\\\"?\\\"\\)?;\"\n '(\"\\\"?\\\"\" font-lock-string-face\n \"?\" rust-question-mark-face)))\n\n(ert-deftest rust-test-default-context-sensitive ()\n (rust-test-font-lock\n \"let default = 7; impl foo { default fn f() { } }\"\n '(\"let\" font-lock-keyword-face\n \"default\" font-lock-variable-name-face\n \"impl\" font-lock-keyword-face\n \"default\" font-lock-keyword-face\n \"fn\" font-lock-keyword-face\n \"f\" font-lock-function-name-face)))\n\n(ert-deftest rust-test-union-context-sensitive ()\n (rust-test-font-lock\n \"let union = 7; union foo { x: &'union bar }\"\n '(\"let\" font-lock-keyword-face\n ;; The first union is a variable name.\n \"union\" font-lock-variable-name-face\n ;; The second union is a contextual keyword.\n \"union\" font-lock-keyword-face\n \"foo\" font-lock-type-face\n \"x\" font-lock-variable-name-face\n ;; This union is the name of a lifetime.\n \"union\" font-lock-variable-name-face\n \"bar\" font-lock-type-face)))\n\n(ert-deftest indent-method-chains-no-align ()\n (let ((rust-indent-method-chain nil)) (test-indent\n \"\nfn main() {\n let x = thing.do_it()\n .aligned()\n .more_alignment();\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-no-align-with-question-mark-operator ()\n (let ((rust-indent-method-chain nil)) (test-indent\n \"\nfn main() {\n let x = thing.do_it()\n .aligned()\n .more_alignment()?\n .more_alignment();\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-with-align ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() {\n let x = thing.do_it()\n .aligned()\n .more_alignment();\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-with-align-with-question-mark-operator ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() {\n let x = thing.do_it()\n .aligned()\n .more_alignment()?\n .more_alignment();\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-with-align-and-second-stmt ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() {\n let x = thing.do_it()\n .aligned()\n .more_alignment();\n foo.bar();\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-field ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() {\n let x = thing.do_it\n .aligned\n .more_alignment();\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-double-field-on-first-line ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() {\n let x = thing.a.do_it\n .aligned\n .more_alignment();\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-no-let ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() {\n thing.a.do_it\n .aligned\n .more_alignment();\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-look-over-comment ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() {\n thing.a.do_it\n \/\/ A comment\n .aligned\n \/\/ Another comment\n .more_alignment();\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-comment ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() {\n \/\/ thing.do_it()\n \/\/ .aligned()\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-close-block ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() {\n foo.bar()\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-after-comment ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() { \/\/ comment here should not push next line out\n foo.bar()\n}\n\"\n )))\n\n(ert-deftest indent-method-chains-after-comment2 ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn main() {\n \/\/ Lorem ipsum lorem ipsum lorem ipsum lorem.ipsum\n foo.bar()\n}\n\"\n )))\n\n(ert-deftest indent-function-after-where ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn each_split_within<'a, F>(ss: &'a str, lim: usize, mut it: F)\n -> bool where F: FnMut(&'a str) -> bool {\n}\n\n#[test]\nfn test_split_within() {\n}\n\"\n )))\n\n(ert-deftest indent-function-after-where-nested ()\n (let ((rust-indent-method-chain t)) (test-indent\n \"\nfn outer() {\n fn each_split_within<'a, F>(ss: &'a str, lim: usize, mut it: F)\n -> bool where F: FnMut(&'a str) -> bool {\n }\n #[test]\n fn test_split_within() {\n }\n fn bar() {\n }\n}\n\"\n )))\n\n(ert-deftest test-for-issue-36-syntax-corrupted-state ()\n \"This is a test for a issue #36, which involved emacs's\ninternal state getting corrupted when actions were done in a\nspecific sequence. The test seems arbitrary, and is, but it was\nnot clear how to narrow it down further.\n\nThe cause of the bug was code that used to set\n`syntax-begin-function' to `beginning-of-defun', which doesn't\nactually fulfill the expectations--`syntax-begin-function' is\nsupposed to back out of all parens, but `beginning-of-defun'\ncould leave it inside parens if a fn appears inside them.\n\nHaving said that, as I write this I don't understand fully what\ninternal state was corrupted and how. There wasn't an obvious\npattern to what did and did not trip it.\"\n \n ;; When bug #36 was present, the following test would pass, but running it\n ;; caused some unknown emacs state to be corrupted such that the following\n ;; test failed. Both the \"blank_line\" and \"indented_closing_brace\" functions\n ;; were needed to expose the error, for instance--deleting either of them\n ;; would make the failure go away.\n (with-temp-buffer\n (rust-mode)\n (insert \"fn blank_line(arg:i32) -> bool {\n\n}\n\nfn indenting_closing_brace() {\n if(true) {\n}\n}\n\nfn indented_already() {\n \\n \/\/ The previous line already has its spaces\n}\n\")\n (font-lock-fontify-buffer)\n (goto-line 11)\n (move-to-column 0)\n (indent-for-tab-command)\n (should (equal (current-column) 4))\n )\n\n ;; This is the test that would fail only after running the previous one. The\n ;; code is extracted from src\/libstd\/collections\/table.rs in the rust tree.\n ;; It was not clear how to reduce it further--removing various bits of it\n ;; would make it no longer fail. In particular, changing only the comment at\n ;; the top of the \"next\" function was sufficient to make it no longer fail.\n (test-indent\n \"\nimpl Foo for Bar {\n \n \/\/\/ Modifies the bucket pointer in place to make it point to the next slot.\n pub fn next(&mut self) {\n \/\/ Branchless bucket\n \/\/ As we reach the end of the table...\n \/\/ We take the current idx: 0111111b\n \/\/ Xor it by its increment: ^ 1000000b\n \/\/ ------------\n \/\/ 1111111b\n \/\/ Then AND with the capacity: & 1000000b\n \/\/ ------------\n \/\/ to get the backwards offset: 1000000b\n let maybe_wraparound_dist = (self.idx ^ (self.idx + 1)) & self.table.capacity();\n \/\/ Finally, we obtain the offset 1 or the offset -cap + 1.\n let dist = 1 - (maybe_wraparound_dist as isize);\n \n self.idx += 1;\n \n unsafe {\n self.raw = self.raw.offset(dist);\n }\n }\n \n \/\/\/ Reads a bucket at a given index, returning an enum indicating whether\n \/\/\/ the appropriate types to call most of the other functions in\n \/\/\/ this module.\n pub fn peek(self) {\n match foo {\n EMPTY_BUCKET =>\n Empty(EmptyBucket {\n raw: self.raw,\n idx: self.idx,\n table: self.table\n }),\n _ =>\n Full(FullBucket {\n raw: self.raw,\n idx: self.idx,\n table: self.table\n })\n }\n } \n}\n\"\n ))\n\n(ert-deftest test-indent-string-with-eol-backslash ()\n (test-indent\n \"\npub fn foo() {\n format!(\\\"abc \\\\\n def\\\")\n}\n\"\n ))\n\n(ert-deftest test-indent-string-with-eol-backslash-at-start ()\n (test-indent\n \"\npub fn foo() {\n format!(\\\"\\\\\n abc \\\\\n def\\\")\n}\n\"\n ))\n\n(ert-deftest test-indent-string-without-eol-backslash-indent-is-not-touched ()\n (test-indent\n \"\npub fn foo() {\n format!(\\\"\nabc\ndef\\\");\n}\n\npub fn foo() {\n format!(\\\"la la la\nla\nla la\\\");\n}\n\"\n ;; Should still indent the code parts but leave the string internals alone:\n \"\n pub fn foo() {\n format!(\\\"\nabc\ndef\\\");\n}\n\npub fn foo() {\n format!(\\\"la la la\nla\nla la\\\");\n }\n\"\n ))\n\n(ert-deftest test-indent-string-eol-backslash-mixed-with-literal-eol ()\n (test-indent\n \"\nfn foo() {\n println!(\\\"\nHere is the beginning of the string\n and here is a line that is arbitrarily indented \\\\\n and a continuation of that indented line\n and another arbitrary indentation\n still another\n yet another \\\\\n with a line continuing it\nAnd another line not indented\n\\\")\n}\n\"\n \"\nfn foo() {\n println!(\\\"\nHere is the beginning of the string\n and here is a line that is arbitrarily indented \\\\\n and a continuation of that indented line\n and another arbitrary indentation\n still another\n yet another \\\\\nwith a line continuing it\nAnd another line not indented\n\\\")\n}\n\"))\n\n(ert-deftest test-indent-string-eol-backslash-dont-touch-raw-strings ()\n (test-indent\n \"\npub fn foo() {\n format!(r\\\"\\\nabc\\\n def\\\");\n}\n\npub fn foo() {\n format!(r\\\"la la la\n la\\\nla la\\\");\n}\n\"\n ;; Should still indent the code parts but leave the string internals alone:\n \"\n pub fn foo() {\n format!(r\\\"\\\nabc\\\n def\\\");\n}\n\npub fn foo() {\n format!(r\\\"la la la\n la\\\nla la\\\");\n}\n\"\n ))\n\n(ert-deftest indent-inside-string-first-line ()\n (test-indent\n ;; Needs to leave 1 space before \"world\"\n \"\\\"hello \\\\\\n world\\\"\"))\n\n(ert-deftest indent-multi-line-type-param-list ()\n (test-indent\n \"\npub fn foo() {\n hello();\n}\"))\n\n(ert-deftest indent-open-paren-in-column0 ()\n ;; Just pass the same text for the \"deindented\" argument. This\n ;; avoids the extra spaces normally inserted, which would mess up\n ;; the test because string contents aren't touched by reindentation.\n (let ((text \"\nconst a: &'static str = r#\\\"\n{}\\\"#;\nfn main() {\n let b = \\\"\/\/\\\";\n let c = \\\"\\\";\n\n}\n\"))\n (test-indent text text)))\n\n(ert-deftest indent-question-mark-operator ()\n (test-indent \"fn foo() {\n if bar()? < 1 {\n }\n baz();\n}\"))\n\n;; Regression test for #212.\n(ert-deftest indent-left-shift ()\n (test-indent \"\nfn main() {\n let a = [[0u32, 0u32]; 1];\n let i = 0;\n let x = a[i][(1 < i)];\n let x = a[i][(1 << i)];\n}\n\"))\n\n(defun rust-test-matching-parens (content pairs &optional nonparen-positions)\n \"Assert that in rust-mode, given a buffer with the given `content',\n emacs's paren matching will find all of the pairs of positions\n as matching braces. The list of nonparen-positions asserts\n specific positions that should NOT be considered to be\n parens\/braces of any kind.\n\n This does not assert that the `pairs' list is\n comprehensive--there can be additional pairs that don't appear\n in the list and the test still passes (as long as none of their\n positions appear in `nonparen-positions'.)\"\n (with-temp-buffer\n (rust-mode)\n (insert content)\n (font-lock-fontify-buffer)\n (dolist (pair pairs)\n (let* ((open-pos (nth 0 pair))\n (close-pos (nth 1 pair)))\n (should (equal 4 (syntax-class (syntax-after open-pos))))\n (should (equal 5 (syntax-class (syntax-after close-pos))))\n (should (equal (scan-sexps open-pos 1) (+ 1 close-pos)))\n (should (equal (scan-sexps (+ 1 close-pos) -1) open-pos))))\n (dolist (nonpar-pos nonparen-positions)\n (let ((nonpar-syntax-class (syntax-class (syntax-after nonpar-pos))))\n (should (not (equal 4 nonpar-syntax-class)))\n (should (not (equal 5 nonpar-syntax-class)))))))\n\n(ert-deftest rust-test-unmatched-single-quote-in-comment-paren-matching ()\n ;; This was a bug from the char quote handling that affected the paren\n ;; matching. An unmatched quote char in a comment caused the problems.\n (rust-test-matching-parens\n \"\/\/ If this appeared first in the file...\n\\\"\\\\\n{\\\";\n\n\/\/ And the { was not the on the first column:\n {\n \/\/ This then messed up the paren matching: '\\\\'\n}\n\n\"\n '((97 150) ;; The { and } at the bottom\n )))\n\n(ert-deftest rust-test-two-character-quotes-in-a-row ()\n (with-temp-buffer\n (rust-mode)\n (font-lock-fontify-buffer)\n (insert \"'\\\\n','a', fn\")\n (font-lock-after-change-function 1 12 0)\n\n (should (equal 'font-lock-string-face (get-text-property 3 'face)))\n (should (equal nil (get-text-property 5 'face)))\n (should (equal 'font-lock-string-face (get-text-property 7 'face)))\n (should (equal nil (get-text-property 9 'face)))\n (should (equal 'font-lock-keyword-face (get-text-property 12 'face)))\n ) \n )\n\n(ert-deftest single-quote-null-char ()\n (rust-test-font-lock\n \"'\\\\0' 'a' fn\"\n '(\"'\\\\0'\" font-lock-string-face\n \"'a'\" font-lock-string-face\n \"fn\" font-lock-keyword-face)))\n\n(ert-deftest r-in-string-after-single-quoted-double-quote ()\n (rust-test-font-lock\n \"'\\\"';\\n\\\"r\\\";\\n\\\"oops\\\";\"\n '(\"'\\\"'\" font-lock-string-face\n \"\\\"r\\\"\" font-lock-string-face\n \"\\\"oops\\\"\" font-lock-string-face\n )))\n\n(ert-deftest char-literal-after-quote-in-raw-string ()\n (rust-test-font-lock\n \"r#\\\"\\\"\\\"#;\\n'q'\"\n '(\"r#\\\"\\\"\\\"#\" font-lock-string-face\n \"'q'\" font-lock-string-face)))\n\n(ert-deftest rust-macro-font-lock ()\n (rust-test-font-lock\n \"foo!\\(\\);\"\n '(\"foo!\" font-lock-preprocessor-face))\n (rust-test-font-lock\n \"foo!{};\"\n '(\"foo!\" font-lock-preprocessor-face))\n (rust-test-font-lock\n \"foo![];\"\n '(\"foo!\" font-lock-preprocessor-face)))\n\n(ert-deftest rust-string-interpolation-matcher-works ()\n (dolist (test '((\"print!\\(\\\"\\\"\\)\" 9 11 nil)\n (\"print!\\(\\\"abcd\\\"\\)\" 9 15 nil)\n (\"print!\\(\\\"abcd {{}}\\\"\\);\" 9 19 nil)\n (\"print!\\(\\\"abcd {{\\\"\\);\" 9 18 nil)\n (\"print!\\(\\\"abcd {}\\\"\\);\" 9 18 ((14 16)))\n (\"print!\\(\\\"abcd {{{}\\\"\\);\" 9 20 ((16 18)))\n (\"print!\\(\\\"abcd {}{{\\\"\\);\" 9 20 ((14 16)))\n (\"print!\\(\\\"abcd {} {{\\\"\\);\" 9 21 ((14 16)))\n (\"print!\\(\\\"abcd {}}}\\\"\\);\" 9 20 ((14 16)))\n (\"print!\\(\\\"abcd {{{}}}\\\"\\);\" 9 20 ((16 18)))\n (\"print!\\(\\\"abcd {0}\\\"\\);\" 9 18 ((14 17)))\n (\"print!\\(\\\"abcd {0} efgh\\\"\\);\" 9 23 ((14 17)))\n (\"print!\\(\\\"{1} abcd {0} efgh\\\"\\);\" 9 27 ((9 12) (18 21)))\n (\"print!\\(\\\"{{{1} abcd }} {0}}} {{efgh}}\\\"\\);\" 9 33 ((11 14) (23 26)))))\n (destructuring-bind (text cursor limit matches) test\n (with-temp-buffer\n ;; make sure we have a clean slate\n (save-match-data\n (set-match-data nil)\n (insert text)\n (goto-char cursor)\n (if (null matches)\n (should (equal (progn\n (rust-string-interpolation-matcher limit)\n (match-data))\n nil))\n (dolist (pair matches)\n (rust-string-interpolation-matcher limit)\n (should (equal (match-beginning 0) (car pair)))\n (should (equal (match-end 0) (cadr pair))))))))))\n\n(ert-deftest rust-formatting-macro-font-lock ()\n ;; test that the block delimiters aren't highlighted and the comment\n ;; is ignored\n (rust-test-font-lock\n \"print!(\\\"\\\"); { \/* print!(\\\"\\\"); *\/ }\"\n '(\"print!\" rust-builtin-formatting-macro-face\n \"\\\"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"print!(\\\"\\\"); *\/\" font-lock-comment-face))\n ;; with newline directly following delimiter\n (rust-test-font-lock\n \"print!(\\n\\\"\\\"\\n); { \/* print!(\\\"\\\"); *\/ }\"\n '(\"print!\" rust-builtin-formatting-macro-face\n \"\\\"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"print!(\\\"\\\"); *\/\" font-lock-comment-face))\n ;; with empty println!()\n (rust-test-font-lock\n \"println!(); { \/* println!(); *\/ }\"\n '(\"println!\" rust-builtin-formatting-macro-face\n \"\/* \" font-lock-comment-delimiter-face\n \"println!(); *\/\" font-lock-comment-face))\n ;; other delimiters\n (rust-test-font-lock\n \"print!{\\\"\\\"}; { \/* no-op *\/ }\"\n '(\"print!\" rust-builtin-formatting-macro-face\n \"\\\"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; other delimiters\n (rust-test-font-lock\n \"print![\\\"\\\"]; { \/* no-op *\/ }\"\n '(\"print!\" rust-builtin-formatting-macro-face\n \"\\\"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; no interpolation\n (rust-test-font-lock\n \"print!(\\\"abcd\\\"); { \/* no-op *\/ }\"\n '(\"print!\" rust-builtin-formatting-macro-face\n \"\\\"abcd\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; only interpolation\n (rust-test-font-lock\n \"print!(\\\"{}\\\"); { \/* no-op *\/ }\"\n '(\"print!\" rust-builtin-formatting-macro-face\n \"\\\"\" font-lock-string-face\n \"{}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; text + interpolation\n (rust-test-font-lock\n \"print!(\\\"abcd {}\\\", foo); { \/* no-op *\/ }\"\n '(\"print!\" rust-builtin-formatting-macro-face\n \"\\\"abcd \" font-lock-string-face\n \"{}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; text + interpolation with specification\n (rust-test-font-lock\n \"print!(\\\"abcd {0}\\\", foo); { \/* no-op *\/ }\"\n '(\"print!\" rust-builtin-formatting-macro-face\n \"\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; text + interpolation with specification and escape\n (rust-test-font-lock\n \"print!(\\\"abcd {0}}}\\\", foo); { \/* no-op *\/ }\"\n '(\"print!\" rust-builtin-formatting-macro-face\n \"\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \"}}\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; multiple pairs\n (rust-test-font-lock\n \"print!(\\\"abcd {0} efgh {1}\\\", foo, bar); { \/* no-op *\/ }\"\n '(\"print!\" rust-builtin-formatting-macro-face\n \"\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \" efgh \" font-lock-string-face\n \"{1}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; println\n (rust-test-font-lock\n \"println!(\\\"abcd {0} efgh {1}\\\", foo, bar); { \/* no-op *\/ }\"\n '(\"println!\" rust-builtin-formatting-macro-face\n \"\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \" efgh \" font-lock-string-face\n \"{1}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; eprint\n (rust-test-font-lock\n \"eprint!(\\\"abcd {0} efgh {1}\\\", foo, bar); { \/* no-op *\/ }\"\n '(\"eprint!\" rust-builtin-formatting-macro-face\n \"\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \" efgh \" font-lock-string-face\n \"{1}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; eprintln\n (rust-test-font-lock\n \"eprintln!(\\\"abcd {0} efgh {1}\\\", foo, bar); { \/* no-op *\/ }\"\n '(\"eprintln!\" rust-builtin-formatting-macro-face\n \"\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \" efgh \" font-lock-string-face\n \"{1}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; format\n (rust-test-font-lock\n \"format!(\\\"abcd {0} efgh {1}\\\", foo, bar); { \/* no-op *\/ }\"\n '(\"format!\" rust-builtin-formatting-macro-face\n \"\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \" efgh \" font-lock-string-face\n \"{1}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; print + raw string\n (rust-test-font-lock\n \"format!(r\\\"abcd {0} efgh {1}\\\", foo, bar); { \/* no-op *\/ }\"\n '(\"format!\" rust-builtin-formatting-macro-face\n \"r\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \" efgh \" font-lock-string-face\n \"{1}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; print + raw string with hash\n (rust-test-font-lock\n \"format!(r#\\\"abcd {0} efgh {1}\\\"#, foo, bar); { \/* no-op *\/ }\"\n '(\"format!\" rust-builtin-formatting-macro-face\n \"r#\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \" efgh \" font-lock-string-face\n \"{1}\" rust-string-interpolation-face\n \"\\\"#\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n ;; print + raw string with two hashes\n (rust-test-font-lock\n \"format!(r##\\\"abcd {0} efgh {1}\\\"##, foo, bar); { \/* no-op *\/ }\"\n '(\"format!\" rust-builtin-formatting-macro-face\n \"r##\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \" efgh \" font-lock-string-face\n \"{1}\" rust-string-interpolation-face\n \"\\\"##\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face)))\n\n(ert-deftest rust-write-macro-font-lock ()\n (rust-test-font-lock\n \"write!(f, \\\"abcd {0}}} efgh {1}\\\", foo, bar); { \/* no-op *\/ }\"\n '(\"write!\" rust-builtin-formatting-macro-face\n \"\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \"}} efgh \" font-lock-string-face\n \"{1}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n (rust-test-font-lock\n \"writeln!(f, \\\"abcd {0}}} efgh {1}\\\", foo, bar); { \/* no-op *\/ }\"\n '(\"writeln!\" rust-builtin-formatting-macro-face\n \"\\\"abcd \" font-lock-string-face\n \"{0}\" rust-string-interpolation-face\n \"}} efgh \" font-lock-string-face\n \"{1}\" rust-string-interpolation-face\n \"\\\"\" font-lock-string-face\n \"\/* \" font-lock-comment-delimiter-face\n \"no-op *\/\" font-lock-comment-face))\n (rust-test-font-lock\n \"println!(\\\"123\\\"); eprintln!(\\\"123\\\"); cprintln!(\\\"123\\\");\"\n '(\"println!\" rust-builtin-formatting-macro-face\n \"\\\"123\\\"\" font-lock-string-face\n \"eprintln!\" rust-builtin-formatting-macro-face\n \"\\\"123\\\"\" font-lock-string-face\n \"cprintln!\" font-lock-preprocessor-face\n \"\\\"123\\\"\" font-lock-string-face)))\n\n(ert-deftest font-lock-fontify-angle-brackets ()\n \"Test that angle bracket fontify\"\n (should (equal (rust-test-fontify-string \"<>\") \"<>\"))\n (should (equal (rust-test-fontify-string \"\") \"\"))\n (should (equal (rust-test-fontify-string \"<<>>\") \"<<>>\"))\n (should (equal (rust-test-fontify-string \"<>>\") \"<>>\"))\n (should (equal (rust-test-fontify-string \"<<>\") \"<<>\")))\n\n(ert-deftest rust-test-basic-paren-matching ()\n (rust-test-matching-parens\n \"\nfn foo() {\n let a = [1, 2, 3];\n}\"\n '((8 9) ;; Parens of foo()\n (11 36) ;; Curly braces\n (25 33) ;; Square brackets\n )))\n\n(ert-deftest rust-test-paren-matching-generic-fn ()\n (rust-test-matching-parens\n \"\nfn foo() {\n}\"\n '((8 10) ;; Angle brackets \n (11 12) ;; Parens\n (14 16) ;; Curly braces\n )))\n\n(ert-deftest rust-test-paren-matching-generic-fn-with-return-value ()\n (rust-test-matching-parens\n \"\nfn foo() -> bool {\n false\n}\"\n '((8 10) ;; Angle brackets \n (11 12) ;; Parens\n (22 34) ;; Curly braces\n )\n \n '(15 ;; The \">\" in \"->\" is not an angle bracket\n )))\n\n(ert-deftest rust-test-paren-matching-match-stmt ()\n (rust-test-matching-parens\n \"\nfn foo() {\n something_str(match ::method() {\n Some(_) => \\\"Got some\\\",\n None => \\\"Nada\\\"\n });\n}\"\n '((8 9) ;; parens of fn foo\n (11 127) ;; curly braces of foo\n (30 124) ;; parens of something_str\n (37 51) ;; angle brackets of \n (60 61) ;; parens of method()\n (63 123) ;; curly braces of match\n (77 79) ;; parens of Some(_)\n )\n \n '(82 ;; > in first =>\n 112 ;; > in second =>\n )))\n\n(ert-deftest rust-test-paren-matching-bitshift-operators ()\n (rust-test-matching-parens\n \"\nfn foo(z:i32) {\n let a:Option> = Some(Ok(4 >> 1));\n let b = a.map(|x| x.map(|y| y << 3));\n let trick_question = z<<::method(); \/\/ First two \n )\n '(64 ;; The >> inside Some(Ok()) are not angle brackets\n 65 ;; The >> inside Some(Ok()) are not angle brackets\n 106 ;; The << inside map() are not angle brackets\n 107 ;; The << inside map() are not angle brackets\n 140 ;; The << before are not angle brackets\n 141 ;; The << before are not angle brackets\n 183 ;; The < inside the comment\n )))\n\n(ert-deftest rust-test-paren-matching-angle-bracket-after-colon-ident ()\n (rust-test-matching-parens\n \"\nstruct Bla {\n a:Option<(i32,Option)>,\n b:Option,\n c:bool\n}\n\nfn f(x:i32,y:Option) {\n let z:Option = None;\n let b:Bla = Bla{\n a:None,\n b:None,\n c:x\n (30 49) ;; Outer angle brackets of a:Option<...>\n (42 47) ;; Inner angle brackets of Option\n (64 66) ;; Angle brackets of Option\n (102 106) ;; Angle brackets of y:Option\n (127 131) ;; Angle brackets of z:Option\n (154 157) ;; Angle brackets of b:Bla\n )\n '(209 ;; less than operator in c:x Bar {\n Bar {\n b:x<3\n }\n}\"\n '()\n '(17 ;; the -> is not a brace\n 46 ;; x<3 the < is a less than sign\n ))\n )\n\n(ert-deftest rust-test-paren-matching-nested-struct-literals ()\n (rust-test-matching-parens\n \"\nfn f(x:i32,y:i32) -> Foo {\n Foo{\n bar:Bar{\n a:3,\n b:x\n )\n '(92 ;; less than operator x X>() -> Z {\n}\n\"\n '((8 23) ;; The angle brackets of foo\n (20 22 ;; The angle brackets of X\n ))\n '(17 ;; The first ->\n 28 ;; The second ->\n )\n ))\n\n(ert-deftest rust-test-paren-matching-lt-ops-in-fn-params ()\n (rust-test-matching-parens\n \"\nfn foo(x:i32) {\n f(x < 3);\n}\n\"\n '()\n '(26 ;; The < inside f is a less than operator\n )\n ))\n\n(ert-deftest rust-test-paren-matching-lt-ops-in-fn-params ()\n (rust-test-matching-parens\n \"\nfn foo(x:i32) -> bool {\n return x < 3;\n}\n\"\n '()\n '(17 ;; The ->\n 39 ;; The < after return is a less than operator\n )\n ))\n\n(ert-deftest rust-test-type-paren-matching-angle-brackets-in-type-items ()\n (rust-test-matching-parens\n \"\ntype Foo = Blah;\ntype Bar = (Foo, Bletch);\ntype ThisThing = HereYouGo B>,E>>;\"\n '((17 21) ;; Angle brackets of Blah\n (32 34) ;; Angle brackets of Bar\n (50 52) ;; Angle brackets of Bletch\n (70 78) ;; Angle brackets of ThisThing\n (91 118) ;; Angle brackets of HereYouGo<...>\n (95 117) ;; Angle brackets of Y\n (106 111) ;; Angle brackets of B>\n (108 110) ;; Angle brackets of C\n (114 116) ;; Angle brackets of E\n )))\n\n(ert-deftest rust-test-paren-matching-tuple-like-struct ()\n (rust-test-matching-parens\n \"\nstruct A(Option);\nstruct C(Result);\"\n '((17 19) ;; The angle brackets \n (10 20) ;; The parens of A();\n (31 33) ;; The angle brackets of C\n (41 47) ;; The angle brackets of Result\n )\n '()))\n\n(ert-deftest rust-test-paren-matching-in-enum ()\n (rust-test-matching-parens\n \"\nenum Boo {\n TupleLike(Option),\n StructLike{foo: Result}\n}\"\n '((10 12) ;; Angle brackets of Boo\n (36 38) ;; Angle brackets of Option\n (68 74) ;; Angle brackets of Result\n )))\n\n(ert-deftest rust-test-paren-matching-assoc-type-bounds ()\n (rust-test-matching-parens\n \"impl >> Thing {}\"\n '((6 29) ;; Outer angle brackets of impl\n (10 28) ;; Outer angle brackets of B>\n (24 26) ;; Inner angle brackets of C\n (36 38) ;; Angle brackets of Thing\n )\n ))\n\n(ert-deftest rust-test-paren-matching-plus-signs-in-expressions-and-bounds ()\n ;; Note that as I write this, the function \"bluh\" below does not compile, but\n ;; it warns that the equality constraint in a where clause is \"not yet\n ;; supported.\" It seems that the compiler will support this eventually, so\n ;; the emacs mode needs to support it.\n (rust-test-matching-parens\n \"fn foo,B>(a:A,b:B) -> bool where B:Trait3+Trait4 {\n 2 + a < 3 && 3 + b > 11\n}\n\nfn bluh() where A:Fn()+MyTrait, MyTrait::AssocType = Option {\n}\n\nfn fluh() where C:Fn(i32) -> (i32, i32) + SomeTrait, C::AssocType = OtherThing {\n}\"\n '((7 30) ;; Angle brackets of foo<...>\n (23 27) ;; Angle brackets of Trait2\n (63 67) ;; Angle brackets of Trait3\n (75 79) ;; Angle brackets of Trait4\n\n (121 123) ;; Angle brackets of bluh\n (147 151) ;; Angle brackets of MyTrait\n\n (161 163) ;; Angle brackets of MyTrait\n (184 189) ;; Angle brackets of Option\n\n (203 205) ;; Angle brackets of \n (250 254) ;; Angle brackets of SomeTrait\n (282 287) ;; Angle brackets of Option\n )\n '(93 ;; Less-than sign of a < 3\n 106 ;; Greater than sign of b > 11\n )))\n\n(ert-deftest rust-test-paren-matching-generic-type-in-tuple-return-type ()\n (rust-test-matching-parens\n \"pub fn take(mut self) -> (EmptyBucket, K, V) {}\"\n '((38 46))\n ))\n\n(ert-deftest rust-test-paren-matching-references-and-logical-and ()\n (rust-test-matching-parens\n \"\nfn ampersand_check(a: &Option, b:bool) -> &Option {\n a.map(|x| {\n b && x < 32\n })\n}\"\n '((31 35) ;; Option\n (56 60) ;; Option\n )\n '(95 ;; x < 32\n )\n )\n )\n\n(ert-deftest rust-test-paren-matching-lt-sign-in-if-statement ()\n (rust-test-matching-parens\n \"\nfn if_check(a:i32,b:i32,c:i32) {\n if a + b < c {\n \n }\n if a < b {\n \n }\n if (c < a) {\n \n }\n}\n\nfn while_check(x:i32,y:i32) -> bool {\n while x < y {\n }\n for x in y < x {\n }\n match y < z {\n true => (), _ => ()\n }\n return z < y;\n}\"\n '()\n '(48 ;; b < c\n 78 ;; a < b\n 109 ;; (c < a)\n\n 184 ;; x < y\n 211 ;; y < x\n 235 ;; y < z\n 288 ;; z < y\n )))\n\n(ert-deftest rust-test-paren-matching-lt-expr-with-field ()\n (rust-test-matching-parens\n \"fn foo() { x.y < 3 }\"\n '()\n '(16 ;; x.y < 3\n )))\n\n(ert-deftest rust-test-paren-matching-lt-expr-with-quote ()\n (rust-test-matching-parens\n \"\nfn quote_check() {\n 'x' < y;\n \\\"y\\\" < x;\n r##\\\"z\\\"## < q;\n a <= 3 && b < '2'\n}\"\n '()\n '(29 ;; 'x' < y\n 42 ;; \"y\" < x\n 60 ;; r##\"z\"## < q\n 71 ;; a <= '3'\n 81 ;; b < '2'\n )))\n\n(ert-deftest rust-test-paren-matching-keywords-capitalized-are-ok-type-names ()\n (rust-test-matching-parens\n \"\nfn foo() -> Box {\n let z:If = If(a < 3);\n}\"\n '((17 21) ;; Box\n (37 42) ;; If\n )\n '(51 ;; If(a < 3)\n )))\n\n(ert-deftest rust-test-paren-matching-lt-expression-inside-macro ()\n (rust-test-matching-parens\n \"fn bla() { assert!(x < y); }\"\n '()\n '(22 ;; x < y\n )))\n\n(ert-deftest rust-test-paren-matching-array-types-with-generics ()\n (rust-test-matching-parens\n \"fn boo () -> [Option] {}\"\n '((21 25))))\n\n(ert-deftest rust-test-paren-matching-angle-bracket-inner-reference ()\n (rust-test-matching-parens\n \"fn x() -> Option<&Node> {}\"\n '((17 26) ;; Option\n (23 25) ;; Node\n )))\n\n(ert-deftest rust-test-paren-matching-lt-operator-after-semicolon ()\n (rust-test-matching-parens\n \"fn f(x:i32) -> bool { (); x < 3 }\"\n '()\n '(29\n )))\n\n(ert-deftest rust-test-paren-matching-lt-operator-after-comma ()\n (rust-test-matching-parens\n \"fn foo() {\n (e, a < b)\n}\"\n '((16 25) ;; The parens ()\n )\n '(22 ;; The < operator\n )))\n\n(ert-deftest rust-test-paren-matching-lt-operator-after-let ()\n (rust-test-matching-parens\n \"fn main() {\n let x = a < b;\n}\"\n '((11 32) ;; The { }\n )\n '(27 ;; The < operator\n )))\n\n(ert-deftest rust-test-paren-matching-two-lt-ops-in-a-row ()\n (rust-test-matching-parens\n \"fn next(&mut self) -> Option<::Item>\"\n '((29 51) ;; Outer Option<>\n (30 44) ;; Inner \n )\n '(21\n )))\n\n(ert-deftest rust-test-paren-matching-lt-after-caret ()\n (rust-test-matching-parens\n \"fn foo() { x^2 < 3 }\"\n '((10 20) ;; The { }\n )\n '(16 ;; The < operator\n )))\n\n(ert-deftest rust-test-paren-matching-lt-operator-after-special-type ()\n (rust-test-matching-parens\n \"fn foo() { low as u128 <= c }\"\n '((10 29))\n '(24)))\n\n(ert-deftest rust-test-paren-matching-lt-operator-after-closing-curly-brace ()\n (rust-test-matching-parens\n \"fn main() { if true {} a < 3 }\"\n '((11 30)\n )\n '(26)))\n\n(ert-deftest rust-test-paren-matching-const ()\n (rust-test-matching-parens\n \"\nconst BLA = 1 << 3;\nconst BLUB = 2 < 4;\"\n '()\n '(16\n 17 ;; Both chars of the << in 1 << 3\n 37 ;; The < in 2 < 4\n )))\n\n(ert-deftest rust-test-paren-matching-c-like-enum ()\n (rust-test-matching-parens\n \"\nenum CLikeEnum {\n Two = 1 << 1,\n Four = 1 << 2 \n}\"\n '((17 56 ;; The { } of the enum\n ))\n '(31\n 32 ;; The first <<\n 50\n 51 ;; The second <<\n )))\n\n(ert-deftest rust-test-paren-matching-no-angle-brackets-in-macros ()\n (rust-test-matching-parens\n \"\nfn foo(a:A) {\n macro_a!( foo:: );\n macro_b![ foo as Option ];\n}\n\nmacro_c!{\n struct Boo {}\n}\"\n '((8 10))\n ;; Inside macros, it should not find any angle brackets, even if it normally\n ;; would\n '(38 ;; macro_a <\n 57 ;; macro_a >\n 89 ;; macro_b <\n 91 ;; macro_b >\n 123 ;; macro_c <\n 125 ;; macro_d >\n )))\n\n(ert-deftest rust-test-paren-matching-type-with-module-name ()\n (rust-test-matching-parens\n \"\nconst X: libc::c_int = 1 << 2;\nfn main() {\n let z: libc::c_uint = 1 << 4;\n}\n\"\n '((43 79)) ;; The curly braces\n '(27\n 28 ;; The first <<\n 73\n 74 ;; The second <<\n )))\n\n(ert-deftest rust-test-paren-matching-qualififed-struct-literal ()\n (rust-test-matching-parens\n \"\nfn foo() -> Fn(asd) -> F {\n let z = foo::Struct{ b: 1 << 4, c: 2 < 4 }\n}\"\n '((30 80) ;; Outer curly brackets\n )\n '(62\n 63 ;; The shift operator\n 73 ;; The less than operator\n )))\n\n(ert-deftest rust-test-paren-matching-let-mut ()\n (rust-test-matching-parens\n \"\nfn f() {\n let mut b = 1 < 3;\n let mut i = 1 << 3;\n}\n\"\n '()\n '(28 ;; 1 < 3\n 51\n 52 ;; 1 << 3\n )))\n\n(ert-deftest rust-test-paren-matching-as-ref-type ()\n (rust-test-matching-parens\n \"fn f() {\n let a = b as &Foo;\n}\"\n '((31 35) ;; Angle brackets Foo\n )))\n\n(ert-deftest rust-test-paren-matching-type-ascription ()\n (rust-test-matching-parens\n \"\nfn rfc803() {\n let z = a < b:FunnkyThing;\n let s = Foo {\n a: b < 3,\n b: d:CrazyStuff < 3,\n c: 2 < x:CrazyStuff\n }\n}\"\n '((45 49) ;; FunkyThing\n (111 115) ;; CrazyStuff\n (149 154) ;; CrazyStuff\n )\n '(30 ;; a < b\n 83 ;; b < 3\n 117 ;; d... < 3\n 135 ;; 2 < x\n )))\n\n(ert-deftest rust-test-paren-matching-angle-brackets-in-enum-with-where-claause ()\n (rust-test-matching-parens\n \"\nenum MyEnum where T:std::fmt::Debug {\n Thing(Option)\n}\"\n '((13 15) ;; MyEnum\n (59 61) ;; Option\n )))\n\n(ert-deftest rust-test-paren-matching-where-clauses-with-closure-types ()\n (rust-test-matching-parens\n \"\nenum Boo<'a,T> where T:Fn() -> Option<&'a str> + 'a {\n Thingy(Option<&'a T>)\n}\n\nfn foo<'a>() -> Result where C::X: D, B:FnMut() -> Option+'a {\n Foo(a < b)\n}\n\ntype Foo where T: Copy = Box;\n\"\n '((10 15) ;; Boo<'a,T>\n (39 47) ;; Option<&'a str>\n (72 78) ;; Option<&'a T>\n\n (106 110) ;; Result\n (125 127) ;; D\n (149 151) ;; Option\n (184 186) ;; Foo\n (207 209) ;; Box\n )\n\n '(168 ;; Foo(a < b)\n )\n ))\n\n(ert-deftest rust-test-angle-bracket-matching-turned-off ()\n (let ((rust-match-angle-brackets nil))\n (rust-test-matching-parens\n \"fn foo() {}\"\n '((10 11))\n '(7 9))))\n\n\n(ert-deftest redo-syntax-after-change-far-from-point ()\n (let*\n ((tmp-file-name (make-temp-file \"rust-mdoe-test-issue104\"))\n (base-contents (apply 'concat (append '(\"fn foo() {\\n\\n}\\n\") (make-list 500 \"\/\/ More stuff...\\n\") '(\"fn bar() {\\n\\n}\\n\")))))\n ;; Create the temp file...\n (with-temp-file tmp-file-name\n (insert base-contents))\n (with-temp-buffer\n (insert-file-contents tmp-file-name 'VISIT nil nil 'REPLACE)\n (rust-mode)\n (goto-char (point-max))\n (should (= 0 (rust-paren-level)))\n (with-temp-file tmp-file-name\n (insert base-contents)\n (goto-char 12) ;; On the blank line in the middle of fn foo\n (insert \" let z = 1 < 3;\")\n )\n (revert-buffer 'IGNORE-AUTO 'NOCONFIRM 'PRESERVE-MODES)\n (should (= 0 (rust-paren-level)))\n )\n )\n )\n\n(defun test-imenu (code expected-items)\n (with-temp-buffer\n (rust-mode)\n (insert code)\n (let ((actual-items\n ;; Replace (\"item\" . #() {\n}\n\npub ( in self::super ) fn f9() {\n}\n\npub ( in super ) fn f10() {\n}\n\npub(in crate) fn f11() {\n}\n\npub (in self) fn f12() {\n}\n\"\n '((\"Fn\"\n \"f1\"\n \"f2\"\n \"f3\"\n \"f4\"\n \"f5\"\n \"f6\"\n \"f7\"\n \"f8\"\n \"f9\"\n \"f10\"\n \"f11\"\n \"f12\"))))\n\n(ert-deftest rust-test-imenu-impl-with-lifetime ()\n (test-imenu\n \"\nimpl<'a> One<'a> {\n fn one() {}\n}\n\nimpl Two<'a> {\n fn two() {}\n}\n\"\n '((\"Impl\" \"One\" \"Two\")\n (\"Fn\" \"one\" \"two\"))))\n\n(ert-deftest font-lock-function-parameters ()\n (rust-test-font-lock\n \"fn foo(a: u32, b : u32) {}\"\n '(\"fn\" font-lock-keyword-face\n \"foo\" font-lock-function-name-face\n \"a\" font-lock-variable-name-face\n \"u32\" font-lock-type-face\n \"b\" font-lock-variable-name-face\n \"u32\" font-lock-type-face)))\n\n(ert-deftest variable-in-for-loop ()\n (rust-test-font-lock\n \"for var in iter\"\n '(\"for\" font-lock-keyword-face\n \"var\" font-lock-variable-name-face\n \"in\" font-lock-keyword-face))\n (rust-test-font-lock\n \"for Foo{var} in iter\"\n '(\"for\" font-lock-keyword-face\n \"Foo\" font-lock-type-face\n \"in\" font-lock-keyword-face)))\n\n(ert-deftest rust-test-dbg-wrap-symbol ()\n (rust-test-manip-code\n \"let x = add(first, second);\"\n 15\n #'rust-dbg-wrap-or-unwrap\n \"let x = add(dbg!(first), second);\"))\n\n(ert-deftest rust-test-dbg-wrap-symbol-unbalanced ()\n (rust-test-manip-code\n \"let x = add((first, second);\"\n 14\n #'rust-dbg-wrap-or-unwrap\n \"let x = add((dbg!(first), second);\"))\n\n(ert-deftest rust-test-dbg-wrap-region ()\n (rust-test-manip-code\n \"let x = add(first, second);\"\n 9\n (lambda ()\n (transient-mark-mode 1)\n (push-mark nil t t)\n (goto-char 26)\n (rust-dbg-wrap-or-unwrap))\n \"let x = dbg!(add(first, second));\"))\n\n(defun rust-test-dbg-unwrap (position)\n (rust-test-manip-code\n \"let x = add(dbg!(first), second);\"\n position\n #'rust-dbg-wrap-or-unwrap\n \"let x = add(first, second);\"))\n\n(ert-deftest rust-test-dbg-uwnrap-within ()\n (rust-test-dbg-unwrap 19))\n\n(ert-deftest rust-test-dbg-uwnrap-on-paren ()\n (rust-test-dbg-unwrap 17))\n\n(ert-deftest rust-test-dbg-uwnrap-on-dbg-middle ()\n (rust-test-dbg-unwrap 15))\n\n(ert-deftest rust-test-dbg-uwnrap-on-dbg-start ()\n (rust-test-dbg-unwrap 13))\n\n(ert-deftest rust-test-dbg-unwrap-inside-string-literal ()\n (rust-test-manip-code\n \"let x = \\\"foo, bar\\\"\";\"\n 15\n #'rust-dbg-wrap-or-unwrap\n \"let x = dbg!(\\\"foo, bar\\\")\"))\n\n(when (executable-find rust-cargo-bin)\n (ert-deftest rust-test-project-located ()\n (lexical-let* ((test-dir (expand-file-name \"test-project\/\" default-directory))\n (manifest-file (expand-file-name \"Cargo.toml\" test-dir)))\n (let ((default-directory test-dir))\n (should (equal (expand-file-name (rust-buffer-project)) manifest-file))))))\n\n(ert-deftest compilation-regexp-dashes ()\n (with-temp-buffer\n ;; should match\n (insert \"error found a -> b\\n --> file1.rs:12:34\\n\\n\")\n (insert \"error[E1234]: found a -> b\\n --> file2.rs:12:34\\n\\n\")\n (insert \"warning found a -> b\\n --> file3.rs:12:34\\n\\n\")\n (insert \"note: `ZZZ` could also refer to the constant imported here -> b\\n --> file4.rs:12:34\\n\\n\")\n ;; should not match\n (insert \"werror found a -> b\\n --> no_match.rs:12:34\\n\\n\")\n\n (goto-char (point-min))\n (let ((matches nil))\n (while (re-search-forward (car rustc-compilation-regexps) nil t)\n (push\n (mapcar (lambda (r)\n (let ((match-pos\n (nth (cdr r) rustc-compilation-regexps)))\n (if (eq :type (car r))\n (compilation-face match-pos)\n (match-string match-pos))))\n ;; see compilation-error-regexp-alist\n '((:file . 1)\n (:line . 2)\n (:column . 3)\n (:type . 4)\n (:mouse-highlight . 5)))\n matches))\n (setq matches (reverse matches))\n\n (should (equal\n '((\"file1.rs\" \"12\" \"34\" compilation-error \"file1.rs:12:34\")\n (\"file2.rs\" \"12\" \"34\" compilation-error \"file2.rs:12:34\")\n (\"file3.rs\" \"12\" \"34\" compilation-warning \"file3.rs:12:34\")\n (\"file4.rs\" \"12\" \"34\" compilation-info \"file4.rs:12:34\"))\n matches)))))\n\n;; If electric-pair-mode is available, load it and run the tests that use it. If not,\n;; no error--the tests will be skipped.\n(require 'elec-pair nil t)\n\n;; The emacs 23 and 24 versions of ERT do not have test skipping\n;; functionality. So don't even define these tests if elec-pair is\n;; not available.\n(when (featurep 'elec-pair)\n (defun test-electric-pair-insert (original point-pos char closer)\n (let ((old-electric-pair-mode electric-pair-mode))\n (electric-pair-mode 1)\n (unwind-protect\n (with-temp-buffer\n (rust-mode)\n (insert original)\n (font-lock-fontify-buffer)\n\n (goto-char point-pos)\n (deactivate-mark)\n (let ((last-command-event char)) (self-insert-command 1))\n (should (equal (char-after)\n (or closer (aref original point-pos)))))\n (electric-pair-mode (or old-electric-pair-mode 1)))))\n\n (ert-deftest rust-test-electric-pair-generic-fn ()\n (test-electric-pair-insert \"fn foo() { }\" 7 ?< ?>))\n\n (ert-deftest rust-test-electric-pair-impl-param ()\n (test-electric-pair-insert \"impl Foo for Bar\" 5 ?< ?>))\n\n (ert-deftest rust-test-electric-pair-impl-for-type-param ()\n (test-electric-pair-insert \"impl Foo for Bar\" 22 ?< ?>))\n\n (ert-deftest rust-test-electric-pair-lt-expression ()\n (test-electric-pair-insert \"fn foo(bar:i32) -> bool { bar }\" 30 ?< nil))\n\n (ert-deftest rust-test-electric-pair-lt-expression-in-struct-literal ()\n (test-electric-pair-insert \"fn foo(x:i32) -> Bar { Bar { a:(bleh() + whatever::()), b:x } }\" 63 ?< nil))\n\n (ert-deftest rust-test-electric-pair-lt-expression-capitalized-keyword ()\n (test-electric-pair-insert \"fn foo() -> Box\" 16 ?< ?>))\n\n (ert-deftest rust-test-electric-pair-<-> ()\n (let ((old-electric-pair-mode electric-pair-mode))\n (electric-pair-mode 1)\n (unwind-protect\n (with-temp-buffer\n (electric-pair-mode 1)\n (rust-mode)\n (mapc (lambda (c)\n (let ((last-command-event c)) (self-insert-command 1)))\n \"tmp\")\n (should\n (equal \"tmp\" (buffer-substring-no-properties (point-min)\n (point-max)))))\n (electric-pair-mode (or old-electric-pair-mode 1))))))\n\n(ert-deftest rust-mode-map ()\n (with-temp-buffer\n (let (from to match (match-count 0))\n (rust-mode)\n (describe-buffer-bindings (current-buffer))\n (goto-char (point-min))\n (re-search-forward \"Major Mode Bindings\")\n (setq from (point))\n (re-search-forward \"\f\")\n (setq to (point))\n (goto-char from)\n (while (re-search-forward \"^C-c.*$\" to t)\n (setq match-count (1+ match-count))\n (setq match (match-string 0))\n (eval\n `(should\n (or\n (string-match \"Prefix Command\" ,match)\n (string-match \"^C-c C\" ,match)))))\n (should (< 0 match-count)))))\n","avg_line_length":27.1409757558,"max_line_length":331,"alphanum_fraction":0.5791040826} {"size":30411,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; pdf-isearch.el --- Isearch in pdf buffers. -*- lexical-binding: t -*-\n\n;; Copyright (C) 2013, 2014 Andreas Politz\n\n;; Author: Andreas Politz \n;; Keywords: files, multimedia\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Commentary:\n;;\n;;; Todo:\n;;\n;; * Add the possibility to limit the search to a range of pages.\n\n(require 'cl-lib)\n(require 'pdf-util)\n(require 'pdf-info)\n(require 'pdf-misc)\n(require 'pdf-view)\n(require 'pdf-cache)\n(require 'let-alist)\n\n;;; Code:\n\n\n\f\n;; * ================================================================== *\n;; * Customizations\n;; * ================================================================== *\n\n(defgroup pdf-isearch nil\n \"Isearch in pdf buffers.\"\n :group 'pdf-tools)\n\n(defface pdf-isearch-match\n '((((background dark)) (:inherit isearch))\n (((background light)) (:inherit isearch)))\n \"Face used to determine the colors of the current match.\"\n :group 'pdf-isearch\n :group 'pdf-tools-faces)\n\n(defface pdf-isearch-lazy\n '((((background dark)) (:inherit lazy-highlight))\n (((background light)) (:inherit lazy-highlight)))\n \"Face used to determine the colors of non-current matches.\"\n :group 'pdf-isearch\n :group 'pdf-tools-faces)\n\n(defface pdf-isearch-batch\n '((((background dark)) (:inherit match))\n (((background light)) (:inherit match)))\n \"Face used to determine the colors in `pdf-isearch-batch-mode'.\"\n :group 'pdf-isearch\n :group 'pdf-tools-faces)\n\n(defcustom pdf-isearch-hyphenation-character \"-\u00ad\"\n \"Characters used as hyphens when word searching.\"\n :group 'pdf-isearch\n :type 'string)\n\n(defvar pdf-isearch-search-fun-function nil\n \"Search function used when searching.\n\nLike `isearch-search-fun-function', though it should return a\nfunction \\(FN STRING &optional PAGES\\), which in turn should\nreturn a result like `pdf-info-search-regexp'.\")\n\n\f\n;; * ================================================================== *\n;; * Internal Variables\n;; * ================================================================== *\n\n(defvar-local pdf-isearch-current-page nil\n \"The page that is currently searched.\")\n\n(defvar-local pdf-isearch-current-match nil\n \"A list ((LEFT TOP RIGHT BOT) ...) of the current match or nil.\n\nA match may contain more than one edges-element, e.g. when regexp\nsearching across multiple lines.\")\n\n(defvar-local pdf-isearch-current-matches nil\n \"A list of matches of the last search.\")\n\n(defvar-local pdf-isearch-current-parameter nil\n \"A list of search parameter \\(search-string regex-p case-fold word-search\\).\")\n\n\f\n;; * ================================================================== *\n;; * Modes\n;; * ================================================================== *\n\n(declare-function pdf-occur \"pdf-occur.el\")\n\n(defvar pdf-isearch-minor-mode-map\n (let ((kmap (make-sparse-keymap)))\n (define-key kmap [remap occur] 'pdf-occur)\n kmap)\n \"Keymap used in `pdf-isearch-minor-mode'.\")\n\n(defvar pdf-isearch-active-mode-map\n (let ((kmap (make-sparse-keymap)))\n (set-keymap-parent kmap isearch-mode-map)\n (define-key kmap (kbd \"C-d\") 'pdf-view-dark-minor-mode)\n (define-key kmap (kbd \"C-b\") 'pdf-isearch-batch-mode)\n (define-key kmap (kbd \"M-s o\") 'pdf-isearch-occur)\n kmap)\n \"Keymap used in `pdf-isearch-active-mode'.\n\nThis keymap is used, when isearching in PDF buffers. Its parent\nkeymap is `isearch-mode-map'.\")\n\n(put 'image-scroll-up 'isearch-scroll t)\n(put 'image-scroll-down 'isearch-scroll t)\n\n(define-minor-mode pdf-isearch-active-mode \"\" nil nil nil\n (cond\n (pdf-isearch-active-mode\n (set (make-local-variable 'isearch-mode-map)\n pdf-isearch-active-mode-map)\n (setq overriding-terminal-local-map\n isearch-mode-map))\n (t\n ;;(setq overriding-terminal-local-map nil) ?\n (kill-local-variable 'isearch-mode-map))))\n\n;;;###autoload\n(define-minor-mode pdf-isearch-minor-mode\n \"Isearch mode for PDF buffer.\n\nWhen this mode is enabled \\\\[isearch-forward], among other keys,\nstarts an incremental search in this PDF document. Since this mode\nuses external programs to highlight found matches via\nimage-processing, proceeding to the next match may be slow.\n\nTherefore two isearch behaviours have been defined: Normal isearch and\nbatch mode. The later one is a minor mode\n\\(`pdf-isearch-batch-mode'\\), which when activated inhibits isearch\nfrom stopping at and highlighting every single match, but rather\ndisplay them batch-wise. Here a batch means a number of matches\ncurrently visible in the selected window.\n\nThe kind of highlighting is determined by three faces\n`pdf-isearch-match' \\(for the current match\\), `pdf-isearch-lazy'\n\\(for all other matches\\) and `pdf-isearch-batch' \\(when in batch\nmode\\), which see.\n\nColors may also be influenced by the minor-mode\n`pdf-view-dark-minor-mode'. If this is minor mode enabled, each face's\ndark colors, are used (see e.g. `frame-background-mode'), instead\nof the light ones.\n\n\\\\{pdf-isearch-minor-mode-map}\nWhile in `isearch-mode' the following keys are available. Note\nthat not every isearch command work as expected.\n\n\\\\{pdf-isearch-active-mode-map}\"\n :group 'pdf-isearch\n (pdf-util-assert-pdf-buffer)\n (cond\n (pdf-isearch-minor-mode\n (when (boundp 'character-fold-search)\n (setq-local character-fold-search nil))\n (set (make-local-variable 'isearch-search-fun-function)\n (lambda nil 'pdf-isearch-search-function))\n (set (make-local-variable 'isearch-push-state-function)\n 'pdf-isearch-push-state-function)\n (set (make-local-variable 'isearch-wrap-function)\n 'pdf-isearch-wrap-function)\n (set (make-local-variable 'isearch-lazy-highlight) nil)\n ;; Make our commands work in isearch-mode.\n (set (make-local-variable 'isearch-allow-scroll) t)\n (set (make-local-variable 'search-exit-option)\n ;; This maybe edit or t, but edit would suppress our cmds\n ;; in isearch-other-meta-char.\n (not (not search-exit-option)))\n ;; FIXME: Die Variable imagemagick-render-type entweder an anderer\n ;; Stelle global setzen oder nur irgendwo auf den\n ;; Performancegewinn hinweisen.\n (when (and (boundp 'imagemagick-render-type)\n (= 0 imagemagick-render-type))\n ;; This enormously speeds up rendering.\n (setq imagemagick-render-type 1))\n (add-hook 'isearch-mode-hook 'pdf-isearch-mode-initialize nil t)\n (add-hook 'isearch-mode-end-hook 'pdf-isearch-mode-cleanup nil t)\n (add-hook 'isearch-update-post-hook 'pdf-isearch-update nil t))\n (t\n (when (boundp 'character-fold-search)\n (kill-local-variable 'character-fold-search))\n (kill-local-variable 'search-exit-option)\n (kill-local-variable 'isearch-allow-scroll)\n (kill-local-variable 'isearch-search-fun-function)\n (kill-local-variable 'isearch-push-state-function)\n (kill-local-variable 'isearch-wrap-function)\n (kill-local-variable 'isearch-lazy-highlight)\n (remove-hook 'isearch-update-post-hook 'pdf-isearch-update t)\n (remove-hook 'isearch-mode-hook 'pdf-isearch-mode-initialize t)\n (remove-hook 'isearch-mode-end-hook 'pdf-isearch-mode-cleanup t))))\n\n(define-minor-mode pdf-isearch-batch-mode\n \"Isearch PDF documents batch-wise.\n\nIf this mode is enabled, isearching does not stop at every match,\nbut rather moves to the next one not currently visible. This\nbehaviour is much faster than ordinary isearch, since far less\ndifferent images have to be displayed.\"\n nil nil nil\n :group 'pdf-isearch\n (when isearch-mode\n (pdf-isearch-redisplay)\n (pdf-isearch-message\n (if pdf-isearch-batch-mode \"batch mode\" \"isearch mode\"))))\n\n\n\f\n;; * ================================================================== *\n;; * Isearch interface\n;; * ================================================================== *\n\n(defvar pdf-isearch-filter-matches-function nil\n \"A function for filtering isearch matches.\n\nThe function receives one argument: a list of matches, each\nbeing a list of edges. It should return a subset of this list.\nEdge coordinates are in image-space.\")\n\n(defvar pdf-isearch-narrow-to-page nil\n \"Non-nil, if the search should be limited to the current page.\")\n\n(defun pdf-isearch-search-function (string &rest _)\n \"Search for STRING in the current PDF buffer.\n\nThis is a Isearch interface function.\"\n (when (> (length string) 0)\n (let ((same-search-p (pdf-isearch-same-search-p))\n (oldpage pdf-isearch-current-page)\n (matches (pdf-isearch-search-page string))\n next-match)\n ;; matches is a list of list of edges ((x0 y1 x1 y2) ...),\n ;; sorted top to bottom ,left to right. Coordinates are in image\n ;; space.\n (unless isearch-forward\n (setq matches (reverse matches)))\n (when pdf-isearch-filter-matches-function\n (setq matches (funcall pdf-isearch-filter-matches-function matches)))\n ;; Where to go next ?\n (setq pdf-isearch-current-page (pdf-view-current-page)\n pdf-isearch-current-matches matches\n next-match\n (pdf-isearch-next-match\n oldpage pdf-isearch-current-page\n pdf-isearch-current-match matches\n same-search-p\n isearch-forward)\n pdf-isearch-current-parameter\n (list string isearch-regexp\n isearch-case-fold-search isearch-word))\n (cond\n (next-match\n (setq pdf-isearch-current-match next-match)\n (pdf-isearch-hl-matches next-match matches)\n (pdf-isearch-focus-match next-match)\n ;; Don't get off track.\n (when (or (and (bobp) (not isearch-forward))\n (and (eobp) isearch-forward))\n (goto-char (1+ (\/ (buffer-size) 2))))\n ;; Signal success to isearch.\n (if isearch-forward\n (re-search-forward \".\")\n (re-search-backward \".\")))\n ((and (not pdf-isearch-narrow-to-page)\n (not (pdf-isearch-empty-match-p matches)))\n (let ((next-page (pdf-isearch-find-next-matching-page\n string pdf-isearch-current-page t)))\n (when next-page\n (pdf-view-goto-page next-page)\n (pdf-isearch-search-function string))))))))\n\n(defun pdf-isearch-push-state-function ()\n \"Push the current search state.\n\nThis is a Isearch interface function.\"\n (let ((hscroll (window-hscroll))\n (vscroll (window-vscroll))\n (parms pdf-isearch-current-parameter)\n (matches pdf-isearch-current-matches)\n (match pdf-isearch-current-match)\n (page pdf-isearch-current-page))\n (lambda (_state)\n (setq pdf-isearch-current-parameter parms\n pdf-isearch-current-matches matches\n pdf-isearch-current-match match\n pdf-isearch-current-page page)\n\n (pdf-view-goto-page pdf-isearch-current-page)\n (when pdf-isearch-current-match\n (pdf-isearch-hl-matches\n pdf-isearch-current-match\n pdf-isearch-current-matches))\n (image-set-window-hscroll hscroll)\n (image-set-window-vscroll vscroll))))\n\n(defun pdf-isearch-wrap-function ()\n \"Go to first or last page.\n\nThis is a Isearch interface function.\"\n (let ((page (if isearch-forward\n 1\n (pdf-cache-number-of-pages))))\n (unless (or pdf-isearch-narrow-to-page\n (= page (pdf-view-current-page)))\n (pdf-view-goto-page page)\n (let ((next-screen-context-lines 0))\n (if (= page 1)\n (image-scroll-down)\n (image-scroll-up)))))\n (setq pdf-isearch-current-match nil))\n\n(defun pdf-isearch-mode-cleanup ()\n \"Cleanup after exiting Isearch.\n\nThis is a Isearch interface function.\"\n (pdf-isearch-active-mode -1)\n (pdf-view-redisplay))\n\n(defun pdf-isearch-mode-initialize ()\n \"Initialize isearching.\n\nThis is a Isearch interface function.\"\n (pdf-isearch-active-mode 1)\n (setq pdf-isearch-current-page (pdf-view-current-page)\n pdf-isearch-current-match nil\n pdf-isearch-current-matches nil\n pdf-isearch-current-parameter nil)\n (goto-char (1+ (\/ (buffer-size) 2))))\n\n(defun pdf-isearch-same-search-p (&optional ignore-search-string-p)\n \"Return non-nil, if search parameter have not changed.\n\nParameter inspected are `isearch-string' (unless\nIGNORE-SEARCH-STRING-P is t) and `isearch-case-fold-search'. If\nthere was no previous search, this function returns t.\"\n (or (null pdf-isearch-current-parameter)\n (let ((parameter (list isearch-string\n isearch-regexp\n isearch-case-fold-search\n isearch-word)))\n (if ignore-search-string-p\n (equal (cdr pdf-isearch-current-parameter)\n (cdr parameter))\n (equal pdf-isearch-current-parameter\n parameter)))))\n\n(defun pdf-isearch-next-match (last-page this-page last-match\n all-matches continued-p\n forward-p)\n \"Determine the next match.\"\n (funcall (if pdf-isearch-batch-mode\n 'pdf-isearch-next-match-batch\n 'pdf-isearch-next-match-isearch)\n last-page this-page last-match\n all-matches continued-p forward-p))\n\n(defun pdf-isearch-focus-match (current-match)\n \"Make the CURRENT-MATCH visible in the window.\"\n (funcall (if pdf-isearch-batch-mode\n 'pdf-isearch-focus-match-batch\n 'pdf-isearch-focus-match-isearch)\n current-match))\n\n(defun pdf-isearch-redisplay ()\n \"Redisplay the current highlighting.\"\n (pdf-isearch-hl-matches pdf-isearch-current-match\n pdf-isearch-current-matches))\n\n(defun pdf-isearch-update ()\n \"Update search and redisplay, if necessary.\"\n (unless (pdf-isearch-same-search-p t)\n (setq pdf-isearch-current-parameter\n (list isearch-string isearch-regexp\n isearch-case-fold-search isearch-word)\n pdf-isearch-current-matches\n (pdf-isearch-search-page isearch-string))\n (pdf-isearch-redisplay)))\n\n(defun pdf-isearch-message (fmt &rest args)\n \"Like `message', but Isearch friendly.\"\n (unless args (setq args (list fmt) fmt \"%s\"))\n (let ((msg (apply 'format fmt args)))\n (if (cl-some (lambda (buf)\n (buffer-local-value 'isearch-mode buf))\n (mapcar 'window-buffer (window-list)))\n (let ((isearch-message-suffix-add\n (format \" [%s]\" msg)))\n (isearch-message)\n (sit-for 1))\n (message \"%s\" msg))))\n\n(defun pdf-isearch-empty-match-p (matches)\n (and matches\n (cl-every\n (lambda (match)\n (cl-every (lambda (edges)\n (cl-every 'zerop edges))\n match))\n matches)))\n\n(defun pdf-isearch-occur ()\n \"Run `occur' using the last search string or regexp.\"\n (interactive)\n (let ((case-fold-search isearch-case-fold-search)\n (regexp\n (cond\n ((functionp isearch-word)\n (funcall isearch-word isearch-string))\n (isearch-word (pdf-isearch-word-search-regexp\n isearch-string nil\n pdf-isearch-hyphenation-character))\n (isearch-regexp isearch-string))))\n (save-selected-window\n (pdf-occur (or regexp isearch-string) regexp))\n (isearch-message)))\n\n\f\n;; * ================================================================== *\n;; * Interface to epdfinfo\n;; * ================================================================== *\n\n(defun pdf-isearch-search-page (string &optional page)\n \"Search STRING on PAGE in the current window.\n\nReturns a list of edges (LEFT TOP RIGHT BOTTOM) in PDF\ncoordinates, sorted top to bottom, then left to right.\"\n\n (unless page (setq page (pdf-view-current-page)))\n (mapcar (lambda (match)\n (let-alist match\n (pdf-util-scale-relative-to-pixel .edges 'round)))\n (let ((case-fold-search isearch-case-fold-search))\n (funcall (pdf-isearch-search-fun)\n string page))))\n\n(defun pdf-isearch-search-fun ()\n (funcall (or pdf-isearch-search-fun-function\n 'pdf-isearch-search-fun-default)))\n\n(defun pdf-isearch-search-fun-default ()\n \"Return default functions to use for the search.\"\n (cond\n ((eq isearch-word t)\n (lambda (string &optional pages)\n ;; Use lax versions to not fail at the end of the word while\n ;; the user adds and removes characters in the search string\n ;; (or when using nonincremental word isearch)\n (let ((lax (not (or isearch-nonincremental\n\t\t\t (null (car isearch-cmds))\n\t\t\t (eq (length isearch-string)\n\t\t\t (length (isearch--state-string\n (car isearch-cmds))))))))\n (pdf-info-search-regexp\n\t (pdf-isearch-word-search-regexp\n\t string lax pdf-isearch-hyphenation-character)\n\t pages 'invalid-regexp))))\n (isearch-regexp\n (lambda (string &optional pages)\n (pdf-info-search-regexp string pages 'invalid-regexp)))\n (t\n 'pdf-info-search-string)))\n\n\n(defun pdf-isearch-word-search-regexp (string &optional lax hyphenization-chars)\n \"Return a PCRE which matches words, ignoring punctuation.\"\n (let ((hyphenization-regexp\n (and hyphenization-chars\n (format \"(?:[%s]\\\\n)?\"\n (replace-regexp-in-string\n \"[]^\\\\\\\\-]\" \"\\\\\\\\\\\\&\"\n hyphenization-chars t)))))\n (cond\n ((equal string \"\") \"\")\n ((string-match-p \"\\\\`\\\\W+\\\\'\" string) \"\\\\W+\")\n (t (concat\n (if (string-match-p \"\\\\`\\\\W\" string) \"\\\\W+\"\n (unless lax \"\\\\b\"))\n (mapconcat (lambda (word)\n (if hyphenization-regexp\n (mapconcat\n (lambda (ch)\n (pdf-util-pcre-quote (string ch)))\n (append word nil)\n hyphenization-regexp)\n (pdf-util-pcre-quote word)))\n (split-string string \"\\\\W+\" t) \"\\\\W+\")\n (if (string-match-p \"\\\\W\\\\'\" string) \"\\\\W+\"\n (unless lax \"\\\\b\")))))))\n\n(defun pdf-isearch-find-next-matching-page (string page &optional interactive-p)\n \"Find STRING after or before page PAGE, according to FORWARD-P.\n\nIf INTERACTIVE-P is non-nil, give some progress feedback.\nReturns the page number where STRING was found, or nil if there\nis no such page.\"\n ;; Do a exponentially expanding search.\n (let* ((incr 1)\n (pages (if isearch-forward\n (cons (1+ page)\n (1+ page))\n (cons (1- page)\n (1- page))))\n (fn (pdf-isearch-search-fun))\n matched-page\n reporter)\n\n (while (and (null matched-page)\n (or (and isearch-forward\n (<= (car pages)\n (pdf-cache-number-of-pages)))\n (and (not isearch-forward)\n (>= (cdr pages) 1))))\n (let* ((case-fold-search isearch-case-fold-search)\n (matches (funcall fn string pages)))\n (setq matched-page\n (alist-get 'page (if isearch-forward\n (car matches)\n (car (last matches))))))\n (setq incr (* incr 2))\n (cond (isearch-forward\n (setcar pages (1+ (cdr pages)))\n (setcdr pages (min (pdf-cache-number-of-pages)\n (+ (cdr pages) incr))))\n (t\n (setcdr pages (1- (car pages)))\n (setcar pages (max 1 (- (car pages)\n incr)))))\n (when interactive-p\n (when (and (not reporter)\n (= incr 8)) ;;Don't bother right away.\n (setq reporter\n (apply\n 'make-progress-reporter \"Searching\"\n (if isearch-forward\n (list (car pages) (pdf-cache-number-of-pages) nil 0)\n (list 1 (cdr pages) nil 0)))))\n (when reporter\n (progress-reporter-update\n reporter (if isearch-forward\n (- (cdr pages) page)\n (- page (car pages)))))))\n matched-page))\n\n\n\f\n;; * ================================================================== *\n;; * Isearch Behavior\n;; * ================================================================== *\n\n(defun pdf-isearch-next-match-isearch (last-page this-page last-match\n matches same-search-p\n forward)\n \"Default function for choosing the next match.\n\nImplements default isearch behaviour, i.e. it stops at every\nmatch.\"\n (cond\n ((null last-match)\n ;; Goto first match from top or bottom of the window.\n (let* ((iedges (pdf-util-image-displayed-edges))\n (pos (pdf-util-with-edges (iedges)\n (if forward\n (list iedges-left iedges-top\n iedges-left iedges-top)\n (list iedges-right iedges-bot\n iedges-right iedges-bot)))))\n (pdf-isearch-closest-match (list pos) matches forward)))\n ((not (eq last-page this-page))\n ;; First match from top-left or bottom-right of the new\n ;; page.\n (car matches))\n (same-search-p\n ;; Next match after the last one.\n (if last-match\n (cadr (member last-match matches))))\n (matches\n ;; Next match of new search closest to the last one.\n (pdf-isearch-closest-match\n last-match matches forward))))\n\n(defun pdf-isearch-focus-match-isearch (match)\n \"Make the image area in MATCH visible in the selected window.\"\n (pdf-util-scroll-to-edges (apply 'pdf-util-edges-union match)))\n\n(defun pdf-isearch-next-match-batch (last-page this-page last-match\n matches same-search-p\n forward-p)\n \"Select the next match, unseen in the current search direction.\"\n\n (if (or (null last-match)\n (not same-search-p)\n (not (eq last-page this-page)))\n (pdf-isearch-next-match-isearch\n last-page this-page last-match matches same-search-p forward-p)\n (pdf-util-with-edges (match iedges)\n (let ((iedges (pdf-util-image-displayed-edges)))\n (car (cl-remove-if\n ;; Filter matches visible on screen.\n (lambda (edges)\n (let ((match (apply 'pdf-util-edges-union edges)))\n (and (<= match-right iedges-right)\n (<= match-bot iedges-bot)\n (>= match-left iedges-left)\n (>= match-top iedges-top))))\n (cdr (member last-match matches))))))))\n\n(defun pdf-isearch-focus-match-batch (match)\n \"Make the image area in MATCH eagerly visible in the selected window.\"\n (pdf-util-scroll-to-edges (apply 'pdf-util-edges-union match) t))\n\n(cl-deftype pdf-isearch-match ()\n `(satisfies\n (lambda (match)\n (cl-every (lambda (edges)\n (and (consp edges)\n (= (length edges) 4)\n (cl-every 'numberp edges)))\n match))))\n\n(cl-deftype list-of (type)\n `(satisfies\n (lambda (l)\n (and (listp l)\n (cl-every (lambda (x)\n (cl-typep x ',type))\n l)))))\n\n(defun pdf-isearch-closest-match (match matches\n &optional forward-p)\n \"Find the nearest element to MATCH in MATCHES.\n\nThe direction in which to look is determined by FORWARD-P.\n\nMATCH should be a list of edges, MATCHES a list of such element;\nit is assumed to be ordered with respect to FORWARD-P.\"\n\n\n (cl-check-type match pdf-isearch-match)\n (cl-check-type matches (list-of pdf-isearch-match))\n (let ((matched (apply 'pdf-util-edges-union match)))\n (pdf-util-with-edges (matched)\n (cl-loop for next in matches do\n (let ((edges (apply 'pdf-util-edges-union next)))\n (pdf-util-with-edges (edges)\n (when (if forward-p\n (or (>= edges-top matched-bot)\n (and (or (>= edges-top matched-top)\n (>= edges-bot matched-bot))\n (>= edges-right matched-right)))\n (or (<= edges-bot matched-top)\n (and (or (<= edges-bot matched-bot)\n (<= edges-top matched-top))\n (<= edges-left matched-left))))\n (cl-return next))))))))\n\n\n\f\n;; * ================================================================== *\n;; * Display\n;; * ================================================================== *\n\n\n(defun pdf-isearch-current-colors ()\n \"Return the current color set.\n\nThe return value depends on `pdf-view-dark-minor-mode' and\n`pdf-isearch-batch-mode'. It is a list of four colors \\(MATCH-FG\nMATCH-BG LAZY-FG LAZY-BG\\).\"\n (let ((dark-p pdf-view-dark-minor-mode))\n (cond\n (pdf-isearch-batch-mode\n (let ((colors (pdf-util-face-colors 'pdf-isearch-batch dark-p)))\n (list (car colors)\n (cdr colors)\n (car colors)\n (cdr colors))))\n (t\n (let ((match (pdf-util-face-colors 'pdf-isearch-match dark-p))\n (lazy (pdf-util-face-colors 'pdf-isearch-lazy dark-p)))\n (list (car match)\n (cdr match)\n (car lazy)\n (cdr lazy)))))))\n\n(defvar pdf-isearch--hl-matches-tick 0)\n\n(defun pdf-isearch-hl-matches (current matches &optional occur-hack-p)\n \"Highlighting edges CURRENT and MATCHES.\"\n (cl-check-type current pdf-isearch-match)\n (cl-check-type matches (list-of pdf-isearch-match))\n (cl-destructuring-bind (fg1 bg1 fg2 bg2)\n (pdf-isearch-current-colors)\n (let* ((width (car (pdf-view-image-size)))\n (page (pdf-view-current-page))\n (window (selected-window))\n (buffer (current-buffer))\n (tick (cl-incf pdf-isearch--hl-matches-tick))\n (pdf-info-asynchronous\n (lambda (status data)\n (when (and (null status)\n (eq tick pdf-isearch--hl-matches-tick)\n (buffer-live-p buffer)\n (window-live-p window)\n (eq (window-buffer window)\n buffer))\n (with-selected-window window\n (when (and (derived-mode-p 'pdf-view-mode)\n (or isearch-mode\n occur-hack-p)\n (eq page (pdf-view-current-page)))\n (pdf-view-display-image\n (pdf-view-create-image data))))))))\n (pdf-info-renderpage-text-regions\n page width t nil\n `(,fg1 ,bg1 ,@(pdf-util-scale-pixel-to-relative\n current))\n `(,fg2 ,bg2 ,@(pdf-util-scale-pixel-to-relative\n (apply 'append\n (remove current matches))))))))\n\n\f\n;; * ================================================================== *\n;; * Debug\n;; * ================================================================== *\n\n;; The following isearch-search function is debuggable.\n;;\n(when nil\n (defun isearch-search ()\n ;; Do the search with the current search string.\n (if isearch-message-function\n (funcall isearch-message-function nil t)\n (isearch-message nil t))\n (if (and (eq isearch-case-fold-search t) search-upper-case)\n (setq isearch-case-fold-search\n (isearch-no-upper-case-p isearch-string isearch-regexp)))\n (condition-case lossage\n (let ((inhibit-point-motion-hooks\n ;; FIXME: equality comparisons on functions is asking for trouble.\n (and (eq isearch-filter-predicate 'isearch-filter-visible)\n search-invisible))\n (inhibit-quit nil)\n (case-fold-search isearch-case-fold-search)\n (retry t))\n (setq isearch-error nil)\n (while retry\n (setq isearch-success\n (isearch-search-string isearch-string nil t))\n ;; Clear RETRY unless the search predicate says\n ;; to skip this search hit.\n (if (or (not isearch-success)\n (bobp) (eobp)\n (= (match-beginning 0) (match-end 0))\n (funcall isearch-filter-predicate\n (match-beginning 0) (match-end 0)))\n (setq retry nil)))\n (setq isearch-just-started nil)\n (if isearch-success\n (setq isearch-other-end\n (if isearch-forward (match-beginning 0) (match-end 0)))))\n\n (quit (isearch-unread ?\\C-g)\n (setq isearch-success nil))\n\n (invalid-regexp\n (setq isearch-error (car (cdr lossage)))\n (if (string-match\n \"\\\\`Premature \\\\|\\\\`Unmatched \\\\|\\\\`Invalid \"\n isearch-error)\n (setq isearch-error \"incomplete input\")))\n\n (search-failed\n (setq isearch-success nil)\n (setq isearch-error (nth 2 lossage)))\n\n ;; (error\n ;; ;; stack overflow in regexp search.\n ;; (setq isearch-error (format \"%s\" lossage)))\n )\n\n (if isearch-success\n nil\n ;; Ding if failed this time after succeeding last time.\n (and (isearch--state-success (car isearch-cmds))\n (ding))\n (if (functionp (isearch--state-pop-fun (car isearch-cmds)))\n (funcall (isearch--state-pop-fun (car isearch-cmds))\n (car isearch-cmds)))\n (goto-char (isearch--state-point (car isearch-cmds))))))\n\n\n(provide 'pdf-isearch)\n\n;;; pdf-isearch.el ends here\n","avg_line_length":37.35995086,"max_line_length":81,"alphanum_fraction":0.5767321035} {"size":2112,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":";;; srecode\/java.el --- Srecode Java support\r\n\r\n;; Copyright (C) 2009-2012 Free Software Foundation, Inc.\r\n\r\n;; Author: Eric M. Ludlam \r\n\r\n;; This file is part of GNU Emacs.\r\n\r\n;; GNU Emacs is free software: you can redistribute it and\/or modify\r\n;; it under the terms of the GNU General Public License as published by\r\n;; the Free Software Foundation, either version 3 of the License, or\r\n;; (at your option) any later version.\r\n\r\n;; GNU Emacs is distributed in the hope that it will be useful,\r\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\n;; GNU General Public License for more details.\r\n\r\n;; You should have received a copy of the GNU General Public License\r\n;; along with GNU Emacs. If not, see .\r\n\r\n;;; Commentary:\r\n;;\r\n;; Special support for the Java language.\r\n\r\n;;; Code:\r\n\r\n(require 'srecode\/dictionary)\r\n\r\n;;;###autoload\r\n(defun srecode-semantic-handle-:java (dict)\r\n \"Add macros into the dictionary DICT based on the current java file.\r\nAdds the following:\r\nFILENAME_AS_PACKAGE - file\/dir converted into a java package name.\r\nFILENAME_AS_CLASS - file converted to a Java class name.\"\r\n ;; A symbol representing\r\n (let* ((fsym (file-name-nondirectory (buffer-file-name)))\r\n\t (fnox (file-name-sans-extension fsym))\r\n\t (dir (file-name-directory (buffer-file-name)))\r\n\t (fpak fsym)\r\n\t )\r\n (while (string-match \"\\\\.\\\\| \" fpak)\r\n (setq fpak (replace-match \"_\" t t fpak)))\r\n (if (string-match \"src\/\" dir)\r\n\t(setq dir (substring dir (match-end 0)))\r\n (setq dir (file-name-nondirectory (directory-file-name dir))))\r\n (while (string-match \"\/\" dir)\r\n (setq dir (replace-match \"_\" t t dir)))\r\n (srecode-dictionary-set-value dict \"FILENAME_AS_PACKAGE\"\r\n\t\t\t\t (concat dir \".\" fpak))\r\n (srecode-dictionary-set-value dict \"FILENAME_AS_CLASS\" fnox)\r\n ))\r\n\r\n(provide 'srecode\/java)\r\n\r\n;; Local variables:\r\n;; generated-autoload-file: \"loaddefs.el\"\r\n;; generated-autoload-load-name: \"srecode\/java\"\r\n;; End:\r\n\r\n;;; srecode\/java.el ends here\r\n","avg_line_length":34.064516129,"max_line_length":72,"alphanum_fraction":0.6837121212} {"size":71539,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; helm-grep.el --- Helm Incremental Grep. -*- lexical-binding: t -*-\n\n;; Copyright (C) 2012 ~ 2019 Thierry Volpiatto \n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Code:\n(require 'cl-lib)\n(require 'format-spec)\n(require 'helm)\n(require 'helm-help)\n(require 'helm-regexp)\n\n;;; load wgrep proxy if it's available\n(require 'wgrep-helm nil t)\n\n(declare-function helm-buffer-list \"helm-buffers\")\n(declare-function View-quit \"view\")\n(declare-function doc-view-goto-page \"doc-view\" (page))\n(declare-function pdf-view-goto-page \"pdf-view\" (page &optional window))\n(declare-function helm-mm-split-pattern \"helm-multi-match\")\n(declare-function helm--ansi-color-apply \"helm-lib\")\n(defvar helm--ansi-color-regexp)\n\n\f\n(defgroup helm-grep nil\n \"Grep related Applications and libraries for Helm.\"\n :group 'helm)\n\n(defcustom helm-grep-default-command\n \"grep --color=always -a -d skip %e -n%cH -e %p %f\"\n \"Default grep format command for `helm-do-grep-1'.\nWhere:\n'%e' format spec is for --exclude or --include grep options or\n ack-grep --type option. (Not mandatory)\n\n'%c' format spec is for case-fold-search,\n whether to use the -i option of grep. (Not mandatory)\n When you specify this spec, helm grep will use smartcase\n that is when a upcase character is found in pattern case will\n be respected and no '-i' option will be used, otherwise, when\n no upcase character is found in pattern always use '-i'.\n If you don't want this behavior, don't use this spec and\n specify or not the '-i' option.\n Note that with ack-grep this is not needed, just specify\n the '--smart-case' option.\n\n'%p' format spec is for pattern. (Mandatory)\n\n'%f' format spec is for filenames. (Mandatory)\n\nIf your grep version doesn't support the --exclude\/include args\ndon't specify the '%e' format spec.\n\nHelm also support ack-grep and git-grep ,\nhere a default command example for ack-grep:\n\n\\(setq helm-grep-default-command \\\"ack-grep -Hn --color --smart-case --no-group %e %p %f\\\"\n helm-grep-default-recurse-command \\\"ack-grep -H --color --smart-case --no-group %e %p %f\\\")\n\nYou can ommit the %e spec if you don't want to be prompted for types.\n\nNOTE: Helm for ack-grep support ANSI sequences, so you can remove\nthe \\\"--no-color\\\" option safely (recommended)\nHowever you should specify --color to enable multi matches highlighting\nbecause ack disable it when output is piped.\n\nSame for grep you can use safely the option \\\"--color=always\\\" (default).\nYou can customize the color of matches using GREP_COLORS env var.\ne.g: \\(setenv \\\"GREP_COLORS\\\" \\\"ms=30;43:mc=30;43:sl=01;37:cx=:fn=35:ln=32:bn=32:se=36\\\")\n\nTo enable ANSI color in git-grep just add \\\"--color=always\\\".\nTo customize the ANSI color in git-grep, GREP_COLORS have no effect,\nyou will have to setup this in your .gitconfig:\n\n [color \\\"grep\\\"]\n match = black yellow\n\nwhere \\\"black\\\" is the foreground and \\\"yellow\\\" the background.\nSee the git documentation for more infos.\n\n`helm-grep-default-command' and `helm-grep-default-recurse-command'are\nindependents, so you can enable `helm-grep-default-command' with ack-grep\nand `helm-grep-default-recurse-command' with grep if you want to be faster\non recursive grep.\n\nNOTE: Remote grepping is not available with ack-grep,\n and badly supported with grep because tramp handle badly\n repeated remote processes in a short delay (< to 5s).\"\n :group 'helm-grep\n :type 'string)\n\n(defcustom helm-grep-default-recurse-command\n \"grep --color=always -a -d recurse %e -n%cH -e %p %f\"\n \"Default recursive grep format command for `helm-do-grep-1'.\nSee `helm-grep-default-command' for format specs and infos about ack-grep.\"\n :group 'helm-grep\n :type 'string)\n\n(defcustom helm-default-zgrep-command\n \"zgrep --color=always -a -n%cH -e %p %f\"\n \"Default command for Zgrep.\nSee `helm-grep-default-command' for infos on format specs.\nOption --color=always is supported and can be used safely\nto replace the helm internal match highlighting,\nsee `helm-grep-default-command' for more infos.\"\n :group 'helm-grep\n :type 'string)\n\n(defcustom helm-pdfgrep-default-command\n \"pdfgrep --color always -niH %s %s\"\n \"Default command for pdfgrep.\nOption \\\"--color always\\\" is supported starting helm version 1.7.8,\nwhen used matchs will be highlighted according to GREP_COLORS env var.\"\n :group 'helm-grep\n :type 'string)\n\n(defcustom helm-pdfgrep-default-recurse-command\n \"pdfgrep --color always -rniH %s %s\"\n \"Default recurse command for pdfgrep.\nOption \\\"--color always\\\" is supported starting helm version 1.7.8,\nwhen used matchs will be highlighted according to GREP_COLORS env var.\"\n :group 'helm-grep\n :type 'string)\n\n(defcustom helm-pdfgrep-default-read-command nil\n \"Default command to read pdf files from pdfgrep.\nWhere '%f' format spec is filename and '%p' is page number.\ne.g In Ubuntu you can set it to:\n\n \\\"evince --page-label=%p '%f'\\\"\n\nIf set to nil either `doc-view-mode' or `pdf-view-mode' will be used\ninstead of an external command.\"\n :group 'helm-grep\n :type 'string)\n\n(defcustom helm-grep-max-length-history 100\n \"Max number of elements to save in `helm-grep-history'.\"\n :group 'helm-grep\n :type 'integer)\n\n(defcustom helm-zgrep-file-extension-regexp\n \".*\\\\(\\\\.gz\\\\|\\\\.bz\\\\|\\\\.xz\\\\|\\\\.lzma\\\\)$\"\n \"Default file extensions zgrep will search in.\"\n :group 'helm-grep\n :type 'string)\n\n(defcustom helm-grep-preferred-ext nil\n \"This file extension will be preselected for grep.\"\n :group 'helm-grep\n :type 'string)\n\n(defcustom helm-grep-save-buffer-name-no-confirm nil\n \"when *hgrep* already exists,auto append suffix.\"\n :group 'helm-grep\n :type 'boolean)\n\n(defcustom helm-grep-ignored-files\n (cons \".#*\" (delq nil (mapcar (lambda (s)\n (unless (string-match-p \"\/\\\\'\" s)\n (concat \"*\" s)))\n completion-ignored-extensions)))\n \"List of file names which `helm-grep' shall exclude.\"\n :group 'helm-grep\n :type '(repeat string))\n\n(defcustom helm-grep-ignored-directories\n helm-walk-ignore-directories\n \"List of names of sub-directories which `helm-grep' shall not recurse into.\"\n :group 'helm-grep\n :type '(repeat string))\n\n(defcustom helm-grep-truncate-lines t\n \"When nil the grep line that appears will not be truncated.\"\n :group 'helm-grep\n :type 'boolean)\n\n(defcustom helm-grep-file-path-style 'basename\n \"File path display style when grep results are displayed.\nPossible value are:\n basename: displays only the filename, none of the directory path\n absolute: displays absolute path\n relative: displays relative path from root grep directory.\"\n :group 'helm-grep\n :type '(choice (const :tag \"Basename\" basename)\n (const :tag \"Absolute\" absolute)\n (const :tag \"Relative\" relative)))\n\n(defcustom helm-grep-actions\n (helm-make-actions\n \"Find File\" 'helm-grep-action\n \"Find file other frame\" 'helm-grep-other-frame\n \"Save results in grep buffer\" 'helm-grep-save-results\n \"Find file other window (C-u vertically)\" 'helm-grep-other-window)\n \"Actions for helm grep.\"\n :group 'helm-grep\n :type '(alist :key-type string :value-type function))\n\n(defcustom helm-grep-pipe-cmd-switches nil\n \"A list of additional parameters to pass to grep pipe command.\nThis will be used for pipe command for multiple pattern matching\nfor grep, zgrep ack-grep and git-grep backends.\nIf you add extra args for ack-grep, use ack-grep options,\nfor others (grep, zgrep and git-grep) use grep options.\nHere are the commands where you may want to add switches:\n\n grep --color=always\n ack-grep --smart-case --color\n\nYou probably don't need to use this unless you know what you are doing.\"\n :group 'helm-grep\n :type 'string)\n\n(defcustom helm-grep-ag-pipe-cmd-switches nil\n \"A list of additional parameters to pass to grep-ag pipe command.\nUse parameters compatibles with the backend you are using\n\\(i.e AG for AG, PT for PT or RG for RG)\n\nYou probably don't need to use this unless you know what you are doing.\"\n :group 'helm-grep\n :type 'string)\n\n(defcustom helm-grep-input-idle-delay 0.6\n \"Same as `helm-input-idle-delay' but for grep commands.\nIt have a higher value than `helm-input-idle-delay' to avoid\nflickering when updating.\"\n :group 'helm-grep\n :type 'float)\n\f\n;;; Faces\n;;\n;;\n(defgroup helm-grep-faces nil\n \"Customize the appearance of helm-grep.\"\n :prefix \"helm-\"\n :group 'helm-grep\n :group 'helm-faces)\n\n(defface helm-grep-match\n '((((background light)) :foreground \"#b00000\")\n (((background dark)) :foreground \"gold1\"))\n \"Face used to highlight grep matches.\nHave no effect when grep backend use \\\"--color=\\\".\"\n :group 'helm-grep-faces)\n\n(defface helm-grep-file\n '((t (:foreground \"BlueViolet\"\n :underline t)))\n \"Face used to highlight grep results filenames.\"\n :group 'helm-grep-faces)\n\n(defface helm-grep-lineno\n '((t (:foreground \"Darkorange1\")))\n \"Face used to highlight grep number lines.\"\n :group 'helm-grep-faces)\n\n(defface helm-grep-finish\n '((t (:foreground \"Green\")))\n \"Face used in mode line when grep is finish.\"\n :group 'helm-grep-faces)\n\n(defface helm-grep-cmd-line\n '((t (:inherit font-lock-type-face)))\n \"Face used to highlight grep command line when no results.\"\n :group 'helm-grep-faces)\n\n\f\n;;; Keymaps\n;;\n;;\n(defvar helm-grep-map\n (let ((map (make-sparse-keymap)))\n (set-keymap-parent map helm-map)\n (define-key map (kbd \"M-\") 'helm-goto-next-file)\n (define-key map (kbd \"M-\") 'helm-goto-precedent-file)\n (define-key map (kbd \"C-c o\") 'helm-grep-run-other-window-action)\n (define-key map (kbd \"C-c C-o\") 'helm-grep-run-other-frame-action)\n (define-key map (kbd \"C-x C-s\") 'helm-grep-run-save-buffer)\n (define-key map (kbd \"DEL\") 'helm-delete-backward-no-update)\n (delq nil map))\n \"Keymap used in Grep sources.\")\n\n(defcustom helm-grep-use-ioccur-style-keys t\n \"Use Arrow keys to jump to occurences.\nNote that if you define this variable with `setq' your change will\nhave no effect, use customize instead.\"\n :group 'helm-grep\n :type 'boolean\n :set (lambda (var val)\n (set var val)\n (if val\n (progn\n (define-key helm-grep-map (kbd \"\") 'helm-execute-persistent-action)\n (define-key helm-grep-map (kbd \"\") 'helm-grep-run-default-action))\n (define-key helm-grep-map (kbd \"\") nil)\n (define-key helm-grep-map (kbd \"\") nil))))\n\n(defvar helm-pdfgrep-map\n (let ((map (make-sparse-keymap)))\n (set-keymap-parent map helm-map)\n (define-key map (kbd \"M-\") 'helm-goto-next-file)\n (define-key map (kbd \"M-\") 'helm-goto-precedent-file)\n (define-key map (kbd \"DEL\") 'helm-delete-backward-no-update)\n map)\n \"Keymap used in pdfgrep.\")\n\n(defvar helm-grep-mode-map\n (let ((map (make-sparse-keymap)))\n (define-key map (kbd \"RET\") 'helm-grep-mode-jump)\n (define-key map (kbd \"C-o\") 'helm-grep-mode-jump-other-window)\n (define-key map (kbd \"\") 'helm-grep-mode-jump-other-window-forward)\n (define-key map (kbd \"\") 'helm-grep-mode-jump-other-window-backward)\n (define-key map (kbd \"\") 'helm-gm-next-file)\n (define-key map (kbd \"\") 'helm-gm-precedent-file)\n (define-key map (kbd \"M-n\") 'helm-grep-mode-jump-other-window-forward)\n (define-key map (kbd \"M-p\") 'helm-grep-mode-jump-other-window-backward)\n (define-key map (kbd \"M-N\") 'helm-gm-next-file)\n (define-key map (kbd \"M-P\") 'helm-gm-precedent-file)\n map))\n\n\f\n;;; Internals vars\n;;\n;;\n(defvar helm-rzgrep-cache (make-hash-table :test 'equal))\n(defvar helm-grep-default-function 'helm-grep-init)\n(defvar helm-zgrep-recurse-flag nil)\n(defvar helm-grep-history nil)\n(defvar helm-grep-ag-history nil)\n(defvar helm-grep-last-targets nil)\n(defvar helm-grep-include-files nil)\n(defvar helm-grep-in-recurse nil)\n(defvar helm-grep-use-zgrep nil)\n(defvar helm-grep-default-directory-fn nil\n \"A function that should return a directory to expand candidate to.\nIt is intended to use as a let-bound variable, DON'T set this globaly.\")\n(defvar helm-pdfgrep-targets nil)\n(defvar helm-grep-last-cmd-line nil)\n(defvar helm-grep-split-line-regexp \"^\\\\([[:lower:][:upper:]]?:?.*?\\\\):\\\\([0-9]+\\\\):\\\\(.*\\\\)\")\n\n\f\n;;; Init\n;;\n;;\n(defun helm-grep-prepare-candidates (candidates in-directory)\n \"Prepare filenames and directories CANDIDATES for grep command line.\"\n ;; If one or more candidate is a directory, search in all files\n ;; of this candidate (e.g \/home\/user\/directory\/*).\n ;; If r option is enabled search also in subdidrectories.\n ;; We need here to expand wildcards to support crap windows filenames\n ;; as grep doesn't accept quoted wildcards (e.g \"dir\/*.el\").\n (if helm-zgrep-recurse-flag\n (mapconcat 'shell-quote-argument candidates \" \")\n ;; When candidate is a directory, search in all its files.\n ;; NOTE that `file-expand-wildcards' will return also\n ;; directories, they will be ignored by grep but not\n ;; by ack-grep that will grep all files of this directory\n ;; without recursing in their subdirs though, see that as a one\n ;; level recursion with ack-grep.\n ;; So I leave it as it is, considering it is a feature. [1]\n (cl-loop for i in candidates append\n (cond ((string-match \"^git\" helm-grep-default-command)\n (list i))\n ;; Candidate is a directory and we use recursion or ack.\n ((and (file-directory-p i)\n (or helm-grep-in-recurse\n ;; ack-grep accept directory [1].\n (helm-grep-use-ack-p)))\n (list (expand-file-name i)))\n ;; Grep doesn't support directory only when not in recurse.\n ((file-directory-p i)\n (file-expand-wildcards\n (concat (file-name-as-directory (expand-file-name i)) \"*\") t))\n ;; Candidate is a file or wildcard and we use recursion, use the\n ;; current directory instead of candidate.\n ((and (or (file-exists-p i) (string-match \"[*]\" i))\n helm-grep-in-recurse)\n (list (expand-file-name\n (directory-file-name ; Needed for windoze.\n (file-name-directory (directory-file-name i))))))\n ;; Else should be one or more file\/directory\n ;; possibly marked.\n ;; When real is a normal filename without wildcard\n ;; file-expand-wildcards returns a list of one file.\n ;; wildcards should have been already handled by\n ;; helm-read-file-name or helm-find-files but do it from\n ;; here too in case we are called from elsewhere.\n (t (file-expand-wildcards i t))) into all-files ; [1]\n finally return\n (let ((files (if (file-remote-p in-directory)\n ;; Grep don't understand tramp filenames\n ;; use the local name.\n (mapcar (lambda (x)\n (file-remote-p x 'localname))\n all-files)\n all-files)))\n ;; When user mark files and use recursion with grep\n ;; backend enabled, the loop collect on each marked\n ;; candidate its `file-name-directory' and we endup with\n ;; duplicates (Issue #1714). FIXME: For now as a quick fix\n ;; I just remove dups here but I should handle this inside\n ;; the cond above.\n (setq files (helm-fast-remove-dups files :test 'equal))\n (if (string-match \"^git\" helm-grep-default-command)\n (mapconcat 'identity files \" \")\n (mapconcat 'shell-quote-argument files \" \"))))))\n\n(defun helm-grep-command (&optional recursive grep)\n (let* ((com (if recursive\n helm-grep-default-recurse-command\n helm-grep-default-command))\n (exe (if grep\n (symbol-name grep)\n (and com (car (split-string com \" \"))))))\n (if (and exe (string= exe \"git\")) \"git-grep\" exe)))\n\n(cl-defun helm-grep-use-ack-p (&key where)\n (let* ((rec-com (helm-grep-command t))\n (norm-com (helm-grep-command))\n (norm-com-ack-p (string-match \"\\\\`ack\" norm-com))\n (rec-com-ack-p (and rec-com (string-match \"\\\\`ack\" rec-com))))\n (cl-case where\n (default (and norm-com norm-com-ack-p))\n (recursive (and rec-com rec-com-ack-p))\n (strict (and norm-com rec-com rec-com-ack-p norm-com-ack-p))\n (t (and (not (and norm-com (string= norm-com \"git-grep\")))\n (or (and norm-com norm-com-ack-p)\n (and rec-com rec-com-ack-p)))))))\n\n(defun helm-grep--pipe-command-for-grep-command (smartcase pipe-switches &optional grep-cmd)\n (pcase (or grep-cmd (helm-grep-command))\n ;; Use grep for GNU regexp based tools.\n ((or \"grep\" \"zgrep\" \"git-grep\")\n (format \"grep --color=always%s %s\"\n (if smartcase \" -i\" \"\")\n pipe-switches))\n ;; Use ack-grep for PCRE based tools.\n ;; Sometimes ack-grep cmd is ack only.\n ((and (pred (string-match-p \"ack\")) ack)\n (format \"%s --smart-case --color %s\" ack pipe-switches))))\n\n(defun helm-grep--prepare-cmd-line (only-files &optional include zgrep)\n (let* ((default-directory (or helm-ff-default-directory\n (helm-default-directory)\n default-directory))\n (fnargs (helm-grep-prepare-candidates\n only-files default-directory))\n (ignored-files (unless (helm-grep-use-ack-p)\n (mapconcat\n (lambda (x)\n (concat \"--exclude=\"\n (shell-quote-argument x)))\n helm-grep-ignored-files \" \")))\n (ignored-dirs (unless (helm-grep-use-ack-p)\n (mapconcat\n ;; Need grep version >=2.5.4\n ;; of Gnuwin32 on windoze.\n (lambda (x)\n (concat \"--exclude-dir=\"\n (shell-quote-argument x)))\n helm-grep-ignored-directories \" \")))\n (exclude (unless (helm-grep-use-ack-p)\n (if helm-grep-in-recurse\n (concat (or include ignored-files)\n \" \" ignored-dirs)\n ignored-files)))\n (types (and (helm-grep-use-ack-p)\n ;; When %e format spec is not specified\n ;; in `helm-grep-default-command'\n ;; we need to pass an empty string\n ;; to types to avoid error.\n (or include \"\")))\n (smartcase (if (helm-grep-use-ack-p)\n \"\"\n (unless (let ((case-fold-search nil))\n (string-match-p\n \"[[:upper:]]\" helm-pattern))\n \"i\")))\n (helm-grep-default-command\n (concat helm-grep-default-command \" %m\")) ; `%m' like multi.\n (patterns (helm-mm-split-pattern helm-pattern t))\n (pipe-switches (mapconcat 'identity helm-grep-pipe-cmd-switches \" \"))\n (pipes\n (helm-aif (cdr patterns)\n (cl-loop with pipcom = (helm-grep--pipe-command-for-grep-command\n smartcase pipe-switches)\n for p in it concat\n (format \" | %s %s\" pipcom (shell-quote-argument p)))\n \"\")))\n (format-spec\n helm-grep-default-command\n (delq nil\n (list (unless zgrep\n (if types\n (cons ?e types)\n (cons ?e exclude)))\n (cons ?c (or smartcase \"\"))\n (cons ?p (shell-quote-argument (car patterns)))\n (cons ?f fnargs)\n (cons ?m pipes))))))\n\n(defun helm-grep-init (cmd-line)\n \"Start an asynchronous grep process with CMD-LINE using ZGREP if non--nil.\"\n (let* ((default-directory (or helm-ff-default-directory\n (helm-default-directory)\n default-directory))\n (zgrep (string-match \"\\\\`zgrep\" cmd-line))\n ;; Use pipe only with grep, zgrep or git-grep.\n (process-connection-type (and (not zgrep) (helm-grep-use-ack-p)))\n (tramp-verbose helm-tramp-verbose)\n (start-time (float-time))\n (proc-name (if helm-grep-use-zgrep\n \"Zgrep\"\n (capitalize\n (if helm-grep-in-recurse\n (helm-grep-command t)\n (helm-grep-command)))))\n non-essential)\n ;; Start grep process.\n (helm-log \"Starting Grep process in directory `%s'\" default-directory)\n (helm-log \"Command line used was:\\n\\n%s\"\n (concat \">>> \" (propertize cmd-line 'face 'helm-grep-cmd-line) \"\\n\\n\"))\n (prog1 ; This function should return the process first.\n (start-file-process-shell-command\n proc-name helm-buffer cmd-line)\n ;; Init sentinel.\n (set-process-sentinel\n (get-buffer-process helm-buffer)\n (lambda (process event)\n (let* ((err (process-exit-status process))\n (noresult (= err 1)))\n (unless (and err (> err 0))\n (helm-process-deferred-sentinel-hook\n process event (helm-default-directory)))\n (cond ((and noresult\n ;; This is a workaround for zgrep\n ;; that exit with code 1\n ;; after a certain amount of results.\n (with-helm-buffer (helm-empty-buffer-p)))\n (with-helm-buffer\n (insert (concat \"* Exit with code 1, no result found,\"\n \" command line was:\\n\\n \"\n (propertize helm-grep-last-cmd-line\n 'face 'helm-grep-cmd-line)))\n (setq mode-line-format\n `(\" \" mode-line-buffer-identification \" \"\n (:eval (format \"L%s\" (helm-candidate-number-at-point))) \" \"\n (:eval (propertize\n (format\n \"[%s process finished - (no results)] \"\n ,proc-name)\n 'face 'helm-grep-finish))))))\n ((or (string= event \"finished\\n\")\n (and noresult\n ;; This is a workaround for zgrep\n ;; that exit with code 1\n ;; after a certain amount of results.\n (with-helm-buffer (not (helm-empty-buffer-p)))))\n (helm-log \"%s process finished with %s results in %fs\"\n proc-name\n (helm-get-candidate-number)\n (- (float-time) start-time))\n (helm-maybe-show-help-echo)\n (with-helm-window\n (setq mode-line-format\n `(\" \" mode-line-buffer-identification \" \"\n (:eval (format \"L%s\" (helm-candidate-number-at-point))) \" \"\n (:eval (propertize\n (format\n \"[%s process finished in %.2fs - (%s results)] \"\n ,proc-name\n ,(- (float-time) start-time)\n (helm-get-candidate-number))\n 'face 'helm-grep-finish))))\n (force-mode-line-update)\n (when helm-allow-mouse\n (helm--bind-mouse-for-selection helm-selection-point))))\n ;; Catch error output in log.\n (t (helm-log\n \"Error: %s %s\"\n proc-name\n (replace-regexp-in-string \"\\n\" \"\" event))))))))))\n\n(defun helm-grep-collect-candidates ()\n (let ((cmd-line (helm-grep--prepare-cmd-line\n helm-grep-last-targets\n helm-grep-include-files\n helm-grep-use-zgrep)))\n (set (make-local-variable 'helm-grep-last-cmd-line) cmd-line)\n (funcall helm-grep-default-function cmd-line)))\n\n\f\n;;; Actions\n;;\n;;\n(defun helm-grep-action (candidate &optional where)\n \"Define a default action for `helm-do-grep-1' on CANDIDATE.\nWHERE can be one of other-window, other-frame.\"\n (let* ((split (helm-grep-split-line candidate))\n (split-pat (helm-mm-split-pattern helm-input))\n (lineno (string-to-number (nth 1 split)))\n (loc-fname (or (with-current-buffer\n (if (eq major-mode 'helm-grep-mode)\n (current-buffer)\n helm-buffer)\n (get-text-property (point-at-bol) 'helm-grep-fname))\n (car split)))\n (tramp-method (file-remote-p (or helm-ff-default-directory\n default-directory) 'method))\n (tramp-host (file-remote-p (or helm-ff-default-directory\n default-directory) 'host))\n (tramp-prefix (concat \"\/\" tramp-method \":\" tramp-host \":\"))\n (fname (if tramp-host\n (concat tramp-prefix loc-fname) loc-fname)))\n (cl-case where\n (other-window (helm-window-show-buffers\n (list (find-file-noselect fname)) t))\n (other-frame (find-file-other-frame fname))\n (grep (helm-grep-save-results-1))\n (pdf (if helm-pdfgrep-default-read-command\n (helm-pdfgrep-action-1 split lineno (car split))\n (find-file (car split)) (if (derived-mode-p 'pdf-view-mode)\n (pdf-view-goto-page lineno)\n (doc-view-goto-page lineno))))\n (t (find-file fname)))\n (unless (or (eq where 'grep) (eq where 'pdf))\n (helm-goto-line lineno))\n ;; Move point to the nearest matching regexp from bol.\n (cl-loop for reg in split-pat\n when (save-excursion\n (condition-case _err\n (if helm-migemo-mode\n (helm-mm-migemo-forward reg (point-at-eol) t)\n (re-search-forward reg (point-at-eol) t))\n (invalid-regexp nil)))\n collect (match-beginning 0) into pos-ls\n finally (when pos-ls (goto-char (apply #'min pos-ls))))\n ;; Save history\n (unless (or helm-in-persistent-action\n (eq major-mode 'helm-grep-mode)\n (string= helm-pattern \"\"))\n (setq helm-grep-history\n (cons helm-pattern\n (delete helm-pattern helm-grep-history)))\n (when (> (length helm-grep-history)\n helm-grep-max-length-history)\n (setq helm-grep-history\n (delete (car (last helm-grep-history))\n helm-grep-history))))))\n\n(defun helm-grep-persistent-action (candidate)\n \"Persistent action for `helm-do-grep-1'.\nWith a prefix arg record CANDIDATE in `mark-ring'.\"\n (helm-grep-action candidate)\n (helm-highlight-current-line))\n\n(defun helm-grep-other-window (candidate)\n \"Jump to result in other window from helm grep.\"\n (helm-grep-action candidate 'other-window))\n\n(defun helm-grep-other-frame (candidate)\n \"Jump to result in other frame from helm grep.\"\n (helm-grep-action candidate 'other-frame))\n\n(defun helm-goto-next-or-prec-file (n)\n \"Go to next or precedent candidate file in helm grep\/etags buffers.\nIf N is positive go forward otherwise go backward.\"\n (let* ((allow-mode (or (eq major-mode 'helm-grep-mode)\n (eq major-mode 'helm-moccur-mode)\n (eq major-mode 'helm-occur-mode)))\n (sel (if allow-mode\n (buffer-substring (point-at-bol) (point-at-eol))\n (helm-get-selection nil t)))\n (current-line-list (helm-grep-split-line sel))\n (current-fname (nth 0 current-line-list))\n (bob-or-eof (if (eq n 1) 'eobp 'bobp))\n (mark-maybe (lambda ()\n (if allow-mode\n (ignore)\n (helm-mark-current-line)))))\n (catch 'break\n (while (not (funcall bob-or-eof))\n (forward-line n) ; Go forward or backward depending of n value.\n ;; Exit when current-fname is not matched or in `helm-grep-mode'\n ;; the line is not a grep line i.e 'fname:num:tag'.\n (setq sel (buffer-substring (point-at-bol) (point-at-eol)))\n (when helm-allow-mouse\n (helm--mouse-reset-selection-help-echo))\n (unless (or (string= current-fname\n (car (helm-grep-split-line sel)))\n (and (eq major-mode 'helm-grep-mode)\n (not (get-text-property (point-at-bol) 'helm-grep-fname))))\n (funcall mark-maybe)\n (throw 'break nil))))\n (cond ((and (> n 0) (eobp))\n (re-search-backward \".\")\n (forward-line 0)\n (funcall mark-maybe))\n ((and (< n 0) (bobp))\n (helm-aif (next-single-property-change (point-at-bol) 'helm-grep-fname)\n (goto-char it)\n (forward-line 1))\n (funcall mark-maybe)))\n (unless allow-mode\n (helm-follow-execute-persistent-action-maybe)\n (helm-log-run-hook 'helm-move-selection-after-hook))))\n\n;;;###autoload\n(defun helm-goto-precedent-file ()\n \"Go to precedent file in helm grep\/etags buffers.\"\n (interactive)\n (with-helm-alive-p\n (with-helm-window\n (helm-goto-next-or-prec-file -1))))\n(put 'helm-goto-precedent-file 'helm-only t)\n\n;;;###autoload\n(defun helm-goto-next-file ()\n \"Go to precedent file in helm grep\/etags buffers.\"\n (interactive)\n (with-helm-window\n (helm-goto-next-or-prec-file 1)))\n\n(defun helm-grep-run-default-action ()\n \"Run grep default action from `helm-do-grep-1'.\"\n (interactive)\n (with-helm-alive-p\n (helm-exit-and-execute-action 'helm-grep-action)))\n(put 'helm-grep-run-default-action 'helm-only t)\n\n(defun helm-grep-run-other-window-action ()\n \"Run grep goto other window action from `helm-do-grep-1'.\"\n (interactive)\n (with-helm-alive-p\n (helm-exit-and-execute-action 'helm-grep-other-window)))\n(put 'helm-grep-run-other-window-action 'helm-only t)\n\n(defun helm-grep-run-other-frame-action ()\n \"Run grep goto other frame action from `helm-do-grep-1'.\"\n (interactive)\n (with-helm-alive-p\n (helm-exit-and-execute-action 'helm-grep-other-frame)))\n(put 'helm-grep-run-other-frame-action 'helm-only t)\n\n(defun helm-grep-run-save-buffer ()\n \"Run grep save results action from `helm-do-grep-1'.\"\n (interactive)\n (with-helm-alive-p\n (helm-exit-and-execute-action 'helm-grep-save-results)))\n(put 'helm-grep-run-save-buffer 'helm-only t)\n\n\f\n;;; helm-grep-mode\n;;\n;;\n(defun helm-grep-save-results (candidate)\n (helm-grep-action candidate 'grep))\n\n(defun helm-grep-save-results-1 ()\n \"Save helm grep result in a `helm-grep-mode' buffer.\"\n (let ((buf \"*hgrep*\")\n new-buf\n (pattern (with-helm-buffer helm-input-local))\n (src-name (assoc-default 'name (helm-get-current-source))))\n (when (get-buffer buf)\n (if helm-grep-save-buffer-name-no-confirm\n (setq new-buf (format \"*hgrep|%s|-%s\" pattern\n (format-time-string \"%H-%M-%S*\")))\n (setq new-buf (helm-read-string \"GrepBufferName: \" buf))\n (cl-loop for b in (helm-buffer-list)\n when (and (string= new-buf b)\n (not (y-or-n-p\n (format \"Buffer `%s' already exists overwrite? \"\n new-buf))))\n do (setq new-buf (helm-read-string \"GrepBufferName: \" \"*hgrep \"))))\n (setq buf new-buf))\n (with-current-buffer (get-buffer-create buf)\n (setq default-directory (or helm-ff-default-directory\n (helm-default-directory)\n default-directory))\n (setq buffer-read-only t)\n (let ((inhibit-read-only t)\n (map (make-sparse-keymap)))\n (erase-buffer)\n (insert \"-*- mode: helm-grep -*-\\n\\n\"\n (format \"%s Results for `%s':\\n\\n\" src-name pattern))\n (save-excursion\n (insert (with-current-buffer helm-buffer\n (goto-char (point-min)) (forward-line 1)\n (buffer-substring (point) (point-max)))))\n (save-excursion\n (while (not (eobp))\n (add-text-properties (point-at-bol) (point-at-eol)\n `(keymap ,map\n help-echo ,(concat\n (get-text-property\n (point) 'helm-grep-fname)\n \"\\nmouse-1: set point\\nmouse-2: jump to selection\")\n mouse-face highlight))\n (define-key map [mouse-1] 'mouse-set-point)\n (define-key map [mouse-2] 'helm-grep-mode-mouse-jump)\n (define-key map [mouse-3] 'ignore)\n (forward-line 1))))\n (helm-grep-mode))\n (pop-to-buffer buf)\n (message \"Helm %s Results saved in `%s' buffer\" src-name buf)))\n\n(defun helm-grep-mode-mouse-jump (event)\n (interactive \"e\")\n (let* ((window (posn-window (event-end event)))\n (pos (posn-point (event-end event))))\n (with-selected-window window\n (when (eq major-mode 'helm-grep-mode)\n (goto-char pos)\n (helm-grep-mode-jump)))))\n(put 'helm-grep-mode-mouse-jump 'helm-only t)\n\n(define-derived-mode helm-grep-mode\n special-mode \"helm-grep\"\n \"Major mode to provide actions in helm grep saved buffer.\n\nSpecial commands:\n\\\\{helm-grep-mode-map}\"\n (set (make-local-variable 'helm-grep-last-cmd-line)\n (with-helm-buffer helm-grep-last-cmd-line))\n (set (make-local-variable 'revert-buffer-function)\n #'helm-grep-mode--revert-buffer-function))\n(put 'helm-grep-mode 'helm-only t)\n\n(defun helm-grep-mode--revert-buffer-function (&optional _ignore-auto _noconfirm)\n (goto-char (point-min))\n (when (re-search-forward helm-grep-split-line-regexp nil t) (forward-line 0))\n (let ((inhibit-read-only t))\n (delete-region (point) (point-max)))\n (message \"Reverting buffer...\")\n (let ((process-connection-type\n ;; Git needs a nil value otherwise it tries to use a pager.\n (null (string-match-p \"\\\\`git\" helm-grep-last-cmd-line))))\n (set-process-sentinel\n (start-file-process-shell-command\n \"hgrep\" (generate-new-buffer \"*hgrep revert*\") helm-grep-last-cmd-line)\n 'helm-grep-mode--sentinel)))\n\n(defun helm-grep-mode--sentinel (process event)\n (when (string= event \"finished\\n\")\n (with-current-buffer (current-buffer)\n (let ((inhibit-read-only t))\n (save-excursion\n (cl-loop for l in (with-current-buffer (process-buffer process)\n (prog1 (split-string (buffer-string) \"\\n\")\n (kill-buffer)))\n for line = (if (string-match-p helm--ansi-color-regexp l)\n (helm--ansi-color-apply l) l)\n when (string-match helm-grep-split-line-regexp line)\n do (insert (propertize\n (car (helm-grep-filter-one-by-one line))\n ;; needed for wgrep.\n 'helm-realvalue line)\n \"\\n\"))))\n (when (fboundp 'wgrep-cleanup-overlays)\n (wgrep-cleanup-overlays (point-min) (point-max)))\n (message \"Reverting buffer done\"))))\n\n(defun helm-gm-next-file ()\n (interactive)\n (helm-goto-next-or-prec-file 1))\n\n(defun helm-gm-precedent-file ()\n (interactive)\n (helm-goto-next-or-prec-file -1))\n\n(defun helm-grep-mode-jump ()\n (interactive)\n (helm-grep-action\n (buffer-substring (point-at-bol) (point-at-eol)))\n (helm-match-line-cleanup-pulse))\n\n(defun helm-grep-mode-jump-other-window-1 (arg)\n (condition-case nil\n (progn\n (when (or (eq last-command 'helm-grep-mode-jump-other-window-forward)\n (eq last-command 'helm-grep-mode-jump-other-window-backward))\n (forward-line arg))\n (save-selected-window\n (helm-grep-action (buffer-substring (point-at-bol) (point-at-eol))\n 'other-window)\n (helm-match-line-cleanup-pulse)\n (recenter)))\n (error nil)))\n\n(defun helm-grep-mode-jump-other-window-forward (arg)\n (interactive \"p\")\n (helm-grep-mode-jump-other-window-1 arg))\n\n(defun helm-grep-mode-jump-other-window-backward (arg)\n (interactive \"p\")\n (helm-grep-mode-jump-other-window-1 (- arg)))\n\n(defun helm-grep-mode-jump-other-window ()\n (interactive)\n (let ((candidate (buffer-substring (point-at-bol) (point-at-eol))))\n (condition-case nil\n (progn (helm-grep-action candidate 'other-window)\n (helm-match-line-cleanup-pulse))\n (error nil))))\n\n\f\n;;; ack-grep types\n;;\n;;\n(defun helm-grep-hack-types ()\n \"Return a list of known ack-grep types.\"\n (with-temp-buffer\n ;; \"--help-types\" works with both 1.96 and 2.1+, while\n ;; \"--help types\" works only with 1.96 Issue #422.\n ;; `helm-grep-command' should return the ack executable\n ;; when this function is used in the right context\n ;; i.e After checking is we are using ack-grep with\n ;; `helm-grep-use-ack-p'.\n (call-process (helm-grep-command t) nil t nil \"--help-types\")\n (goto-char (point-min))\n (cl-loop while (re-search-forward\n \"^ *--\\\\(\\\\[no\\\\]\\\\)\\\\([^. ]+\\\\) *\\\\(.*\\\\)\" nil t)\n collect (cons (concat (match-string 2)\n \" [\" (match-string 3) \"]\")\n (match-string 2))\n collect (cons (concat \"no\" (match-string 2)\n \" [\" (match-string 3) \"]\")\n (concat \"no\" (match-string 2))))))\n\n(defun helm-grep-ack-types-transformer (candidates _source)\n (cl-loop for i in candidates\n if (stringp i)\n collect (rassoc i helm-grep-ack-types-cache)\n else\n collect i))\n\n(defvar helm-grep-ack-types-cache nil)\n(defun helm-grep-read-ack-type ()\n \"Select types for the '--type' argument of ack-grep.\"\n (require 'helm-mode)\n (require 'helm-adaptive)\n (setq helm-grep-ack-types-cache (helm-grep-hack-types))\n (let ((types (helm-comp-read\n \"Types: \" helm-grep-ack-types-cache\n :name \"*Ack-grep types*\"\n :marked-candidates t\n :must-match t\n :fc-transformer '(helm-adaptive-sort\n helm-grep-ack-types-transformer)\n :buffer \"*helm ack-types*\")))\n (mapconcat (lambda (type) (concat \"--type=\" type)) types \" \")))\n\n\f\n;;; grep extensions\n;;\n;;\n(defun helm-grep-guess-extensions (files)\n \"Try to guess file extensions in FILES list when using grep recurse.\nThese extensions will be added to command line with --include arg of grep.\"\n (cl-loop with ext-list = (list helm-grep-preferred-ext \"*\")\n with lst = (if (file-directory-p (car files))\n (directory-files\n (car files) nil\n directory-files-no-dot-files-regexp)\n files)\n for i in lst\n for ext = (file-name-extension i 'dot)\n for glob = (and ext (not (string= ext \"\"))\n (concat \"*\" ext))\n unless (or (not glob)\n (and glob-list (member glob glob-list))\n (and glob-list (member glob ext-list))\n (and glob-list (member glob helm-grep-ignored-files)))\n collect glob into glob-list\n finally return (delq nil (append ext-list glob-list))))\n\n(defun helm-grep-get-file-extensions (files)\n \"Try to return a list of file extensions to pass to '--include' arg of grep.\"\n (require 'helm-adaptive)\n (let* ((all-exts (helm-grep-guess-extensions\n (mapcar 'expand-file-name files)))\n (extensions (helm-comp-read \"Search Only in: \" all-exts\n :marked-candidates t\n :fc-transformer 'helm-adaptive-sort\n :buffer \"*helm grep exts*\"\n :name \"*helm grep extensions*\")))\n (when (listp extensions) ; Otherwise it is empty string returned by C-RET.\n ;; If extensions is a list of one string containing spaces,\n ;; assume user entered more than one glob separated by space(s) and\n ;; split this string to pass it later to mapconcat.\n ;; e.g '(\"*.el *.py\")\n (cl-loop for i in extensions\n append (split-string-and-unquote i \" \")))))\n\n\f\n;;; Set up source\n;;\n;;\n(defvar helm-grep-before-init-hook nil\n \"Hook that runs before initialization of the helm buffer.\")\n\n(defvar helm-grep-after-init-hook nil\n \"Hook that runs after initialization of the helm buffer.\")\n\n(defclass helm-grep-class (helm-source-async)\n ((candidates-process :initform 'helm-grep-collect-candidates)\n (filter-one-by-one :initform 'helm-grep-filter-one-by-one)\n (keymap :initform helm-grep-map)\n (pcre :initarg :pcre :initform nil\n :documentation\n \" Backend is using pcre regexp engine when non--nil.\")\n (nohighlight :initform t)\n (nomark :initform t)\n (backend :initarg :backend\n :initform nil\n :documentation\n \" The grep backend that will be used.\n It is actually used only as an internal flag\n and don't set the backend by itself.\n You probably don't want to modify this.\")\n (candidate-number-limit :initform 9999)\n (help-message :initform 'helm-grep-help-message)\n (history :initform 'helm-grep-history)\n (action :initform 'helm-grep-actions)\n (persistent-action :initform 'helm-grep-persistent-action)\n (persistent-help :initform \"Jump to line (`C-u' Record in mark ring)\")\n (requires-pattern :initform 2)\n (before-init-hook :initform 'helm-grep-before-init-hook)\n (after-init-hook :initform 'helm-grep-after-init-hook)\n (group :initform 'helm-grep)))\n\n(defvar helm-source-grep nil)\n\n(defmethod helm--setup-source ((source helm-grep-class))\n (call-next-method)\n (helm-aif (and helm-follow-mode-persistent\n (if (eq (slot-value source 'backend) 'git)\n helm-source-grep-git\n helm-source-grep))\n (setf (slot-value source 'follow)\n (assoc-default 'follow it))))\n\n(cl-defun helm-do-grep-1 (targets &optional recurse backend exts\n default-input input (source 'helm-source-grep))\n \"Launch helm using backend BACKEND on a list of TARGETS files.\n\nWhen RECURSE is given and BACKEND is 'grep' use -r option of\nBACKEND and prompt user for EXTS to set the --include args of BACKEND.\nInteractively you can give more than one arg separated by space at prompt.\ne.g\n $Pattern: *.el *.py *.tex\n\nFrom lisp use the EXTS argument as a list of extensions as above.\nIf you are using ack-grep, you will be prompted for --type\ninstead and EXTS will be ignored.\nIf prompt is empty `helm-grep-ignored-files' are added to --exclude.\n\nArgument DEFAULT-INPUT is use as `default' arg of `helm' and INPUT\nis used as `input' arg of `helm', See `helm' docstring.\n\nArg BACKEND when non--nil specify which backend to use\nIt is used actually to specify 'zgrep' or 'git'.\nWhen BACKEND 'zgrep' is used don't prompt for a choice\nin recurse, and ignore EXTS, search being made recursively on files matching\n`helm-zgrep-file-extension-regexp' only.\"\n (let* (non-essential\n (ack-rec-p (helm-grep-use-ack-p :where 'recursive))\n (exts (and recurse\n ;; [FIXME] I could handle this from helm-walk-directory.\n (not (eq backend 'zgrep)) ; zgrep doesn't handle -r opt.\n (not ack-rec-p)\n (or exts (helm-grep-get-file-extensions targets))))\n (include-files\n (and exts\n (mapconcat (lambda (x)\n (concat \"--include=\"\n (shell-quote-argument x)))\n (if (> (length exts) 1)\n (remove \"*\" exts)\n exts) \" \")))\n (types (and (not include-files)\n (not (eq backend 'zgrep))\n recurse\n ack-rec-p\n ;; When %e format spec is not specified\n ;; ignore types and do not prompt for choice.\n (string-match \"%e\" helm-grep-default-command)\n (helm-grep-read-ack-type)))\n (src-name (capitalize (helm-grep-command recurse backend)))\n (com (cond ((eq backend 'zgrep) helm-default-zgrep-command)\n ((eq backend 'git) helm-grep-git-grep-command)\n (recurse helm-grep-default-recurse-command)\n ;; When resuming, the local value of\n ;; `helm-grep-default-command' is used, only git-grep\n ;; should need this.\n (t helm-grep-default-command))))\n ;; When called as action from an other source e.g *-find-files\n ;; we have to kill action buffer.\n (when (get-buffer helm-action-buffer)\n (kill-buffer helm-action-buffer))\n ;; If `helm-find-files' haven't already started,\n ;; give a default value to `helm-ff-default-directory'\n ;; and set locally `default-directory' to this value . See below [1].\n (unless helm-ff-default-directory\n (setq helm-ff-default-directory default-directory))\n ;; We need to store these vars locally\n ;; to pass infos later to `helm-resume'.\n (helm-set-local-variable\n 'helm-zgrep-recurse-flag (and recurse (eq backend 'zgrep))\n 'helm-grep-last-targets targets\n 'helm-grep-include-files (or include-files types)\n 'helm-grep-in-recurse recurse\n 'helm-grep-use-zgrep (eq backend 'zgrep)\n 'helm-grep-default-command com\n 'helm-input-idle-delay helm-grep-input-idle-delay\n 'default-directory helm-ff-default-directory) ;; [1]\n ;; Setup the source.\n (set source (helm-make-source src-name 'helm-grep-class\n :backend backend\n :pcre (string-match-p \"\\\\`ack\" com)))\n (helm\n :sources source\n :buffer (format \"*helm %s*\" (helm-grep-command recurse backend))\n :default default-input\n :input input\n :keymap helm-grep-map\n :history 'helm-grep-history\n :truncate-lines helm-grep-truncate-lines)))\n\n\f\n;;; zgrep\n;;\n;;\n(defun helm-ff-zgrep-1 (flist recursive)\n (unwind-protect\n (let* ((def-dir (or helm-ff-default-directory\n default-directory))\n (only (if recursive\n (or (gethash def-dir helm-rzgrep-cache)\n (puthash\n def-dir\n (helm-walk-directory\n def-dir\n :directories nil\n :path 'full\n :match helm-zgrep-file-extension-regexp)\n helm-rzgrep-cache))\n flist)))\n (helm-do-grep-1 only recursive 'zgrep))\n (setq helm-zgrep-recurse-flag nil)))\n\n\f\n;;; transformers\n;;\n;;\n(defun helm-grep-split-line (line)\n \"Split a grep output line.\"\n ;; The output of grep may send a truncated line in this chunk,\n ;; so don't split until grep line is valid, that is\n ;; once the second part of the line comes with next chunk\n ;; send by process.\n (when (string-match helm-grep-split-line-regexp line)\n ;; Don't use split-string because buffer\/file name or string\n ;; may contain a \":\".\n (cl-loop for n from 1 to 3 collect (match-string n line))))\n\n(defun helm-grep--filter-candidate-1 (candidate &optional dir)\n (let* ((root (or dir (and helm-grep-default-directory-fn\n (funcall helm-grep-default-directory-fn))))\n (ansi-p (string-match-p helm--ansi-color-regexp candidate))\n (line (if ansi-p (helm--ansi-color-apply candidate) candidate))\n (split (helm-grep-split-line line))\n (fname (if (and root split)\n ;; Filename should always be provided as a local\n ;; path, if the root directory is remote, the\n ;; tramp prefix will be added before executing\n ;; action, see `helm-grep-action' and issue #2032.\n (expand-file-name (car split)\n (or (file-remote-p root 'localname)\n root))\n (car-safe split)))\n (lineno (nth 1 split))\n (str (nth 2 split))\n (display-fname (cl-ecase helm-grep-file-path-style\n (basename (and fname (file-name-nondirectory fname)))\n (absolute fname)\n (relative (and fname root\n (file-relative-name fname root))))))\n (if (and display-fname lineno str)\n (cons (concat (propertize display-fname\n 'face 'helm-grep-file\n 'help-echo (abbreviate-file-name fname)\n 'helm-grep-fname fname)\n \":\"\n (propertize lineno 'face 'helm-grep-lineno)\n \":\"\n (if ansi-p str (helm-grep-highlight-match str t)))\n line)\n \"\")))\n\n(defun helm-grep-filter-one-by-one (candidate)\n \"`filter-one-by-one' transformer function for `helm-do-grep-1'.\"\n (let ((helm-grep-default-directory-fn\n (or helm-grep-default-directory-fn\n (lambda () (or helm-ff-default-directory\n (and (null (eq major-mode 'helm-grep-mode))\n (helm-default-directory))\n default-directory)))))\n (if (consp candidate)\n ;; Already computed do nothing (default as input).\n candidate\n (and (stringp candidate)\n (helm-grep--filter-candidate-1 candidate)))))\n\n(defun helm-grep-highlight-match (str &optional multi-match)\n \"Highlight in string STR all occurences matching `helm-pattern'.\"\n (let (beg end)\n (condition-case-unless-debug nil\n (with-temp-buffer\n (insert (propertize str 'read-only nil)) ; Fix (#1176)\n (goto-char (point-min))\n (cl-loop for reg in\n (if multi-match\n ;; (m)occur.\n (cl-loop for r in (helm-mm-split-pattern\n helm-pattern)\n unless (string-match \"\\\\`!\" r)\n collect\n (helm-aif (and helm-migemo-mode\n (assoc r helm-mm--previous-migemo-info))\n (cdr it) r))\n ;; async sources (grep, gid etc...)\n (list helm-input))\n do\n (while (and (re-search-forward reg nil t)\n (> (- (setq end (match-end 0))\n (setq beg (match-beginning 0))) 0))\n (helm-add-face-text-properties beg end 'helm-grep-match))\n do (goto-char (point-min)))\n (buffer-string))\n (error nil))))\n\n\f\n;;; Grep from buffer list\n;;\n;;\n(defun helm-grep-buffers-1 (candidate &optional zgrep)\n \"Run grep on all file--buffers or CANDIDATE if it is a file--buffer.\nIf one of selected buffers is not a file--buffer,\nit is ignored and grep will run on all others file--buffers.\nIf only one candidate is selected and it is not a file--buffer,\nswitch to this buffer and run `helm-occur'.\nIf a prefix arg is given run grep on all buffers ignoring non--file-buffers.\"\n (let* ((prefarg (or current-prefix-arg helm-current-prefix-arg))\n (helm-ff-default-directory\n (if (and helm-ff-default-directory\n (file-remote-p helm-ff-default-directory))\n default-directory\n helm-ff-default-directory))\n (cands (if prefarg\n (buffer-list)\n (helm-marked-candidates)))\n (win-conf (current-window-configuration))\n ;; Non--fname and remote buffers are ignored.\n (bufs (cl-loop for buf in cands\n for fname = (buffer-file-name (get-buffer buf))\n when (and fname (not (file-remote-p fname)))\n collect (expand-file-name fname))))\n (if bufs\n (if zgrep\n (helm-do-grep-1 bufs nil 'zgrep)\n (helm-do-grep-1 bufs))\n ;; bufs is empty, thats mean we have only CANDIDATE\n ;; and it is not a buffer-filename, fallback to occur.\n (switch-to-buffer candidate)\n (when (get-buffer helm-action-buffer)\n (kill-buffer helm-action-buffer))\n (helm-occur)\n (when (eq helm-exit-status 1)\n (set-window-configuration win-conf)))))\n\n(defun helm-grep-buffers (candidate)\n \"Action to grep buffers.\"\n (helm-grep-buffers-1 candidate))\n\n(defun helm-zgrep-buffers (candidate)\n \"Action to zgrep buffers.\"\n (helm-grep-buffers-1 candidate 'zgrep))\n\n\f\n;;; Helm interface for pdfgrep\n;; pdfgrep program \n;; and a pdf-reader (e.g xpdf) are needed.\n;;\n(defvar helm-pdfgrep-default-function 'helm-pdfgrep-init)\n(defun helm-pdfgrep-init (only-files &optional recurse)\n \"Start an asynchronous pdfgrep process in ONLY-FILES list.\"\n (let* ((default-directory (or helm-ff-default-directory\n default-directory))\n (fnargs (helm-grep-prepare-candidates\n (if (file-remote-p default-directory)\n (mapcar (lambda (x)\n (file-remote-p x 'localname))\n only-files)\n only-files)\n default-directory))\n (cmd-line (format (if recurse\n helm-pdfgrep-default-recurse-command\n helm-pdfgrep-default-command)\n helm-pattern\n fnargs))\n process-connection-type)\n ;; Start pdf grep process.\n (helm-log \"Starting Pdf Grep process in directory `%s'\" default-directory)\n (helm-log \"Command line used was:\\n\\n%s\"\n (concat \">>> \" (propertize cmd-line 'face 'helm-grep-cmd-line) \"\\n\\n\"))\n (prog1\n (start-file-process-shell-command\n \"pdfgrep\" helm-buffer cmd-line)\n (message nil)\n (set-process-sentinel\n (get-buffer-process helm-buffer)\n (lambda (_process event)\n (if (string= event \"finished\\n\")\n (with-helm-window\n (setq mode-line-format\n '(\" \" mode-line-buffer-identification \" \"\n (:eval (format \"L%s\" (helm-candidate-number-at-point))) \" \"\n (:eval (propertize\n (format \"[Pdfgrep Process Finish - %s result(s)] \"\n (max (1- (count-lines\n (point-min) (point-max))) 0))\n 'face 'helm-grep-finish))))\n (force-mode-line-update)\n (when helm-allow-mouse\n (helm--bind-mouse-for-selection helm-selection-point)))\n (helm-log \"Error: Pdf grep %s\"\n (replace-regexp-in-string \"\\n\" \"\" event))))))))\n\n(defun helm-do-pdfgrep-1 (only &optional recurse)\n \"Launch pdfgrep with a list of ONLY files.\"\n (unless (executable-find \"pdfgrep\")\n (error \"Error: No such program `pdfgrep'.\"))\n (let (helm-grep-in-recurse) ; recursion is implemented differently in *pdfgrep.\n ;; When called as action from an other source e.g *-find-files\n ;; we have to kill action buffer.\n (when (get-buffer helm-action-buffer)\n (kill-buffer helm-action-buffer))\n (setq helm-pdfgrep-targets only)\n (helm\n :sources (helm-build-async-source \"PdfGrep\"\n :init (lambda ()\n ;; If `helm-find-files' haven't already started,\n ;; give a default value to `helm-ff-default-directory'.\n (setq helm-ff-default-directory (or helm-ff-default-directory\n default-directory)))\n :candidates-process (lambda ()\n (funcall helm-pdfgrep-default-function\n helm-pdfgrep-targets recurse))\n :nohighlight t\n :nomark t\n :filter-one-by-one #'helm-grep-filter-one-by-one\n :candidate-number-limit 9999\n :history 'helm-grep-history\n :keymap helm-pdfgrep-map\n :help-message 'helm-pdfgrep-help-message\n :action #'helm-pdfgrep-action\n :persistent-help \"Jump to PDF Page\"\n :requires-pattern 2)\n :buffer \"*helm pdfgrep*\"\n :history 'helm-grep-history)))\n\n(defun helm-pdfgrep-action (candidate)\n (helm-grep-action candidate 'pdf))\n\n(defun helm-pdfgrep-action-1 (_split pageno fname)\n (save-selected-window\n (start-file-process-shell-command\n \"pdf-reader\" nil\n (format-spec helm-pdfgrep-default-read-command\n (list (cons ?f fname) (cons ?p pageno))))))\n\f\n;;; AG - PT - RG\n;;\n;; https:\/\/github.com\/ggreer\/the_silver_searcher\n;; https:\/\/github.com\/monochromegane\/the_platinum_searcher\n;; https:\/\/github.com\/BurntSushi\/ripgrep\n\n(defcustom helm-grep-ag-command\n \"ag --line-numbers -S --hidden --color --nogroup %s %s %s\"\n \"The default command for AG, PT or RG.\n\nTakes three format specs, the first for type(s), the second for pattern\nand the third for directory.\n\nYou can use safely \\\"--color\\\" (used by default) with AG RG and PT.\n\nFor ripgrep here is the command line to use:\n\n rg --color=always --smart-case --no-heading --line-number %s %s %s\n\nNOTE: Old versions of ripgrep was not supporting colors in emacs and a\nworkaround had to be used (i.e prefixing command line with\n\\\"TERM=eterm-color\\\"), this is no more needed.\nSee issue for more infos.\n\nYou must use an output format that fit with helm grep, that is:\n\n \\\"filename:line-number:string\\\"\n\nThe option \\\"--nogroup\\\" allow this.\nThe option \\\"--line-numbers\\\" is also mandatory except with PT (not supported).\nFor RG the options \\\"--no-heading\\\" and \\\"--line-number\\\" are the ones to use.\n\nWhen modifying the default colors of matches with e.g \\\"--color-match\\\" option of AG\nyou may want to modify as well `helm-grep-ag-pipe-cmd-switches' to have all matches\ncolorized with same color in multi match.\"\n :group 'helm-grep\n :type 'string)\n\n(defun helm-grep--ag-command ()\n (car (helm-remove-if-match\n \"\\\\`[A-Z]*=\" (split-string helm-grep-ag-command))))\n\n(defun helm-grep-ag-get-types ()\n \"Returns a list of AG types if available with AG version.\nSee AG option \\\"--list-file-types\\\"\nRipgrep (rg) types are also supported if this backend is used.\"\n (with-temp-buffer\n (let* ((com (helm-grep--ag-command))\n (ripgrep (string= com \"rg\"))\n (regex (if ripgrep \"^\\\\(.*\\\\):\" \"^ *\\\\(--[a-z]*\\\\)\"))\n (prefix (if ripgrep \"-t\" \"\")))\n (when (equal (call-process com\n nil t nil\n (if ripgrep\n \"--type-list\" \"--list-file-types\")) 0)\n (goto-char (point-min))\n (cl-loop while (re-search-forward regex nil t)\n for type = (match-string 1)\n collect (cons type (concat prefix type)))))))\n\n(defun helm-grep-ag-prepare-cmd-line (pattern directory &optional type)\n \"Prepare AG command line to search PATTERN in DIRECTORY.\nWhen TYPE is specified it is one of what returns `helm-grep-ag-get-types'\nif available with current AG version.\"\n (let* ((patterns (helm-mm-split-pattern pattern t))\n (pipe-switches (mapconcat 'identity helm-grep-ag-pipe-cmd-switches \" \"))\n (pipe-cmd (helm-acase (helm-grep--ag-command)\n ((\"ag\" \"pt\")\n (format \"%s -S --color%s\" it (concat \" \" pipe-switches)))\n (\"rg\" (format \"rg -N -S --color=always%s\"\n (concat \" \" pipe-switches)))))\n (cmd (format helm-grep-ag-command\n (mapconcat 'identity type \" \")\n (shell-quote-argument (car patterns))\n (shell-quote-argument directory))))\n (helm-aif (cdr patterns)\n (concat cmd (cl-loop for p in it concat\n (format \" | %s %s\"\n pipe-cmd (shell-quote-argument p))))\n cmd)))\n\n(defun helm-grep-ag-init (directory &optional type)\n \"Start AG process in DIRECTORY maybe searching only files of type TYPE.\"\n (let ((default-directory (or helm-ff-default-directory\n (helm-default-directory)\n default-directory))\n (cmd-line (helm-grep-ag-prepare-cmd-line\n helm-pattern (or (file-remote-p directory 'localname)\n directory)\n type))\n (start-time (float-time))\n (proc-name (helm-grep--ag-command)))\n (set (make-local-variable 'helm-grep-last-cmd-line) cmd-line)\n (helm-log \"Starting %s process in directory `%s'\"\n proc-name directory)\n (helm-log \"Command line used was:\\n\\n%s\"\n (concat \">>> \" cmd-line \"\\n\\n\"))\n (prog1\n (start-file-process-shell-command\n proc-name helm-buffer cmd-line)\n (set-process-sentinel\n (get-buffer-process helm-buffer)\n (lambda (process event)\n (let* ((err (process-exit-status process))\n (noresult (= err 1)))\n (cond (noresult\n (with-helm-buffer\n (insert (concat \"* Exit with code 1, no result found,\"\n \" command line was:\\n\\n \"\n (propertize helm-grep-last-cmd-line\n 'face 'helm-grep-cmd-line)))\n (setq mode-line-format\n `(\" \" mode-line-buffer-identification \" \"\n (:eval (format \"L%s\" (helm-candidate-number-at-point))) \" \"\n (:eval (propertize\n (format\n \"[%s process finished - (no results)] \"\n ,(upcase proc-name))\n 'face 'helm-grep-finish))))))\n ((string= event \"finished\\n\")\n (helm-log \"%s process finished with %s results in %fs\"\n proc-name\n (helm-get-candidate-number)\n (- (float-time) start-time))\n (helm-maybe-show-help-echo)\n (with-helm-window\n (setq mode-line-format\n `(\" \" mode-line-buffer-identification \" \"\n (:eval (format \"L%s\" (helm-candidate-number-at-point))) \" \"\n (:eval (propertize\n (format\n \"[%s process finished in %.2fs - (%s results)] \"\n ,(upcase proc-name)\n ,(- (float-time) start-time)\n (helm-get-candidate-number))\n 'face 'helm-grep-finish))))\n (force-mode-line-update)\n (when helm-allow-mouse\n (helm--bind-mouse-for-selection helm-selection-point))))\n (t (helm-log\n \"Error: %s %s\"\n proc-name\n (replace-regexp-in-string \"\\n\" \"\" event))))))))))\n\n(defclass helm-grep-ag-class (helm-source-async)\n ((nohighlight :initform t)\n (pcre :initarg :pcre :initform t\n :documentation\n \" Backend is using pcre regexp engine when non--nil.\")\n (keymap :initform helm-grep-map)\n (history :initform 'helm-grep-ag-history)\n (help-message :initform 'helm-grep-help-message)\n (filter-one-by-one :initform 'helm-grep-filter-one-by-one)\n (persistent-action :initform 'helm-grep-persistent-action)\n (persistent-help :initform \"Jump to line (`C-u' Record in mark ring)\")\n (candidate-number-limit :initform 99999)\n (requires-pattern :initform 2)\n (nomark :initform t)\n (action :initform 'helm-grep-actions)\n (group :initform 'helm-grep)))\n\n(defvar helm-source-grep-ag nil)\n\n(defmethod helm--setup-source ((source helm-grep-ag-class))\n (call-next-method)\n (helm-aif (and helm-follow-mode-persistent\n helm-source-grep-ag\n (assoc-default 'follow helm-source-grep-ag))\n (setf (slot-value source 'follow) it)))\n\n(defun helm-grep-ag-1 (directory &optional type)\n \"Start helm ag in DIRECTORY maybe searching in files of type TYPE.\"\n (setq helm-source-grep-ag\n (helm-make-source (upcase (helm-grep--ag-command)) 'helm-grep-ag-class\n :header-name (lambda (name)\n (format \"%s [%s]\"\n name (abbreviate-file-name directory)))\n :candidates-process\n (lambda () (helm-grep-ag-init directory type))))\n (helm-set-local-variable 'helm-input-idle-delay helm-grep-input-idle-delay)\n (helm :sources 'helm-source-grep-ag\n :keymap helm-grep-map\n :history 'helm-grep-ag-history\n :truncate-lines helm-grep-truncate-lines\n :buffer (format \"*helm %s*\" (helm-grep--ag-command))))\n\n(defun helm-grep-ag (directory with-types)\n \"Start grep AG in DIRECTORY.\nWhen WITH-TYPES is non-nil provide completion on AG types.\"\n (require 'helm-adaptive)\n (helm-grep-ag-1 directory\n (helm-aif (and with-types\n (helm-grep-ag-get-types))\n (helm-comp-read\n \"Ag type: \" it\n :must-match t\n :marked-candidates t\n :fc-transformer 'helm-adaptive-sort\n :buffer \"*helm ag types*\"))))\n\n;;; Git grep\n;;\n;;\n(defvar helm-source-grep-git nil)\n\n(defcustom helm-grep-git-grep-command\n \"git --no-pager grep -n%cH --color=always --full-name -e %p -- %f\"\n \"The git grep default command line.\nThe option \\\"--color=always\\\" can be used safely.\nThe color of matched items can be customized in your .gitconfig\nSee `helm-grep-default-command' for more infos.\n\nThe \\\"--exclude-standard\\\" and \\\"--no-index\\\" switches allow\nskipping unwanted files specified in ~\/.gitignore_global\nand searching files not already staged (not enabled by default).\n\nYou have also to enable this in global \\\".gitconfig\\\" with\n \\\"git config --global core.excludesfile ~\/.gitignore_global\\\".\"\n :group 'helm-grep\n :type 'string)\n\n(defun helm-grep-git-1 (directory &optional all default input)\n \"Run git-grep on DIRECTORY.\nIf DIRECTORY is not inside or part of a git repo exit with error.\nIf optional arg ALL is non-nil grep the whole repo otherwise start\nat DIRECTORY.\nArg DEFAULT is what you will have with `next-history-element',\narg INPUT is what you will have by default at prompt on startup.\"\n (require 'vc)\n (let* (helm-grep-default-recurse-command\n ;; Expand filename of each candidate with the git root dir.\n ;; The filename will be in the helm-grep-fname prop.\n (helm-grep-default-directory-fn (lambda ()\n (vc-find-root directory \".git\")))\n (helm-ff-default-directory (funcall helm-grep-default-directory-fn)))\n (cl-assert helm-ff-default-directory nil \"Not inside a Git repository\")\n (helm-do-grep-1 (if all '(\"\") `(,(expand-file-name directory)))\n nil 'git nil default input 'helm-source-grep-git)))\n\n\f\n;;;###autoload\n(defun helm-do-grep-ag (arg)\n \"Preconfigured helm for grepping with AG in `default-directory'.\nWith prefix-arg prompt for type if available with your AG version.\"\n (interactive \"P\")\n (require 'helm-files)\n (helm-grep-ag (expand-file-name default-directory) arg))\n\n;;;###autoload\n(defun helm-grep-do-git-grep (arg)\n \"Preconfigured helm for git-grepping `default-directory'.\nWith a prefix arg ARG git-grep the whole repository.\"\n (interactive \"P\")\n (require 'helm-files)\n (helm-grep-git-1 default-directory arg))\n\n\n(provide 'helm-grep)\n\n;; Local Variables:\n;; byte-compile-warnings: (not obsolete)\n;; coding: utf-8\n;; indent-tabs-mode: nil\n;; End:\n\n;;; helm-grep.el ends here\n","avg_line_length":43.0439229844,"max_line_length":105,"alphanum_fraction":0.5634548987} {"size":32592,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; nnreddit.el --- Reddit backend for Gnus\n\n;; Copyright (C) 2016 Paul Issartel\n\n;; Author: Paul Issartel \n;; Keywords: news\n\n;; This file is not is part of GNU Emacs.\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Commentary:\n\n;;\n\n;;; Code:\n\n(eval-when-compile (require 'cl))\n\n(require 'nnheader)\n(require 'nnoo)\n(require 'gnus-group)\n(require 'gnus-sum)\n(require 'gnus-art)\n(require 'gnus-util)\n(require 'json)\n(require 'mm-url)\n\n(nnoo-declare nnreddit)\n\n(nnoo-define-basics nnreddit)\n\n(defcustom nnreddit-subjects-from-body t\n \"Construct the subject line of comment articles from the\ncomment's body.\"\n :group 'nnreddit)\n\n(defcustom nnreddit-insert-title-in-body t\n \"For 'link' articles, insert the full (unelided) title at the\nbeginning of the article's body.\"\n :group 'nnreddit)\n\n(defcustom nnreddit-elide-link-subjects 120\n \"If set to a number, cut long subject lines of 'link' posts\nto the given width.\"\n :group 'nnreddit)\n\n(defcustom nnreddit-elide-comment-subjects 70\n \"If set to a number, cut long subject lines of 'comment' posts\nto the given width.\"\n :group 'nnreddit)\n\n(defcustom nnreddit-always-show-subject t\n \"If t, always show the Subject header, even when\n`nnreddit-subjects-from-body' is set to t.\"\n :group 'nnreddit)\n\n(defcustom nnreddit-link-count 50\n \"How many links to initially retrieve from a subreddit.\"\n :group 'nnreddit)\n\n(defcustom nnreddit-insert-score-header nil\n \"Whether to insert the Score: header in articles.\"\n :group 'nnreddit)\n\n(defcustom nnreddit-auto-open-threads t\n \"If t, automatically insert comments when a 'link' article is selected.\nIf nil, only insert comments when the keybinding for\n`gnus-summary-show-thread' is pressed.\"\n :group 'nnreddit)\n\n(defcustom nnreddit-show-images t\n \"Whether to display images in the body of 'link' articles.\"\n :group 'nnreddit)\n\n(defcustom nnreddit-preview-width 320\n \"Width of the preview images in 'link' articles.\"\n :group 'nnreddit)\n\n(defcustom nnreddit-num-comments-in-subject \"(%d) \"\n \"If non-nil, prepend the number of comments to subject lines\naccording to the given format string.\"\n :group 'nnreddit)\n\n(defconst nnreddit-subreddits-url\n \"https:\/\/www.reddit.com\/subreddits.json?limit=100\")\n\n(defconst nnreddit-subreddit-listing-url\n \"https:\/\/www.reddit.com\/r\/%s\/.json?limit=%d\")\n\n(defconst nnreddit-comments-url\n \"https:\/\/www.reddit.com\/r\/%s\/comments\/%s\/.json\")\n\n(defconst nnreddit-comment-kind \"t1\")\n(defconst nnreddit-link-kind \"t3\")\n(defconst nnreddit-subreddit-kind \"t5\")\n\n(defvar nnreddit-subreddit nil)\n(defvar nnreddit-subreddits-hashtb nil)\n(defvar nnreddit-data-by-id-by-subreddit nil)\n(defvar nnreddit-fetched-comment-pages nil)\n(defvar nnreddit-links-by-reddit-ids nil)\n(defvar nnreddit-comments-by-reddit-ids-by-subreddit nil)\n\n;; From: https:\/\/github.com\/death\/reddit-mode\/blob\/master\/reddit.el\n(defmacro nnreddit-alet (vars alist &rest forms)\n (let ((alist-var (make-symbol \"alist\")))\n `(let* ((,alist-var ,alist)\n ,@(loop for var in vars\n collecting `(,var (assoc-default ',var ,alist-var))))\n ,@forms)))\n\n(defun nnreddit-sanitize-string (str)\n (gnus-replace-in-string\n (gnus-replace-in-string\n str\n \" *\\r?\\n *\" \" \")\n \"[\\000-\\037\\177]+\\\\|^ +\\\\| +$\" \"\"))\n\n(defun nnreddit-decode-entities-string (string)\n (with-temp-buffer\n (insert string)\n (mm-url-decode-entities-nbsp)\n (buffer-string)))\n\n(defun nnreddit-retrieve-subreddit-list-json ()\n ;; (message \"fetching subreddit list\")\n (with-temp-buffer\n (mm-url-insert nnreddit-subreddits-url)\n (goto-char (point-min))\n (json-read)))\n\n(defun nnreddit-retrieve-subreddit-json (subreddit)\n ;; (message \"fetching listing\")\n (with-temp-buffer\n (mm-url-insert (format nnreddit-subreddit-listing-url\n subreddit nnreddit-link-count))\n (goto-char (point-min))\n (json-read)))\n\n(defun nnreddit-retrieve-comments-json (subreddit reddit-id)\n ;; (message \"fetching comments\")\n (with-temp-buffer\n (mm-url-insert (format nnreddit-comments-url subreddit reddit-id))\n (goto-char (point-min))\n (json-read)))\n\n(defun nnreddit-parse-subreddit-description (data)\n (let ((kind (assoc-default 'kind data)))\n (assert (equal nnreddit-subreddit-kind kind))\n (nnreddit-alet (id display_name url public_description)\n (assoc-default 'data data)\n (list :id id\n :name display_name\n :url url\n :description public_description))))\n\n(defun nnreddit-find-preview-image-url (preview preferred-width)\n (condition-case nil\n (let* ((resolutions\n (assoc-default 'resolutions\n (aref (assoc-default 'images preview) 0)))\n (best (car\n (sort\n (append resolutions nil)\n (lambda (p1 p2)\n (let ((w1 (assoc-default 'width p1))\n (w2 (assoc-default 'width p2)))\n (< (abs (- w1 preferred-width))\n (abs (- w2 preferred-width)))))))))\n (assoc-default 'url best))\n (error nil)))\n\n(defun nnreddit-field-exists (field)\n (and (stringp field) (not (equal field \"\"))))\n\n(defun nnreddit-make-link-body ()\n ;; Here, \"title\", \"selftext_html\", \"url\", \"is_self\", \"preview\" and\n ;; \"thumbnail\" are bound from `nnreddit-parse-link'\n (let ((notself (not (eq is_self t)))) ; NOTE: \"is_self\" may be non-nil but\n ; still false, e.g. \":json-false\"\n (concat\n ;; Prepend the full title if `nnreddit-insert-title-in-body' is set\n (and title\n nnreddit-insert-title-in-body\n ;; (format \"

%s<\/h1>\\n\" title))\n (format \"

%s<\/p>\\n\" title))\n (cond\n ;; If the post contains a selftext, use that\n (selftext_html)\n ;; Otherwise try to use the preview image if available\n ((and nnreddit-show-images\n preview\n (let ((image-url (nnreddit-find-preview-image-url\n preview\n nnreddit-preview-width)))\n (if (nnreddit-field-exists image-url)\n (nnreddit-decode-entities-string\n (concat (format \"\"\n nnreddit-preview-width\n image-url)\n ;; Append the link if provided\n (and (nnreddit-field-exists url)\n (format \"%s<\/a>\"\n url url))))))))\n ;; Or use the thumbnail if provided\n ((and nnreddit-show-images\n (nnreddit-field-exists thumbnail) notself)\n (nnreddit-decode-entities-string\n (if (nnreddit-field-exists url)\n (format \"<\/a>%s<\/a>\"\n url nnreddit-preview-width thumbnail url url)\n (format \"\" thumbnail))))\n ;; Or just insert the link if this is not a \"self\" post\n ((and (nnreddit-field-exists url) notself)\n (nnreddit-decode-entities-string\n (format \"%s<\/a>\" url url)))))))\n\n (defun nnreddit-parse-link (data)\n (let ((kind (assoc-default 'kind data)))\n (assert (equal nnreddit-link-kind kind))\n (nnreddit-alet\n (id title author created_utc score thumbnail preview url is_self\n selftext_html num_comments)\n (assoc-default 'data data)\n (list :id id\n :title title\n :author author\n :date (seconds-to-time created_utc)\n :text (nnreddit-make-link-body)\n :score score\n :num_comments num_comments))))\n\n(defun nnreddit-sort-by-score (c1 c2)\n \"Sort two comments by highest score.\"\n (>= (plist-get c1 :score) (plist-get c2 :score)))\n\n(defun nnreddit-parse-comment (data &optional parent-id sort-children)\n (let ((kind (assoc-default 'kind data)))\n ;; (assert (equal nnreddit-comment-kind kind))\n (when (equal nnreddit-comment-kind kind) ; FIXME: handle other types?\n (nnreddit-alet\n (id body body_html author created_utc score replies)\n (assoc-default 'data data)\n (let* ((replies-data\n (and (listp replies)\n (assoc-default 'data replies)))\n (children\n (and (listp replies-data)\n (assoc-default 'children replies-data)))\n (children-comments\n (remove nil\n (mapcar\n (lambda (data)\n (nnreddit-parse-comment data id sort-children))\n children))))\n (if sort-children\n (setq children-comments\n (sort children-comments 'nnreddit-sort-by-score)))\n (list :id id\n :title nil\n :author author\n :date (seconds-to-time created_utc)\n :text body_html\n :raw_text body\n :score (or score 1)\n :parent_id parent-id\n :children children-comments))))))\n\n;; Parse a list of subreddits converted from json format (with `json-read')\n(defun nnreddit-parse-subreddit-list (data)\n (let ((kind (assoc-default 'kind data)))\n (assert (equal \"Listing\" kind))\n (let ((children (assoc-default 'children (assoc-default 'data data))))\n (mapcar #'nnreddit-parse-subreddit-description children))))\n\n;; Parse a subreddit listing converted from json format (with `json-read')\n(defun nnreddit-parse-subreddit (data)\n (let ((kind (assoc-default 'kind data)))\n (assert (equal \"Listing\" kind))\n (let ((children (assoc-default 'children (assoc-default 'data data))))\n (mapcar #'nnreddit-parse-link children))))\n\n;; Parse a link+comments page converted from json format (with `json-read')\n(defun nnreddit-parse-comments (data &optional parent-id sort-children)\n (assert (and (arrayp data))\n (>= (length data) 2))\n (let* ((link (assoc-default 'data (aref data 0)))\n (comments (assoc-default 'data (aref data 1)))\n (children (assoc-default 'children comments))\n (comments\n (remove nil\n (mapcar\n (lambda (data)\n (nnreddit-parse-comment data parent-id sort-children))\n children))))\n (if sort-children\n (sort comments 'nnreddit-sort-by-score)\n comments)))\n\n(defun nnreddit-make-date-header (date)\n (let ((system-time-locale \"C\"))\n (format-time-string \"%a, %d %h %Y %T %z (%Z)\" date)))\n\n(defun nnreddit-make-message-id (reddit-id)\n (format \"<%s@reddit.com>\" reddit-id))\n\n;; (defun nnreddit-id-to-number (reddit-id)\n;; \"Convert a Reddit ID (6 alphanumeric characters) to an integer.\"\n;; (car (read-from-string (concat \"#36r\" reddit-id))))\n\n;; ;; FIXME: does not give useful results on HTML content\n;; (defun nnreddit-count-lines (str)\n;; (let ((start 0) (n 0))\n;; (while (string-match \"\\n\" str start)\n;; (incf n)\n;; (setq start (match-end 0)))\n;; n))\n\n(defun nnreddit-make-header (elt id)\n (let* ((reddit-id (plist-get elt :id))\n (title (plist-get elt :title))\n (clean-title (and title (nnreddit-sanitize-string title)))\n (clean-author (nnreddit-sanitize-string (plist-get elt :author)))\n (date-str (nnreddit-make-date-header (plist-get elt :date)))\n (message-id (nnreddit-make-message-id reddit-id))\n (text (plist-get elt :text))\n (score (plist-get elt :score))\n (num_comments (plist-get elt :num_comments)))\n (make-full-mail-header\n id\n clean-title\n clean-author\n date-str\n message-id\n nil ; no references\n (and text (string-bytes text))\n nil ;; (and text (nnreddit-count-lines text))\n nil ; no cross references\n ;; Extra headers\n (append `((X-Reddit-ID . ,reddit-id))\n (if (integerp score)\n `((X-Reddit-Score . ,(number-to-string score))))\n (if (integerp num_comments)\n `((X-Reddit-Comments . ,(number-to-string num_comments))))))))\n\n(defun nnreddit-flatten-comments (comments)\n \"Turn a comment tree into a comment list, with :children fields\nset to nil.\"\n (let (result)\n (dolist (c comments)\n (let ((children (plist-get c :children)))\n (push (plist-put (copy-tree c) :children nil) result)\n (if (car children)\n (setq result\n (append result\n (nnreddit-flatten-comments children))))))\n (nreverse result)))\n\n(defun nnreddit-elide-subject (subject width)\n (if (numberp width)\n (truncate-string-to-width\n subject\n width\n nil nil t)\n subject))\n\n(defun nnreddit-alter-header (header data type)\n (let ((header (copy-tree header t)))\n (cond\n ((eq type 'link)\n (mail-header-set-subject\n header\n (concat\n (if (stringp nnreddit-num-comments-in-subject)\n (format nnreddit-num-comments-in-subject\n (plist-get data :num_comments)))\n (nnreddit-elide-subject\n (mail-header-subject header)\n nnreddit-elide-link-subjects))))\n ((eq type 'comment)\n (if nnreddit-subjects-from-body\n (mail-header-set-subject\n header\n (let* ((raw-text (plist-get data :raw_text))\n (decoded (and raw-text\n (nnreddit-decode-entities-string\n (nnreddit-sanitize-string\n raw-text)))))\n (nnreddit-elide-subject decoded nnreddit-elide-comment-subjects))))))\n header))\n\n(defun nnreddit-get-subreddit-articles ()\n (gethash nnreddit-subreddit nnreddit-data-by-id-by-subreddit))\n\n(defun nnreddit-get-subreddit-comments ()\n (gethash nnreddit-subreddit nnreddit-comments-by-reddit-ids-by-subreddit))\n\n(defun nnreddit-get-subreddit-article-ids (&optional not-root)\n (let (ids)\n (maphash (lambda (id value)\n (if (and (eq (caddr value) 'link)\n ;; Exclude root articles when requested (root\n ;; articles are single 'link' articles that\n ;; serve as root of the group when the group is\n ;; actually a single thread)\n (or (not not-root) (not (cadddr value))))\n (push id ids)))\n (nnreddit-get-subreddit-articles))\n (nreverse ids)))\n\n(defun nnreddit-retrieve-headers (articles &optional group server fetch-old)\n (nnreddit-possibly-change-group group)\n (with-current-buffer nntp-server-buffer\n (erase-buffer)\n (dolist (id articles)\n (let ((value (gethash id (nnreddit-get-subreddit-articles))))\n (when value\n (let ((header (car value))\n (data (cadr value))\n (type (caddr value)))\n (nnheader-insert-nov\n (nnreddit-alter-header header data type)))))))\n 'nov)\n\n(defun nnreddit-treat-quotes ()\n \"Convert the leading spaces from

HTML tags to\nproper citation marks.\"\n (gnus-with-article-buffer\n (article-goto-body)\n ;; ;; Unsplit URLs\n ;; (save-excursion\n ;; (while (re-search-forward\n ;; \"\\\\(\\\\(https?\\\\|ftp\\\\):\/\/\\\\S-+\\\\) *\\n *\\\\(\\\\S-+\\\\)\" nil t)\n ;; (replace-match \"\\\\1\\\\3\" t)))\n ;;\n ;; Iterate over all lines that look like \n ;; FIXME: seems to match
  • too...\n (while (re-search-forward \"^ +\" nil t)\n (beginning-of-line)\n ;; Don't add citation marks to the attribution line\n (when (re-search-forward \"^\\\\( +\\\\).*wrote:$\" nil t)\n (delete-region (match-beginning 1) (match-end 1))\n (forward-line)\n ;; Delete any blank line immediately following the\n ;; attribution line\n (if (looking-at \"^ *$\")\n (delete-region (point) (1+ (line-end-position)))))\n ;; Replace leading spaces with citation marks\n (while (re-search-forward \"^ +\" (line-end-position) t)\n (replace-match \"> \" t)\n (forward-line))\n ;; Delete any trailing blank line after the citation block\n (backward-char)\n (if (looking-back \"> \")\n (delete-region (line-beginning-position) (point))))))\n\n(defun nnreddit-request-article (id &optional group server buffer)\n (nnreddit-possibly-change-group group)\n (with-current-buffer (or buffer nntp-server-buffer)\n (erase-buffer)\n (let ((value (gethash id (nnreddit-get-subreddit-articles))))\n (when value\n (let ((header (car value))\n (data (cadr value))\n (type (caddr value)))\n\n (let ((nnreddit-num-comments-in-subject nil))\n (setq header (nnreddit-alter-header header data type)))\n\n ;; (nnheader-insert-header header)\n (insert\n \"From: \" (or (mail-header-from header) \"(nobody)\") \"\\n\"\n (if (or nnreddit-always-show-subject\n (not nnreddit-subjects-from-body))\n (concat \"Subject: \" (or (mail-header-subject header) \"(none)\") \"\\n\")\n \"\")\n \"Date: \" (or (mail-header-date header) \"\") \"\\n\"\n \"Message-ID: \" (or (mail-header-id header) (nnmail-message-id)) \"\\n\"\n \"References: \" (or (mail-header-references header) \"\") \"\\n\"\n \"Content-Type: text\/html; charset=utf-8\" \"\\n\"\n (let ((score (plist-get data :score)))\n (if (and nnreddit-insert-score-header\n (numberp score)\n (not (eq score 1)) ; default value for unscored posts\n )\n (format \"Score: %d\\n\" score)\n \"\"))\n \"\\n\")\n\n (let ((text (plist-get data :text)))\n (when text\n (unless (string-match-p \"<blockquote>\" text)\n ;; If there is not already a citation block in the text,\n ;; quote the entire parent comment.\n ;; Can be paired with `nnreddit-treat-quotes' for\n ;; a better rendering of citations.\n (let* ((parent-id (plist-get data :parent_id))\n (parent (and parent-id\n (or (gethash parent-id nnreddit-links-by-reddit-ids)\n (gethash parent-id (nnreddit-get-subreddit-comments)))))\n (parent (and parent (cadr parent)))\n (parent-text (and parent (plist-get parent :text))))\n (when (and parent parent-text)\n (insert \"
    \"\n (nnreddit-sanitize-string\n (plist-get parent :author)) \" wrote:\"\n ;; Insert the parent comment, removing the image\n ;; preview if needed\n (replace-regexp-in-string\n \"]*>\\\\(?:\\\\)*\" \"\"\n parent-text)\n \"<\/blockquote>\\n\\n\"))))\n (goto-char (point-max))\n\n (insert text)\n (mm-url-decode-entities-nbsp)))\n\n ;; Return value, as per Gnus documentation\n (cons nnreddit-subreddit id))))))\n\n(defmacro nnreddit-generate-comments (comments parent-link n)\n `(let (comment-ids)\n (dolist (c ,comments)\n ;; Only create a new article for this comment if one does\n ;; not already exist in the cache\n (let* ((comment-reddit-id (plist-get c :id))\n (value (gethash comment-reddit-id\n (nnreddit-get-subreddit-comments))))\n (if value\n (push (car value) comment-ids)\n (let ((header (nnreddit-make-header c (incf ,n)))\n (parent-id (or (plist-get c :parent_id)\n (plist-get ,parent-link :id))))\n ;; FIXME: do this directly in `nnreddit-make-header'??\n (mail-header-set-references\n header\n (nnreddit-make-message-id parent-id))\n ;; FIXME: do this directly in `nnreddit-make-header'??\n (mail-header-set-subject\n header\n (plist-get ,parent-link :title))\n (push ,n comment-ids)\n (puthash ,n (list header c 'comment) (nnreddit-get-subreddit-articles))\n (puthash comment-reddit-id (list ,n c) (nnreddit-get-subreddit-comments))))))\n comment-ids))\n\n(defun nnreddit-insert-comments (id)\n (let ((value (gethash id (nnreddit-get-subreddit-articles))))\n (when value\n (let* ((link (cadr value))\n (link-reddit-id (plist-get link :id))\n (comments\n (or\n ;; Don't fetch comments again if they are cached\n ;; TODO: add some way to force re-fetching comments\n (gethash link-reddit-id nnreddit-fetched-comment-pages)\n ;; Or fetch the comment page if we have to\n (let* ((json-data\n (nnreddit-retrieve-comments-json\n nnreddit-subreddit\n link-reddit-id))\n (comments\n (nnreddit-flatten-comments\n (nnreddit-parse-comments json-data link-reddit-id t))))\n (puthash link-reddit-id comments nnreddit-fetched-comment-pages))))\n ;; Make sure to always create new article IDs\n (n (hash-table-count (nnreddit-get-subreddit-articles)))\n ;; Generate comments, fill in hash tables, and return\n ;; article IDs of the generated comments\n (comment-ids\n (nnreddit-generate-comments comments link n)))\n (let ((new-limit (number-sequence 1 n)))\n (gnus-summary-insert-articles comment-ids)\n (gnus-summary-limit new-limit)\n ;; `gnus-summary-limit' seems to auto-expand all other threads,\n ;; so we close them and re-expand the current thread\n (save-excursion\n (gnus-summary-hide-all-threads)\n (gnus-summary-goto-subject id)\n (gnus-summary-show-thread)))))))\n\n(defun nnreddit-should-fetch-thread (article)\n \"Check if the current article is a 'link' article, and is not\nthe \\\"root article\\\" of the group.\"\n (member article (nnreddit-get-subreddit-article-ids t)))\n\n(defun nnreddit-expand-thread (&optional article)\n (let ((article (or article (gnus-summary-article-number))))\n (when (and (nnreddit-is-nnreddit)\n (nnreddit-should-fetch-thread article))\n (nnreddit-insert-comments article))))\n\n(defun nnreddit-request-group (group &optional server dont-check info)\n (nnreddit-possibly-change-group group)\n (unless dont-check\n (cond\n ((not nnreddit-subreddit)\n (nnheader-report 'nnreddit \"No subreddit selected\"))\n (t\n (let ((json-data\n (nnreddit-retrieve-subreddit-json nnreddit-subreddit))\n (n 0))\n (cond\n ((arrayp json-data)\n ;; The requested group is actually a Reddit thread\n (let* ((link (nnreddit-parse-link\n (aref\n (assoc-default 'children\n (assoc-default 'data (aref json-data 0))) 0)))\n (id (plist-get link :id))\n (comments (nnreddit-flatten-comments\n (nnreddit-parse-comments json-data id t)))\n (header (nnreddit-make-header link (incf n))))\n ;; Create one \"link\" article, marked as a special \"root article\"\n ;; (4th parameter in the hash table)\n (puthash n (list header link 'link t) (nnreddit-get-subreddit-articles))\n (puthash id (list n link) nnreddit-links-by-reddit-ids)\n ;; Then generate comments and fill in hash tables\n (nnreddit-generate-comments comments link n)))\n (t\n ;; The requested group is a subreddit\n (let ((links (nnreddit-parse-subreddit json-data)))\n (dolist (l links)\n (let ((id (plist-get l :id))\n (header (nnreddit-make-header l (incf n))))\n (puthash n (list header l 'link) (nnreddit-get-subreddit-articles))\n (puthash id (list n l) nnreddit-links-by-reddit-ids))))))\n (nnheader-insert \"211 %d %d %d %s\\n\" n 1 n group)))))\n t)\n\n(defun nnreddit-build-subreddit-list ()\n (unless nnreddit-subreddits-hashtb ; only fetch the subreddit list once\n (setq nnreddit-subreddits-hashtb (make-hash-table :size 128))\n (let* ((json-data (nnreddit-retrieve-subreddit-list-json))\n (subreddits (nnreddit-parse-subreddit-list json-data)))\n (dolist (s subreddits)\n (let* ((name (plist-get s :name))\n (clean-name (downcase (nnreddit-sanitize-string name))))\n (puthash clean-name s nnreddit-subreddits-hashtb))))))\n\n(defun nnreddit-request-list (&optional server)\n (nnreddit-possibly-change-group group)\n (with-current-buffer nntp-server-buffer\n (erase-buffer)\n (nnreddit-build-subreddit-list)\n (maphash (lambda (name s)\n ;; TODO: correct message count?\n (insert (format \"%s %d 1 n\\n\" name nnreddit-link-count)))\n nnreddit-subreddits-hashtb))\n t)\n\n(defun nnreddit-request-list-newsgroups (&optional server)\n (nnreddit-possibly-change-group group)\n (with-current-buffer nntp-server-buffer\n (erase-buffer)\n (nnreddit-build-subreddit-list)\n (maphash (lambda (name s)\n (insert (format \"%s %s\\n\"\n name\n (nnreddit-decode-entities-string\n (nnreddit-sanitize-string\n (plist-get s :description))))))\n nnreddit-subreddits-hashtb))\n t)\n\n(defun nnreddit-request-newgroups (date &optional server)\n (nnheader-report 'nnreddit \"NEWSGROUPS is not implemented.\"))\n\n(defun nnreddit-request-type (group &optional article)\n 'unknown)\n\n(defun nnreddit-close-group (group &optional server)\n (nnreddit-possibly-change-group group)\n t)\n\n(defun nnreddit-open-server (server &optional defs)\n t)\n\n(defun nnreddit-possibly-change-group (&optional group)\n (unless nnreddit-data-by-id-by-subreddit\n (setq nnreddit-data-by-id-by-subreddit (make-hash-table :size 128 :test 'equal)))\n (unless nnreddit-fetched-comment-pages\n (setq nnreddit-fetched-comment-pages (make-hash-table :size 1024 :test 'equal)))\n (unless nnreddit-links-by-reddit-ids\n (setq nnreddit-links-by-reddit-ids (make-hash-table :size 1024 :test 'equal)))\n (unless nnreddit-comments-by-reddit-ids-by-subreddit\n (setq nnreddit-comments-by-reddit-ids-by-subreddit (make-hash-table :size 128 :test 'equal)))\n (when group\n (setq nnreddit-subreddit\n ;; Remove trailing slashes\n (replace-regexp-in-string \"\/$\" \"\" group))\n (unless (gethash nnreddit-subreddit\n nnreddit-data-by-id-by-subreddit)\n (puthash nnreddit-subreddit\n (make-hash-table :size 1024)\n nnreddit-data-by-id-by-subreddit))\n (unless (gethash nnreddit-subreddit\n nnreddit-comments-by-reddit-ids-by-subreddit)\n (puthash nnreddit-subreddit\n (make-hash-table :size 1024)\n nnreddit-comments-by-reddit-ids-by-subreddit))))\n\n(gnus-declare-backend \"nnreddit\" 'none)\n\n(defun nnreddit-subscribe-to-thread (group)\n \"Subscribe to the thread or sub-thread at point.\"\n (interactive\n (list\n (let* ((article (gnus-summary-article-number))\n (value (gethash article\n (nnreddit-get-subreddit-articles)))\n (data (cadr value))\n (type (caddr value))\n (reddit-id (plist-get data :id))\n (subreddit\n (replace-regexp-in-string \"\/.*$\" \"\" nnreddit-subreddit))\n (url (concat\n (symbol-name\n (car (gnus-find-method-for-group gnus-newsgroup-name)))\n \":\"\n ;; FIXME: create new constants for these format strings\n (cond\n ((eq type 'link)\n (format \"%s\/comments\/%s\" subreddit reddit-id))\n ((eq type 'comment)\n (let* ((root-article\n (let ((parent article) a)\n (while parent\n (setq a parent)\n (setq parent (gnus-summary-article-parent parent)))\n a))\n (root-reddit-id\n (plist-get\n (cadr\n (gethash root-article\n (nnreddit-get-subreddit-articles))) :id)))\n (format \"%s\/comments\/%s\/comments\/%s\"\n subreddit\n root-reddit-id\n reddit-id)))))))\n (gnus-group-completing-read nil nil nil url))))\n (gnus-group-unsubscribe-group group))\n\n;; ======================================================\n;; Add a few hooks to automatically expand comments, etc.\n\n(defun nnreddit-is-nnreddit ()\n (eq 'nnreddit (car (gnus-find-method-for-group gnus-newsgroup-name))))\n\n;; If `nnreddit-auto-open-threads' is t, automatically insert comments\n;; when a 'post' article is selected\n(add-hook 'gnus-select-article-hook\n '(lambda ()\n (when (and (nnreddit-is-nnreddit)\n nnreddit-auto-open-threads\n (nnreddit-should-fetch-thread article))\n (nnreddit-expand-thread article))))\n\n;; This function replaces the keybinding for `gnus-summary-show-thread'.\n;; If `nnreddit-auto-open-threads' is nil, only insert comments when\n;; this keybinding is pressed.\n(defun nnreddit-show-thread ()\n (interactive)\n (unless nnreddit-auto-open-threads\n (nnreddit-expand-thread))\n (call-interactively 'gnus-summary-show-thread))\n\n(add-hook 'gnus-summary-mode-hook\n (lambda ()\n (when (nnreddit-is-nnreddit)\n ;; We know that references are correct\n (set (make-local-variable 'gnus-summary-thread-gathering-function)\n 'gnus-gather-threads-by-references)\n ;; Prevent threads from jumping around when comments with\n ;; possibly more recent dates are dynamically inserted in\n ;; the summary buffer\n (set (make-local-variable 'gnus-thread-sort-functions)\n 'gnus-thread-sort-by-number)\n ;; Intercept the keybinding for `gnus-summary-show-thread'\n ;; to insert comments if `nnreddit-auto-open-threads'\n ;; is nil\n (substitute-key-definition 'gnus-summary-show-thread\n 'nnreddit-show-thread\n (current-local-map)))))\n(add-hook 'gnus-part-display-hook\n (lambda ()\n (when (nnreddit-is-nnreddit)\n ;; Treat citations\n (nnreddit-treat-quotes)\n ;; Also treat weird characters\n (article-translate-strings '((25 \"'\") (20 \"\u2014\"))))))\n\n(add-hook 'gnus-article-prepare-hook\n (lambda ()\n (when (nnreddit-is-nnreddit)\n ;; Display image previews on \"link\" articles\n (when nnreddit-show-images\n (gnus-article-show-images))\n ;; Show the Score: header\n (when nnreddit-insert-score-header\n (if (not (string-match-p \"\\\\\\\\|^Score:\" gnus-visible-headers))\n (set (make-local-variable 'gnus-visible-headers)\n (concat gnus-visible-headers \"\\\\|^Score:\")))))))\n\n(provide 'nnreddit)\n\n;;; nnreddit.el ends here\n","avg_line_length":39.7463414634,"max_line_length":97,"alphanum_fraction":0.5755706922} {"size":8494,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":";; Copyright (C) 2010-2011, 2013-2014, 2016-2020 Free Software Foundation, Inc\n\n;; Author: Rocky Bernstein \n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n; Should realgud:file-loc-from-line be here or elsewhere?\n(require 'load-relative)\n(require 'seq) ;; for seq-find seq-filter\n(require-relative-list '(\"helper\" \"loc\") \"realgud-\")\n(require-relative-list '(\"buffer\/command\") \"realgud-buffer-\")\n\n(declare-function realgud:strip 'realgud)\n(declare-function realgud-loc-goto 'realgud-loc)\n(declare-function realgud-get-cmdbuf 'realgud-buffer-helper)\n(declare-function buffer-killed? 'helper)\n(declare-function compilation-find-file 'compile)\n(declare-function realgud-cmdbuf-info-ignore-re-file-list 'realgud-buffer-command)\n(declare-function realgud-cmdbuf-info-source-path= 'realgud-buffer-command)\n(declare-function realgud-cmdbuf-mutex 'realgud-buffer-command)\n(declare-function realgud-cmdbuf-filename-remap-alist 'realgud-buffer-command)\n(declare-function realgud-cmdbuf-filename-remap-alist= 'realgud-buffer-command)\n(declare-function realgud-cmdbuf-mutex 'realgud-buffer-command)\n\n(defcustom realgud-file-find-function 'compilation-find-file\n;;(defcustom realgud-file-find-function 'compilation-find-file\n \"Function to call when we can't easily find file\"\n :type 'function\n :group 'realgud)\n\n(defun realgud--file-matching-suffix(paths suffix)\n (seq-filter (lambda (x) (string-suffix-p suffix x)) paths))\n\n(defun realgud:file-line-count(filename)\n \"Return the number of lines in file FILENAME, or nil FILENAME can't be\nfound\"\n (if (file-exists-p filename)\n (let ((file-buffer (find-file-noselect filename)))\n\t(with-current-buffer-safe file-buffer\n\t (line-number-at-pos (point-max))))\n nil))\n\n(defun realgud:file-column-from-string(filename line-number source-text\n\t\t\t\t\t\t&optional no-strip-blanks)\n \"Return the column of the first column position of SOURCE-TEXT\nat LINE-NUMBER or nil if it is not there\"\n (condition-case nil\n (when (and source-text (file-exists-p filename))\n (let ((file-buffer (find-file-noselect filename)))\n (with-current-buffer-safe file-buffer\n (save-excursion\n (goto-char (point-min))\n (forward-line (1- line-number))\n (unless no-strip-blanks\n (setq source-text (realgud:strip source-text)))\n (when (search-forward source-text (point-at-eol))\n (goto-char (match-beginning 0))\n (current-column))))))\n (error nil)))\n\n(defun realgud:file-ignore(filename ignore-re-file-list)\n (seq-find '(lambda (file-re) (string-match file-re filename)) ignore-re-file-list))\n\n;; FIXME: should allow column number to be passed in.\n(defun realgud:file-loc-from-line(filename line-number\n\t\t\t\t\t &optional cmd-marker source-text bp-num\n\t\t\t\t\t find-file-fn directory)\n \"Return a realgud-loc for FILENAME and LINE-NUMBER and the\nother optional position information.\n\nCMD-MARKER and BP-NUM get stored in the realgud-loc\nobject. FIND-FILE-FN is a function which do special things to\ntransform filename so it can be found. This could include\nsearching classpaths (in Java), stripping leading and trailing\nblanks, or deliberately ignoring 'pseudo-file patterns like (eval\n1) of Perl and of Python.\n\nIf we're unable find the source code we return a string describing the\nproblem as best as we can determine.\"\n\n (let* ((cmdbuf (or (realgud-get-cmdbuf) cmd-marker))\n\t (ignore-re-file-list (realgud-cmdbuf-ignore-re-file-list cmdbuf))\n\t (filename-remap-alist (realgud-cmdbuf-filename-remap-alist cmdbuf))\n\t (remapped-filename\n\t (assoc filename filename-remap-alist))\n\t (mutex (realgud-cmdbuf-mutex cmdbuf))\n\t (matching-file-list)\n\t (buffer-files))\n\n ;;(with-mutex\n ;; mutex\n (when remapped-filename\n (if (file-readable-p (cdr remapped-filename))\n\t (setq filename (cdr remapped-filename))\n\t ;; else remove from map since no find\n\t (realgud-cmdbuf-filename-remap-alist=\n\t (delq (assoc remapped-filename filename-remap-alist)\n\t\t\t\t\t filename-remap-alist))))\n\n (unless (and filename (file-readable-p filename))\n\n (with-current-buffer cmdbuf\n\t (cond\n\t ;; Is file already listed for ignore?\n\t ((realgud:file-ignore filename ignore-re-file-list)\n\t (message \"tracking ignored for %s\" filename))\n\n\t ;; If we can find the filename, e.g. \"src\/code.c\" as a suffix of file in\n\t ;; the list of buffers seen, use that\n\t ((and\n\t (setq buffer-files\n\t\t (with-current-buffer (marker-buffer cmd-marker)\n\t\t (mapcar (lambda (buf) (buffer-file-name buf))\n\t\t\t (realgud-cmdbuf-info-srcbuf-list realgud-cmdbuf-info))))\n\t (setq matching-file-list (realgud--file-matching-suffix buffer-files filename))\n\t (car matching-file-list)))\n\n\t ;; Do we want to blacklist this?\n\t ((y-or-n-p (format \"Unable to locate %s\\nBlacklist it for location tracking?\" filename))\n\t ;; FIXME: there has to be a simpler way to set ignore-file-list\n\t (progn\n\t (push filename ignore-re-file-list)\n\t (realgud-cmdbuf-info-ignore-re-file-list= ignore-re-file-list)\n\t (setq filename nil)\n\t ))\n\n\t ;; Do we have a custom find-file function?\n\t (find-file-fn\n\t (setq filename (funcall find-file-fn cmd-marker filename directory)))\n\n\t (t\n\t (let ((found-file (funcall realgud-file-find-function (point-marker) filename directory)))\n\t (if found-file\n\t\t (progn\n\t\t (setq remapped-filename (buffer-file-name found-file))\n\t\t (when (and remapped-filename (file-exists-p remapped-filename))\n\t\t (realgud-cmdbuf-filename-remap-alist=\n\t\t (cons\n\t\t (cons filename remapped-filename)\n\t\t filename-remap-alist)\n\t\t cmdbuf)\n\t\t (setq filename remapped-filename)\n\t\t ))\n\t ;; else\n\t (setq filename nil)\n\t )))\n\t ))))\n ;;)\n\n (if filename\n (if (file-readable-p filename)\n\t (if (integerp line-number)\n\t (if (> line-number 0)\n\t\t (let ((line-count))\n\t\t (if (setq line-count (realgud:file-line-count filename))\n\t\t\t(if (> line-count line-number)\n\t\t\t (let* ((column-number\n\t\t\t\t (realgud:file-column-from-string filename\n\t\t\t\t\t\t\t\t line-number\n\t\t\t\t\t\t\t\t source-text))\n\t\t\t\t (source-buffer (find-file-noselect filename))\n\t\t\t\t (source-mark))\n\n\t\t\t ;; Set this filename as the last one seen in cmdbuf\n\t\t\t (realgud-cmdbuf-info-source-path= filename)\n\n\t\t\t ;; And you thought we'd never get around to\n\t\t\t ;; doing something other than validation?\n\t\t\t (with-current-buffer source-buffer\n\t\t\t\t(goto-char (point-min))\n\t\t\t\t;; FIXME also allow column number and byte offset\n\t\t\t\t(forward-line (1- line-number))\n\t\t\t\t(make-realgud-loc\n\t\t\t\t :num bp-num\n\t\t\t\t :cmd-marker cmd-marker\n\t\t\t\t :filename filename\n\t\t\t\t :line-number line-number\n\t\t\t\t :column-number column-number\n\t\t\t\t :source-text source-text\n\t\t\t\t :marker (point-marker)\n\t\t\t\t )\n\t\t\t\t))\n\t\t\t ;; else\n\t\t\t (format \"File %s has only %d lines. (Line %d requested.)\"\n\t\t\t\t filename line-count line-number))\n\t\t (format \"Problem getting line count for file `%s'\" filename)))\n\t\t(format \"line number %s should be greater than 0\" line-number))\n\t (format \"%s is not an integer\" line-number))\n\t;; else\n\t(if filename\n\t (format \"File named `%s' not readable\" filename))))\n )\n\n;; FIXME: should allow column number to be passed in.\n(defun realgud:file-remove-ignore(path-to-stop-ignoring)\n \"Remove `path-to-stop-ignoring' from the list of paths which\nare ignored in debugger location tracking. You might do this if you accidentllay\nadded a a path for ignoring by mistake.\"\n (interactive\n (list (completing-read \"File name to stop ignoring: \"\n\t\t (realgud-cmdbuf-ignore-re-file-list (current-buffer))\n\t\t nil t)))\n (when (member path-to-stop-ignoring (realgud-cmdbuf-ignore-re-file-list (current-buffer)))\n (realgud-cmdbuf-info-ignore-re-file-list=\n (delete path-to-stop-ignoring (realgud-cmdbuf-ignore-re-file-list (current-buffer)))))\n )\n\n\n(provide-me \"realgud-\")\n","avg_line_length":38.9633027523,"max_line_length":94,"alphanum_fraction":0.6790675771} {"size":1276,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; init-plantuml.el --- Provides plantuml-mode -*- lexical-binding: t -*-\n;;; Commentary:\n;; plantuml like bindings\n;;; Code:\n\n(unless (package-installed-p 'plantuml-mode)\n (package-install 'plantuml-mode))\n\n(setq plantuml-path \"~\/.emacs.d\/plantuml.jar\")\n\n(when (file-exists-p plantuml-path)\n (setq plantuml-jar-path plantuml-path)\n (setq plantuml-default-exec-mode 'jar))\n\n;; Enable plantuml-mode for PlantUML files\n(add-to-list 'auto-mode-alist '(\"\\\\.plantuml\\\\'\" . plantuml-mode))\n\n(add-to-list\n 'org-src-lang-modes '(\"plantuml\" . plantuml))\n\n(setq plantuml_helper_path \"~\/.emacs.d\/site-lisp\/plantuml_helpers.el\")\n\n(setq plantuml-dw-cmd\n (concat\n \"curl \"\n \" -LO \"\n \"https:\/\/gist.githubusercontent.com\/\"\n \"Randy1Burrell\/7ed8899da46f2c73564a6103e419aa32\/\"\n \"raw\/d1bf8c898af7ea1a0f294087059dc76a6521f4d2\/plantuml_helpers.el\"))\n\n(when (not (file-exists-p plantuml_helper_path))\n (shell-command-to-string plantuml-dw-cmd)\n (unless (file-exists-p plantuml_helper_path)\n (shell-command-to-string\n \"mv plantuml_helpers.el ~\/.emacs.d\/site-lisp\/\"))\n (when (file-exists-p plantuml_helper_path)\n (add-to-list 'load-path plantuml_helper_path)\n (require 'plantuml_helpers)))\n\n(provide 'init-plantuml)\n;;; init-plantuml.el ends here\n","avg_line_length":30.380952381,"max_line_length":75,"alphanum_fraction":0.7045454545} {"size":44455,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; magit.el --- A Git porcelain inside Emacs -*- lexical-binding: t; coding: utf-8 -*-\n\n;; Copyright (C) 2008-2017 The Magit Project Contributors\n;;\n;; You should have received a copy of the AUTHORS.md file which\n;; lists all contributors. If not, see http:\/\/magit.vc\/authors.\n\n;; Author: Marius Vollmer \n;; Maintainer: Jonas Bernoulli \n;;\tKyle Meyer \n;;\tNoam Postavsky \n;; Former-Maintainers:\n;;\tNicolas Dudebout \n;;\tPeter J. Weisberg \n;;\tPhil Jackson \n;;\tR\u00e9mi Vanicat \n;;\tYann Hodique \n\n;; Package-Requires: ((emacs \"24.4\") (async \"20170219.942\") (dash \"20170207.2056\") (with-editor \"20170111.609\") (git-commit \"20170214.347\") (magit-popup \"20170214.347\"))\n;; Keywords: git tools vc\n;; Homepage: https:\/\/github.com\/magit\/magit\n\n;; Magit requires at least GNU Emacs 24.4 and Git 1.9.4.\n\n;; Magit is free software; you can redistribute it and\/or modify it\n;; under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n;;\n;; Magit is distributed in the hope that it will be useful, but WITHOUT\n;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public\n;; License for more details.\n;;\n;; You should have received a copy of the GNU General Public License\n;; along with Magit. If not, see http:\/\/www.gnu.org\/licenses.\n\n;;; Commentary:\n\n;; Magit is an interface to the version control system Git,\n;; implemented as an Emacs package. Magit aspires to be a complete\n;; Git porcelain. While we cannot (yet) claim, that Magit wraps and\n;; improves upon each and every Git command, it is complete enough to\n;; allow even experienced Git users to perform almost all of their\n;; daily version control tasks directly from within Emacs. While many\n;; fine Git clients exist, only Magit and Git itself deserve to be\n;; called porcelains.\n\n;;; Code:\n\n(require 'cl-lib)\n(require 'dash)\n\n(require 'with-editor)\n(require 'git-commit)\n(require 'magit-core)\n(require 'magit-diff)\n(require 'magit-apply)\n(require 'magit-log)\n(require 'magit-repos)\n\n(require 'format-spec)\n(require 'package nil t) ; used in `magit-version'\n\n(eval-when-compile (require 'dired-x))\n(declare-function dired-jump 'dired-x)\n(eval-when-compile (require 'eshell))\n(declare-function eshell-parse-arguments 'eshell)\n(eval-when-compile (require 'message))\n\n(defconst magit--minimal-git \"1.9.4\")\n(defconst magit--minimal-emacs \"24.4\")\n\n;;; Faces\n\n(defface magit-header-line\n '((t :inherit magit-section-heading))\n \"Face for the `header-line'.\"\n :group 'magit-faces)\n\n(defface magit-dimmed\n '((((class color) (background light)) :foreground \"grey50\")\n (((class color) (background dark)) :foreground \"grey50\"))\n \"Face for text that shouldn't stand out.\"\n :group 'magit-faces)\n\n(defface magit-hash\n '((((class color) (background light)) :foreground \"grey60\")\n (((class color) (background dark)) :foreground \"grey40\"))\n \"Face for the sha1 part of the log output.\"\n :group 'magit-faces)\n\n(defface magit-tag\n '((((class color) (background light)) :foreground \"Goldenrod4\")\n (((class color) (background dark)) :foreground \"LightGoldenrod2\"))\n \"Face for tag labels shown in log buffer.\"\n :group 'magit-faces)\n\n(defface magit-branch-remote\n '((((class color) (background light)) :foreground \"DarkOliveGreen4\")\n (((class color) (background dark)) :foreground \"DarkSeaGreen2\"))\n \"Face for remote branch head labels shown in log buffer.\"\n :group 'magit-faces)\n\n(defface magit-branch-local\n '((((class color) (background light)) :foreground \"SkyBlue4\")\n (((class color) (background dark)) :foreground \"LightSkyBlue1\"))\n \"Face for local branches.\"\n :group 'magit-faces)\n\n(defface magit-branch-current\n '((((class color) (background light)) :inherit magit-branch-local :box t)\n (((class color) (background dark)) :inherit magit-branch-local :box t))\n \"Face for current branch.\"\n :group 'magit-faces)\n\n(defface magit-head\n '((((class color) (background light)) :inherit magit-branch-local)\n (((class color) (background dark)) :inherit magit-branch-local))\n \"Face for the symbolic ref `HEAD'.\"\n :group 'magit-faces)\n\n(defface magit-refname\n '((((class color) (background light)) :foreground \"grey30\")\n (((class color) (background dark)) :foreground \"grey80\"))\n \"Face for refnames without a dedicated face.\"\n :group 'magit-faces)\n\n(defface magit-refname-stash\n '((t :inherit magit-refname))\n \"Face for wip refnames.\"\n :group 'magit-faces)\n\n(defface magit-refname-wip\n '((t :inherit magit-refname))\n \"Face for wip refnames.\"\n :group 'magit-faces)\n\n(defface magit-keyword\n '((t :inherit font-lock-string-face))\n \"Face for parts of commit messages inside brackets.\"\n :group 'magit-faces)\n\n(defface magit-signature-good\n '((t :foreground \"green\"))\n \"Face for good signatures.\"\n :group 'magit-faces)\n\n(defface magit-signature-bad\n '((t :foreground \"red\" :weight bold))\n \"Face for bad signatures.\"\n :group 'magit-faces)\n\n(defface magit-signature-untrusted\n '((t :foreground \"cyan\"))\n \"Face for good untrusted signatures.\"\n :group 'magit-faces)\n\n(defface magit-signature-expired\n '((t :foreground \"orange\"))\n \"Face for signatures that have expired.\"\n :group 'magit-faces)\n\n(defface magit-signature-expired-key\n '((t :inherit magit-signature-expired))\n \"Face for signatures made by an expired key.\"\n :group 'magit-faces)\n\n(defface magit-signature-revoked\n '((t :foreground \"violet red\"))\n \"Face for signatures made by a revoked key.\"\n :group 'magit-faces)\n\n(defface magit-signature-error\n '((t :foreground \"firebrick3\"))\n \"Face for signatures that cannot be checked (e.g. missing key).\"\n :group 'magit-faces)\n\n(defface magit-cherry-unmatched\n '((t :foreground \"cyan\"))\n \"Face for unmatched cherry commits.\"\n :group 'magit-faces)\n\n(defface magit-cherry-equivalent\n '((t :foreground \"magenta\"))\n \"Face for equivalent cherry commits.\"\n :group 'magit-faces)\n\n(defface magit-filename\n '((t :weight normal))\n \"Face for filenames.\"\n :group 'magit-faces)\n\n;;; Commands\n;;;; Merge\n\n;;;###autoload (autoload 'magit-merge-popup \"magit\" nil t)\n(magit-define-popup magit-merge-popup\n \"Popup console for merge commands.\"\n :man-page \"git-merge\"\n :switches '((?f \"Fast-forward only\" \"--ff-only\")\n (?n \"No fast-forward\" \"--no-ff\")\n (?s \"Squash\" \"--squash\"))\n :options '((?s \"Strategy\" \"--strategy=\"))\n :actions '((?m \"Merge\" magit-merge)\n (?e \"Merge and edit message\" magit-merge-editmsg)\n (?p \"Preview merge\" magit-merge-preview)\n (?n \"Merge but don't commit\" magit-merge-nocommit))\n :sequence-actions '((?m \"Commit merge\" magit-commit)\n (?a \"Abort merge\" magit-merge-abort))\n :sequence-predicate 'magit-merge-state\n :default-action 'magit-merge\n :max-action-columns 2)\n\n;;;###autoload\n(defun magit-merge (rev &optional args nocommit)\n \"Merge commit REV into the current branch; using default message.\n\nUnless there are conflicts or a prefix argument is used create a\nmerge commit using a generic commit message and without letting\nthe user inspect the result. With a prefix argument pretend the\nmerge failed to give the user the opportunity to inspect the\nmerge.\n\n\\(git merge --no-edit|--no-commit [ARGS] REV)\"\n (interactive (list (magit-read-other-branch-or-commit \"Merge\")\n (magit-merge-arguments)\n current-prefix-arg))\n (magit-merge-assert)\n (magit-run-git-async \"merge\" (if nocommit \"--no-commit\" \"--no-edit\") args rev))\n\n;;;###autoload\n(defun magit-merge-editmsg (rev &optional args)\n \"Merge commit REV into the current branch; and edit message.\nPerform the merge and prepare a commit message but let the user\nedit it.\n\\n(git merge --edit --no-ff [ARGS] REV)\"\n (interactive (list (magit-read-other-branch-or-commit \"Merge\")\n (magit-merge-arguments)))\n (magit-merge-assert)\n (cl-pushnew \"--no-ff\" args :test #'equal)\n (apply #'magit-run-git-with-editor \"merge\" \"--edit\"\n (append args (list rev))))\n\n;;;###autoload\n(defun magit-merge-nocommit (rev &optional args)\n \"Merge commit REV into the current branch; pretending it failed.\nPretend the merge failed to give the user the opportunity to\ninspect the merge and change the commit message.\n\\n(git merge --no-commit --no-ff [ARGS] REV)\"\n (interactive (list (magit-read-other-branch-or-commit \"Merge\")\n (magit-merge-arguments)))\n (magit-merge-assert)\n (cl-pushnew \"--no-ff\" args :test #'equal)\n (magit-run-git-async \"merge\" \"--no-commit\" args rev))\n\n;;;###autoload\n(defun magit-merge-preview (rev)\n \"Preview result of merging REV into the current branch.\"\n (interactive (list (magit-read-other-branch-or-commit \"Preview merge\")))\n (magit-mode-setup #'magit-merge-preview-mode rev))\n\n(define-derived-mode magit-merge-preview-mode magit-diff-mode \"Magit Merge\"\n \"Mode for previewing a merge.\"\n :group 'magit-diff\n (hack-dir-local-variables-non-file-buffer))\n\n(defun magit-merge-preview-refresh-buffer (rev)\n (let* ((branch (magit-get-current-branch))\n (head (or branch (magit-rev-verify \"HEAD\"))))\n (setq header-line-format\n (propertize (format \"Preview merge of %s into %s\"\n rev (or branch \"HEAD\"))\n 'face 'magit-header-line))\n (magit-insert-section (diffbuf)\n (magit-git-wash #'magit-diff-wash-diffs\n \"merge-tree\" (magit-git-string \"merge-base\" head rev) head rev))))\n\n;;;###autoload\n(defun magit-merge-abort ()\n \"Abort the current merge operation.\n\\n(git merge --abort)\"\n (interactive)\n (if (file-exists-p (magit-git-dir \"MERGE_HEAD\"))\n (when (magit-confirm 'abort-merge)\n (magit-run-git-async \"merge\" \"--abort\"))\n (user-error \"No merge in progress\")))\n\n(defun magit-checkout-stage (file arg)\n \"During a conflict checkout and stage side, or restore conflict.\"\n (interactive\n (let ((file (magit-completing-read \"Checkout file\"\n (magit-tracked-files) nil nil nil\n 'magit-read-file-hist\n (magit-current-file))))\n (cond ((member file (magit-unmerged-files))\n (list file (magit-checkout-read-stage file)))\n ((yes-or-no-p (format \"Restore conflicts in %s? \" file))\n (list file \"--merge\"))\n (t\n (user-error \"Quit\")))))\n (pcase (cons arg (cddr (car (magit-file-status file))))\n ((or `(\"--ours\" ?D ,_)\n `(\"--theirs\" ,_ ?D))\n (magit-run-git \"rm\" \"--\" file))\n (_ (if (equal arg \"--merge\")\n ;; This fails if the file was deleted on one\n ;; side. And we cannot do anything about it.\n (magit-run-git \"checkout\" \"--merge\" \"--\" file)\n (magit-call-git \"checkout\" arg \"--\" file)\n (magit-run-git \"add\" \"-u\" \"--\" file)))))\n\n(defun magit-merge-state ()\n (file-exists-p (magit-git-dir \"MERGE_HEAD\")))\n\n(defun magit-merge-assert ()\n (or (not (magit-anything-modified-p t))\n (magit-confirm 'merge-dirty\n \"Merging with dirty worktree is risky. Continue\")\n (user-error \"Abort\")))\n\n(defun magit-checkout-read-stage (file)\n (magit-read-char-case (format \"For %s checkout: \" file) t\n (?o \"[o]ur stage\" \"--ours\")\n (?t \"[t]heir stage\" \"--theirs\")\n (?c \"[c]onflict\" \"--merge\")))\n\n(defun magit-insert-merge-log ()\n \"Insert section for the on-going merge.\nDisplay the heads that are being merged.\nIf no merge is in progress, do nothing.\"\n (-when-let (heads (mapcar 'magit-get-shortname\n (magit-file-lines (magit-git-dir \"MERGE_HEAD\"))))\n (magit-insert-section (commit (car heads))\n (magit-insert-heading\n (format \"Merging %s:\" (mapconcat 'identity heads \", \")))\n (magit-insert-log\n (concat (magit-git-string \"merge-base\" \"--octopus\" \"HEAD\" (car heads))\n \"..\" (car heads))\n (let ((args magit-log-section-arguments))\n (unless (member \"--decorate=full\" magit-log-section-arguments)\n (push \"--decorate=full\" args))\n args)))))\n\n;;;; Reset\n\n;;;###autoload (autoload 'magit-reset-popup \"magit\" nil t)\n(magit-define-popup magit-reset-popup\n \"Popup console for reset commands.\"\n :man-page \"git-reset\"\n :actions '((?m \"reset mixed (HEAD and index)\" magit-reset-head)\n (?s \"reset soft (HEAD only)\" magit-reset-soft)\n (?h \"reset hard (HEAD, index, and files)\" magit-reset-hard)\n (?i \"reset index (index only)\" magit-reset-index) nil\n (?f \"reset a file\" magit-file-checkout))\n :max-action-columns 1)\n\n;;;###autoload\n(defun magit-reset-index (commit)\n \"Reset the index to COMMIT.\nKeep the head and working tree as-is, so if COMMIT refers to the\nhead this effectively unstages all changes.\n\\n(git reset COMMIT .)\"\n (interactive (list (magit-read-branch-or-commit \"Reset index to\")))\n (magit-reset-internal nil commit \".\"))\n\n;;;###autoload\n(defun magit-reset (commit &optional hard)\n \"Reset the head and index to COMMIT, but not the working tree.\nWith a prefix argument also reset the working tree.\n\\n(git reset --mixed|--hard COMMIT)\"\n (interactive (list (magit-read-branch-or-commit\n (if current-prefix-arg\n \"Hard reset to\"\n \"Reset head to\"))\n current-prefix-arg))\n (magit-reset-internal (if hard \"--hard\" \"--mixed\") commit))\n\n;;;###autoload\n(defun magit-reset-head (commit)\n \"Reset the head and index to COMMIT, but not the working tree.\n\\n(git reset --mixed COMMIT)\"\n (interactive (list (magit-read-branch-or-commit \"Reset head to\")))\n (magit-reset-internal \"--mixed\" commit))\n\n;;;###autoload\n(defun magit-reset-soft (commit)\n \"Reset the head to COMMIT, but not the index and working tree.\n\\n(git reset --soft REVISION)\"\n (interactive (list (magit-read-branch-or-commit \"Soft reset to\")))\n (magit-reset-internal \"--soft\" commit))\n\n;;;###autoload\n(defun magit-reset-hard (commit)\n \"Reset the head, index, and working tree to COMMIT.\n\\n(git reset --hard REVISION)\"\n (interactive (list (magit-read-branch-or-commit \"Hard reset to\")))\n (magit-reset-internal \"--hard\" commit))\n\n(defun magit-reset-internal (arg commit &optional path)\n (when (and (not (member arg '(\"--hard\" nil)))\n (equal (magit-rev-parse commit)\n (magit-rev-parse \"HEAD~\")))\n (with-temp-buffer\n (magit-git-insert \"show\" \"-s\" \"--format=%B\" \"HEAD\")\n (when git-commit-major-mode\n (funcall git-commit-major-mode))\n (git-commit-setup-font-lock)\n (git-commit-save-message)))\n (let ((cmd (if (and (equal commit \"HEAD\") (not arg)) \"unstage\" \"reset\")))\n (magit-wip-commit-before-change nil (concat \" before \" cmd))\n (magit-run-git \"reset\" arg commit \"--\" path)\n (when (equal cmd \"unstage\")\n (magit-wip-commit-after-apply nil \" after unstage\"))))\n\n;;;; Tag\n\n;;;###autoload (autoload 'magit-tag-popup \"magit\" nil t)\n(magit-define-popup magit-tag-popup\n \"Popup console for tag commands.\"\n :man-page \"git-tag\"\n :switches '((?a \"Annotate\" \"--annotate\")\n (?s \"Sign\" \"--sign\")\n (?f \"Force\" \"--force\"))\n :actions '((?t \"Create\" magit-tag)\n (?k \"Delete\" magit-tag-delete)\n (?p \"Prune\" magit-tag-prune))\n :default-action 'magit-tag)\n\n;;;###autoload\n(defun magit-tag (name rev &optional args)\n \"Create a new tag with the given NAME at REV.\nWith a prefix argument annotate the tag.\n\\n(git tag [--annotate] NAME REV)\"\n (interactive (list (magit-read-tag \"Tag name\")\n (or (and (memq 'magit-tag magit-no-confirm-default)\n (or (magit-branch-or-commit-at-point)\n (magit-get-current-branch)))\n (magit-read-branch-or-commit \"Place tag on\"))\n (let ((args (magit-tag-arguments)))\n (when current-prefix-arg\n (cl-pushnew \"--annotate\" args))\n args)))\n (magit-run-git-with-editor \"tag\" args name rev))\n\n;;;###autoload\n(defun magit-tag-delete (tags)\n \"Delete one or more tags.\nIf the region marks multiple tags (and nothing else), then offer\nto delete those, otherwise prompt for a single tag to be deleted,\ndefaulting to the tag at point.\n\\n(git tag -d TAGS)\"\n (interactive (list (--if-let (magit-region-values 'tag)\n (magit-confirm t nil \"Delete %i tags\" it)\n (magit-read-tag \"Delete tag\" t))))\n (magit-run-git \"tag\" \"-d\" tags))\n\n(defun magit-tag-prune (tags remote-tags remote)\n \"Offer to delete tags missing locally from REMOTE, and vice versa.\"\n (interactive\n (let* ((remote (magit-read-remote \"Prune tags using remote\"))\n (tags (magit-list-tags))\n (rtags (prog2 (message \"Determining remote tags...\")\n (magit-remote-list-tags remote)\n (message \"Determining remote tags...done\")))\n (ltags (-difference tags rtags))\n (rtags (-difference rtags tags)))\n (unless (or ltags rtags)\n (message \"Same tags exist locally and remotely\"))\n (unless (magit-confirm t \"Delete %s locally\"\n \"Delete %i tags locally\" ltags)\n (setq ltags nil))\n (unless (magit-confirm t \"Delete %s from remote\"\n \"Delete %i tags from remote\" rtags)\n (setq rtags nil))\n (list ltags rtags remote)))\n (when tags\n (magit-call-git \"tag\" \"-d\" tags))\n (when remote-tags\n (magit-run-git-async \"push\" remote (--map (concat \":\" it) remote-tags))))\n\n;;;; Dispatch Popup\n\n;;;###autoload (autoload 'magit-dispatch-popup \"magit\" nil t)\n(magit-define-popup magit-dispatch-popup\n \"Popup console for dispatching other popups.\"\n :actions '(\"Popup and dwim commands\"\n (?A \"Cherry-picking\" magit-cherry-pick-popup)\n (?b \"Branching\" magit-branch-popup)\n (?B \"Bisecting\" magit-bisect-popup)\n (?c \"Committing\" magit-commit-popup)\n (?d \"Diffing\" magit-diff-popup)\n (?D \"Change diffs\" magit-diff-refresh-popup)\n (?e \"Ediff dwimming\" magit-ediff-dwim)\n (?E \"Ediffing\" magit-ediff-popup)\n (?f \"Fetching\" magit-fetch-popup)\n (?F \"Pulling\" magit-pull-popup)\n (?l \"Logging\" magit-log-popup)\n (?L \"Change logs\" magit-log-refresh-popup)\n (?m \"Merging\" magit-merge-popup)\n (?M \"Remoting\" magit-remote-popup)\n (?o \"Submodules\" magit-submodule-popup)\n (?O \"Subtrees\" magit-subtree-popup)\n (?P \"Pushing\" magit-push-popup)\n (?r \"Rebasing\" magit-rebase-popup)\n (?t \"Tagging\" magit-tag-popup)\n (?T \"Notes\" magit-notes-popup)\n (?V \"Reverting\" magit-revert-popup)\n (?w \"Apply patches\" magit-am-popup)\n (?W \"Format patches\" magit-patch-popup)\n (?X \"Resetting\" magit-reset-popup)\n (?y \"Show Refs\" magit-show-refs-popup)\n (?z \"Stashing\" magit-stash-popup)\n (?! \"Running\" magit-run-popup)\n \"Applying changes\"\n (?a \"Apply\" magit-apply)\n (?s \"Stage\" magit-stage)\n (?u \"Unstage\" magit-unstage)\n (?v \"Reverse\" magit-reverse)\n (?S \"Stage all\" magit-stage-modified)\n (?U \"Unstage all\" magit-unstage-all)\n (?k \"Discard\" magit-discard)\n \"Essential commands\"\n (?g \" refresh current buffer\" magit-refresh)\n ;; These bindings only work because of :setup-function.\n (?\\t \" toggle section at point\" magit-section-toggle)\n (?\\r \" visit thing at point\" magit-visit-thing)\n ;; This binding has no effect and only appears to do\n ;; so because it is identical to the global binding.\n (\"C-h m\" \"show all key bindings\" describe-mode))\n :setup-function 'magit-dispatch-popup-setup\n :max-action-columns (lambda (heading)\n (pcase heading\n (\"Popup and dwim commands\" 4)\n (\"Applying changes\" 3)\n (\"Essential commands\" 1))))\n\n(defvar magit-dispatch-popup-map\n (let ((map (make-sparse-keymap)))\n (set-keymap-parent map magit-popup-mode-map)\n (cond ((featurep 'jkl)\n (define-key map [tab] 'magit-invoke-popup-action)\n (define-key map [return] 'magit-invoke-popup-action))\n (t\n (define-key map (kbd \"C-i\") 'magit-invoke-popup-action)\n (define-key map (kbd \"C-m\") 'magit-invoke-popup-action)))\n map)\n \"Keymap used by `magit-dispatch-popup'.\")\n\n(defun magit-dispatch-popup-setup (val def)\n (magit-popup-default-setup val def)\n (use-local-map magit-dispatch-popup-map)\n ;; This is necessary for users (i.e. me) who have broken the\n ;; connection between C-i (aka TAB) and tab, and C-m (aka RET)\n ;; and return.\n (magit-popup-put\n :actions (nconc (magit-popup-get :actions)\n (list (make-magit-popup-event :key 'tab\n :fun 'magit-section-toggle)\n (make-magit-popup-event :key 'return\n :fun 'magit-visit-thing)))))\n\n;;;; Git Popup\n\n(defcustom magit-shell-command-verbose-prompt t\n \"Whether to show the working directory when reading a command.\nThis affects `magit-git-command', `magit-git-command-topdir',\n`magit-shell-command', and `magit-shell-command-topdir'.\"\n :package-version '(magit . \"2.11.0\")\n :group 'magit-commands\n :type 'boolean)\n\n(defvar magit-git-command-history nil)\n\n;;;###autoload (autoload 'magit-run-popup \"magit\" nil t)\n(magit-define-popup magit-run-popup\n \"Popup console for running raw Git commands.\"\n :actions '((?! \"Git Subcommand (in topdir)\" magit-git-command-topdir)\n (?k \"Gitk\" magit-run-gitk)\n (?p \"Git Subcommand (in pwd)\" magit-git-command)\n (?a \"Gitk --all\" magit-run-gitk-all)\n (?s \"Shell command (in topdir)\" magit-shell-command-topdir)\n (?b \"Gitk --branches\" magit-run-gitk-branches)\n (?S \"Shell command (in pwd)\" magit-shell-command)\n (?g \"Git Gui\" magit-run-git-gui))\n :default-action 'magit-git-command\n :max-action-columns 2)\n\n;;;###autoload\n(defun magit-git-command (command)\n \"Execute COMMAND asynchonously; display output.\n\nInteractively, prompt for COMMAND in the minibuffer. \\\"git \\\" is\nused as initial input, but can be deleted to run another command.\n\nWith a prefix argument COMMAND is run in the top-level directory\nof the current working tree, otherwise in `default-directory'.\"\n (interactive (list (magit-read-shell-command nil \"git \")))\n (magit--shell-command command))\n\n;;;###autoload\n(defun magit-git-command-topdir (command)\n \"Execute COMMAND asynchonously; display output.\n\nInteractively, prompt for COMMAND in the minibuffer. \\\"git \\\" is\nused as initial input, but can be deleted to run another command.\n\nCOMMAND is run in the top-level directory of the current\nworking tree.\"\n (interactive (list (magit-read-shell-command t \"git \")))\n (magit--shell-command command (magit-toplevel)))\n\n;;;###autoload\n(defun magit-shell-command (command)\n \"Execute COMMAND asynchonously; display output.\n\nInteractively, prompt for COMMAND in the minibuffer. With a\nprefix argument COMMAND is run in the top-level directory of\nthe current working tree, otherwise in `default-directory'.\"\n (interactive (list (magit-read-shell-command)))\n (magit--shell-command command))\n\n;;;###autoload\n(defun magit-shell-command-topdir (command)\n \"Execute COMMAND asynchonously; display output.\n\nInteractively, prompt for COMMAND in the minibuffer. COMMAND\nis run in the top-level directory of the current working tree.\"\n (interactive (list (magit-read-shell-command t)))\n (magit--shell-command command (magit-toplevel)))\n\n(defun magit--shell-command (command &optional directory)\n (let ((default-directory (or directory default-directory))\n (process-environment process-environment))\n (push \"GIT_PAGER=cat\" process-environment)\n (magit-start-process shell-file-name nil\n shell-command-switch command))\n (magit-process-buffer))\n\n(defun magit-read-shell-command (&optional toplevel initial-input)\n (let ((dir (abbreviate-file-name\n (if (or toplevel current-prefix-arg)\n (or (magit-toplevel)\n (user-error \"Not inside a Git repository\"))\n default-directory))))\n (read-shell-command (if magit-shell-command-verbose-prompt\n (format \"Async shell command in %s: \" dir)\n \"Async shell command: \")\n initial-input 'magit-git-command-history)))\n\n;;; Revision Stack\n\n(defvar magit-revision-stack nil)\n\n(defcustom magit-pop-revision-stack-format\n '(\"[%N: %h] \" \"%N: %H\\n %s\\n\" \"\\\\[\\\\([0-9]+\\\\)[]:]\")\n \"Control how `magit-pop-revision-stack' inserts a revision.\n\nThe command `magit-pop-revision-stack' inserts a representation\nof the revision last pushed to the `magit-revision-stack' into\nthe current buffer. It inserts text at point and\/or near the end\nof the buffer, and removes the consumed revision from the stack.\n\nThe entries on the stack have the format (HASH TOPLEVEL) and this\noption has the format (POINT-FORMAT EOB-FORMAT INDEX-REGEXP), all\nof which may be nil or a string (though either one of EOB-FORMAT\nor POINT-FORMAT should be a string, and if INDEX-REGEXP is\nnon-nil, then the two formats should be too).\n\nFirst INDEX-REGEXP is used to find the previously inserted entry,\nby searching backward from point. The first submatch must match\nthe index number. That number is incremented by one, and becomes\nthe index number of the entry to be inserted. If you don't want\nto number the inserted revisions, then use nil for INDEX-REGEXP.\n\nIf INDEX-REGEXP is non-nil, then both POINT-FORMAT and EOB-FORMAT\nshould contain \\\"%N\\\", which is replaced with the number that was\ndetermined in the previous step.\n\nBoth formats, if non-nil and after removing %N, are then expanded\nusing `git show --format=FORMAT ...' inside TOPLEVEL.\n\nThe expansion of POINT-FORMAT is inserted at point, and the\nexpansion of EOB-FORMAT is inserted at the end of the buffer (if\nthe buffer ends with a comment, then it is inserted right before\nthat).\"\n :package-version '(magit . \"2.3.0\")\n :group 'magit-commands\n :type '(list (choice (string :tag \"Insert at point format\")\n (cons (string :tag \"Insert at point format\")\n (repeat (string :tag \"Argument to git show\")))\n (const :tag \"Don't insert at point\" nil))\n (choice (string :tag \"Insert at eob format\")\n (cons (string :tag \"Insert at eob format\")\n (repeat (string :tag \"Argument to git show\")))\n (const :tag \"Don't insert at eob\" nil))\n (choice (regexp :tag \"Find index regexp\")\n (const :tag \"Don't number entries\" nil))))\n\n(defun magit-pop-revision-stack (rev toplevel)\n \"Insert a representation of a revision into the current buffer.\n\nPop a revision from the `magit-revision-stack' and insert it into\nthe current buffer according to `magit-pop-revision-stack-format'.\nRevisions can be put on the stack using `magit-copy-section-value'\nand `magit-copy-buffer-revision'.\n\nIf the stack is empty or with a prefix argument, instead read a\nrevision in the minibuffer. By using the minibuffer history this\nallows selecting an item which was popped earlier or to insert an\narbitrary reference or revision without first pushing it onto the\nstack.\n\nWhen reading the revision from the minibuffer, then it might not\nbe possible to guess the correct repository. When this command\nis called inside a repository (e.g. while composing a commit\nmessage), then that repository is used. Otherwise (e.g. while\ncomposing an email) then the repository recorded for the top\nelement of the stack is used (even though we insert another\nrevision). If not called inside a repository and with an empty\nstack, or with two prefix arguments, then read the repository in\nthe minibuffer too.\"\n (interactive\n (if (or current-prefix-arg (not magit-revision-stack))\n (let ((default-directory\n (or (and (not (= (prefix-numeric-value current-prefix-arg) 16))\n (or (magit-toplevel)\n (cadr (car magit-revision-stack))))\n (magit-read-repository))))\n (list (magit-read-branch-or-commit \"Insert revision\")\n default-directory))\n (push (caar magit-revision-stack) magit-revision-history)\n (pop magit-revision-stack)))\n (if rev\n (-let [(pnt-format eob-format idx-format) magit-pop-revision-stack-format]\n (let ((default-directory toplevel)\n (idx (and idx-format\n (save-excursion\n (if (re-search-backward idx-format nil t)\n (number-to-string\n (1+ (string-to-number (match-string 1))))\n \"1\"))))\n pnt-args eob-args)\n (when (listp pnt-format)\n (setq pnt-args (cdr pnt-format))\n (setq pnt-format (car pnt-format)))\n (when (listp eob-format)\n (setq eob-args (cdr eob-format))\n (setq eob-format (car eob-format)))\n (when pnt-format\n (when idx-format\n (setq pnt-format\n (replace-regexp-in-string \"%N\" idx pnt-format t t)))\n (magit-rev-insert-format pnt-format rev pnt-args)\n (backward-delete-char 1))\n (when eob-format\n (when idx-format\n (setq eob-format\n (replace-regexp-in-string \"%N\" idx eob-format t t)))\n (save-excursion\n (goto-char (point-max))\n (skip-syntax-backward \">s-\")\n (beginning-of-line)\n (if (and comment-start (looking-at comment-start))\n (while (looking-at comment-start)\n (forward-line -1))\n (forward-line)\n (unless (= (current-column) 0)\n (insert ?\\n)))\n (insert ?\\n)\n (magit-rev-insert-format eob-format rev eob-args)\n (backward-delete-char 1)))))\n (user-error \"Revision stack is empty\")))\n\n(define-key git-commit-mode-map\n (kbd \"C-c C-w\") 'magit-pop-revision-stack)\n\n(defun magit-copy-section-value ()\n \"Save the value of the current section for later use.\n\nSave the section value to the `kill-ring', and, provided that\nthe current section is a commit, branch, or tag section, push\nthe (referenced) revision to the `magit-revision-stack' for use\nwith `magit-pop-revision-stack'.\n\nWhen the current section is a branch or a tag, and a prefix\nargument is used, then save the revision at its tip to the\n`kill-ring' instead of the reference name.\n\nWhen the region is active, then save that to the `kill-ring',\nlike `kill-ring-save' would, instead of behaving as described\nabove.\"\n (interactive)\n (if (use-region-p)\n (copy-region-as-kill nil nil 'region)\n (-when-let* ((section (magit-current-section))\n (value (magit-section-value section)))\n (magit-section-case\n ((branch commit module-commit tag)\n (let ((default-directory default-directory) ref)\n (magit-section-case\n ((branch tag)\n (setq ref value))\n (module-commit\n (setq default-directory\n (file-name-as-directory\n (expand-file-name (magit-section-parent-value section)\n (magit-toplevel))))))\n (setq value (magit-rev-parse value))\n (push (list value default-directory) magit-revision-stack)\n (kill-new (message \"%s\" (or (and current-prefix-arg ref)\n value)))))\n (t (kill-new (message \"%s\" value)))))))\n\n(defun magit-copy-buffer-revision ()\n \"Save the revision of the current buffer for later use.\n\nSave the revision shown in the current buffer to the `kill-ring'\nand push it to the `magit-revision-stack'.\n\nThis command is mainly intended for use in `magit-revision-mode'\nbuffers, the only buffers where it is always unambiguous exactly\nwhich revision should be saved.\n\nMost other Magit buffers usually show more than one revision, in\nsome way or another, so this command has to select one of them,\nand that choice might not always be the one you think would have\nbeen the best pick.\n\nIn such buffers it is often more useful to save the value of\nthe current section instead, using `magit-copy-section-value'.\n\nWhen the region is active, then save that to the `kill-ring',\nlike `kill-ring-save' would, instead of behaving as described\nabove.\"\n (interactive)\n (if (use-region-p)\n (copy-region-as-kill nil nil 'region)\n (-when-let (rev (cond ((memq major-mode '(magit-cherry-mode\n magit-log-select-mode\n magit-reflog-mode\n magit-refs-mode\n magit-revision-mode\n magit-stash-mode\n magit-stashes-mode))\n (car magit-refresh-args))\n ((memq major-mode '(magit-diff-mode\n magit-log-mode))\n (let ((r (caar magit-refresh-args)))\n (if (string-match \"\\\\.\\\\.\\\\.?\\\\(.+\\\\)\" r)\n (match-string 1 r)\n r)))\n ((eq major-mode 'magit-status-mode) \"HEAD\")))\n (when (magit-rev-verify-commit rev)\n (setq rev (magit-rev-parse rev))\n (push (list rev default-directory) magit-revision-stack)\n (kill-new (message \"%s\" rev))))))\n\n;;; (Keywords)\n\n(defconst magit-font-lock-keywords\n (eval-when-compile\n `((,(concat \"(\\\\(magit-define-section-jumper\\\\)\\\\_>\"\n \"[ \\t'\\(]*\"\n \"\\\\(\\\\(?:\\\\sw\\\\|\\\\s_\\\\)+\\\\)?\")\n (1 'font-lock-keyword-face)\n (2 'font-lock-function-name-face nil t))\n (,(concat \"(\" (regexp-opt '(\"magit-insert-section\"\n \"magit-section-case\"\n \"magit-section-when\"\n \"magit-bind-match-strings\"\n \"magit-with-temp-index\"\n \"magit-with-blob\"\n \"magit-with-toplevel\") t)\n \"\\\\_>\")\n . 1))))\n\n(font-lock-add-keywords 'emacs-lisp-mode magit-font-lock-keywords)\n\n;;; (Versions)\n\n(defvar magit-version 'undefined\n \"The version of Magit that you're using.\nUse the function by the same name instead of this variable.\")\n\n;;;###autoload\n(defun magit-version (&optional print-dest)\n \"Return the version of Magit currently in use.\nIf optional argument PRINT-DEST is non-nil, output\nstream (interactively, the echo area, or the current buffer with\na prefix argument), also print the used versions of Magit, Git,\nand Emacs to it.\"\n (interactive (list (if current-prefix-arg (current-buffer) t)))\n (let ((magit-git-global-arguments nil)\n (toplib (or load-file-name buffer-file-name))\n debug)\n (unless (and toplib\n (equal (file-name-nondirectory toplib) \"magit.el\"))\n (setq toplib (locate-library \"magit.el\")))\n (setq toplib (and toplib (file-chase-links toplib)))\n (push toplib debug)\n (when toplib\n (let* ((topdir (file-name-directory toplib))\n (gitdir (expand-file-name\n \".git\" (file-name-directory\n (directory-file-name topdir))))\n (static (locate-library \"magit-version.el\" nil (list topdir)))\n (static (and static (file-chase-links static))))\n (or (progn\n (push 'repo debug)\n (when (and (file-exists-p gitdir)\n ;; It is a repo, but is it the Magit repo?\n (file-exists-p\n (expand-file-name \"..\/lisp\/magit.el\" gitdir)))\n (push t debug)\n ;; Inside the repo the version file should only exist\n ;; while running make.\n (when (and static (not noninteractive))\n (ignore-errors (delete-file static)))\n (setq magit-version\n (let ((default-directory topdir))\n (magit-git-string \"describe\" \"--tags\" \"--dirty\")))))\n (progn\n (push 'static debug)\n (when (and static (file-exists-p static))\n (push t debug)\n (load-file static)\n magit-version))\n (when (featurep 'package)\n (push 'elpa debug)\n (ignore-errors\n (--when-let (assq 'magit package-alist)\n (push t debug)\n (setq magit-version\n (and (fboundp 'package-desc-version)\n (package-version-join\n (package-desc-version (cadr it))))))))\n (progn\n (push 'debug debug)\n (let ((dirname (file-name-nondirectory\n (directory-file-name topdir))))\n (when (string-match \"\\\\`magit-\\\\([0-9]\\\\{8\\\\}\\\\.[0-9]*\\\\)\"\n dirname)\n (setq magit-version (match-string 1 dirname))))))))\n (if (stringp magit-version)\n (when print-dest\n (princ (format \"Magit %s, Git %s, Emacs %s, %s\"\n (or magit-version \"(unknown)\")\n (or (let ((magit-git-debug\n (lambda (err)\n (display-warning '(magit git)\n err :error))))\n (magit-git-version t))\n \"(unknown)\")\n emacs-version\n system-type)\n print-dest))\n (setq debug (reverse debug))\n (setq magit-version 'error)\n (when magit-version\n (push magit-version debug))\n (unless (equal (getenv \"TRAVIS\") \"true\")\n ;; The repository is a sparse clone.\n (message \"Cannot determine Magit's version %S\" debug)))\n magit-version))\n\n(defun magit-debug-git-executable ()\n \"Display a buffer with information about `magit-git-executable'.\nSee info node `(magit)Debugging Tools' for more information.\"\n (interactive)\n (with-current-buffer (get-buffer-create \"*magit-git-debug*\")\n (pop-to-buffer (current-buffer))\n (erase-buffer)\n (insert (format \"magit-git-executable: %S\" magit-git-executable)\n (unless (file-name-absolute-p magit-git-executable)\n (format \" [%S]\" (executable-find magit-git-executable)))\n (format \" (%s)\\n\"\n (let* ((errmsg nil)\n (magit-git-debug (lambda (err) (setq errmsg err))))\n (or (magit-git-version t) errmsg))))\n (insert (format \"exec-path: %S\\n\" exec-path))\n (--when-let (cl-set-difference\n (-filter #'file-exists-p (remq nil (parse-colon-path\n (getenv \"PATH\"))))\n (-filter #'file-exists-p (remq nil exec-path))\n :test #'file-equal-p)\n (insert (format \" entries in PATH, but not in exec-path: %S\\n\" it)))\n (dolist (execdir exec-path)\n (insert (format \" %s (%s)\\n\" execdir (car (file-attributes execdir))))\n (when (file-directory-p execdir)\n (dolist (exec (directory-files\n execdir t (concat\n \"\\\\`git\" (regexp-opt exec-suffixes) \"\\\\'\")))\n (insert (format \" %s (%s)\\n\" exec\n (let* ((magit-git-executable exec)\n (errmsg nil)\n (magit-git-debug (lambda (err) (setq errmsg err))))\n (or (magit-git-version t) errmsg)))))))))\n\n;;; (Asserts)\n\n(defun magit-startup-asserts ()\n (let ((version (magit-git-version)))\n (when (and version\n (version< version magit--minimal-git)\n (not (equal (getenv \"TRAVIS\") \"true\")))\n (display-warning 'magit (format \"\\\nMagit requires Git >= %s, you are using %s.\n\nIf this comes as a surprise to you, because you do actually have\na newer version installed, then that probably means that the\nolder version happens to appear earlier on the `$PATH'. If you\nalways start Emacs from a shell, then that can be fixed in the\nshell's init file. If you start Emacs by clicking on an icon,\nor using some sort of application launcher, then you probably\nhave to adjust the environment as seen by graphical interface.\nFor X11 something like ~\/.xinitrc should work.\n\nIf you use Tramp to work inside remote Git repositories, then you\nhave to make sure a suitable Git is used on the remote machines\ntoo.\\n\" magit--minimal-git version) :error)))\n (when (version< emacs-version magit--minimal-emacs)\n (display-warning 'magit (format \"\\\nMagit requires Emacs >= %s, you are using %s.\n\nIf this comes as a surprise to you, because you do actually have\na newer version installed, then that probably means that the\nolder version happens to appear earlier on the `$PATH'. If you\nalways start Emacs from a shell, then that can be fixed in the\nshell's init file. If you start Emacs by clicking on an icon,\nor using some sort of application launcher, then you probably\nhave to adjust the environment as seen by graphical interface.\nFor X11 something like ~\/.xinitrc should work.\\n\"\n magit--minimal-emacs emacs-version)\n :error))\n (--each '((magit-log-edit . git-commit)\n (git-commit-mode . git-commit)\n (git-rebase-mode . git-rebase))\n (when (or (featurep (car it)) (locate-library (symbol-name (car it))))\n (display-warning 'magit (format \"%s has to be removed\n\nMagit is no longer compatible with the library `%s',\nwhich was used in earlier releases. Please remove it, so that\nMagit can use the successor `%s' without the obsolete\nlibrary getting in the way. Then restart Emacs.\\n\"\n (car it) (car it) (cdr it)) :error))))\n\n;;; (Features)\n\n(provide 'magit)\n\n(cl-eval-when (load eval)\n (require 'magit-status)\n (require 'magit-refs)\n (require 'magit-files)\n (require 'magit-branch)\n (require 'magit-worktree)\n (require 'magit-notes)\n (require 'magit-sequence)\n (require 'magit-commit)\n (require 'magit-remote)\n (require 'magit-bisect)\n (require 'magit-stash)\n (require 'magit-blame)\n (require 'magit-obsolete)\n (unless (load \"magit-autoloads\" t t)\n (require 'magit-submodule)\n (require 'magit-subtree)\n (require 'magit-ediff)\n (require 'magit-extras)\n (require 'git-rebase)\n (require 'magit-imenu)\n (require 'magit-bookmark)))\n\n(eval-after-load 'bookmark\n '(require 'magit-bookmark))\n\n(if after-init-time\n (progn (magit-startup-asserts)\n (magit-version))\n (add-hook 'after-init-hook #'magit-startup-asserts t)\n (add-hook 'after-init-hook #'magit-version t))\n\n;;; magit.el ends here\n","avg_line_length":40.9723502304,"max_line_length":169,"alphanum_fraction":0.6043414689} {"size":202,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; init-git.el --- Configure magit -*- lexical-binding: t -*-\n;;; Commentary:\n;;; Code:\n\n(use-package magit\n :ensure\n :bind ((\"C-x g\" . magit-status)))\n\n(provide 'init-git)\n;;; init-git.el ends here\n","avg_line_length":18.3636363636,"max_line_length":62,"alphanum_fraction":0.603960396} {"size":11269,"ext":"el","lang":"Emacs Lisp","max_stars_count":4.0,"content":";; haskell-c2hs-tests.el --- -*- lexical-binding: t; -*-\n\n(require 'ert)\n(require 'haskell-c2hs)\n(require 'haskell-test-utils)\n\n(ert-deftest haskell-c2hs-basic-import-hook ()\n \"C2HS import hook\"\n (check-properties\n '(\"{# import Foo #}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"import\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-qualified-import-hook ()\n \"C2HS qualified import hook\"\n (check-properties\n '(\"{#import qualified Foo #}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"import\" \"w\" haskell-c2hs-hook-name-face)\n (\"qualified\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-full-context-hook ()\n \"C2HS full context hook\"\n (check-properties\n '(\"{# context lib = \\\"libgtk.so\\\" prefix = \\\"gtk\\\" add prefix = \\\"CGtk\\\" #}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"context\" \"w\" haskell-c2hs-hook-name-face)\n (\"lib\" \"w\" haskell-c2hs-hook-name-face)\n (\"prefix\" \"w\" haskell-c2hs-hook-name-face)\n (\"add\" \"w\" haskell-c2hs-hook-name-face)\n (\"prefix\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-type-hook ()\n \"C2HS type hook\"\n (check-properties\n '(\"{# type gint #}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"type\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-sizeof-hook ()\n \"C2HS sizeof hook\"\n (check-properties\n '(\"{# sizeof double #}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"sizeof\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-enum-hook ()\n \"C2HS enum hook\"\n ;; note that this has multiline constructs that do not work reliably at this point\n :expected-result :failed\n (check-properties\n '(\"{#enum v4l2_quantization as Quantization\"\n \" { V4L2_QUANTIZATION_DEFAULT as Default\"\n \" , V4L2_QUANTIZATION_FULL_RANGE as FullRange\"\n \" , V4L2_QUANTIZATION_LIM_RANGE as LimitedRange\"\n \" }\"\n \" deriving (Show, Eq, Ord)\"\n \" #}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"enum\" \"w\" haskell-c2hs-hook-name-face)\n (\"as\" \"w\" haskell-c2hs-hook-name-face)\n (\"Quantization\" \"w\" haskell-constructor-face)\n (\"V4L2_QUANTIZATION_DEFAULT\" \"w\" haskell-constructor-face)\n (\"Default\" \"w\" haskell-constructor-face)\n (\"V4L2_QUANTIZATION_FULL_RANGE\" \"w\" haskell-constructor-face)\n (\"FullRange\" \"w\" haskell-constructor-face)\n (\"V4L2_QUANTIZATION_LIM_RANGE\" \"w\" haskell-constructor-face)\n (\"LimitedRange\" \"w\" haskell-constructor-face)\n (\"deriving\" \"w\" haskell-keyword-face)\n (\"Show\" \"w\" haskell-constructor-face)\n (\"Eq\" \"w\" haskell-constructor-face)\n (\"Ord\" \"w\" haskell-constructor-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-enum-define-hook ()\n \"C2HS enum define hook\"\n ;; note that this has multiline constructs that do not work reliably at this point\n :expected-result :failed\n (check-properties\n '(\"{#enum define MMapProtectionFlag\"\n \" { PROT_READ as ProtRead\"\n \" , PROT_WRITE as ProtWrite\"\n \" , PROT_EXEC as ProtExec\"\n \" , PROT_NONE as ProtNone\"\n \" }\"\n \" deriving (Show, Eq, Ord)\"\n \" #}\"\n )\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"enum\" \"w\" haskell-c2hs-hook-name-face)\n (\"define\" \"w\" haskell-c2hs-hook-name-face)\n (\"MMapProtectionFlag\" \"w\" haskell-constructor-face)\n (\"PROT_READ\" \"w\" haskell-constructor-face)\n (\"ProtRead\" \"w\" haskell-constructor-face)\n (\"PROT_WRITE\" \"w\" haskell-constructor-face)\n (\"ProtWrite\" \"w\" haskell-constructor-face)\n (\"PROT_EXEC\" \"w\" haskell-constructor-face)\n (\"ProtExec\" \"w\" haskell-constructor-face)\n (\"PROT_NONE\" \"w\" haskell-constructor-face)\n (\"ProtNone\" \"w\" haskell-constructor-face)\n (\"deriving\" \"w\" haskell-keyword-face)\n (\"Show\" \"w\" haskell-constructor-face)\n (\"Eq\" \"w\" haskell-constructor-face)\n (\"Ord\" \"w\" haskell-constructor-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-pure-call-hook ()\n \"C2HS pure call hook\"\n (check-properties\n '(\"sin :: Float -> Float\"\n \"sin = {#call pure sin as \\\"_sin\\\"#}\")\n '((\"sin\" \"w\" haskell-definition-face)\n (\"::\" t haskell-operator-face)\n (\"Float\" \"w\" haskell-type-face)\n (\"->\" t haskell-operator-face)\n (\"Float\" \"w\" haskell-type-face)\n (\"sin\" \"w\" haskell-definition-face)\n (\"=\" t haskell-operator-face)\n (\"{#\" t haskell-c2hs-hook-pair-face)\n (\"call\" \"w\" haskell-c2hs-hook-name-face)\n (\"pure\" \"w\" haskell-c2hs-hook-name-face)\n (\"as\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-unsafe-call-hook ()\n \"C2HS unsafe fun hook\"\n (check-properties\n '(\"{#fun unsafe sin as ^#}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"fun\" \"w\" haskell-c2hs-hook-name-face)\n (\"unsafe\" \"w\" haskell-c2hs-hook-name-face)\n (\"as\" \"w\" haskell-c2hs-hook-name-face)\n (\"^\" t font-lock-negation-char-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-pure-fun-hook ()\n \"C2HS pure call hook\"\n (check-properties\n '(\"{#fun pure sin as \\\"_sin\\\"#}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"fun\" \"w\" haskell-c2hs-hook-name-face)\n (\"pure\" \"w\" haskell-c2hs-hook-name-face)\n (\"as\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-unsafe-fun-hook ()\n \"C2HS unsafe fun hook\"\n (check-properties\n '(\"{#fun unsafe sin as ^#}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"fun\" \"w\" haskell-c2hs-hook-name-face)\n (\"unsafe\" \"w\" haskell-c2hs-hook-name-face)\n (\"as\" \"w\" haskell-c2hs-hook-name-face)\n (\"^\" t font-lock-negation-char-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-get-hook ()\n \"C2HS get hook\"\n (check-properties\n '(\"visualGetType :: Visual -> IO VisualType\"\n \"visualGetType (Visual vis) = liftM cToEnum $ {#get Visual->type#} vis\")\n '((\"visualGetType\" \"w\" haskell-definition-face)\n (\"::\" t haskell-operator-face)\n (\"Visual\" \"w\" haskell-type-face)\n (\"->\" t haskell-operator-face)\n (\"IO\" \"w\" haskell-type-face)\n (\"VisualType\" \"w\" haskell-type-face)\n (\"visualGetType\" \"w\" haskell-definition-face)\n (\"Visual\" \"w\" haskell-constructor-face)\n (\"=\" t haskell-operator-face)\n (\"$\" t haskell-operator-face)\n (\"{#\" t haskell-c2hs-hook-pair-face)\n (\"get\" \"w\" haskell-c2hs-hook-name-face)\n (\"Visual\" \"w\" haskell-constructor-face)\n (\"->\" t haskell-operator-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-set-hook ()\n \"C2HS set hook\"\n (check-properties\n '(\"{#set sockaddr_in.sin_family#} addr_in (cFromEnum AF_NET)\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"set\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face)\n (\"AF_NET\" \"w_\" haskell-constructor-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-pointer-hook-1 ()\n \"C2HS pointer hook\"\n (check-properties\n '(\"{#pointer *GtkObject as Object foreign newtype#}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"pointer\" \"w\" haskell-c2hs-hook-name-face)\n (\"*\" t haskell-c2hs-hook-name-face)\n (\"GtkObject\" \"w\" haskell-constructor-face)\n (\"as\" \"w\" haskell-c2hs-hook-name-face)\n (\"Object\" \"w\" haskell-constructor-face)\n (\"foreign\" \"w\" haskell-c2hs-hook-name-face)\n (\"newtype\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-pointer-hook-2 ()\n \"C2HS pointer hook\"\n (check-properties\n '(\"{# pointer point as PointPtr -> Point #}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"pointer\" \"w\" haskell-c2hs-hook-name-face)\n (\"PointPtr\" \"w\" haskell-constructor-face)\n (\"->\" t haskell-operator-face)\n (\"Point\" \"w\" haskell-constructor-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-full-pointer-hook ()\n \"C2HS full pointer hook\"\n (check-properties\n '(\"{#pointer * foo_t as FooPtr stable -> MkFooPtr nocode#}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"pointer\" \"w\" haskell-c2hs-hook-name-face)\n (\"*\" t haskell-c2hs-hook-name-face)\n (\"as\" \"w\" haskell-c2hs-hook-name-face)\n (\"FooPtr\" \"w\" haskell-constructor-face)\n (\"stable\" \"w\" haskell-c2hs-hook-name-face)\n (\"MkFooPtr\" \"w\" haskell-constructor-face)\n (\"nocode\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-class-hook ()\n \"C2HS class hook\"\n (check-properties\n '(\"{# class GtkObjectClass => GtkWidgetClass GtkWidget #}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"class\" \"w\" haskell-c2hs-hook-name-face)\n (\"GtkObjectClass\" \"w\" haskell-type-face)\n (\"=>\" t haskell-operator-face)\n (\"GtkWidgetClass\" \"w\" haskell-type-face)\n (\"GtkWidget\" \"w\" haskell-type-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-alignof-hook ()\n \"C2HS alignof hook\"\n (check-properties\n '(\"gIntAlign :: Int\"\n \"gIntAlign = {#alignof gint#}\")\n '((\"gIntAlign\" \"w\" haskell-definition-face)\n (\"::\" t haskell-operator-face)\n (\"Int\" \"w\" haskell-type-face)\n (\"gIntAlign\" \"w\" haskell-definition-face)\n (\"=\" t haskell-operator-face)\n (\"{#\" t haskell-c2hs-hook-pair-face)\n (\"alignof\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-offsetof-hook ()\n \"C2HS offsetof hook\"\n (check-properties\n '(\"{#offsetof struct_t->somefield#}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"offsetof\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-const-hook ()\n \"C2HS const hook\"\n (check-properties\n '(\"{#const FOO_BAR #}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"const\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-typedef-hook ()\n \"C2HS typedef hook\"\n (check-properties\n '(\"{# typedef size_t CSize #}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"typedef\" \"w\" haskell-c2hs-hook-name-face)\n (\"CSize\" \"w\" haskell-constructor-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n(ert-deftest haskell-c2hs-nongnu-hook ()\n \"C2HS nonGNU hook\"\n (check-properties\n '(\"{#nonGNU#}\")\n '((\"{#\" t haskell-c2hs-hook-pair-face)\n (\"nonGNU\" \"w\" haskell-c2hs-hook-name-face)\n (\"#}\" t haskell-c2hs-hook-pair-face))\n 'haskell-c2hs-mode))\n\n;; haskell-c2hs-tests.el ends here\n\n","avg_line_length":35.8885350318,"max_line_length":84,"alphanum_fraction":0.6143402254} {"size":1658,"ext":"el","lang":"Emacs Lisp","max_stars_count":21.0,"content":";;; golint.el --- lint for the Go source code\r\n\r\n;; Copyright 2013 The Go Authors. All rights reserved.\r\n;; Use of this source code is governed by a BSD-style\r\n;; license that can be found in the LICENSE file.\r\n\r\n;; URL: https:\/\/github.com\/golang\/lint\r\n\r\n;;; Commentary:\r\n\r\n;; To install golint, add the following lines to your .emacs file:\r\n;; (add-to-list 'load-path \"PATH CONTAINING golint.el\" t)\r\n;; (require 'golint)\r\n;;\r\n;; After this, type M-x golint on Go source code.\r\n;;\r\n;; Usage:\r\n;; C-x `\r\n;; Jump directly to the line in your code which caused the first message.\r\n;; \r\n;; For more usage, see Compilation-Mode:\r\n;; http:\/\/www.gnu.org\/software\/emacs\/manual\/html_node\/emacs\/Compilation-Mode.html\r\n\r\n;;; Code:\r\n(require 'compile)\r\n\r\n(defun go-lint-buffer-name (mode) \r\n \"*Golint*\") \r\n\r\n(defun golint-process-setup ()\r\n \"Setup compilation variables and buffer for `golint'.\"\r\n (run-hooks 'golint-setup-hook))\r\n\r\n(define-compilation-mode golint-mode \"golint\"\r\n \"Golint is a linter for Go source code.\"\r\n (set (make-local-variable 'compilation-scroll-output) nil)\r\n (set (make-local-variable 'compilation-disable-input) t)\r\n (set (make-local-variable 'compilation-process-setup-function)\r\n 'golint-process-setup)\r\n)\r\n\r\n;;;###autoload\r\n(defun golint ()\r\n \"Run golint on the current file and populate the fix list. Pressing C-x ` will jump directly to the line in your code which caused the first message.\"\r\n (interactive)\r\n (compilation-start\r\n (mapconcat #'shell-quote-argument\r\n (list \"golint\" (expand-file-name buffer-file-name)) \" \")\r\n 'golint-mode))\r\n\r\n(provide 'golint)\r\n\r\n;;; golint.el ends here\r\n","avg_line_length":30.7037037037,"max_line_length":153,"alphanum_fraction":0.671893848} {"size":3022,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":";;; org-docview.el --- support for links to doc-view-mode buffers\n\n;; Copyright (C) 2009-2012 Free Software Foundation, Inc.\n\n;; Author: Jan B\u00f6cker \n;; Keywords: outlines, hypermedia, calendar, wp\n;; Homepage: http:\/\/orgmode.org\n;;\n;; This file is part of GNU Emacs.\n;;\n;; GNU Emacs is free software: you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; GNU Emacs is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs. If not, see .\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;\n;;; Commentary:\n\n;; This file implements links to open files in doc-view-mode.\n;; Org-mode loads this module by default - if this is not what you want,\n;; configure the variable `org-modules'.\n\n;; The links take the form\n;;\n;; docview:::\n;;\n;; for example: [[docview:~\/.elisp\/org\/doc\/org.pdf::1][Org-Mode Manual]]\n;;\n;; Autocompletion for inserting links is supported; you will be\n;; prompted for a file and a page number.\n;;\n;; If you use org-store-link in a doc-view mode buffer, the stored\n;; link will point to the current page.\n\n;;; Code:\n\n\n(require 'org)\n\n(declare-function doc-view-goto-page \"ext:doc-view\" (page))\n(declare-function image-mode-window-get \"ext:image-mode\"\n\t\t (prop &optional winprops))\n\n(autoload 'doc-view-goto-page \"doc-view\")\n\n(org-add-link-type \"docview\" 'org-docview-open)\n(add-hook 'org-store-link-functions 'org-docview-store-link)\n\n(defun org-docview-open (link)\n (when (string-match \"\\\\(.*\\\\)::\\\\([0-9]+\\\\)$\" link)\n (let* ((path (match-string 1 link))\n\t (page (string-to-number (match-string 2 link))))\n (org-open-file path 1) ;; let org-mode open the file (in-emacs = 1)\n ;; to ensure org-link-frame-setup is respected\n (doc-view-goto-page page)\n )))\n\n(defun org-docview-store-link ()\n \"Store a link to a docview buffer.\"\n (when (eq major-mode 'doc-view-mode)\n ;; This buffer is in doc-view-mode\n (let* ((path buffer-file-name)\n\t (page (image-mode-window-get 'page))\n\t (link (concat \"docview:\" path \"::\" (number-to-string page)))\n\t (description \"\"))\n (org-store-link-props\n :type \"docview\"\n :link link\n :description path))))\n\n(defun org-docview-complete-link ()\n \"Use the existing file name completion for file.\nLinks to get the file name, then ask the user for the page number\nand append it.\"\n (concat (replace-regexp-in-string \"^file:\" \"docview:\" (org-file-complete-link))\n\t \"::\"\n\t (read-from-minibuffer \"Page:\" \"1\")))\n\n\n(provide 'org-docview)\n\n;;; org-docview.el ends here\n","avg_line_length":33.2087912088,"max_line_length":81,"alphanum_fraction":0.6651224355} {"size":14273,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; About\n\n;; A boring part but really important when making Inside Emacs videos\n;; is to transform the story (written in a specific formated text\n;; file) to beautiful footage. So far it involves 3 steps:\n;; 1) parse the story (specific formated text),\n;; 2) generate \"svg\" files (the story) from the specific\n;; formated text,\n;; 3) generate \"kdenlive\" files with the previous \"svg\" files.\n;;\n;; In this file, we treat the parts 2) and 3) and\n;; The part 1) is treated in the file .\/ie-story-parse.el .\n;;\n;; Usage:\n;; To generate the description svg files telling the story of\n;; Inside Emacs videos, visite the file where the story is written\n;; (following the format described in .\/ie-story-parse.el and run\n;; the command `ie-story-generate-all-descriptions-svg':\n;;\n;; M-x ie-story-generate-all-descriptions-svg\n;;\n;; The generated svg files are saved in the subdirectory\n;; `ie-story-generate-images-dir'.\n\n;;; Packages\n\n(require 'comment) ; https:\/\/github.com\/tonyaldon\/emacs.d\/blob\/master\/settings\/packages\/comment.el\n(require 'dash)\n(require 'f)\n(require 'ie-story-parse)\n(require 'kdenlive)\n(require 's)\n(require 'svg)\n\n;;; Global variables\n\n(defvar ie-story-generate-images-dir \"r-images\"\n \"Name of the subdirectory where the svg images are saved.\n\nSee `ie-story-generate-all-descriptions-svg'.\")\n\n(defvar ie-story-generate-kdenlive-dir \"kdenlive\"\n \"Name of the subdirectory where the \\\".kdenlive\\\" are saved.\n\nSee `ie-story-generate-all-edited-scenes-kdenlive'.\")\n\n;;; Generate svg files\n\n(defun ie-story-generate-description-path (scene index folder)\n \"Generate full path of a description of Inside Emacs.\n\nSCENE is the scene (kebab-case) of the scene the description\nbelongs to.\nIf INDEX non-nil, it is the apparition order of the description\nin the SCENE. If INDEX is nil, the returned path is the full path\ncorresponding to the svg title of the SCENE.\nFOLDER is the parent of the file path returned.\n\"\n (let* ((tail (or (and index (number-to-string index)) \"title\"))\n (base (s-join \"-\" `(\"description\" ,scene ,tail))))\n (f-full (f-join folder (s-concat base \".svg\")))))\n\n(defun ie-story-generate-description-scene-title-svg (scene-buffer-position folder)\n \"Generate svg title scene of Inside Emacs at SCENE-BUFFER-POSITION.\n\nThe svg file generated is save in FOLDER with a unique name.\"\n (unless (f-exists? folder) (f-mkdir folder))\n (let* ((scene-title\n (ie-story-parse-scene-title scene-buffer-position))\n (scene-title-kebab-case\n (ie-story-parse-scene-title scene-buffer-position t))\n (path (ie-story-generate-description-path\n scene-title-kebab-case nil folder))\n (svg (svg-create 1920 1080))\n (style \"font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:96px;line-height:1.25;font-family:Ramabhadra;-inkscape-font-specification:'Ramabhadra Bold';letter-spacing:0px;word-spacing:0px;fill:#f0f0f0;fill-opacity:0.941176;stroke:none;stroke-width:0.264583\")\n (x-start-line 90)\n (y-start-line 194))\n (svg-text svg scene-title\n :style style :x x-start-line :y y-start-line)\n (with-temp-buffer\n (svg-print svg)\n (write-region (point-min) (point-max) path))))\n\n(defun ie-story-generate-description-svg (lines scene index folder)\n \"Generate svg description of Inside Emacs.\n\nLINES is a list of strings representing the description.\nSCENE is the scene (kebab-case) of the scene the description belongs to.\nINDEX is the apparition order of the description in the SCENE.\n\nThe svg file generated is save in FOLDER with a unique name.\"\n (unless (f-exists? folder) (f-mkdir folder))\n (let ((path (ie-story-generate-description-path scene index folder))\n (svg (svg-create 1920 1080))\n (style \"font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:96px;line-height:1.25;font-family:Ramabhadra;-inkscape-font-specification:'Ramabhadra Bold';letter-spacing:0px;word-spacing:0px;fill:#f0f0f0;fill-opacity:0.941176;stroke:none;stroke-width:0.264583\")\n (lines-reversed (reverse lines))\n (x-start-line 90)\n (y-start-lines '(1016 896 776 656)))\n (while lines-reversed\n (svg-text svg (pop lines-reversed)\n :style style :x x-start-line :y (pop y-start-lines)))\n (with-temp-buffer\n (svg-print svg)\n (write-region (point-min) (point-max) path))))\n\n(defun ie-story-generate-descriptions-in-scene-svg (scene-buffer-position folder)\n \"Generate all svg descriptions of Inside Emacs in the scene at SCENE-BUFFER-POSITION.\n\nThe svg files generated are saved in FOLDER.\nSee `ie-story-generate-all-descriptions-svg'.\"\n (let ((scene-name\n (ie-story-parse-scene-title scene-buffer-position t)))\n (--each-indexed (ie-story-parse-descriptions-in-scene\n scene-buffer-position)\n (ie-story-generate-description-svg\n (ie-story-parse-description it)\n scene-name (1+ it-index) folder))))\n\n(defun ie-story-generate-all-descriptions-svg ()\n \"Generate all svg descriptions of Inside Emacs for the current buffer.\n\nThe files are saved in the subdirectory `ie-story-generate-images-dir'.\"\n (interactive)\n (org-show-all)\n (--each (ie-story-parse-scenes)\n (ie-story-generate-description-scene-title-svg\n it ie-story-generate-images-dir)\n (ie-story-generate-descriptions-in-scene-svg\n it ie-story-generate-images-dir))\n (message \"svg description files saved in %s\"\n ie-story-generate-images-dir))\n\n;;; Generate kdenlive files\n\n(defun ie-story-generate-description-images-for-kdenlive\n (scene-buffer-position\n duration\n scene-name\n folder-descriptions\n images-dir)\n \"Helper intended to be used in `ie-story-generate-edited-scene-kdenlive'.\"\n (let ((indexes (number-sequence\n 1 (length\n (ie-story-parse-descriptions-in-scene\n scene-buffer-position)))))\n (cons\n (kdenlive-image-in-folder\n duration\n (ie-story-generate-description-path scene-name nil images-dir)\n folder-descriptions)\n (--map (kdenlive-image-in-folder\n duration\n (ie-story-generate-description-path scene-name it images-dir)\n folder-descriptions)\n indexes))))\n\n(defun ie-story-generate-edited-scene-kdenlive (scene-buffer-position &optional kdenlive-dir images-dir)\n \"Generate \\\".kdenlive\\\" edited scene file of Inside Emacs video\nfor the scene at SCENE-BUFFER-POSITION in the current buffer.\n\nThe \\\".kdenlive\\\" project is saved in KDENLIVE-DIR.\nThe images used in \\\".kdenlive\\\" project are located in IMAGES-DIR.\"\n (let* ((kdenlive-dir (or kdenlive-dir ie-story-generate-kdenlive-dir))\n (images-dir (or images-dir ie-story-generate-images-dir))\n (scene-name\n (ie-story-parse-scene-title scene-buffer-position t))\n (project-name (s-concat \"edited-\" scene-name \".kdenlive\"))\n (path (f-full (f-join kdenlive-dir project-name)))\n (root (f-full kdenlive-dir))\n (duration 300)\n (folder-descriptions \"descriptions\")\n (folders `(,folder-descriptions \"helpers\" \"scenes\"))\n (images\n (ie-story-generate-description-images-for-kdenlive\n scene-buffer-position duration scene-name folder-descriptions images-dir)))\n (unless (f-exists? (f-join default-directory \"kdenlive\"))\n (f-mkdir \"kdenlive\"))\n (kdenlive-write\n (kdenlive-skeleton-with-images root folders images) path t)))\n\n(defun ie-story-generate-all-edited-scenes-kdenlive ()\n \"Generate all \\\".kdenlive\\\" edited scenes files of Inside Emacs\nfor the current buffer.\n\nThe files are saved in the subdirectory `ie-story-generate-kdenlive-dir'.\"\n (interactive)\n (org-show-all)\n (--each (ie-story-parse-scenes)\n (ie-story-generate-edited-scene-kdenlive\n it ie-story-generate-kdenlive-dir))\n (message \"edited kdenlive files saved in %s\"\n ie-story-generate-kdenlive-dir))\n\n;;; Generate both svg and kdenlive files\n\n(defun ie-story-generate-all ()\n \"Generate svg and kdenlive files of an Inside Emacs video.\n\nCall `ie-story-generate-all-descriptions-svg' and\n`ie-story-generate-all-edited-scenes-kdenlive'.\"\n (interactive)\n (ie-story-generate-all-descriptions-svg)\n (ie-story-generate-all-edited-scenes-kdenlive))\n\n;;; Comments\n\n;;;; Generate svg files\n\n(comment ; ie-story-generate-description-path\n (let ((scene \"a-scene\")\n (folder \"r-images\"))\n (f-relative (ie-story-generate-description-path scene nil folder)) ; \"r-images\/description-a-scene-title.svg\"\n (f-relative (ie-story-generate-description-path scene 1 folder)) ; \"r-images\/description-a-scene-1.svg\"\n )\n )\n\n(comment ; ie-story-generate-description-scene-title-svg\n (let ((default-directory (f-full \"test\"))\n (folder \"r-images\")\n (story\n \"#+TITLE: Inside Emacs\n#+AUTHOR: Tony aldon\n\n* a heading\n* another heading\n* scenes\n** scene 0: intro\n# description\na description splited\ninto two lines\n\n** scene 1: First Scene\n# description\nA one line paragraph\n\n# description\nwe handle only\nparagraph with 4 lines\nto be readable\nfor the reader\"))\n (unless (f-exists? default-directory) (f-mkdir default-directory))\n (with-temp-buffer\n (insert story)\n (goto-line 7)\n (ie-story-generate-description-scene-title-svg (point) folder)\n (goto-line 12)\n (ie-story-generate-description-scene-title-svg (point) folder)))\n )\n\n(comment ; ie-story-generate-description-svg\n (let ((default-directory (f-full \"test\"))\n (folder \"r-images\"))\n (unless (f-exists? default-directory) (f-mkdir default-directory))\n (ie-story-generate-description-svg '(\"line 1\") \"my-scene\" 1 folder)\n (ie-story-generate-description-svg '(\"line 1\" \"line 2\")\n \"my-scene\" 2 folder)\n (ie-story-generate-description-svg '(\"line 1\" \"line 2\" \"line 3\")\n \"my-scene\" 3 folder)\n (ie-story-generate-description-svg '(\"line 1\" \"line 2\"\n \"line 3\" \"line 4\")\n \"my-scene\" 4 folder))\n )\n\n(comment ; ie-story-generate-descriptions-in-scene-svg\n (let ((default-directory (f-full \"test\"))\n (folder \"r-images\")\n (story\n \"#+TITLE: Inside Emacs\n#+AUTHOR: Tony aldon\n\n* a heading\n* another heading\n* scenes\n** scene 0: intro\n# description\na description splited\ninto two lines\n\n** scene 1: First Scene\n# description\nA one line paragraph\n\n# description\nwe handle only\nparagraph with 4 lines\nto be readable\nfor the reader\"))\n (unless (f-exists? default-directory) (f-mkdir default-directory))\n (with-temp-buffer\n (insert story)\n (goto-line 7)\n (ie-story-generate-descriptions-in-scene-svg (point) folder)\n (goto-line 12)\n (ie-story-generate-descriptions-in-scene-svg (point) folder)))\n )\n\n(comment ; ie-story-generate-all-descriptions-svg\n (let ((default-directory (f-full \"test\"))\n (story\n \"#+TITLE: Inside Emacs\n#+AUTHOR: Tony aldon\n\n* a heading\n* another heading\n* scenes\n** scene 0: intro\n# description\na description splited\ninto two lines\n\n** scene 1: First Scene\n# description\nA one line paragraph\n\n# description\nwe handle only\nparagraph with 4 lines\nto be readable\nfor the reader\"))\n (with-temp-buffer\n (insert story)\n (call-interactively 'ie-story-generate-all-descriptions-svg)))\n )\n\n;;;; Generate kdenlive files\n\n(comment ; ie-story-generate-description-images-for-kdenlive\n (let ((default-directory (f-full \"test\"))\n (story\n \"#+TITLE: Inside Emacs\n#+AUTHOR: Tony aldon\n\n* a heading\n* another heading\n* scenes\n** scene 0: intro\n# description\na description splited\ninto two lines\n\n** scene 1: First Scene\n# description\nA one line paragraph\n\n# description\nwe handle only\nparagraph with 4 lines\nto be readable\nfor the reader\"))\n (unless (f-exists? default-directory) (f-mkdir default-directory))\n (with-temp-buffer\n (insert story)\n (goto-line 7)\n (ie-story-generate-description-images-for-kdenlive\n (point) 300 \"scene-name\" \"descriptions\" \"r-images\")\n (goto-line 12)\n (ie-story-generate-description-images-for-kdenlive\n (point) 300 \"scene-name\" \"descriptions\" \"r-images\")\n ))\n )\n\n(comment ; ie-story-generate-edited-scene-kdenlive\n (let ((default-directory (f-full \"test\"))\n (story\n \"#+TITLE: Inside Emacs\n#+AUTHOR: Tony aldon\n\n* a heading\n* another heading\n* scenes\n** scene 0: intro\n# description\na description splited\ninto two lines\n\n** scene 1: First Scene\n# description\nA one line paragraph\n\n# description\nwe handle only\nparagraph with 4 lines\nto be readable\nfor the reader\"))\n (unless (f-exists? default-directory) (f-mkdir default-directory))\n (with-temp-buffer\n (insert story)\n (goto-line 7)\n (ie-story-generate-edited-scene-kdenlive (point))\n (goto-line 12)\n (ie-story-generate-edited-scene-kdenlive (point))\n ))\n )\n\n(comment ; ie-story-generate-all-edited-scenes-kdenlive\n (let ((default-directory (f-full \"test\"))\n (story\n \"#+TITLE: Inside Emacs\n#+AUTHOR: Tony aldon\n\n* a heading\n* another heading\n* scenes\n** scene 0: intro\n# description\na description splited\ninto two lines\n\n** scene 1: First Scene\n# description\nA one line paragraph\n\n# description\nwe handle only\nparagraph with 4 lines\nto be readable\nfor the reader\"))\n (unless (f-exists? default-directory) (f-mkdir default-directory))\n (with-temp-buffer\n (insert story)\n (ie-story-generate-all-edited-scenes-kdenlive)))\n )\n\n;;;; Generate both svg and kdenlive files\n\n(comment ; ie-story-generate-all\n (let ((default-directory (f-full \"test\"))\n (story\n \"#+TITLE: Inside Emacs\n#+AUTHOR: Tony aldon\n\n* a heading\n* another heading\n* scenes\n** scene 0: intro\n# description\na description splited\ninto two lines\n\n** scene 1: First Scene\n# description\nA one line paragraph\n\n# description\nwe handle only\nparagraph with 4 lines\nto be readable\nfor the reader\"))\n (unless (f-exists? default-directory) (f-mkdir default-directory))\n (with-temp-buffer\n (insert story)\n (ie-story-generate-all)))\n )\n\n;;;; emacs-lisp\n\n(comment ; --each-indexed\n (let (l) (--each-indexed '(a b c) (push (list it it-index) l)) l) ; '((c 2) (b 1) (a 0))\n )\n\n;;; Footer\n\n(provide 'ie-story-generate)\n","avg_line_length":30.7607758621,"max_line_length":300,"alphanum_fraction":0.6836684649} {"size":1768,"ext":"el","lang":"Emacs Lisp","max_stars_count":42.0,"content":";;; random-utils.el --- Missing random functions in elisp\n\n;; Copyright (C) 2013 Wilfred Hughes \n;;\n;; Author: Wilfred Hughes \n;; Created: 3 December 2013\n;; Version: 1.0\n\n(defun random-choice (list)\n \"Return a random element from LIST.\"\n (let ((random-index (random (length list))))\n (nth random-index list)))\n\n(defun random-string (length chars)\n \"Generate a random string of LENGTH using characters in list CHARS.\"\n (let ((string \"\"))\n (while (< (length string) length)\n (setq string (concat string (random-choice chars))))\n string))\n\n(defun random-reseed-securely ()\n \"Securely reseed Emacs' random number generator.\"\n (random (shell-command \"cat < \/dev\/urandom | fold -w32 | head -n1\")))\n\n(defun wh\/words ()\n (let ((buf (find-file-noselect \"~\/.emacs.d\/user-lisp\/words.txt\")))\n (with-current-buffer buf\n (s-lines (s-trim (buffer-string))))))\n\n(defun random-xkcd-password (&optional word-count)\n (interactive)\n (unless word-count\n (setq word-count 4))\n (let ((all-words (wh\/words))\n words\n password)\n (dotimes (_ word-count)\n (push (random-choice all-words) words))\n (setq password (s-join \" \" words))\n (message \"%s (also copied to clipboard)\" password)\n (let ((select-enable-clipboard t))\n (kill-new password))))\n\n(defun random-password ()\n \"Generate a random 32 character string.\"\n (interactive)\n (random-reseed-securely)\n (let ((password\n (random-string\n 32\n (split-string\n \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 !&.|@\"\n \"\" t))))\n (message \"%s (also copied to clipboard)\" password)\n (let ((x-select-enable-clipboard t))\n (kill-new password))))\n\n(provide 'random-utils)\n","avg_line_length":29.9661016949,"max_line_length":81,"alphanum_fraction":0.645361991} {"size":443,"ext":"el","lang":"Emacs Lisp","max_stars_count":1.0,"content":";;; Generated package description from bind-key-2.4.1\/bind-key.el -*- no-byte-compile: t -*-\n(define-package \"bind-key\" \"2.4.1\" \"A simple way to manage personal keybindings\" 'nil :commit \"caa92f1d64fc25480551757d854b4b49981dfa6b\" :keywords '(\"keys\" \"keybinding\" \"config\" \"dotemacs\") :authors '((\"John Wiegley\" . \"johnw@newartisans.com\")) :maintainer '(\"John Wiegley\" . \"johnw@newartisans.com\") :url \"https:\/\/github.com\/jwiegley\/use-package\")\n","avg_line_length":147.6666666667,"max_line_length":348,"alphanum_fraction":0.7246049661} {"size":225,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(define-package \"cmd-to-echo\" \"20161203.1333\" \"Show the output of long-running commands in the echo area\" '((emacs \"24.4\") (s \"1.11.0\") (shell-split-string \"20151224.208\")) :commit \"e0e874fc0e1ad6d291e39ed76023445297ad438a\")\n","avg_line_length":112.5,"max_line_length":224,"alphanum_fraction":0.7422222222} {"size":1343,"ext":"el","lang":"Emacs Lisp","max_stars_count":14529.0,"content":";; -*- no-byte-compile: t; -*-\n;;; lang\/scheme\/packages.el\n\n(when (package! geiser :pin \"327ff01e5b9c6e019fdd0cb710a4c19082249345\")\n (package! macrostep-geiser :pin \"f6a2d5bb96ade4f23df557649af87ebd0cc45125\")\n (when (featurep! +chez)\n (package! geiser-chez :pin \"03da1c17253856d8713bc5a25140cb5002c9c188\"))\n (when (featurep! +chibi)\n (package! geiser-chibi :pin \"6f59291d8d1dc92ffd3f53f919d8cab4bf50b7d3\"))\n (when (featurep! +chicken)\n (package! geiser-chicken :pin \"ceab39c89607f55cba88e5606ba5eb37c7df5260\"))\n (when (featurep! +gambit)\n (package! geiser-gambit :pin \"3294c944d1c3b79db44ed14b133129fec454bd60\"))\n (when (featurep! +gauche)\n (package! geiser-gauche :pin \"fd52cbaed9b0a0d0f10e87674b5747e5ee44ebc9\"))\n (when (featurep! +guile)\n (package! geiser-guile :pin \"8dda28f4f1758221f84f5cb5dc5b5ca5fd56caa9\")\n (when (featurep! :checkers syntax)\n (package! flycheck-guile\n :recipe (:host github :repo \"flatwhatson\/flycheck-guile\")\n :pin \"e46d6e5453dd7471309fae6549445c48e6d8f340\")))\n (when (featurep! +kawa)\n (package! geiser-kawa :pin \"3d999a33deedd62dae60f3f7cedfbdb715587ea7\"))\n (when (featurep! +mit)\n (package! geiser-mit :pin \"d17394f577aaa2854a74a1a0039cb8f73378b400\"))\n (when (featurep! +racket)\n (package! geiser-racket :pin \"22e56ce80389544d3872cf4beb4008fb514b2218\")))\n","avg_line_length":47.9642857143,"max_line_length":78,"alphanum_fraction":0.7416232316} {"size":12581,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"<<<<<<< HEAD\n;;; init.el --- Load the full configuration -*- lexical-binding: t -*-\n;;; Commentary:\n\n;; This file bootstraps the configuration, which is divided into\n;; a number of other files.\n\n;;; Code:\n\n;; Produce backtraces when errors occur\n(setq debug-on-error t)\n\n(let ((minver \"24.4\"))\n (when (version< emacs-version minver)\n (error \"Your Emacs is too old -- this config requires v%s or higher\" minver)))\n(when (version< emacs-version \"25.1\")\n (message \"Your Emacs is old, and some functionality in this config will be disabled. Please upgrade if possible.\"))\n\n(add-to-list 'load-path (expand-file-name \"lisp\" user-emacs-directory))\n(require 'init-benchmarking) ;; Measure startup time\n\n(defconst *spell-check-support-enabled* nil) ;; Enable with t if you prefer\n(defconst *is-a-mac* (eq system-type 'darwin))\n\n;;----------------------------------------------------------------------------\n;; Adjust garbage collection thresholds during startup, and thereafter\n;;----------------------------------------------------------------------------\n(let ((normal-gc-cons-threshold (* 20 1024 1024))\n (init-gc-cons-threshold (* 128 1024 1024)))\n (setq gc-cons-threshold init-gc-cons-threshold)\n (add-hook 'emacs-startup-hook\n (lambda () (setq gc-cons-threshold normal-gc-cons-threshold))))\n\n;;----------------------------------------------------------------------------\n;; Bootstrap config\n;;----------------------------------------------------------------------------\n(setq custom-file (expand-file-name \"custom.el\" user-emacs-directory))\n(require 'init-utils)\n(require 'init-site-lisp) ;; Must come before elpa, as it may provide package.el\n;; Calls (package-initialize)\n(require 'init-elpa) ;; Machinery for installing required packages\n(require 'init-exec-path) ;; Set up $PATH\n\n;;----------------------------------------------------------------------------\n;; Allow users to provide an optional \"init-preload-local.el\"\n;;----------------------------------------------------------------------------\n(require 'init-preload-local nil t)\n\n;;----------------------------------------------------------------------------\n;; Load configs for specific features and modes\n;;----------------------------------------------------------------------------\n\n(require-package 'diminish)\n(require-package 'scratch)\n(require-package 'command-log-mode)\n\n(require 'init-frame-hooks)\n(require 'init-xterm)\n(require 'init-themes)\n(require 'init-osx-keys)\n(require 'init-gui-frames)\n(require 'init-dired)\n(require 'init-isearch)\n(require 'init-grep)\n(require 'init-uniquify)\n(require 'init-ibuffer)\n(require 'init-flycheck)\n\n(require 'init-recentf)\n(require 'init-smex)\n(require 'init-ivy)\n(require 'init-helm)\n(require 'init-hippie-expand)\n(require 'init-company)\n(require 'init-windows)\n(require 'init-sessions)\n(require 'init-mmm)\n\n(require 'init-editing-utils)\n(require 'init-whitespace)\n\n(require 'init-vc)\n(require 'init-darcs)\n(require 'init-git)\n(require 'init-github)\n\n(require 'init-projectile)\n\n(require 'init-compile)\n(require 'init-textile)\n(require 'init-markdown)\n(require 'init-csv)\n(require 'init-erlang)\n(require 'init-javascript)\n(require 'init-php)\n(require 'init-org)\n(require 'init-nxml)\n(require 'init-html)\n(require 'init-css)\n(require 'init-haml)\n(require 'init-http)\n(require 'init-python)\n(require 'init-haskell)\n(require 'init-elm)\n(require 'init-purescript)\n(require 'init-ruby)\n(require 'init-rails)\n(require 'init-sql)\n(require 'init-rust)\n(require 'init-toml)\n(require 'init-yaml)\n(require 'init-docker)\n(require 'init-terraform)\n(require 'init-golang)\n;;(require 'init-nix)\n(maybe-require-package 'nginx-mode)\n\n(require 'init-paredit)\n(require 'init-lisp)\n(require 'init-slime)\n(require 'init-clojure)\n(require 'init-clojure-cider)\n(require 'init-common-lisp)\n\n(when *spell-check-support-enabled*\n (require 'init-spelling))\n\n(require 'init-misc)\n\n(require 'init-folding)\n(require 'init-dash)\n\n;;(require 'init-twitter)\n;; (require 'init-mu)\n(require 'init-ledger)\n;; Extra packages which don't require any configuration\n\n(require-package 'gnuplot)\n(require-package 'lua-mode)\n(require-package 'htmlize)\n(require-package 'dsvn)\n(when *is-a-mac*\n (require-package 'osx-location))\n(unless (eq system-type 'windows-nt)\n (maybe-require-package 'daemons))\n(maybe-require-package 'dotenv-mode)\n\n(when (maybe-require-package 'uptimes)\n (setq-default uptimes-keep-count 200)\n (add-hook 'after-init-hook (lambda () (require 'uptimes))))\n\n\n;;----------------------------------------------------------------------------\n;; Allow access from emacsclient\n;;----------------------------------------------------------------------------\n(add-hook 'after-init-hook\n (lambda ()\n (require 'server)\n (unless (server-running-p)\n (server-start))))\n\n;;----------------------------------------------------------------------------\n;; Variables configured via the interactive 'customize' interface\n;;----------------------------------------------------------------------------\n(when (file-exists-p custom-file)\n (load custom-file))\n\n\n;;----------------------------------------------------------------------------\n;; Locales (setting them earlier in this file doesn't work in X)\n;;----------------------------------------------------------------------------\n(require 'init-locales)\n\n\n;;----------------------------------------------------------------------------\n;; Allow users to provide an optional \"init-local\" containing personal settings\n;;----------------------------------------------------------------------------\n(require 'init-local nil t)\n\n\n\n(provide 'init)\n\n;; Local Variables:\n;; coding: utf-8\n;; no-byte-compile: t\n;; End:\n;;; init.el ends here\n(require 'org)\n(package-initialize)\n(require 'ein)\n(require 'ein-notebook)\n(require 'ein-subpackages)\n=======\n;;; init.el --- Prelude's configuration entry point.\n;;\n;; Copyright (c) 2011-2018 Bozhidar Batsov\n;;\n;; Author: Bozhidar Batsov \n;; URL: http:\/\/batsov.com\/prelude\n;; Version: 1.0.0\n;; Keywords: convenience\n\n;; This file is not part of GNU Emacs.\n\n;;; Commentary:\n\n;; This file simply sets up the default load path and requires\n;; the various modules defined within Emacs Prelude.\n\n;;; License:\n\n;; This program is free software; you can redistribute it and\/or\n;; modify it under the terms of the GNU General Public License\n;; as published by the Free Software Foundation; either version 3\n;; of the License, or (at your option) any later version.\n;;\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n;;\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs; see the file COPYING. If not, write to the\n;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,\n;; Boston, MA 02110-1301, USA.\n\n;;; Code:\n\n;; Added by Package.el. This must come before configurations of\n;; installed packages. Don't delete this line. If you don't want it,\n;; just comment it out by adding a semicolon to the start of the line.\n;; You may delete these explanatory comments.\n;(package-initialize)\n\n(defvar current-user\n (getenv\n (if (equal system-type 'windows-nt) \"USERNAME\" \"USER\")))\n\n(message \"Prelude is powering up... Be patient, Master %s!\" current-user)\n\n(when (version< emacs-version \"25.1\")\n (error \"Prelude requires GNU Emacs 25.1 or newer, but you're running %s\" emacs-version))\n\n;; Always load newest byte code\n(setq load-prefer-newer t)\n\n(defvar prelude-dir (file-name-directory load-file-name)\n \"The root dir of the Emacs Prelude distribution.\")\n(defvar prelude-core-dir (expand-file-name \"core\" prelude-dir)\n \"The home of Prelude's core functionality.\")\n(defvar prelude-modules-dir (expand-file-name \"modules\" prelude-dir)\n \"This directory houses all of the built-in Prelude modules.\")\n(defvar prelude-personal-dir (expand-file-name \"personal\" prelude-dir)\n \"This directory is for your personal configuration.\n\nUsers of Emacs Prelude are encouraged to keep their personal configuration\nchanges in this directory. All Emacs Lisp files there are loaded automatically\nby Prelude.\")\n(defvar prelude-personal-preload-dir (expand-file-name \"preload\" prelude-personal-dir)\n \"This directory is for your personal configuration, that you want loaded before Prelude.\")\n(defvar prelude-vendor-dir (expand-file-name \"vendor\" prelude-dir)\n \"This directory houses packages that are not yet available in ELPA (or MELPA).\")\n(defvar prelude-savefile-dir (expand-file-name \"savefile\" prelude-dir)\n \"This folder stores all the automatically generated save\/history-files.\")\n(defvar prelude-modules-file (expand-file-name \"prelude-modules.el\" prelude-personal-dir)\n \"This file contains a list of modules that will be loaded by Prelude.\")\n(defvar prelude-deprecated-modules-file\n (expand-file-name \"prelude-modules.el\" prelude-dir)\n (format \"This file may contain a list of Prelude modules.\n\nThis is DEPRECATED, use %s instead.\" prelude-modules-file))\n\n(unless (file-exists-p prelude-savefile-dir)\n (make-directory prelude-savefile-dir))\n\n(defun prelude-add-subfolders-to-load-path (parent-dir)\n \"Add all level PARENT-DIR subdirs to the `load-path'.\"\n (dolist (f (directory-files parent-dir))\n (let ((name (expand-file-name f parent-dir)))\n (when (and (file-directory-p name)\n (not (string-prefix-p \".\" f)))\n (add-to-list 'load-path name)\n (prelude-add-subfolders-to-load-path name)))))\n\n;; add Prelude's directories to Emacs's `load-path'\n(add-to-list 'load-path prelude-core-dir)\n(add-to-list 'load-path prelude-modules-dir)\n(add-to-list 'load-path prelude-vendor-dir)\n(prelude-add-subfolders-to-load-path prelude-vendor-dir)\n\n;; reduce the frequency of garbage collection by making it happen on\n;; each 50MB of allocated data (the default is on every 0.76MB)\n(setq gc-cons-threshold 50000000)\n\n;; warn when opening files bigger than 100MB\n(setq large-file-warning-threshold 100000000)\n\n;; preload the personal settings from `prelude-personal-preload-dir'\n(when (file-exists-p prelude-personal-preload-dir)\n (message \"Loading personal configuration files in %s...\" prelude-personal-preload-dir)\n (mapc 'load (directory-files prelude-personal-preload-dir 't \"^[^#\\.].*el$\")))\n\n(message \"Loading Prelude's core...\")\n\n;; the core stuff\n(require 'prelude-packages)\n(require 'prelude-custom) ;; Needs to be loaded before core, editor and ui\n(require 'prelude-ui)\n(require 'prelude-core)\n(require 'prelude-mode)\n(require 'prelude-editor)\n(require 'prelude-global-keybindings)\n\n;; macOS specific settings\n(when (eq system-type 'darwin)\n (require 'prelude-macos))\n\n;; Linux specific settings\n(when (eq system-type 'gnu\/linux)\n (require 'prelude-linux))\n\n(message \"Loading Prelude's modules...\")\n\n;; the modules\n(if (file-exists-p prelude-modules-file)\n (progn\n (load prelude-modules-file)\n (if (file-exists-p prelude-deprecated-modules-file)\n (message \"Loading new modules configuration, ignoring DEPRECATED prelude-module.el\")))\n (if (file-exists-p prelude-deprecated-modules-file)\n (progn\n (load prelude-deprecated-modules-file)\n (message (format \"The use of %s is DEPRECATED! Use %s instead!\"\n prelude-deprecated-modules-file\n prelude-modules-file)))\n (message \"Missing modules file %s\" prelude-modules-file)\n (message \"You can get started by copying the bundled example file from sample\/prelude-modules.el\")))\n\n;; config changes made through the customize UI will be stored here\n(setq custom-file (expand-file-name \"custom.el\" prelude-personal-dir))\n\n;; load the personal settings (this includes `custom-file')\n(when (file-exists-p prelude-personal-dir)\n (message \"Loading personal configuration files in %s...\" prelude-personal-dir)\n (mapc 'load (delete\n prelude-modules-file\n (directory-files prelude-personal-dir 't \"^[^#\\.].*\\\\.el$\"))))\n\n(message \"Prelude is ready to do thy bidding, Master %s!\" current-user)\n\n;; Patch security vulnerability in Emacs versions older than 25.3\n(when (version< emacs-version \"25.3\")\n (with-eval-after-load \"enriched\"\n (defun enriched-decode-display-prop (start end &optional param)\n (list start end))))\n\n(prelude-eval-after-init\n ;; greet the use with some useful tip\n (run-at-time 5 nil 'prelude-tip-of-the-day))\n\n;;; init.el ends here\n>>>>>>> 1ec67804787b43153f3aaaf9feed3fa9d1d5fa06\n","avg_line_length":34.5631868132,"max_line_length":117,"alphanum_fraction":0.6482791511} {"size":2683,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(custom-set-variables\n ;; custom-set-variables was added by Custom.\n ;; If you edit it by hand, you could mess it up, so be careful.\n ;; Your init file should contain only one such instance.\n ;; If there is more than one, they won't work right.\n '(company-auto-commit nil)\n '(company-dabbrev-downcase nil)\n '(company-eclim-executable nil)\n '(company-minimum-prefix-length 1)\n '(company-show-numbers t)\n '(company-tooltip-idle-delay 0.08)\n '(custom-safe-themes\n '(\"d3a406c5905923546d8a3ad0164a266deaf451856eca5f21b36594ffcb08413a\" \"c59857e3e950131e0c17c65711f1812d20a54b829115b7c522672ae6ba0864cc\" default))\n '(ecb-auto-activate t)\n '(ecb-auto-expand-tag-tree 'all)\n '(ecb-auto-update-methods-after-save t)\n '(ecb-layout-name \"left9\")\n '(ecb-layout-window-sizes\n '((\"left9\"\n (ecb-methods-buffer-name 0.12871287128712872 . 0.9833333333333333))))\n '(ecb-options-version \"2.50\")\n '(ecb-tip-of-the-day nil)\n '(ecb-toggle-layout-sequence '(\"left9\"))\n '(eclim-executable \"\/Applications\/Eclipse.app\/Contents\/Eclipse\/eclim\")\n '(eclimd-executable \"\/Applications\/Eclipse.app\/Contents\/Eclipse\/eclimd\")\n '(font-lock-global-modes '(not speedbar-mode))\n '(global-company-mode t)\n '(imenu-list-minor-mode nil)\n '(imenu-list-position 'left)\n '(imenu-list-size 0.1)\n '(lsp-auto-execute-action nil)\n '(lsp-headerline-breadcrumb-enable t)\n '(lsp-idle-delay 0.1)\n '(lsp-ui-doc-position 'bottom t)\n '(org-emphasis-alist\n '((\"*\" bold)\n (\"\/\" italic)\n (\"_\" underline)\n (\"=\" org-verbatim verbatim)\n (\"~\" org-code verbatim)\n (\"+\"\n (:strike-through t))))\n '(org-trello-current-prefix-keybinding \"C-c o\")\n '(package-selected-packages\n '(json-mode yang-mode dashboard markdown-toc use-package hide-mode-line lsp-treemacs lsp-ui helm-ls-git which-key quickrun helm-company company company-box multiple-cursors org-download rainbow-delimiters smartparens undo-tree hungry-delete yasnippet-snippets monokai-theme move-text goto-line-preview window-numbering helm-gtags helm-c-yasnippet helm-ag column-enforce-mode bug-hunter))\n '(rainbow-identifiers-choose-face-function 'ostnm\/rainbow-identifiers-predefined-choose-face)\n '(yas-inhibit-overlay-modification-protection t))\n(custom-set-faces\n ;; custom-set-faces was added by Custom.\n ;; If you edit it by hand, you could mess it up, so be careful.\n ;; Your init file should contain only one such instance.\n ;; If there is more than one, they won't work right.\n '(font-lock-function-name-face ((t (:foreground \"#A6E22E\" :weight bold :height 1.3))))\n '(imenu-list-entry-face-0 ((t (:inherit imenu-list-entry-face :foreground \"light green\"))))\n '(imenu-list-entry-face-1 ((t (:inherit imenu-list-entry-face :foreground \"gold\")))))\n","avg_line_length":47.9107142857,"max_line_length":390,"alphanum_fraction":0.7279165114} {"size":1860,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(add-auto-mode\r\n 'nxml-mode\r\n (concat \"\\\\.\"\r\n (regexp-opt\r\n '(\"xml\" \"xsd\" \"sch\" \"rng\" \"xslt\" \"svg\" \"rss\"\r\n \"gpx\" \"tcx\" \"plist\"))\r\n \"\\\\'\"))\r\n(setq magic-mode-alist (cons '(\"<\\\\?xml \" . nxml-mode) magic-mode-alist))\r\n(fset 'xml-mode 'nxml-mode)\r\n(add-hook 'nxml-mode-hook (lambda ()\r\n (set (make-local-variable 'ido-use-filename-at-point) nil)))\r\n(setq nxml-slash-auto-complete-flag t)\r\n\r\n\r\n;; See: http:\/\/sinewalker.wordpress.com\/2008\/06\/26\/pretty-printing-xml-with-emacs-nxml-mode\/\r\n(defun sanityinc\/pp-xml-region (beg end)\r\n \"Pretty format XML markup in region. The function inserts\r\nlinebreaks to separate tags that have nothing but whitespace\r\nbetween them. It then indents the markup by using nxml's\r\nindentation rules.\"\r\n (interactive \"r\")\r\n (unless (use-region-p)\r\n (setq beg (point-min)\r\n end (point-max)))\r\n ;; Use markers because our changes will move END\r\n (setq beg (set-marker (make-marker) begin)\r\n end (set-marker (make-marker) end))\r\n (save-excursion\r\n (goto-char beg)\r\n (while (search-forward-regexp \"\\>[ \\\\t]*\\<\" end t)\r\n (backward-char) (insert \"\\n\"))\r\n (nxml-mode)\r\n (indent-region begin end)))\r\n\r\n;;----------------------------------------------------------------------------\r\n;; Integration with tidy for html + xml\r\n;;----------------------------------------------------------------------------\r\n(require-package 'tidy)\r\n(add-hook 'nxml-mode-hook (lambda () (tidy-build-menu nxml-mode-map)))\r\n\r\n(defun sanityinc\/tidy-buffer-xml (beg end)\r\n \"Run \\\"tidy -xml\\\" on the region from BEG to END, or whole buffer.\"\r\n (interactive \"r\")\r\n (unless (use-region-p)\r\n (setq beg (point-min)\r\n end (point-max)))\r\n (shell-command-on-region beg end \"tidy -xml -q -i\" (current-buffer) t \"*tidy-errors*\" t))\r\n\r\n\r\n(provide 'init-nxml)\r\n","avg_line_length":36.4705882353,"max_line_length":93,"alphanum_fraction":0.5623655914} {"size":139,"ext":"el","lang":"Emacs Lisp","max_stars_count":20.0,"content":";;; Directory Local Variables\n;;; For more information see (info \"(emacs) Directory Variables\")\n\n((markdown-mode\n (eval auto-fill-mode)))\n","avg_line_length":23.1666666667,"max_line_length":65,"alphanum_fraction":0.7122302158} {"size":3710,"ext":"el","lang":"Emacs Lisp","max_stars_count":157.0,"content":";;; An asynchronous data model sample for ctable.el -*- lexical-binding: t; -*-\n\n(require 'ctable)\n(require 'deferred)\n\n\f\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; synchronous version\n\n(defun ctbl:sync-demo1 ()\n (interactive)\n (ctbl:open-table-buffer-easy\n (cl-loop with lim = 4000\n for i from 0 upto lim\n for d = (\/ (random 1000) 1000.0)\n collect \n (list i d (exp (- (\/ i 1.0 lim))) (exp (* (- (\/ i 1.0 lim)) d))))))\n\n;; (ctbl:sync-demo1) ; 5 seconds to display!\n\n\f\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; asynchronous version\n\n(defun ctbl:async-demo ()\n \"Sample code for implementation for async data model table.\"\n (interactive)\n (let ((param (copy-ctbl:param ctbl:default-rendering-param)))\n (setf (ctbl:param-fixed-header param) t)\n (let* ((async-model ; define async-data-model\n (make-ctbl:async-model\n :request 'ctbl:async-demo-request\n :cancel 'ctbl:async-demo-cancel\n :reset 'ctbl:async-demo-reset\n :init-num 40 :more-num 20))\n (cp\n (ctbl:create-table-component-buffer\n :model\n (make-ctbl:model\n :column-model\n (list (make-ctbl:cmodel :title \"row\")\n (make-ctbl:cmodel :title \"delta\")\n (make-ctbl:cmodel :title \"exp\")\n (make-ctbl:cmodel :title \"exp-delta\"))\n :data async-model) ; here!\n :param param)))\n (ctbl:cp-add-click-hook\n cp (lambda () (message \"CTable : Click Hook [%S]\"\n (ctbl:cp-get-selected-data-row cp))))\n (pop-to-buffer (ctbl:cp-get-buffer cp)))))\n\n(defvar ctbl:async-demo-timer nil)\n\n(defun ctbl:async-demo-request (row-num len responsef errorf &rest _)\n (let \n ((row-num row-num) (len len)\n (responsef responsef) (errorf errorf))\n (setq ctbl:async-demo-timer\n (deferred:$\n (deferred:wait 500)\n (deferred:nextc it\n (lambda (x) \n (setq ctbl:async-demo-timer nil)\n (funcall responsef\n (if (< 500 row-num) nil\n (cl-loop with lim = 100\n for i from row-num below (+ row-num len)\n for d = (\/ (random 1000) 1000.0)\n collect\n (list i d (exp (- (\/ i 1.0 lim)))\n (exp (* (- (\/ i 1.0 lim)) d))))))))))))\n\n(defun ctbl:async-demo-reset (&rest)\n (message \"RESET async data!!\"))\n\n(defun ctbl:async-demo-cancel (&rest)\n (when ctbl:async-demo-timer\n (deferred:cancel ctbl:async-demo-timer)))\n\n;; (progn (eval-buffer) (ctbl:async-demo))\n\n\n\f\n;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n;;; async wrapper version\n\n(defun ctbl:sync-demo2 ()\n (interactive)\n (let* ((async-model ; wrapping a huge data in async-data-model\n (ctbl:async-model-wrapper\n (cl-loop with lim = 4000\n for i from 0 upto lim\n for d = (\/ (random 1000) 1000.0)\n collect \n (list i d (exp (- (\/ i 1.0 lim))) (exp (* (- (\/ i 1.0 lim)) d))))))\n (cp\n (ctbl:create-table-component-buffer\n :model\n (make-ctbl:model\n :column-model\n (list (make-ctbl:cmodel :title \"row\")\n (make-ctbl:cmodel :title \"delta\")\n (make-ctbl:cmodel :title \"exp\")\n (make-ctbl:cmodel :title \"exp-delta\"))\n :data async-model))))\n (pop-to-buffer (ctbl:cp-get-buffer cp))))\n\n;; (progn (eval-current-buffer) (ctbl:sync-demo2))\n\n\n","avg_line_length":33.4234234234,"max_line_length":84,"alphanum_fraction":0.4900269542} {"size":88,"ext":"el","lang":"Emacs Lisp","max_stars_count":3.0,"content":"(define-package \"cl-lib\" \"0.5\" \"Properly prefixed CL functions and macros\" (quote nil))\n","avg_line_length":44.0,"max_line_length":87,"alphanum_fraction":0.7272727273} {"size":180,"ext":"el","lang":"Emacs Lisp","max_stars_count":3.0,"content":";;; tools\/magit.el -*- lexical-binding: t; -*-\n\n(use-package magit\n :ensure-system-package git\n :commands magit-status\n :config\n (setq magit-section-visibility-indicator nil))\n","avg_line_length":22.5,"max_line_length":48,"alphanum_fraction":0.7055555556} {"size":10219,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; exec-path-from-shell.el --- Get environment variables such as $PATH from the shell\n\n;; `exec-path' used by a windowed Emacs instance will usually be the\n;; system-wide default path, rather than that seen in a terminal\n;; window.\n\n;; This library allows the user to set Emacs' `exec-path' and $PATH\n;; from the shell path, so that `shell-command', `compile' and the\n;; like work as expected.\n\n;; It also allows other environment variables to be retrieved from the\n;; shell, so that Emacs will see the same values you get in a terminal.\n\n;; If you use a non-POSIX-standard shell like \"tcsh\" or \"fish\", your\n;; shell will be asked to execute \"sh\" as a subshell in order to print\n;; out the variables in a format which can be reliably parsed. \"sh\"\n;; must be a POSIX-compliant shell in this case.\n\n;; Note that shell variables which have not been exported as\n;; environment variables (e.g. using the \"export\" keyword) may not be\n;; visible to `exec-path-from-shell'.\n\n;; Installation:\n\n;; ELPA packages are available on Marmalade and MELPA. Alternatively,\n;; place this file on a directory in your `load-path', and explicitly\n;; require it.\n\n;; Usage:\n;;\n;; (require 'exec-path-from-shell) ;; if not using the ELPA package\n;; (exec-path-from-shell-initialize)\n;;\n;; Customize `exec-path-from-shell-variables' to modify the list of\n;; variables imported.\n;;\n;; If you use your Emacs config on other platforms, you can instead\n;; make initialization conditional as follows:\n;;\n;; (when (memq window-system '(mac ns))\n;; (exec-path-from-shell-initialize))\n;;\n;; Alternatively, you can use `exec-path-from-shell-copy-envs' or\n;; `exec-path-from-shell-copy-env' directly, e.g.\n;;\n;; (exec-path-from-shell-copy-env \"PYTHONPATH\")\n\n;;; Code:\n\n(defgroup exec-path-from-shell nil\n \"Make Emacs use shell-defined values for $PATH etc.\"\n :prefix \"exec-path-from-shell-\"\n :group 'environment)\n\n(defcustom exec-path-from-shell-variables\n '(\"PATH\" \"MANPATH\")\n \"List of environment variables which are copied from the shell.\"\n :type '(repeat (string :tag \"Environment variable\"))\n :group 'exec-path-from-shell)\n\n(defcustom exec-path-from-shell-check-startup-files t\n \"If non-nil, warn if variables are being set in the wrong shell startup files.\nEnvironment variables should be set in .profile or .zshenv rather than\n.bashrc or .zshrc.\"\n :type 'boolean\n :group 'exec-path-from-shell)\n\n(defcustom exec-path-from-shell-shell-name nil\n \"If non-nil, use this shell executable.\nOtherwise, use either `shell-file-name' (if set), or the value of\nthe SHELL environment variable.\"\n :type '(choice\n (file :tag \"Shell executable\")\n (const :tag \"Use `shell-file-name' or $SHELL\" nil))\n :group 'exec-path-from-shell)\n\n(defvar exec-path-from-shell-debug nil\n \"Display debug info when non-nil.\")\n\n(defun exec-path-from-shell--double-quote (s)\n \"Double-quote S, escaping any double-quotes already contained in it.\"\n (concat \"\\\"\" (replace-regexp-in-string \"\\\"\" \"\\\\\\\\\\\"\" s) \"\\\"\"))\n\n(defun exec-path-from-shell--shell ()\n \"Return the shell to use.\nSee documentation for `exec-path-from-shell-shell-name'.\"\n (or\n exec-path-from-shell-shell-name\n shell-file-name\n (getenv \"SHELL\")\n (error \"SHELL environment variable is unset\")))\n\n(defcustom exec-path-from-shell-arguments\n (if (string-match-p \"t?csh$\" (exec-path-from-shell--shell))\n (list \"-d\")\n (list \"-l\" \"-i\"))\n \"Additional arguments to pass to the shell.\n\nThe default value denotes an interactive login shell.\"\n :type '(repeat (string :tag \"Shell argument\"))\n :group 'exec-path-from-shell)\n\n(defun exec-path-from-shell--debug (msg &rest args)\n \"Print MSG and ARGS like `message', but only if debug output is enabled.\"\n (when exec-path-from-shell-debug\n (apply 'message msg args)))\n\n(defun exec-path-from-shell--standard-shell-p (shell)\n \"Return non-nil iff the shell supports the standard ${VAR-default} syntax.\"\n (not (string-match \"\\\\(fish\\\\|t?csh\\\\)$\" shell)))\n\n(defun exec-path-from-shell-printf (str &optional args)\n \"Return the result of printing STR in the user's shell.\n\nExecutes the shell as interactive login shell.\n\nSTR is inserted literally in a single-quoted argument to printf,\nand may therefore contain backslashed escape sequences understood\nby printf.\n\nARGS is an optional list of args which will be inserted by printf\nin place of any % placeholders in STR. ARGS are not automatically\nshell-escaped, so they may contain $ etc.\"\n (let* ((printf-bin (or (executable-find \"printf\") \"printf\"))\n (printf-command\n (concat printf-bin\n \" '__RESULT\\\\000\" str \"\\\\000__RESULT' \"\n (mapconcat #'exec-path-from-shell--double-quote args \" \")))\n (shell (exec-path-from-shell--shell))\n (shell-args (append exec-path-from-shell-arguments\n (list \"-c\"\n (if (exec-path-from-shell--standard-shell-p shell)\n printf-command\n (concat \"sh -c \" (shell-quote-argument printf-command)))))))\n (with-temp-buffer\n (exec-path-from-shell--debug \"Invoking shell %s with args %S\" shell shell-args)\n (let ((exit-code (apply #'call-process shell nil t nil shell-args)))\n (exec-path-from-shell--debug \"Shell printed: %S\" (buffer-string))\n (unless (zerop exit-code)\n (error \"Non-zero exit code from shell %s invoked with args %S. Output was:\\n%S\"\n shell shell-args (buffer-string))))\n (goto-char (point-min))\n (if (re-search-forward \"__RESULT\\0\\\\(.*\\\\)\\0__RESULT\" nil t)\n (match-string 1)\n (error \"Expected printf output from shell, but got: %S\" (buffer-string))))))\n\n(defun exec-path-from-shell-getenvs (names)\n \"Get the environment variables with NAMES from the user's shell.\n\nExecute the shell according to `exec-path-from-shell-arguments'.\nThe result is a list of (NAME . VALUE) pairs.\"\n (let* ((random-default (md5 (format \"%s%s%s\" (emacs-pid) (random) (current-time))))\n (dollar-names (mapcar (lambda (n) (format \"${%s-%s}\" n random-default)) names))\n (values (split-string (exec-path-from-shell-printf\n (mapconcat #'identity (make-list (length names) \"%s\") \"\\\\000\")\n dollar-names) \"\\0\")))\n (let (result)\n (while names\n (prog1\n (let ((value (car values)))\n (push (cons (car names)\n (unless (string-equal random-default value)\n value))\n result))\n (setq values (cdr values)\n names (cdr names))))\n result)))\n\n(defun exec-path-from-shell-getenv (name)\n \"Get the environment variable NAME from the user's shell.\n\nExecute the shell as interactive login shell, have it output the\nvariable of NAME and return this output as string.\"\n (cdr (assoc name (exec-path-from-shell-getenvs (list name)))))\n\n(defun exec-path-from-shell-setenv (name value)\n \"Set the value of environment var NAME to VALUE.\nAdditionally, if NAME is \\\"PATH\\\" then also set corresponding\nvariables such as `exec-path'.\"\n (setenv name value)\n (when (string-equal \"PATH\" name)\n (setq eshell-path-env value\n exec-path (append (parse-colon-path value) (list exec-directory)))))\n\n;;;###autoload\n(defun exec-path-from-shell-copy-envs (names)\n \"Set the environment variables with NAMES from the user's shell.\n\nAs a special case, if the variable is $PATH, then `exec-path' and\n`eshell-path-env' are also set appropriately. The result is an alist,\nas described by `exec-path-from-shell-getenvs'.\"\n (let ((pairs (exec-path-from-shell-getenvs names)))\n (when exec-path-from-shell-check-startup-files\n (exec-path-from-shell--maybe-warn-about-startup-files pairs))\n (mapc (lambda (pair)\n (exec-path-from-shell-setenv (car pair) (cdr pair)))\n pairs)))\n\n(defun exec-path-from-shell--maybe-warn-about-startup-files (pairs)\n \"Warn the user if the value of PAIRS seems to depend on interactive shell startup files.\"\n (let ((without-minus-i (remove \"-i\" exec-path-from-shell-arguments)))\n ;; If the user is using \"-i\", we warn them if it is necessary.\n (unless (eq exec-path-from-shell-arguments without-minus-i)\n (let* ((exec-path-from-shell-arguments without-minus-i)\n (alt-pairs (exec-path-from-shell-getenvs (mapcar 'car pairs)))\n different)\n (dolist (pair pairs)\n (unless (equal pair (assoc (car pair) alt-pairs))\n (push (car pair) different)))\n (when different\n (message \"You appear to be setting environment variables %S in your .bashrc or .zshrc: those files are only read by interactive shells, so you should instead set environment variables in startup files like .profile, .bash_profile or .zshenv. Refer to your shell's man page for more info. Customize `exec-path-from-shell-arguments' to remove \\\"-i\\\" when done, or disable `exec-path-from-shell-check-startup-files' to disable this message.\" different))))))\n\n;;;###autoload\n(defun exec-path-from-shell-copy-env (name)\n \"Set the environment variable $NAME from the user's shell.\n\nAs a special case, if the variable is $PATH, then `exec-path' and\n`eshell-path-env' are also set appropriately. Return the value\nof the environment variable.\"\n (interactive \"sCopy value of which environment variable from shell? \")\n (cdar (exec-path-from-shell-copy-envs (list name))))\n\n;;;###autoload\n(defun exec-path-from-shell-initialize ()\n \"Initialize environment from the user's shell.\n\nThe values of all the environment variables named in\n`exec-path-from-shell-variables' are set from the corresponding\nvalues used in the user's shell.\"\n (interactive)\n (exec-path-from-shell-copy-envs exec-path-from-shell-variables))\n\n\n(provide 'exec-path-from-shell)\n\n;; Local Variables:\n;; coding: utf-8\n;; indent-tabs-mode: nil\n;; mangle-whitespace: t\n;; require-final-newline: t\n;; checkdoc-minor-mode: t\n;; End:\n\n;;; exec-path-from-shell.el ends here\n","avg_line_length":41.7102040816,"max_line_length":466,"alphanum_fraction":0.6612192974} {"size":3496,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":";; logview.el --- major mode to view log files\n;; Copyright (C) 2015-2019 Dan Harms (dharms)\n;; Author: Dan Harms \n;; Created: Saturday, February 28, 2015\n;; Modified Time-stamp: <2019-07-11 16:06:50 dan.harms>\n;; Keywords: tools\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Commentary:\n;; Provide utilities to examine application log files.\n;;\n\n;;; Code:\n(require 'autorevert)\n\n(defgroup logview-mode nil \"*log file mode\" :group 'logview)\n\n(defvar logview-mode-font-lock-keywords nil\n \"Keywords used in logview-mode.\")\n\n(defcustom logview-user-initials \"\"\n \"User-specific keyword to highlight as a comment in log files.\")\n\n(defun logview-hide-ctrl-a ()\n \"Don't show `C-a' in log files.\nThis helps delimit fields in the fix protocol, using a pipe `|'.\"\n (interactive)\n (setq buffer-display-table (make-display-table))\n (aset buffer-display-table ?\\^A [?|]))\n\n(add-hook 'logview-mode-hook #'logview-hide-ctrl-a)\n\n(defun logview-mode()\n \"This logview mode is a mode for browsing log files.\"\n (interactive)\n (kill-all-local-variables)\n (setq major-mode 'logview-mode)\n (setq mode-name \"logview\")\n ;; (modify-syntax-entry ?_ \"w\")\n (make-local-variable 'font-lock-defaults)\n (setq logview-mode-font-lock-keywords\n (list\n (list \"\\\\<\\\\(ERROR\\\\|FATAL\\\\|WARN\\\\|[^W]error\\\\)\\\\>\"\n '(1 font-lock-warning-face))\n\n ;; log statements\n ;; TODO: insert regex here\n ;; '(1 font-lock-builtin-face)\n ;; '(2 font-lock-function-name-face)\n ;; '(3 font-lock-keyword-face)\n ;; '(4 font-lock-constant-face)\n ;; '(5 font-lock-warning-face)\n ;; '(6 font-lock-variable-name-face)\n\n ;; single quote strings\n (list \"[^\\\\]'.+?[^\\\\]'\" '(0 font-lock-string-face))\n ;; key=value pairs\n (list \"\\\\([^[:space:];|=<',]+\\\\)=\\\\([^[:space:];|=',]*\\\\)\"\n '(1 font-lock-variable-name-face)\n '(2 font-lock-constant-face))\n (list \"<.+?>\" '(0 font-lock-doc-face))\n ;; text within brackets\n (list \"\\\\[.+?\\\\]\" '(0 font-lock-keyword-face))\n ;; ip address:port (overrides prior fontification)\n (list \"\\\\(\\\\(?:[[:digit:]]+\\\\.\\\\)\\\\{3\\\\}[[:digit:]]+\\\\)\\\\(:[[:digit:]]\\\\{2,5\\\\}\\\\)?\"\n '(1 font-lock-variable-name-face t)\n '(2 font-lock-constant-face t t))\n ;; personal debug statements\n (list logview-user-initials '(0 font-lock-comment-face t))\n ))\n (setq font-lock-defaults '(logview-mode-font-lock-keywords))\n (run-hooks 'logview-mode-hook)\n )\n\n;;;###autoload\n(defun logview-enter-tail-mode ()\n \"Enable `auto-revert-tail-mode' for the current buffer.\"\n (interactive)\n (setq auto-revert-interval 2)\n (set (make-local-variable 'auto-revert-remote-files) t)\n (auto-revert-set-timer)\n (auto-revert-tail-mode 1))\n\n(provide 'logview)\n;;; logview.el ends here\n","avg_line_length":35.6734693878,"max_line_length":93,"alphanum_fraction":0.6272883295} {"size":1264,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(eval-when-compile\n (require 'use-package))\n\n(use-package helm\n :ensure t)\n\n(use-package projectile\n :ensure t)\n\n(use-package helm-projectile\n :ensure t)\n\n(use-package projectile-rails\n :ensure t)\n\n(use-package window-purpose\n :ensure t)\n\n(use-package magit\n :ensure t)\n\n(use-package exec-path-from-shell\n :ensure t)\n\n(use-package znc\n :ensure t)\n\n(use-package pomodoro\n :ensure t)\n\n(use-package xclip\n :ensure t)\n\n(use-package color-theme-sanityinc-tomorrow\n :ensure t\n :config\n (load-theme 'sanityinc-tomorrow-night t)\n (let ((line (face-attribute 'mode-line :underline)))\n (set-face-attribute 'mode-line nil :overline line)\n (set-face-attribute 'mode-line-inactive nil :overline line)\n (set-face-attribute 'mode-line-inactive nil :underline line)\n (set-face-attribute 'mode-line nil :box nil)\n (set-face-attribute 'mode-line-inactive nil :box nil)))\n ;;(set-face-attribute 'mode-line-inactive nil :background \"#f9f2d9\")))\n\n(use-package minions\n :ensure t\n :init (minions-mode))\n\n(use-package moody\n :ensure t\n :config\n (setq x-underline-at-descent-line t)\n (setq moody-slant-function 'moody-slant-apple-rgb)\n (moody-replace-mode-line-buffer-identification)\n (moody-replace-vc-mode))\n","avg_line_length":22.1754385965,"max_line_length":74,"alphanum_fraction":0.6859177215} {"size":149,"ext":"el","lang":"Emacs Lisp","max_stars_count":8.0,"content":";; Must exist because this file is used to find my-project-root\n;;\n;; Here contains nothing (), however you can fill it with\n;; your usual stuff.\n()\n","avg_line_length":24.8333333333,"max_line_length":63,"alphanum_fraction":0.7046979866} {"size":1519,"ext":"el","lang":"Emacs Lisp","max_stars_count":2.0,"content":";;; string.el --- Assorted string functions for emacs-parinfer. -*- lexical-binding: t; -*-\n\n;; Copyright (C) 2015 Roger Randall\n\n;; Author: Roger Randall \n;; Keywords: files, convenience, lisp, tools\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Commentary:\n;;; RER 11\/18\/15 Each of these functions work the same as their cljs counterparts when\n;;; compared using their respective REPLs.\n\n;;\n\n;;; Code:\n;; No outside package requirements.\n\n(defun parinfer-insert-string (orig idx insert)\n (concat (substring orig 0 idx)\n insert\n (substring orig idx)))\n\n(defun parinfer-remove-str-range (orig start end)\n (concat (substring orig 0 start)\n (substring orig end)))\n\n(defun parinfer-get-lines (text)\n ;; Get all lines (even empty ones)\n ;; source: http:\/\/stackoverflow.com\/a\/29614863\/142317\n (split-string text \"\\n\"))\n\n(provide 'string)\n;;; string.el ends here\n","avg_line_length":33.0217391304,"max_line_length":92,"alphanum_fraction":0.7142857143} {"size":1794,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; elixir-mode-autoloads.el --- automatically extracted autoloads\n;;\n;;; Code:\n(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n\f\n;;;### (autoloads nil \"elixir-mode\" \"elixir-mode.el\" (22846 9558\n;;;;;; 0 0))\n;;; Generated autoloads from elixir-mode.el\n\n(autoload 'elixir-mode-open-modegithub \"elixir-mode\" \"\\\nElixir mode open GitHub page.\n\n\\(fn)\" t nil)\n\n(autoload 'elixir-mode-open-elixir-home \"elixir-mode\" \"\\\nElixir mode go to language home.\n\n\\(fn)\" t nil)\n\n(autoload 'elixir-mode-open-docs-master \"elixir-mode\" \"\\\nElixir mode go to master documentation.\n\n\\(fn)\" t nil)\n\n(autoload 'elixir-mode-open-docs-stable \"elixir-mode\" \"\\\nElixir mode go to stable documentation.\n\n\\(fn)\" t nil)\n\n(autoload 'elixir-mode-version \"elixir-mode\" \"\\\nGet the Elixir-Mode version as string.\n\nIf called interactively or if SHOW-VERSION is non-nil, show the\nversion in the echo area and the messages buffer.\n\nThe returned string includes both, the version from package.el\nand the library version, if both a present and different.\n\nIf the version number could not be determined, signal an error,\nif called interactively, or if SHOW-VERSION is non-nil, otherwise\njust return nil.\n\n\\(fn &optional SHOW-VERSION)\" t nil)\n\n(autoload 'elixir-mode \"elixir-mode\" \"\\\nMajor mode for editing Elixir code.\n\n\\\\{elixir-mode-map}\n\n\\(fn)\" t nil)\n\n(add-to-list 'auto-mode-alist '(\"\\\\.elixir\\\\'\" . elixir-mode))\n\n(add-to-list 'auto-mode-alist '(\"\\\\.ex\\\\'\" . elixir-mode))\n\n(add-to-list 'auto-mode-alist '(\"\\\\.exs\\\\'\" . elixir-mode))\n\n;;;***\n\f\n;;;### (autoloads nil nil (\"elixir-mode-pkg.el\" \"elixir-smie.el\")\n;;;;;; (22846 9558 0 0))\n\n;;;***\n\f\n;; Local Variables:\n;; version-control: never\n;; no-byte-compile: t\n;; no-update-autoloads: t\n;; End:\n;;; elixir-mode-autoloads.el ends here\n","avg_line_length":25.2676056338,"max_line_length":92,"alphanum_fraction":0.6895206243} {"size":6474,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; flymake-eslint.el --- A Flymake backend for Javascript using eslint -*- lexical-binding: t; -*-\n\n;;; Version: 1.3.2\n\n;;; Author: Dan Orzechowski\n\n;;; URL: https:\/\/github.com\/orzechowskid\/flymake-eslint\n\n;;; Package-Requires: ((emacs \"26.0\"))\n\n;;; Commentary:\n;; A backend for Flymake which uses eslint. Enable it with `M-x flymake-eslint-enable [RET]'.\n;; Alternately, configure a mode-hook for your Javascript major mode of choice:\n;;\n;; (add-hook 'some-js-major-mode-hook\n;; (lambda () (flymake-eslint-enable))\n;;\n;; A handful of configurable options can be found in the `flymake-eslint' customization group: view and modify them with the command `M-x customize-group [RET] flymake-eslint [RET]'.\n\n;;; License: MIT\n\n;;; Code:\n\n\n;; our own customization group\n\n\n(defgroup flymake-eslint nil\n \"Flymake checker for Javascript using eslint\"\n :group 'programming\n :prefix \"flymake-eslint-\")\n\n\n;; useful variables\n\n\n(defcustom flymake-eslint-executable-name \"eslint\"\n \"Name of executable to run when checker is called. Must be present in variable `exec-path'.\"\n :type 'string\n :group 'flymake-eslint)\n\n(defcustom flymake-eslint-executable-args nil\n \"Extra arguments to pass to eslint.\"\n :type 'string\n :group 'flymake-eslint)\n\n(defcustom flymake-eslint-show-rule-name t\n \"Set to t to append rule name to end of warning or error message, nil otherwise.\"\n :type 'boolean\n :group 'flymake-eslint)\n\n\n;; internal variables\n\n\n(defvar flymake-eslint--message-regex \"^[[:space:]]*\\\\([0-9]+\\\\):\\\\([0-9]+\\\\)[[:space:]]+\\\\(warning\\\\|error\\\\)[[:space:]]+\\\\(.+?\\\\)[[:space:]]\\\\{2,\\\\}\\\\(.*\\\\)$\"\n \"Internal variable.\nRegular expression definition to match eslint messages.\")\n\n(defvar-local flymake-eslint--process nil\n \"Internal variable.\nHandle to the linter process for the current buffer.\")\n\n\n;; internal functions\n\n\n(defun flymake-eslint--ensure-binary-exists ()\n \"Internal function.\nThrow an error and tell REPORT-FN to disable itself if `flymake-eslint-executable-name' can't be found on variable `exec-path'\"\n (unless (executable-find flymake-eslint-executable-name)\n (error (message \"can't find '%s' in exec-path - try M-x set-variable flymake-eslint-executable-name maybe?\" flymake-eslint-executable-name))))\n\n(defun flymake-eslint--report (eslint-stdout-buffer source-buffer)\n \"Internal function.\nCreate Flymake diag messages from contents of ESLINT-STDOUT-BUFFER, to be reported against SOURCE-BUFFER. Returns a list of results\"\n (with-current-buffer eslint-stdout-buffer\n ;; start at the top and check each line for an eslint message\n (goto-char (point-min))\n (if (looking-at-p \"Error:\")\n (let ((diag (flymake-make-diagnostic source-buffer (point-min) (point-max) :error (thing-at-point 'line t))))\n ;; ehhhhh point-min and point-max here are of the eslint output buffer\n ;; containing the error message, not source-buffer\n (list diag))\n (let ((results '()))\n (while (not (eobp))\n (when (looking-at flymake-eslint--message-regex)\n (let* ((row (string-to-number (match-string 1)))\n (column (string-to-number (match-string 2)))\n (type (match-string 3))\n (msg (match-string 4))\n (lint-rule (match-string 5))\n\t (msg-text (if flymake-eslint-show-rule-name\n (format \"%s: %s [%s]\" type msg lint-rule)\n (format \"%s: %s\" type msg)))\n (type-symbol (if (string-equal \"warning\" type) :warning :error))\n (src-pos (flymake-diag-region source-buffer row column)))\n ;; new Flymake diag message\n (push (flymake-make-diagnostic source-buffer (car src-pos) (cdr src-pos) type-symbol msg-text) results)))\n (forward-line 1))\n results))))\n\n;; heavily based on the example found at\n;; https:\/\/www.gnu.org\/software\/emacs\/manual\/html_node\/flymake\/An-annotated-example-backend.html\n(defun flymake-eslint--create-process (source-buffer callback)\n \"Internal function.\nCreate linter process for SOURCE-BUFFER which invokes CALLBACK once linter is finished. CALLBACK is passed one argument, which is a buffer containing stdout from linter.\"\n (when (process-live-p flymake-eslint--process)\n (kill-process flymake-eslint--process))\n (setq flymake-eslint--process\n (make-process\n :name \"flymake-eslint\"\n :connection-type 'pipe\n :noquery t\n :buffer (generate-new-buffer \" *flymake-eslint*\")\n :command (list flymake-eslint-executable-name \"--no-color\" \"--no-ignore\" \"--stdin\" \"--stdin-filename\" (buffer-file-name source-buffer) (or flymake-eslint-executable-args \"\"))\n :sentinel (lambda (proc &rest ignored)\n ;; do stuff upon child process termination\n (when (and (eq 'exit (process-status proc))\n ;; make sure we're using the latest lint process\n (with-current-buffer source-buffer (eq proc flymake-eslint--process)))\n ;; read from eslint output then destroy temp buffer when done\n (let ((proc-buffer (process-buffer proc)))\n (funcall callback proc-buffer)\n (kill-buffer proc-buffer)))))))\n\n(defun flymake-eslint--check-and-report (source-buffer flymake-report-fn)\n \"Internal function.\nRun eslint against SOURCE-BUFFER and use FLYMAKE-REPORT-FN to report results.\"\n (flymake-eslint--create-process\n source-buffer\n (lambda (eslint-stdout)\n (funcall flymake-report-fn (flymake-eslint--report eslint-stdout source-buffer))))\n (with-current-buffer source-buffer\n (process-send-string flymake-eslint--process (buffer-string))\n (process-send-eof flymake-eslint--process)))\n\n(defun flymake-eslint--checker (flymake-report-fn &rest ignored)\n \"Internal function.\nRun eslint on the current buffer, and report results using FLYMAKE-REPORT-FN. All other parameters are currently IGNORED.\"\n (flymake-eslint--check-and-report (current-buffer) flymake-report-fn))\n\n\n;; module entry point\n\n\n;;;###autoload\n(defun flymake-eslint-enable ()\n \"Enable Flymake and add flymake-eslint as a buffer-local Flymake backend.\"\n (interactive)\n (flymake-eslint--ensure-binary-exists)\n (flymake-mode t)\n (add-hook 'flymake-diagnostic-functions 'flymake-eslint--checker nil t))\n\n\n(provide 'flymake-eslint)\n\n\n;;; flymake-eslint.el ends here\n","avg_line_length":40.4625,"max_line_length":183,"alphanum_fraction":0.6634229225} {"size":10850,"ext":"el","lang":"Emacs Lisp","max_stars_count":6.0,"content":";;; tikz.el --- AUCTeX style for `tikz.sty'\n\n;; Copyright (C) 2016 Free Software Foundation, Inc.\n\n;; Author: Matthew Leach \n;; Maintainer: auctex-devel@gnu.org\n;; Created: 2016-22-03\n;; Keywords: tex tikz\n\n;; This file is part of AUCTeX.\n\n;; AUCTeX is free software; you can redistribute it and\/or modify it\n;; under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 3, or (at your option)\n;; any later version.\n\n;; AUCTeX is distributed in the hope that it will be useful, but\n;; WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n;; General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with AUCTeX; see the file COPYING. If not, write to the Free\n;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n;; 02110-1301, USA.\n\n;;; Commentary:\n\n;; This file adds some support for `tikz.sty'\n\n;;; Code:\n\n(defun TeX-TikZ-get-opt-arg-string (arg &optional open close)\n \"Return a string for optional arguments.\nIf ARG is nil or \\\"\\\", return \\\"\\\". Otherwise return \\\"OPEN ARG\nCLOSE\\\". If OPEN or CLOSE are nil, set them to `LaTeX-optop' and\n`LaTeX-optcl' respectively.\"\n (unless (or open close)\n (setq open LaTeX-optop)\n (setq close LaTeX-optcl))\n (if (and arg (> (length arg) 0))\n (concat open arg close)\n \"\"))\n\n(defun TeX-TikZ-arg-rect-point (_ignored &optional prefix)\n \"Prompt the user for a point on the Cartesian plane.\nAsk the user for an X and Y coordinate, and return the string\n\\\"(X,Y)\\\".\"\n (let ((x (TeX-read-string (TeX-argument-prompt nil nil \"X-coordinate\")))\n (y (TeX-read-string (TeX-argument-prompt nil nil \"Y-coordinate\"))))\n (concat \" \" prefix \"(\" x \", \" y\") \")))\n\n(defun TeX-TikZ-arg-polar-point (_ignored &optional prefix)\n \"Prompt the user for a point on the polar plane.\nAsk the user for r and theta values, and return the string\n\\\"(THETA:R)\\\".\"\n (let ((r (TeX-read-string (TeX-argument-prompt nil nil \"R\")))\n (theta (TeX-read-string (TeX-argument-prompt nil nil \"Theta\"))))\n (concat \" \" prefix \"(\" theta \":\" r \") \")))\n\n(defun TeX-TikZ-arg-options (optional)\n \"Prompt the user for options to a TikZ macro.\nIf OPTIONAL is non-nil, always return `LaTeX-optop' and\n`LaTeX-optcl', even if the user doesn't provide any input.\"\n (let ((options (TeX-read-string (TeX-argument-prompt optional nil \"Options\" ))))\n (if optional\n (TeX-TikZ-get-opt-arg-string options)\n (concat LaTeX-optop options LaTeX-optcl))))\n\n(defun TeX-TikZ-arg-name (optional)\n \"Prompt the user for a TikZ name.\nIf OPTIONAL is non-nil, always return \\\"()\\\", even if the user\ndoesn't provide any input.\"\n (let ((name (TeX-read-string (TeX-argument-prompt optional nil \"Name\" ))))\n (if optional\n (TeX-TikZ-get-opt-arg-string name \"(\" \")\")\n (concat \"(\" name \")\"))))\n\n(defun TeX-TikZ-arg-label (optional)\n \"Prompt the user for TikZ label.\nIf OPTIONAL is non-nil always return `TeX-grop' and `TeX-grcl',\neven if the user doesn't provide any input.\"\n (let ((label (TeX-read-string (TeX-argument-prompt optional nil \"Label\" ))))\n (if optional\n (TeX-TikZ-get-opt-arg-string label TeX-grop TeX-grcl)\n (concat TeX-grop label TeX-grcl))))\n\n(defun TeX-TikZ-arg-node (_ignored)\n \"Prompt the user for the deatils of a node.\nAsk the user for the name and text for a node and return the\nstring \\\"node[OPTIONS](NAME){TEXT}\\\".\"\n (let ((options (TeX-TikZ-arg-options t))\n (name (TeX-TikZ-arg-name t))\n (label (TeX-TikZ-arg-label nil)))\n (concat \"node\" options name label \" \")))\n\n(defun TeX-TikZ-get-arg-type (types prompt)\n \"Prompt the user for an argument type.\nTYPES is a list of possible types that the user can specify. Use\nPROMPT as the prompt for input.\"\n (let ((completion-ignore-case t))\n (completing-read prompt types nil t)))\n\n(defun TeX-TikZ-single-macro-arg (function-alist prompt &optional optional)\n \"Prompt the user for a single argument to compose a TikZ macro.\nFUNCTION-ALIST is a mapping of argument-types to functions. The\nuser is prompted for the argument type, the chosen function is\nthen called and the value returned. PROMPT is used as the prompt\nfor the argument type. When OPTIONAL is non-nil, add \\\"\\\" to\nFUNCTION-ALIST with a mapping to `identity', permitting an\noptional input.\"\n (let* ((selected-argument-type (TeX-TikZ-get-arg-type function-alist prompt))\n (fn-alist-with-optional-elm (if optional\n `(,@function-alist (\"\" identity))\n function-alist))\n (selected-mapping (assoc selected-argument-type\n fn-alist-with-optional-elm)))\n\n (eval\n ;; Build the form we wish to evaluate. This will be the function\n ;; to be called (the second element in the assoc element),\n ;; followed by the type name (the first element), followed by any\n ;; other elements in the list as extra arguments.\n `(,(cadr selected-mapping)\n ,(car selected-mapping)\n ,@(cddr selected-mapping)))))\n\n\n(defun TeX-TikZ-macro-arg (function-alist)\n \"Prompt the user for arguments to compose a TikZ macro.\nFUNCTION-ALIST is a mapping of argument-types to functions. The\nuser is repeatedly prompted for the next argument-type; they can\nchoose form the cars in FUNCTION-ALIST and the appropriate\nfunction is then called. If the user enters \\\"\\\", then the macro\nis finished.\"\n (let* ((options (TeX-TikZ-arg-options t))\n (prompt \"Next argument type (RET to finish): \")\n (string-to-insert (TeX-TikZ-single-macro-arg function-alist prompt t)))\n\n ;; Insert the macro options.\n (insert options \" \")\n\n ;; Iteratively prompt the user for TikZ's arguments until \"\" is\n ;; returned.\n (while (not (string= string-to-insert \"\"))\n (insert string-to-insert)\n (setq string-to-insert\n (TeX-TikZ-single-macro-arg function-alist prompt t)))\n\n ;; Finish the macro.\n (insert \";\")))\n\n(defcustom TeX-TikZ-point-name-regexp\n \"(\\\\([A-Za-z0-9]+\\\\))\"\n \"A regexp that matches TikZ names.\"\n :type 'regexp\n :group 'auctex-tikz)\n\n(defun TeX-TikZ-find-named-points ()\n \"Find TiKZ named points in current enviroment.\nBegin by finding the span of the current TikZ enviroment and then\nsearching within that span to find all named-points and return\nthem as a list of strings, dropping the '()'.\"\n (let* ((env-end (save-excursion\n (LaTeX-find-matching-end)\n (point)))\n (matches))\n ;; TODO: Handle cases where we are in a nested environment, \\scope\n ;; for example.\n (save-excursion\n (LaTeX-find-matching-begin)\n (save-match-data\n (while (re-search-forward TeX-TikZ-point-name-regexp env-end t)\n (push (match-string 1) matches))))\n matches))\n\n(defun TeX-TikZ-arg-named-point (_ignored &optional prefix)\n \"Prompt the user for the name of a previous named-point.\"\n (let ((point-name (completing-read \"Point name: \"\n (TeX-TikZ-find-named-points))))\n (concat \" \" prefix \"(\" point-name \") \")))\n\n(defun TeX-TikZ-arg-circle (_ignored)\n \"Prompt the user for the arguments to the circle command.\"\n (let ((options (TeX-TikZ-arg-options t)))\n (concat \"circle\" options)))\n\n(defun TeX-TikZ-arg-arc (_ignored)\n \"Prompt the user for the arguments to the arc command.\"\n (let ((options (TeX-TikZ-arg-options t)))\n (concat \"arc\" options)))\n\n(defun TeX-TikZ-arg-bend (optional)\n \"Prompt the user for a bend argument.\nIf OPTIONAL is non-nil and the user doesn't provide a point,\n return \\\"\\\".\"\n (let ((point\n (TeX-TikZ-single-macro-arg TeX-TikZ-point-function-map\n (TeX-argument-prompt optional nil \"Bend point\")\n optional)))\n (if (string= point \"\")\n point\n (concat \" bend\" point))))\n\n(defun TeX-TikZ-arg-parabola (_ignored)\n \"Prompt the user for the arguments to the parabola command.\"\n (let ((options (TeX-TikZ-arg-options t))\n (bend (TeX-TikZ-arg-bend t)))\n (concat \"parabola\" options bend)))\n\n(defun TeX-TikZ-arg-grid (_ignored)\n \"Prompt the user for the arguments to the grid command.\"\n (let ((options (TeX-TikZ-arg-options t)))\n (concat \"grid\" options)))\n\n(defconst TeX-TikZ-point-function-map\n '((\"Rect Point\" TeX-TikZ-arg-rect-point)\n (\"Polar Point\" TeX-TikZ-arg-polar-point)\n (\"Named Point\" TeX-TikZ-arg-named-point))\n \"An alist of point specification types and their functions.\")\n\n(defconst TeX-TikZ-relative-point-function-map\n (apply 'append (mapcar\n (lambda (point-map)\n (let ((key (car point-map))\n (value (cadr point-map)))\n `((,(concat \"+\" key) ,value \"+\")\n (,(concat \"++\" key) ,value \"++\"))))\n TeX-TikZ-point-function-map))\n \"`TeX-TikZ-point-function-map' with \\\"+\\\" and \\\"++\\\" as a\nprefix.\")\n\n(defconst TeX-TikZ-path-connector-function-map\n '((\"--\" identity)\n (\"|-\" identity)\n ( \"-|\" identity)\n (\"sin\" identity)\n (\"cos\" identity))\n \"An alist of path connectors.\")\n\n(defconst TeX-TikZ-draw-arg-function-map\n `(,@TeX-TikZ-point-function-map\n ,@TeX-TikZ-relative-point-function-map\n ,@TeX-TikZ-path-connector-function-map\n (\"Node\" TeX-TikZ-arg-node)\n (\"Circle\" TeX-TikZ-arg-circle)\n (\"Arc\" TeX-TikZ-arg-arc)\n (\"Parabola\" TeX-TikZ-arg-parabola)\n (\"Grid\" TeX-TikZ-arg-grid))\n \"An alist of argument names and functoins for TikZ's \\draw.\")\n\n(defun TeX-TikZ-draw-arg (_ignored)\n \"Prompt the user for the arguments to a TikZ draw macro.\"\n (TeX-TikZ-macro-arg TeX-TikZ-draw-arg-function-map))\n\n(defun TeX-TikZ-coordinate-arg (_ignored)\n \"Prompt the user for the arguments to a TikZ coordinate macro.\"\n (let ((options (TeX-TikZ-arg-options t))\n (name (TeX-TikZ-arg-name nil))\n (point (TeX-TikZ-single-macro-arg TeX-TikZ-point-function-map\n \"Coordinate point type: \")))\n (insert options \" \" name \" at\" point \";\")))\n\n(defun TeX-TikZ-node-arg (_ignored)\n \"Prompt the user for the arguments to a TikZ node macro.\"\n (let ((options (TeX-TikZ-arg-options t))\n (name (TeX-TikZ-arg-name nil))\n (point (TeX-TikZ-single-macro-arg TeX-TikZ-point-function-map\n \"Node point type: \"))\n (label (TeX-TikZ-arg-label nil)))\n (insert options \" \" name \" at\" point label \";\")))\n\n(TeX-add-style-hook\n \"tikz\"\n (lambda ()\n (TeX-add-symbols\n '(\"draw\" (TeX-TikZ-draw-arg))\n '(\"coordinate\" (TeX-TikZ-coordinate-arg))\n '(\"node\" (TeX-TikZ-node-arg)))\n (LaTeX-add-environments\n '(\"tikzpicture\"))))\n\n;;; tikz.el ends here\n","avg_line_length":38.2042253521,"max_line_length":83,"alphanum_fraction":0.6467281106} {"size":2891,"ext":"el","lang":"Emacs Lisp","max_stars_count":1.0,"content":";;; htmlize-autoloads.el --- automatically extracted autoloads\n;;\n;;; Code:\n(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n\f\n;;;### (autoloads nil \"htmlize\" \"htmlize.el\" (23256 35455 0 0))\n;;; Generated autoloads from htmlize.el\n\n(autoload 'htmlize-buffer \"htmlize\" \"\\\nConvert BUFFER to HTML, preserving colors and decorations.\n\nThe generated HTML is available in a new buffer, which is returned.\nWhen invoked interactively, the new buffer is selected in the current\nwindow. The title of the generated document will be set to the buffer's\nfile name or, if that's not available, to the buffer's name.\n\nNote that htmlize doesn't fontify your buffers, it only uses the\ndecorations that are already present. If you don't set up font-lock or\nsomething else to fontify your buffers, the resulting HTML will be\nplain. Likewise, if you don't like the choice of colors, fix the mode\nthat created them, or simply alter the faces it uses.\n\n\\(fn &optional BUFFER)\" t nil)\n\n(autoload 'htmlize-region \"htmlize\" \"\\\nConvert the region to HTML, preserving colors and decorations.\nSee `htmlize-buffer' for details.\n\n\\(fn BEG END)\" t nil)\n\n(autoload 'htmlize-file \"htmlize\" \"\\\nLoad FILE, fontify it, convert it to HTML, and save the result.\n\nContents of FILE are inserted into a temporary buffer, whose major mode\nis set with `normal-mode' as appropriate for the file type. The buffer\nis subsequently fontified with `font-lock' and converted to HTML. Note\nthat, unlike `htmlize-buffer', this function explicitly turns on\nfont-lock. If a form of highlighting other than font-lock is desired,\nplease use `htmlize-buffer' directly on buffers so highlighted.\n\nBuffers currently visiting FILE are unaffected by this function. The\nfunction does not change current buffer or move the point.\n\nIf TARGET is specified and names a directory, the resulting file will be\nsaved there instead of to FILE's directory. If TARGET is specified and\ndoes not name a directory, it will be used as output file name.\n\n\\(fn FILE &optional TARGET)\" t nil)\n\n(autoload 'htmlize-many-files \"htmlize\" \"\\\nConvert FILES to HTML and save the corresponding HTML versions.\n\nFILES should be a list of file names to convert. This function calls\n`htmlize-file' on each file; see that function for details. When\ninvoked interactively, you are prompted for a list of files to convert,\nterminated with RET.\n\nIf TARGET-DIRECTORY is specified, the HTML files will be saved to that\ndirectory. Normally, each HTML file is saved to the directory of the\ncorresponding source file.\n\n\\(fn FILES &optional TARGET-DIRECTORY)\" t nil)\n\n(autoload 'htmlize-many-files-dired \"htmlize\" \"\\\nHTMLize dired-marked files.\n\n\\(fn ARG &optional TARGET-DIRECTORY)\" t nil)\n\n;;;***\n\f\n;; Local Variables:\n;; version-control: never\n;; no-byte-compile: t\n;; no-update-autoloads: t\n;; End:\n;;; htmlize-autoloads.el ends here\n","avg_line_length":37.5454545455,"max_line_length":92,"alphanum_fraction":0.7582151505} {"size":3513,"ext":"el","lang":"Emacs Lisp","max_stars_count":1.0,"content":";;; private\/notmuch\/config.el -*- lexical-binding: t; -*-\n\n(load! +bindings)\n\n(defvar maildir \"~\/mail\")\n\n(def-package! smtpmail\n :config\n (setq smtpmail-default-smtp-server \"nix.aminb.org\"\n smtpmail-local-domain \"aminb.org\"\n smtpmail-smtp-server \"nix.aminb.org\"\n smtpmail-stream-type 'starttls\n smtpmail-smtp-service 587))\n\n(def-package! sendmail\n :config\n (setq send-mail-function 'smtpmail-send-it))\n\n(def-package! message\n :config\n (setq message-kill-buffer-on-exit t\n message-directory \"drafts\"\n message-user-fqdn \"aminb.org\")\n (add-hook 'message-mode-hook\n '(lambda () (setq fill-column 65))\n 'append)\n ;; (add-hook 'message-setup-hook\n ;; #'mml-secure-message-sign-pgpmime)\n )\n\n(after! mml-sec\n (setq mml-secure-openpgp-encrypt-to-self t\n mml-secure-openpgp-sign-with-sender t))\n\n(def-package! notmuch\n :config\n (setq notmuch-hello-sections\n '(notmuch-hello-insert-header\n notmuch-hello-insert-saved-searches\n ;; notmuch-hello-insert-search\n notmuch-hello-insert-alltags)\n notmuch-search-oldest-first nil\n notmuch-show-all-tags-list t\n notmuch-hello-thousands-separator \",\"\n notmuch-fcc-dirs\n '((\"amin@aminb.org\" . \"amin\/Sent\")\n (\"aminb@gnu.org\" . \"gnu\/Sent\")\n (\".*\" . \"sent\")))\n )\n\n(after! notmuch-crypto\n (setq notmuch-crypto-process-mime t))\n\n(after! notmuch-hello\n (define-key notmuch-hello-mode-map \"g\"\n 'notmuch-poll-and-refresh-this-buffer)\n\n (define-key notmuch-hello-mode-map \"i\"\n (lambda ()\n \"Search for `inbox' tagged messages.\"\n (interactive)\n (notmuch-hello-search \"tag:inbox\")))\n\n (define-key notmuch-hello-mode-map \"u\"\n (lambda ()\n \"Search for `unread' tagged messages.\"\n (interactive)\n (notmuch-hello-search \"tag:unread\"))))\n\n(after! notmuch\n (define-key notmuch-search-mode-map \"g\"\n 'notmuch-poll-and-refresh-this-buffer)\n\n (define-key notmuch-search-mode-map \"k\"\n (lambda ()\n \"Mark message read.\"\n (interactive)\n (notmuch-search-tag '(\"-unread\"))\n ;; (notmuch-search-archive-thread)\n (notmuch-search-next-thread)))\n\n (define-key notmuch-search-mode-map \"u\"\n (lambda ()\n \"Mark message unread.\"\n (interactive)\n (notmuch-search-tag '(\"+unread\"))\n (notmuch-search-next-thread)))\n\n (define-key notmuch-search-mode-map \"K\"\n (lambda ()\n \"Mark message deleted.\"\n (interactive)\n (notmuch-search-tag '(\"-unread\" \"-inbox\" \"+deleted\"))\n (notmuch-search-archive-thread)))\n\n (define-key notmuch-search-mode-map \"S\"\n (lambda ()\n \"Mark message as spam\"\n (interactive)\n (notmuch-search-tag '(\"-unread\" \"-inbox\" \"+spam\"))\n (notmuch-search-archive-thread)))\n\n (define-key notmuch-tree-mode-map \"S\"\n (lambda ()\n \"Mark message as spam\"\n (interactive)\n (notmuch-tree-tag '(\"-unread\" \"-inbox\" \"+spam\"))\n (notmuch-tree-archive-thread))))\n\n;; TODO: Additional `notmuch-tree' key bindings\n\n(after! evil\n (mapc (lambda (str) (evil-set-initial-state (car str) (cdr str)))\n '((notmuch-hello-mode . emacs)\n (notmuch-search-mode . emacs)\n (notmuch-tree-mode . emacs))))\n\n(after! recentf\n (add-to-list 'recentf-exclude (expand-file-name maildir)))\n\n;; notmuch's buffers should be real\n(defun notmuch-buffer-p (buffer)\n (string-match-p \"^\\\\*notmuch-\" (buffer-name buffer)))\n(push #'notmuch-buffer-p doom-real-buffer-functions)\n","avg_line_length":28.104,"max_line_length":67,"alphanum_fraction":0.6231141475} {"size":1434,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(package-initialize)\n(require 'org)\n(require 'ox)\n(require 'ox-publish)\n\n(setq org-html-postamble-format \n '((\"en\" \"

    Last Updated %T.<\/p>\")))\n\n(setq org-publish-project-alist\n '(\n ;; org files to be exported to HTML.\n (\"org\"\n :author \"Kaushik Kulkarni\"\n :base-directory \".\/org\"\n :base-extension \"org\"\n :publishing-directory \".\/html\"\n :publishing-function org-html-publish-to-html\n :section-numbers nil\n :with-toc nil\n :html-extension \"html\"\n :html-html5-fancy t\n :html-doctype \"html5\"\n :html-postamble t\n :recursive t)\n\n ;; CSS files to be copied to the html folder.\n (\"html\"\n :base-directory \".\/org\"\n :base-extension \"html\"\n :publishing-directory \".\/html\"\n :publishing-function org-publish-attachment)\n\n ;; CSS files to be copied to the html folder.\n (\"css\"\n :base-directory \".\/org\/css\"\n :base-extension \"css\"\n :publishing-directory \".\/html\/css\"\n :publishing-function org-publish-attachment)\n\n ;; Extra files to be copied to the html folder.\n (\"extras\"\n :base-directory \".\/org\/extras\"\n :base-extension \"pdf\"\n :publishing-directory \".\/html\/extras\"\n :publishing-function org-publish-attachment)\n\n ;; Publish all of the components in order.\n (\"personal-webpage\" :components (\"org\" \"html\" \"css\" \"extras\"))\n )\n)\n","avg_line_length":28.1176470588,"max_line_length":68,"alphanum_fraction":0.5990237099} {"size":530,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; csv-nav-autoloads.el --- automatically extracted autoloads\n;;\n;;; Code:\n(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n\f\n;;;### (autoloads nil \"csv-nav\" \"csv-nav.el\" (22995 1714 597410 226000))\n;;; Generated autoloads from csv-nav.el\n\n(autoload 'csv-nav-mode \"csv-nav\" \"\\\nMajor mode for viewing and editing CSV files.\n\n\\(fn)\" t nil)\n\n;;;***\n\f\n;; Local Variables:\n;; version-control: never\n;; no-byte-compile: t\n;; no-update-autoloads: t\n;; End:\n;;; csv-nav-autoloads.el ends here\n","avg_line_length":24.0909090909,"max_line_length":92,"alphanum_fraction":0.6660377358} {"size":231,"ext":"el","lang":"Emacs Lisp","max_stars_count":11.0,"content":";;; Directory Local Variables\n;;; For more information see (info \"(emacs) Directory Variables\")\n\n((nil . ((fill-column . 120)))\n (python-mode . ((flycheck-checker . python-flake8)\n (flycheck-flake8rc . \\.flake8))))\n","avg_line_length":33.0,"max_line_length":65,"alphanum_fraction":0.632034632} {"size":523,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(define-package \"lsp-mode\" \"20201001.1404\" \"LSP mode\"\n '((emacs \"26.1\")\n (dash \"2.14.1\")\n (dash-functional \"2.14.1\")\n (f \"0.20.0\")\n (ht \"2.0\")\n (spinner \"1.7.3\")\n (markdown-mode \"2.3\")\n (lv \"0\"))\n :commit \"440fe8f35a2511edb71edea0f78fac05eacef05e\" :keywords\n '(\"languages\")\n :authors\n '((\"Vibhav Pant, Fangrui Song, Ivan Yonchovski\"))\n :maintainer\n '(\"Vibhav Pant, Fangrui Song, Ivan Yonchovski\")\n :url \"https:\/\/github.com\/emacs-lsp\/lsp-mode\")\n;; Local Variables:\n;; no-byte-compile: t\n;; End:\n","avg_line_length":26.15,"max_line_length":62,"alphanum_fraction":0.6156787763} {"size":4580,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"\n;; When using this directly, you will need to have use-package installed:\n;; M-x package-install, select use-package. But if you start via\n;; `standalone.el', this is being taken care of automatically.\n\n\n;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n;; rustic = basic rust-mode + additions\n\n(use-package rustic\n :ensure\n :bind (:map rustic-mode-map\n (\"M-j\" . lsp-ui-imenu)\n (\"M-?\" . lsp-find-references)\n (\"C-c C-c l\" . flycheck-list-errors)\n (\"C-c C-c a\" . lsp-execute-code-action)\n (\"C-c C-c r\" . lsp-rename)\n (\"C-c C-c q\" . lsp-workspace-restart)\n (\"C-c C-c Q\" . lsp-workspace-shutdown)\n (\"C-c C-c s\" . lsp-rust-analyzer-status)\n (\"C-c C-c e\" . lsp-rust-analyzer-expand-macro)\n\t (\"C-c C-c t\" . lsp-rust-analyzer-open-cargo-toml)\n\t (\"C-c C-c w\" . lsp-ui-flycheck-list)\n \t (\"C-c C-c o\" . lsp-ui-find-workspace-symbol)\n \t (\"C-c C-c i\" . helm-imenu)\n (\"C-c C-c d\" . dap-hydra)\n (\"C-c C-c h\" . lsp-ui-doc-glance))\n :config\n ;; uncomment for less flashiness\n (setq lsp-eldoc-hook nil)\n ;;(setq lsp-enable-symbol-highlighting nil)\n ;;(setq lsp-signature-auto-activate nil)\n\n ;; comment to disable rustfmt on save\n (setq rustic-format-on-save t)\n (add-hook 'rustic-mode-hook 'rk\/rustic-mode-hook))\n\n(defun rk\/rustic-mode-hook ()\n ;; so that run C-c C-c C-r works without having to confirm, but don't try to\n ;; save rust buffers that are not file visiting. Once\n ;; https:\/\/github.com\/brotzeit\/rustic\/issues\/253 has been resolved this should\n ;; no longer be necessary.\n (when buffer-file-name\n (setq-local buffer-save-without-query t)))\n\n;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n;; for rust-analyzer integration\n\n(use-package lsp-mode\n :ensure\n :commands lsp\n :custom\n ;; what to use when checking on-save. \"check\" is default, I prefer clippy\n (lsp-rust-analyzer-cargo-watch-command \"clippy\")\n (lsp-eldoc-render-all nil)\n (lsp-idle-delay 1)\n (lsp-rust-analyzer-server-display-inlay-hints t)\n :config\n (add-hook 'lsp-mode-hook 'lsp-ui-mode)\n )\n\n\n(use-package lsp-ui\n :ensure\n :commands lsp-ui-mode\n :custom\n (lsp-ui-peek-always-show t)\n (lsp-ui-sideline-show-hover nil)\n (lsp-ui-doc-enable nil))\n\n\n;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n;; inline errors\n\n(use-package flycheck :ensure)\n\n\n;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n;; auto-completion and code snippets\n\n(use-package yasnippet\n :ensure\n :config\n (yas-reload-all)\n (add-hook 'prog-mode-hook 'yas-minor-mode)\n (add-hook 'text-mode-hook 'yas-minor-mode))\n\n(use-package company\n :ensure\n :bind\n (:map company-active-map\n (\"C-n\". company-select-next)\n (\"C-p\". company-select-previous)\n (\"M-<\". company-select-first)\n (\"M->\". company-select-last))\n (:map company-mode-map\n (\"\". tab-indent-or-complete)\n (\"TAB\". tab-indent-or-complete)))\n\n(defun company-yasnippet-or-completion ()\n (interactive)\n (or (do-yas-expand)\n (company-complete-common)))\n\n(defun check-expansion ()\n (save-excursion\n (if (looking-at \"\\\\_>\") t\n (backward-char 1)\n (if (looking-at \"\\\\.\") t\n (backward-char 1)\n (if (looking-at \"::\") t nil)))))\n\n(defun do-yas-expand ()\n (let ((yas\/fallback-behavior 'return-nil))\n (yas\/expand)))\n\n(defun tab-indent-or-complete ()\n (interactive)\n (if (minibufferp)\n (minibuffer-complete)\n (if (or (not yas\/minor-mode)\n (null (do-yas-expand)))\n (if (check-expansion)\n (company-complete-common)\n (indent-for-tab-command)))))\n\n\n;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n;; for Cargo.toml and other config files\n\n(use-package toml-mode :ensure)\n\n\n;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n;; setting up debugging support with dap-mode\n\n(use-package exec-path-from-shell\n :ensure\n :init (exec-path-from-shell-initialize))\n\n(when (executable-find \"lldb-mi\")\n (use-package dap-mode\n :ensure\n :config\n (dap-ui-mode)\n (dap-ui-controls-mode 1)\n\n (require 'dap-lldb)\n (require 'dap-gdb-lldb)\n ;; installs .extension\/vscode\n (dap-gdb-lldb-setup)\n (dap-register-debug-template\n \"Rust::LLDB Run Configuration\"\n (list :type \"lldb\"\n :request \"launch\"\n :name \"LLDB::Run\"\n\t :gdbpath \"rust-lldb\"\n ;; uncomment if lldb-mi is not in PATH\n ;; :lldbmipath \"path\/to\/lldb-mi\"\n ))))\n","avg_line_length":28.4472049689,"max_line_length":80,"alphanum_fraction":0.56069869} {"size":928,"ext":"el","lang":"Emacs Lisp","max_stars_count":3.0,"content":";;; tools\/imenu\/config.el -*- lexical-binding: t; -*-\n\n(def-package! imenu-anywhere\n :commands (ido-imenu-anywhere ivy-imenu-anywhere helm-imenu-anywhere)\n :config (setq imenu-anywhere-delimiter \": \"))\n\n\n(def-package! imenu-list\n :commands imenu-list-minor-mode\n :config\n (setq imenu-list-focus-after-activation t)\n (set! :popup imenu-list-buffer-name :size 35 :align 'right)\n\n ;; use popups\n (defun doom*imenu-list-show ()\n (doom-popup-buffer (get-buffer imenu-list-buffer-name)))\n (advice-add #'imenu-list-show :override #'doom*imenu-list-show)\n (advice-add #'imenu-list-show-noselect :override #'doom*imenu-list-show)\n\n ;; auto kill imenu-list on deactivation\n (defun doom|kill-imenu-list ()\n (when (and (not imenu-list-minor-mode)\n (get-buffer imenu-list-buffer-name))\n (kill-buffer (get-buffer imenu-list-buffer-name))))\n (add-hook 'imenu-list-minor-mode-hook #'doom|kill-imenu-list))\n","avg_line_length":35.6923076923,"max_line_length":74,"alphanum_fraction":0.6918103448} {"size":2321,"ext":"el","lang":"Emacs Lisp","max_stars_count":91.0,"content":";;; setup-lsp.el -*- lexical-binding: t; -*-\n;; Time-stamp: <2021-03-24 04:19:13 csraghunandan>\n\n;; Copyright (C) 2016-2020 Chakravarthy Raghunandan\n;; Author: Chakravarthy Raghunandan \n\n;; lsp-mode: Emacs client\/library for the Language Server Protocol\n;; https:\/\/github.com\/emacs-lsp\/lsp-mode\n(use-package lsp-mode\n :commands lsp lsp-deferred\n :hook ((lsp-after-open . lsp-enable-imenu)\n (lsp-mode . lsp-enable-which-key-integration)\n (lsp-after-open . (lambda ()\n (setq-local company-minimum-prefix-length 1\n company-idle-delay 0.0) ;; default is 0.2\n )))\n :bind (:map lsp-mode-map\n (\"C-c C-t\" . lsp-describe-thing-at-point))\n :config\n (setq lsp-prefer-flymake nil)\n (setq lsp-auto-guess-root t ; Detect project root\n lsp-keep-workspace-alive nil ; Auto-kill LSP server\n lsp-prefer-capf t\n lsp-enable-indentation nil\n lsp-enable-symbol-highlighting nil\n lsp-enable-on-type-formatting nil))\n\n;; lsp-ui: This contains all the higher level UI modules of lsp-mode, like flycheck support and code lenses.\n;; https:\/\/github.com\/emacs-lsp\/lsp-ui\n(use-package lsp-ui\n :config\n (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)\n (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)\n (setq lsp-ui-sideline-enable t\n lsp-ui-sideline-update-mode 'line\n lsp-ui-sideline-show-code-actions t\n lsp-ui-sideline-show-hover t\n lsp-ui-doc-enable t\n lsp-ui-doc-include-signature t\n lsp-eldoc-enable-hover nil ; Disable eldoc displays in minibuffer\n lsp-ui-doc-position 'at-point\n lsp-ui-imenu-enable t\n lsp-ui-sideline-ignore-duplicate t))\n\n;; debugger adapter protocol support for emacs\n;; https:\/\/github.com\/emacs-lsp\/dap-mode\/\n(use-package dap-mode\n :defer 4\n :config\n ;; call dap-hydra when going to the next breakpoint\n (add-hook 'dap-stopped-hook\n (lambda (arg) (call-interactively #'dap-hydra)))\n (add-hook 'dap-mode-hook #'dap-ui-mode) ; use a hook so users can remove it\n (dap-mode 1))\n\n;; load gdb-lldb package\n(use-package dap-gdb-lldb\n :defer 5\n :straight nil)\n\n(provide 'setup-lsp)\n","avg_line_length":37.435483871,"max_line_length":108,"alphanum_fraction":0.6566135287} {"size":3695,"ext":"el","lang":"Emacs Lisp","max_stars_count":42.0,"content":";;; treemacs-diagnostics.el --- A tree style file viewer package -*- lexical-binding: t -*-\n\n;; Copyright (C) 2020 Alexander Miller\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Commentary:\n;;; WIP implementation of diagnostics display.\n\n;;; Code:\n\n(require 'ht)\n(require 'thunk)\n(require 'dash)\n(require 'overlay)\n(require 'treemacs-dom)\n(require 'treemacs-scope)\n(require 'treemacs-workspaces)\n(require 'treemacs-core-utils)\n\n(eval-when-compile\n (require 'treemacs-macros))\n\n(defconst treemacs--diag-store (make-hash-table :size 50 :test 'equal))\n\n(defvar treemacs--diagnostic-timer nil\n \"Debounce guard for the application of diagnostics.\")\n\n(defconst treemacs--apply-diagnostics-delay 3\n \"Debounce delay for the application of diagnostics.\")\n\n(defface treemacs-diagnostic-error-face\n '((t :underline \"red\"))\n \"TODO\"\n :group 'treemacs-faces)\n\n(defface treemacs-diagnostic-warning-face\n '((t :underline \"yellow\"))\n \"TODO\"\n :group 'treemacs-faces)\n\n(defun treemacs--reset-and-save-diagnosics (path diagnostics)\n \"TODO PATH DIAGNOSTICS.\"\n (-let [ht (ht-get treemacs--diag-store path)]\n (if ht\n (ht-clear! ht)\n (setf ht (make-hash-table :size 100 :test 'equal))\n (ht-set! treemacs--diag-store path ht))\n (while diagnostics\n (ht-set! ht (pop diagnostics) (pop diagnostics)))))\n\n(defun treemacs-apply-diagnostics (provider)\n \"Display diagnostics based on the given arguments PROVIDER.\nPROVIDER should be a `thunk' (see thunk.el) that, when evaluated, returns a flat\nlist of consecutive path and face items.\n\nFile paths should use treemacs' canonical format - they should be absolute,\nexpanded and *not* have a trailing slash.\n\nThe diagnostic faces could be any face symbols or raw face literals. Treemacs\nfeatures several pre-made faces named `treemacs-diagnostic-*-face'.\n\nThis method is debounced, it will never run more often than once every 3\nseconds. In addition the use of a lazy thunk ensures that potentially expensive\ntransformations happen only once and only when required. Performance is thus not\nexpected to be a major issue.\n\nA basic example use would look like this:\n\n\\(treemacs-apply-diagnostics\n (thunk-delay '(\\\"\/path\/to\/file\/x\\\" 'treemacs-diagnostic-warning-face\n \\\"\/path\/to\/file\/y\\\" 'treemacs-diagnostic-error-face\n \\\"\/path\/to\/file\/z\\\" '((:underline \\\"green\\\")))))\"\n (treemacs-debounce treemacs--diagnostic-timer treemacs--apply-diagnostics-delay\n (treemacs-run-in-every-buffer\n (save-excursion\n (-each (overlays-in (point-min) (point-max)) #'delete-overlay)\n (-let [diagnostics (thunk-force provider)]\n (while diagnostics\n (let ((path (pop diagnostics))\n (state (pop diagnostics)))\n (when (treemacs-is-path-visible? path)\n (-let [btn (treemacs-find-file-node path)]\n (-doto (make-overlay (treemacs-button-start btn) (treemacs-button-end btn))\n (overlay-put 'face state))))))))\n (hl-line-highlight))))\n\n(provide 'treemacs-diagnostics)\n\n;;; treemacs-diagnostics.el ends here\n","avg_line_length":36.2254901961,"max_line_length":92,"alphanum_fraction":0.7025710419} {"size":38629,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; mmm-vars.el --- Variables for MMM Mode\n\n;; Copyright (C) 2000, 2004 by Michael Abraham Shulman\n\n;; Author: Michael Abraham Shulman \n;; Version: $Id$\n\n;;{{{ GPL\n\n;; This file is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation; either version 2, or (at your option)\n;; any later version.\n\n;; This file is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs; see the file COPYING. If not, write to\n;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n;; Boston, MA 02111-1307, USA.\n\n;;}}}\n\n;;; Commentary:\n\n;; This file provides the definitions for the variables used by MMM\n;; Mode, as well as several functions to manipulate them. It also\n;; defines the errors that MMM Mode can signal.\n\n;;; Code:\n\n(require 'cl)\n(require 'mmm-compat)\n(require 'mmm-utils)\n\n;; MISCELLANEOUS\n;;{{{ Shut up the Byte Compiler\n\n;; Otherwise it complains about undefined variables.\n(eval-when-compile\n (defvar mmm-current-submode)\n (defvar mmm-current-overlay)\n (defvar mmm-save-local-variables)\n (defvar mmm-mode-string)\n (defvar mmm-submode-mode-line-format)\n (defvar mmm-mode-ext-classes-alist)\n (defvar mmm-mode-prefix-key)\n (defvar mmm-global-mode)\n (defvar mmm-primary-mode)\n (defvar mmm-classes-alist)\n (defvar mmm-current-submode))\n (declare-function mmm-set-class-parameter \"mmm-class\")\n (declare-function mmm-get-class-parameter \"mmm-class\")\n;;}}}\n;;{{{ Error Conditions\n\n;; Most of these should be caught internally and never seen by the\n;; user, except when the user is creating submode regions manually.\n\n;; Signalled when we try to put a submode region inside one where it\n;; isn't meant to go.\n(put 'mmm-subregion-invalid-parent\n 'error-conditions\n '(mmm-subregion-invalid-parent mmm-error error))\n(put 'mmm-subregion-invalid-parent\n 'error-message\n \"Invalid submode region parent\")\n\n;; Signalled when we try to put a submode region overlapping others in\n;; an invalid way.\n(put 'mmm-subregion-invalid-placement\n 'error-conditions\n '(mmm-subregion-invalid-placement mmm-error error))\n(put 'mmm-subregion-invalid-placement\n 'error-message\n \"Submode region placement invalid\")\n\n;; Signalled when we try to apply a submode class that doesn't exist.\n(put 'mmm-invalid-submode-class\n 'error-conditions\n '(mmm-invalid-submode-class mmm-error error))\n(put 'mmm-invalid-submode-class\n 'error-message\n \"Invalid or undefined submode class\")\n\n;; Signalled by :match-submode functions when they are unable to\n;; resolve a submode. This error should *always* be caught internally\n;; and never seen by the user.\n(put 'mmm-no-matching-submode\n 'error-conditions\n '(mmm-no-matching-submode mmm-error error))\n(put 'mmm-no-matching-submode\n 'error-message\n \"Internal error: no matching submode.\")\n\n;;}}}\n\n;; USER VARIABLES\n;;{{{ Customization Group\n\n(defgroup mmm nil\n \"Multiple Major Modes in one buffer.\"\n :group 'tools)\n\n;;}}}\n;;{{{ Save Local Variables\n\n(defvar mmm-c-derived-modes\n '(c-mode c++-mode objc-mode pike-mode java-mode jde-mode javascript-mode\n php-mode))\n\n(defvar mmm-save-local-variables\n `(;; Don't use `function' (#') here!! We're already inside `quote'!\n major-mode\n comment-start\n comment-end\n (comment-line-start-skip buffer (fortran-mode))\n comment-start-skip\n (comment-column buffer)\n comment-indent-function\n comment-line-break-function\n sentence-end\n ,@(when mmm-xemacs\n\t'(mode-popup-menu\n\t (((lambda () current-menubar) . set-buffer-menubar))\n\t ))\n font-lock-keywords\n font-lock-keywords-only\n font-lock-keywords-case-fold-search\n font-lock-syntax-table\n font-lock-mark-block-function ; Override this?\n font-lock-syntactic-keywords\n indent-line-function\n parse-sexp-ignore-comments ; Fixes indentation in PHP-mode?\n ;; Can be different in different buffers\n (c-basic-offset\n buffer (c-mode c++-mode objc-mode pike-mode java-mode jde-mode))\n ;; These are necessary for C syntax parsing\n (c-class-key nil ,mmm-c-derived-modes)\n (c-extra-toplevel-key nil ,mmm-c-derived-modes)\n (c-inexpr-class-key nil ,mmm-c-derived-modes)\n (c-conditional-key nil ,mmm-c-derived-modes)\n semantic-bovinate-toplevel-override\n semantic-toplevel-bovine-table\n ;; Indentation style control variables.\n ;; These have to be localized in Emacs: see `mmm-mode-on'.\n ,@(mapcar\n #'(lambda (var) (list var nil mmm-c-derived-modes))\n '(c++-template-syntax-table\n\t c-<-op-cont-regexp\n\t c->-op-cont-regexp\n\t c-after-suffixed-type-decl-key\n\t c-after-suffixed-type-maybe-decl-key\n\t c-any-class-key\n\t c-any-class-key\n\t c-asm-stmt-kwds\n\t c-assignment-op-regexp\n\t c-backslash-column\n\t c-basic-offset\n\t c-bitfield-kwds\n\t c-block-comment-prefix\n\t c-block-decls-with-vars\n\t c-block-stmt-1-key\n\t c-block-stmt-1-key\n\t c-block-stmt-1-kwds\n\t c-block-stmt-2-key\n\t c-block-stmt-2-key\n\t c-block-stmt-2-kwds\n\t c-brace-list-key\n\t c-cast-parens\n\t c-class-key\n\t c-class-key\n\t c-class-kwds\n\t c-cleanup-list\n\t c-colon-type-list-re\n\t c-comment-only-line-offset\n\t c-comment-prefix-regexp\n\t c-comment-start-regexp\n\t c-comment-start-regexp\n\t c-cpp-defined-fns\n\t c-current-comment-prefix\n\t c-decl-block-key\n\t c-decl-block-key\n\t c-decl-prefix-re\n\t c-decl-spec-kwds\n\t c-doc-comment-start-regexp\n\t c-expr-kwds\n\t c-file-offsets\n\t c-file-style\n\t c-hanging-braces-alist\n\t c-hanging-colons-alist\n\t c-hanging-comment-ender-p\n\t c-hanging-comment-starter-p\n\t c-hanging-semi\\&comma-criteria\n\t c-identifier-key\n\t c-identifier-last-sym-match\n\t c-identifier-start\n\t c-identifier-syntax-modifications\n\t c-identifier-syntax-table\n\t c-in-comment-lc-prefix\n\t c-indent-comment-alist\n\t c-indent-comments-syntactically-p\n\t c-indentation-style\n\t c-inexpr-block-kwds\n\t c-inexpr-class-kwds\n\t c-keywords\n\t c-keywords-obarray\n\t c-keywords-regexp\n\t c-keywords-regexp\n\t c-known-type-key\n\t c-label-key\n\t c-label-key\n\t c-label-kwds\n\t c-label-kwds-regexp\n\t c-label-kwds-regexp\n\t c-label-minimum-indentation\n\t c-lambda-kwds\n\t c-literal-start-regexp\n\t c-nonsymbol-chars\n\t c-nonsymbol-token-regexp\n\t c-not-decl-init-keywords\n\t c-offsets-alist\n\t c-opt-<>-arglist-start\n\t c-opt-<>-arglist-start-in-paren\n\t c-opt-<>-sexp-key\n\t c-opt-access-key\n\t c-opt-access-key\n\t c-opt-asm-stmt-key\n\t c-opt-asm-stmt-key\n\t c-opt-bitfield-key\n\t c-opt-bitfield-key\n\t c-opt-block-decls-with-vars-key\n\t c-opt-block-stmt-key\n\t c-opt-block-stmt-key\n\t c-opt-cpp-prefix\n\t c-opt-cpp-start\n\t c-opt-decl-spec-key\n\t c-opt-friend-key\n\t c-opt-friend-key\n\t c-opt-identifier-concat-key\n\t c-opt-inexpr-block-key\n\t c-opt-inexpr-block-key\n\t c-opt-inexpr-brace-list-key\n\t c-opt-inexpr-class-key\n\t c-opt-inexpr-class-key\n\t c-opt-lambda-key\n\t c-opt-lambda-key\n\t c-opt-method-key\n\t c-opt-method-key\n\t c-opt-postfix-decl-spec-key\n\t c-opt-type-component-key\n\t c-opt-type-concat-key\n\t c-opt-type-modifier-key\n\t c-opt-type-suffix-key\n\t c-other-decl-block-key\n\t c-other-decl-block-key\n\t c-other-decl-block-kwds\n\t c-other-decl-kwds\n\t c-overloadable-operators-regexp\n\t c-paragraph-separate\n\t c-paragraph-start\n\t c-paren-stmt-key\n\t c-primary-expr-regexp\n\t c-primitive-type-key\n\t c-primitive-type-kwds\n\t c-protection-kwds\n\t c-recognize-<>-arglists\n\t c-recognize-knr-p\n\t c-recognize-knr-p\n\t c-recognize-paren-inits\n\t c-recognize-typeless-decls\n\t c-regular-keywords-regexp\n\t c-simple-stmt-key\n\t c-simple-stmt-kwds\n\t c-special-brace-lists\n\t c-special-brace-lists\n\t c-specifier-key\n\t c-specifier-kwds\n\t c-stmt-delim-chars\n\t c-stmt-delim-chars-with-comma\n\t c-symbol-key\n\t c-symbol-key\n\t c-symbol-start\n\t c-syntactic-eol\n\t c-syntactic-ws-end\n\t c-syntactic-ws-start\n\t c-type-decl-prefix-key\n\t c-type-decl-suffix-key\n\t c-type-prefix-key\n\t comment-end\n\t comment-start\n\t comment-start-skip))\n ;; Skeleton insertion\n skeleton-transformation\n ;; Abbrev mode\n abbrev-mode\n local-abbrev-table\n ;; And finally the syntax table and local map.\n ((syntax-table . set-syntax-table))\n ((current-local-map . use-local-map) buffer)\n paragraph-separate\n paragraph-start\n )\n \"Which local variables to save for major mode regions.\nEach element has the form \\(VARIABLE [TYPE [MODES]]), causing VARIABLE\nto be saved for all major modes in the list MODES. If MODES is t or\nabsent, the variable is saved for all major modes. MODES can also be\na function of no arguments which returns non-nil whenever the variable\nshould be saved.\n\nTYPE should be either the symbol `global', meaning to save the\nvariable globally, the symbol `buffer', meaning to save it per buffer,\nor the symbol `region', meaning to save it for each submode region.\nIf TYPE has any other value, such as nil, or is absent, the variable\nis saved globally. If all optional parameters are omitted, the\nelement may be simply VARIABLE instead of \\(VARIABLE).\n\nIt is possible for VARIABLE to be not a symbol but a cons cell of the\nform \\(GETTER . SETTER), thus specifying special functions to set and\nget the value of the \\\"variable\\\". This is used for objects like\nlocal maps, syntax tables, etc. which need to be installed in a\nspecial way. GETTER should be a function of no arguments, and SETTER\na function of one. In this case, even if TYPE and MODES are omitted,\nthe list cannot be flattened--it must be \\((GETTER . SETTER)).\n\\\"Variables\\\" of this type cannot be seen with `mmm-get-saved-local'.\n\nA single variable may appear more than once in this list, with\ndifferent modes and\/or types. If the same mode appears more than once\nfor the same variable with different types, the behavior is undefined.\nChanging the value of this variable after MMM Mode has been activated\nin some buffer may produce unpredictable results.\n\nGlobally saved variables are saved in the mmm-local-variables property\nof the mode symbol. Buffer saved variables are saved in the alist\n`mmm-buffer-saved-locals'. Region saved variables are saved in the\nmmm-local-variables property of the overlay.\")\n\n(defvar mmm-buffer-saved-locals ()\n \"Stores saved local variables for this buffer, by mode.\nEach element looks like \\(MODE \\(VAR VALUE) ...).\")\n(make-variable-buffer-local 'mmm-buffer-saved-locals)\n\n(defvar mmm-region-saved-locals-defaults ()\n \"Stores saved defaults for region-saved locals, by mode.\nEach element looks like \\(MODE \\(VAR VALUE) ...). Used to initialize\nnew submode regions.\")\n(make-variable-buffer-local 'mmm-region-saved-locals-defaults)\n\n(defvar mmm-region-saved-locals-for-dominant ()\n \"Stores saved region locals for the dominant major mode.\nThe dominant major mode is considered to be one region for purposes of\nsaving region variables. Region-saved variables for submode regions\nare saved as overlay properties.\")\n(make-variable-buffer-local 'mmm-region-saved-locals-for-dominant)\n\n;;}}}\n;;{{{ Submode Faces\n\n(defgroup mmm-faces nil\n \"Faces and coloring for submode regions.\nIn general, only background colors should be set, to avoid interfering\nwith font-lock.\"\n :group 'mmm)\n\n(defcustom mmm-submode-decoration-level 1\n \"*Amount of coloring to use in submode regions.\nShould be either 0, 1, or 2, representing None, Low, and High amounts\nof coloring respectively.\n* None (0) means to use no coloring at all.\n* Low (1) means to use `mmm-default-submode-face' for all submode\n regions \\(except for \\\"non-submode\\\" regions, i.e. those that are of\n the primary mode) and `mmm-delimiter-face' for region delimiters.\n* High (2) means to use different faces for different types of submode\n regions and delimiters, such as initialization code, expressions that\n are output, declarations, and so on, as specified by the submode\n class. The default faces are still used for regions that do not\n specify a face.\"\n :group 'mmm-faces\n :type '(choice (const :tag \"None\" 0)\n\t\t (const :tag \"Low\" 1)\n\t\t (const :tag \"High\" 2)))\n\n(defface mmm-init-submode-face '((t (:background \"Pink\")))\n \"Face used for submodes containing initialization code.\"\n :group 'mmm-faces)\n\n(defface mmm-cleanup-submode-face '((t (:background \"Wheat\")))\n \"Face used for submodes containing cleanup code.\"\n :group 'mmm-faces)\n\n(defface mmm-declaration-submode-face '((t (:background \"Aquamarine\")))\n \"Face used for submodes containing declarations.\"\n :group 'mmm-faces)\n\n(defface mmm-comment-submode-face '((t (:background \"SkyBlue\")))\n \"Face used for submodes containing comments and documentation.\"\n :group 'mmm-faces)\n\n(defface mmm-output-submode-face '((t (:background \"Plum\")))\n \"Face used for submodes containing expression that are output.\"\n :group 'mmm-faces)\n\n(defface mmm-special-submode-face '((t (:background \"MediumSpringGreen\")))\n \"Face used for special submodes not fitting any other category.\"\n :group 'mmm-faces)\n\n(defface mmm-code-submode-face '((t (:background \"LightGray\")))\n \"Face used for submodes containing ordinary code.\"\n :group 'mmm-faces)\n\n(defface mmm-default-submode-face '((t (:background \"gray85\")))\n \"Face used for all submodes at decoration level 1.\nAlso used at decoration level 2 for submodes not specifying a type.\"\n :group 'mmm-faces)\n\n(defface mmm-delimiter-face nil\n \"Face used to mark submode delimiters.\"\n :group 'mmm-faces)\n\n;;}}}\n;;{{{ Mode Line Format\n\n(defcustom mmm-mode-string \" MMM\"\n \"*String to display in mode line as MMM minor mode indicator.\"\n :group 'mmm\n :type 'string)\n\n(defcustom mmm-submode-mode-line-format \"~M[~m]\"\n \"*Format of the mode-line display when point is in a submode region.\n\n~M is replaced by the name of the primary major mode \\(which may be\nreplaced by a combined-mode function, see the info documentation).\n\n~m is replaced by the submode region overlay's `display-name'\nproperty, if it has one. Otherwise it is replaced by the mode name of\nthe submode region.\n\nIf `mmm-primary-mode-display-name' is non-nil, then this variable is\nused even when point is not in a submode region \\(i.e. it is in a\nprimary mode region), with ~m being replaced by the value of that\nvariable.\"\n :group 'mmm\n :type 'string)\n\n(defvar mmm-primary-mode-display-name nil\n \"If non-nil, displayed as the primary mode name in the mode line.\nSee also `mmm-buffer-mode-display-name'.\")\n(make-variable-buffer-local 'mmm-primary-mode-display-name)\n\n(defvar mmm-buffer-mode-display-name nil\n \"If non-nil, displayed in the mode line instead of the primary mode\nname, which is then shown next to it as if it were a submode when in a\nprimary mode region, i.e. outside all submode regions.\")\n(make-variable-buffer-local 'mmm-buffer-mode-display-name)\n\n(defun mmm-set-mode-line ()\n \"Set the mode line display correctly for the current submode,\naccording to `mmm-submode-mode-line-format'.\"\n (let ((primary (or mmm-primary-mode-display-name\n\t\t (get mmm-primary-mode 'mmm-mode-name)))\n\t(submode (and mmm-current-overlay\n\t\t (or (overlay-get mmm-current-overlay 'display-name)\n\t\t\t (get mmm-current-submode 'mmm-mode-name)))))\n (if mmm-buffer-mode-display-name\n\t(setq mode-name\n\t (mmm-format-string mmm-submode-mode-line-format\n\t\t\t\t `((\"~M\" . ,mmm-buffer-mode-display-name)\n\t\t\t\t (\"~m\" . ,(or submode primary)))))\n (if submode\n\t (setq mode-name\n\t\t(mmm-format-string mmm-submode-mode-line-format\n\t\t\t\t `((\"~M\" . ,primary)\n\t\t\t\t (\"~m\" . ,submode))))\n\t(setq mode-name primary))))\n (force-mode-line-update))\n\n;;}}}\n;;{{{ Submode Classes\n\n(defvar mmm-classes nil\n \"*List of submode classes that apply to a buffer.\nGenerally set in a file local variables list. Can either be one\nsymbol, or a list of symbols. Automatically buffer-local.\")\n(make-variable-buffer-local 'mmm-classes)\n\n(defvar mmm-global-classes '(universal)\n \"*List of submode classes that apply to all buffers.\nCan be overridden in a file local variables list.\")\n\n;;}}}\n;;{{{ Modes and Extensions\n\n(defcustom mmm-mode-ext-classes-alist nil\n \"Alist of submode classes for major modes and\/or file extensions.\nThis variable can now be directly modified.\n\nElements look like \\(MODE EXT CLASS), where MODE is a major mode, EXT\nis a regexp to match a filename such as in `auto-mode-alist', and\nCLASS is a submode class. CLASS is activated in all buffers in mode\nMODE \\(if non-nil) and whose filenames match EXT \\(if non-nil). If\nboth MODE and EXT are nil, CLASS is activated in all buffers. If CLASS\nis the symbol t, MMM Mode is turned on in all buffers matching MODE\nand EXT, but no classes are activated.\n\nSee `mmm-global-mode'.\"\n :group 'mmm\n :type '(repeat (list (symbol :tag \"Major Mode\")\n\t\t (string :tag \"Filename Regexp\")\n\t\t (symbol :tag \"Class\")))\n :require 'mmm-mode)\n\n(defun mmm-add-mode-ext-class (mode ext class)\n \"Add an element to `mmm-mode-ext-classes-alist', which see.\nThat variable can now be directly modified, so this function is\nunnecessary. It probably won't go away, though.\"\n (add-to-list 'mmm-mode-ext-classes-alist (list mode ext class)))\n\n;;}}}\n;;{{{ Preferred Major Modes\n\n(defcustom mmm-major-mode-preferences\n '((perl cperl-mode perl-mode)\n (javascript javascript-mode c++-mode)\n (java jde-mode java-mode c++-mode)\n (css css-mode c++-mode))\n \"User preferences about what major modes to use.\nEach element has the form \\(LANGUAGE . MODES) where LANGUAGE is the\nname of a programming language such as `perl' as a symbol, and MODES\nis a list of possible major modes to use, such as `cperl-mode' or\n`perl-mode'. The first element of MODES which is `fboundp' is used\nfor submodes of LANGUAGE. The last element of MODES should be a mode\nwhich will always be available.\"\n :group 'mmm\n :type '(repeat (cons symbol\n\t\t (repeat\n\t\t\t(restricted-sexp :match-alternatives\n\t\t\t\t\t (fboundp))))))\n\n(defun mmm-add-to-major-mode-preferences (language mode &optional default)\n \"Set the preferred major mode for LANGUAGE to MODE.\nThis sets the value of `mmm-major-mode-preferences'. If DEFAULT is\nnil or unsupplied, MODE is added at the front of the list of modes for\nLANGUAGE. If DEFAULT is non-nil, then it is added at the end. This\nmay be used by packages to ensure that some mode is present, but not\noverride any user-specified mode.\"\n (let ((pair (assq language mmm-major-mode-preferences)))\n (if pair\n\t;; Existing mode preferences\n\t(if default\n\t (setcdr pair (cons mode (cdr pair)))\n\t (setcdr pair (append (cdr pair) (list mode))))\n ;; No existing mode preference\n (add-to-list 'mmm-major-mode-preferences (list language mode)))))\n\n(defun mmm-ensure-modename (symbol)\n \"Return SYMBOL if it is a valid submode name, else nil.\nValid submode names are either `fboundp' or present as the `car' of an\nelement in `mmm-major-mode-preferences'.\"\n (if (or (fboundp symbol)\n\t (assq symbol mmm-major-mode-preferences))\n symbol\n nil))\n\n(defun mmm-modename->function (mode)\n \"Convert MODE to a mode function, nil if impossible.\nValid submode names are either `fboundp' or present as the `car' of an\nelement in `mmm-major-mode-preferences'. In the latter case, the\nfirst `fboundp' element of the `cdr' is returned, or nil if none.\"\n (if (fboundp mode)\n mode\n (car (remove-if-not\n\t #'fboundp\n\t (cdr (assq mode mmm-major-mode-preferences))))))\n\n;;}}}\n;;{{{ Delimiter Regions\n\n(defcustom mmm-delimiter-mode 'fundamental-mode\n \"Major mode used by default for delimiter regions.\nClasses are encouraged to override this by providing a delimiter-mode\nparameter-- see `mmm-classes-alist'.\"\n :group 'mmm\n :type 'function)\n\n;;}}}\n;;{{{ Key Bindings\n\n(defcustom mmm-mode-prefix-key [(control ?c) ?%]\n \"Prefix key for the MMM Minor Mode Keymap.\"\n :group 'mmm\n :type 'vector)\n\n(defcustom mmm-command-modifiers '(control)\n \"List of key modifiers for MMM command keys.\nThe MMM commands in the MMM Mode map, after `mmm-mode-prefix-key',\nare bound to default keys with these modifiers added. This variable\nmust be set before MMM Mode is loaded to have an effect.\n\nIt is suggested that the value of this variable be either nil or\n\\(control), as the default keys are either plain keys or have only a\nmeta modifier. The shift modifier is not particularly portable between\nEmacsen. The values of this variable and `mmm-insert-modifiers' should\nbe disjoint.\"\n :group 'mmm\n :type '(repeat (symbol :tag \"Modifier\")))\n\n(defcustom mmm-insert-modifiers '()\n \"List of key modifiers for MMM submode insertion keys.\nWhen a key pressed after `mmm-mode-prefix-key' has no MMM Mode command\nbinding, and its modifiers include these, then its basic type, plus any\nmodifiers in addition to these, is looked up in classes' :insert\nspecifications.\n\nIt is suggested that the value of this variable be either nil or\n\\(control), allowing submode classes to specify the presence or\nabsence of the meta modifier. The shift modifier is not particularly\nportable between Emacsen. The values of `mmm-command-modifiers' and\nthis variable should be disjoint.\"\n :group 'mmm\n :type '(repeat (symbol :tag \"Modifier\")))\n\n(defcustom mmm-use-old-command-keys nil\n \"Non-nil means to Use the old command keys for MMM Mode.\nMMM Mode commands then have no modifier while insertion commands have\na control modifier, i.e. `mmm-command-modifiers' is set to nil and\n`mmm-insert-modifiers' is set to \\(control). If nil, the values of\nthese variables are as the default, or whatever the user has set them\nto. This variable must be set before MMM Mode is loaded.\"\n :group 'mmm\n :type 'boolean)\n\n(defun mmm-use-old-command-keys ()\n \"Use the old command keys \\(no control modifer) in MMM Mode.\"\n (setq mmm-command-modifiers '()\n\tmmm-insert-modifiers '(control)))\n\n;;}}}\n;;{{{ MMM Hooks\n\n(defcustom mmm-mode-hook ()\n \"Hook run when MMM Mode is enabled in a buffer.\n\nA hook named mmm--hook is also run, if it exists. For\nexample, `mmm-html-mode-hook' is run whenever MMM Mode is entered with\nHTML mode the dominant mode.\n\nA hook named mmm--submode-hook is run when a submode region\nof a given mode is created. For example, `mmm-cperl-mode-submode-hook'\nis run whenever a CPerl mode submode region is created, in any buffer.\nWhen this hooks are run, point is guaranteed to be at the start of\nthe newly created submode region.\n\nFinally, a hook named mmm--class-hook is run whenever a buffer\nis first mmm-ified with a given submode class. For example,\n`mmm-mason-class-hook' is run whenever the `mason' class is first\napplied in a buffer.\"\n :group 'mmm\n :type 'hook)\n\n(defun mmm-run-constructed-hook (body &optional suffix)\n \"Run the hook named `mmm---hook', if it exists.\nIf SUFFIX is nil or unsupplied, run `mmm--hook' instead.\"\n (let ((hook (intern-soft (if suffix\n\t\t\t (format \"mmm-%s-%s-hook\" body suffix)\n\t\t\t (format \"mmm-%s-hook\" body)))))\n (if hook (run-hooks hook))))\n\n(defun mmm-run-major-hook ()\n (mmm-run-constructed-hook mmm-primary-mode))\n\n(defun mmm-run-submode-hook (submode)\n (mmm-run-constructed-hook submode \"submode\"))\n\n(defvar mmm-class-hooks-run ()\n \"List of submode classes for which hooks have already been run in\nthe current buffer.\")\n(make-variable-buffer-local 'mmm-class-hooks-run)\n\n(defun mmm-run-class-hook (class)\n (unless (member class mmm-class-hooks-run)\n (mmm-run-constructed-hook class \"class\")\n (add-to-list 'mmm-class-hooks-run class)))\n\n(defvar mmm-primary-mode-entry-hook nil\n \"Hook run when point moves into a region of the primary mode.\nEach submode region can have an `entry-hook' property which is run\nwhen they are entered, but since primary mode regions have no overlay\nto store properties, this is a buffer-local variable.\n\nN.B. This variable is not a standard Emacs hook. Unlike Emacs'\n\\\"local hooks\\\" it has *no* global value, only a local one. Its value\nshould always be a list of functions \\(possibly empty) and never a\nsingle function. It may be used with `add-hook', however.\")\n(make-variable-buffer-local 'mmm-primary-mode-entry-hook)\n\n;;}}}\n;;{{{ Major Mode Hook\n\n(defcustom mmm-major-mode-hook ()\n \"Hook run whenever a new major mode is finished starting up.\nMMM Mode implements this with a hack \\(see comments in the source) so\nthat `mmm-global-mode' will function correctly, but makes this hook\navailable so that others can take advantage of the hack as well.\n\nNote that file local variables have *not* been processed by the time\nthis hook is run. If a function needs to inspect them, it should also\nbe added to `find-file-hooks'. However, `find-file-hooks' is not run\nwhen creating a non-file-based buffer, or when changing major modes in\nan existing buffer.\"\n :group 'mmm\n :type 'hook)\n\n(defun mmm-run-major-mode-hook ()\n (dolist (func mmm-major-mode-hook)\n (ignore-errors (funcall func))))\n\n;;}}}\n;;{{{ MMM Global Mode\n\n;;; There's a point to be made that this variable should default to\n;;; `maybe' (i.e. not nil and not t), because that's what practically\n;;; everyone wants. I subscribe, however, to the view that simply\n;;; *loading* a lisp extension should not change the (user-visible)\n;;; behavior of Emacs, until it is configured or turned on in some\n;;; way, which dictates that the default for this must be nil.\n(defcustom mmm-global-mode nil\n \"*Specify in which buffers to turn on MMM Mode automatically.\n\n- If nil, MMM Mode is never enabled automatically.\n- If t, MMM Mode is enabled automatically in all buffers.\n- If any other symbol, MMM mode is enabled only in those buffers that\n have submode classes associated with them. See `mmm-classes' and\n `mmm-mode-ext-classes-alist' for more information.\"\n :group 'mmm\n :type '(choice (const :tag \"Always\" t)\n\t\t (const :tag \"Never\" nil)\n\t\t (other :tag \"Maybe\" maybe))\n :require 'mmm-mode)\n\n;; These are not traditional editing modes, so mmm makes no sense, and\n;; can mess things up seriously if it doesn't know not to try.\n(defcustom mmm-never-modes\n '(\n help-mode\n Info-mode\n dired-mode\n comint-mode\n telnet-mode\n shell-mode\n eshell-mode\n forms-mode\n )\n \"List of modes in which MMM Mode is never activated.\"\n :group 'mmm\n :type '(repeat (symbol :tag \"Mode\")))\n\n;;}}}\n;;{{{ Buffer File Name\n\n(defvar mmm-set-file-name-for-modes '(mew-draft-mode)\n \"List of modes for which the temporary buffers MMM creates have a\nfile name. In these modes, this file name is the same as that of the\nparent buffer. In general, this has been found to cause more problems\nthan it solves, but some modes require it.\")\n\n;;}}}\n\n;; NON-USER VARIABLES\n;;{{{ Mode Variable\n\n(defvar mmm-mode nil\n \"Non-nil means MMM Mode is turned on in this buffer.\nDo not set this variable directly; use the function `mmm-mode'.\")\n(make-variable-buffer-local 'mmm-mode)\n\n;;}}}\n;;{{{ Primary Mode\n\n(defvar mmm-primary-mode nil\n \"The primary major mode in the current buffer.\")\n(make-variable-buffer-local 'mmm-primary-mode)\n\n;;}}}\n;;{{{ Classes Alist\n\n;; Notes:\n;; 1. :parent could be an all-class argument. Same with :keymap.\n;; 2. :match-submode really does have to be distinct from :submode,\n;; because 'functionp' isn't enough to distinguish which is meant.\n(defvar mmm-classes-alist nil\n \"Alist containing all defined mmm submode classes.\nA submode class is a named recipe for parsing a document into submode\nregions, and sometimes for inserting new ones while editing.\n\nEach element of this alist looks like \\(CLASS . ARGS) where CLASS is a\nsymbol naming the submode class and ARGS is a list of keyword\narguments, called a \\\"class specifier\\\". There are a large number of\naccepted keyword arguments in the class specifier.\n\nThe argument CLASSES, if supplied, must be a list of other submode\nclass names, or class specifiers, representing other classes to call\nrecursively. The FACE arguments of these classes are overridden by\nthe FACE argument of this class. If the argument CLASSES is supplied,\nall other arguments to this class are ignored. That is, \\\"grouping\\\"\nclasses can do nothing but group other classes.\n\nThe argument HANDLER, if supplied, also overrides any other processing.\nIt must be a function, and all the arguments are passed to it as\nkeywords, and it must do everything. See `mmm-ify' for what sorts of\nthings it must do. This back-door interface should be cleaned up.\n\nThe optional argument FACE gives the display face of the submode\nregions under high decoration (see `mmm-submode-decoration-level').\nIt must be a valid face. The standard faces used for submode regions\nare `mmm-*-submode-face' where * is one of `init', `cleanup',\n`declaration', `comment', `output', `special', or `code'. A more\nflexible alternative is the argument MATCH-FACE. MATCH-FACE can be a\nfunction, which is called with one argument, the form of the front\ndelimiter \\(found from FRONT-FORM, below), and should return the face\nto use. It can also be an alist, with each element of the form\n\\(DELIM . FACE).\n\nIf neither CLASSES nor HANDLER are supplied, either SUBMODE or\nMATCH-SUBMODE must be. SUBMODE specifies the submode to use for the\nsubmode regions, a symbol such as `cperl-mode' or `emacs-lisp-mode',\nwhile MATCH-SUBMODE must be a function to be called immediately after\na match is found for FRONT, which is passed one argument, the form of\nthe front delimiter \\(found from FRONT-FORM, below), and return a\nsymbol such as SUBMODE would be set to. If MATCH-SUBMODE detects an\ninvalid match--for example a specified mode which is not `fboundp'--it\nshould \\(signal 'mmm-no-matching-submode nil).\n\nFRONT and BACK are the means to find the submode regions, and can be\neither buffer positions \\(number-or-markers), regular expressions, or\nfunctions. If they are absolute buffer positions, only one submode\nregion is created, from FRONT to BACK. This is generally not used in\nnamed classes. \\(Unnamed classes are created by interactive commands\nin `mmm-interactive-history').\n\nIf FRONT is a regexp, then that regexp is searched for, and the end of\nits FRONT-MATCH'th match \\(or the beginning thereof, if INCLUDE-FRONT\nis non-nil), plus FRONT-OFFSET, becomes the beginning of the submode\nregion. If FRONT is a function, that function is called instead, and\nmust act somewhat like a search, in that it should start at point,\ntake one argument as a search bound, and set the match data. A\nsimilar pattern is followed for BACK \\(the search starts at the\nbeginning of the submode region), save that the beginning of its\nBACK-MATCH'th match \\(or the end, if INCLUDE-BACK is non-nil) becomes\nthe end of the submode region, plus BACK-OFFSET.\n\nIf SAVE-MATCHES is non-nil, then BACK, if it is a regexp, is formatted\nby replacing strings of the form \\\"~N\\\" by the corresponding value of\n\\(match-string n) after matching FRONT.\n\nFRONT-MATCH and BACK-MATCH default to zero. They specify which\nsub-match of the FRONT and BACK regexps to treat as the delimiter.\nThis number will be passed to any calls to `match-beginning' and\ncompany.\n\nFRONT- and BACK-OFFSET default to 0. In addition to numbers, they can\nalso be functions to call which should move point to the correct\nposition for the beginning or end of the submode region. Common\nchoices include `beginning-of-line' and `end-of-line', and new\nfunctions can of course be written. They can also be lists which will\nbe applied in sequence, such as \\(end-of-line 1) meaning move to end\nof line and then forward one character.\n\nFRONT-VERIFY and BACK-VERIFY, if supplied, must be functions that\ninspect the match data to see if a match found by FRONT or BACK\nrespectively is valid.\n\nFRONT-DELIM \\(resp. BACK-DELIM), if supplied, can take values like\nthose of FRONT-OFFSET \\(resp. BACK-OFFSET), specifying the offset from\nthe start \\(resp. end) of the match for FRONT \\(resp. BACK) to use as\nthe starting \\(resp. ending) point for the front \\(resp. back)\ndelimiter. If nil, it means not to make a region for the respective\ndelimiter at all.\n\nDELIMITER-MODE, if supplied, specifies what submode to use for the\ndelimiter regions, if any. If `nil', the primary mode is used. If\nnot supplied, `mmm-delimiter-mode' is used.\n\nFRONT-FACE and BACK-FACE specify faces to use for displaying the\ndelimiter regions, under high decoration.\n\nFRONT-FORM and BACK-FORM, if given, must supply a regexp used to match\nthe *actual* delimiter. If they are strings, they are used as-is. If\nthey are functions, they are called and must inspect the match data.\nIf they are lists, their `car' is taken as the delimiter. The default\nfor both is \\(regexp-quote \\(match-string 0)).\n\nThe last case--them being a list--is usually used to set the delimiter\nto a function. Such a function must take 1-2 arguments, the first\nbeing the overlay in question, and the second meaning to insert the\ndelimiter and adjust the overlay rather than just matching the\ndelimiter. See `mmm-match-front', `mmm-match-back', and\n`mmm-end-current-region'.\n\nCASE-FOLD-SEARCH, if specified, controls whether the search is\ncase-insensitive. See `case-fold-search'. It defaults to `t'.\n\nCREATION-HOOK, if specified, should be a function which is run\nwhenever a submode region is created, with point at the beginning of\nthe new region. One use for it is to set region-saved local variables\n\\(see `mmm-save-local-variables').\n\nINSERT specifies the keypress insertion spec for such submode regions.\nINSERT's value should be list of elements of the form \\(KEY NAME .\nSPEC). Each KEY should be either a character, a function key symbol,\nor a dotted list \\(MOD . KEY) where MOD is a symbol for a modifier\nkey. The use of any other modifier than meta is discouraged, as\n`mmm-insert-modifiers' is sometimes set to \\(control), and other\nmodifiers are not very portable. Each NAME should be a symbol\nrepresenting the insertion for that key. Each SPEC can be either a\nskeleton, suitable for passing to `skeleton-insert' to create a\nsubmode region, or a dotted pair \\(OTHER-KEY . ARG) meaning to use the\nskeleton defined for OTHER-KEY but pass it the argument ARG as the\n`str' variable, possible replacing a prompt string. Skeletons for\ninsertion should have the symbol `_' where point \\(or wrapped text)\nshould go, and the symbol `@' in four different places: at the\nbeginning of the front delimiter, the beginning of the submode region,\nthe end of the submode region, and the end of the back delimiter.\n\nIf END-NOT-BEGIN is non-nil, it specifies that a BACK delimiter cannot\nbegin a new submode region.\n\nMATCH-NAME, if supplied, specifies how to determine the \\\"name\\\" for\neach submode region. It must be a string or a function. If it is a\nfunction, it is passed the value of FRONT-FORM and must return the\nname to use. If it is a string, it is used as-is unless SAVE-NAME has\na non-nil value, in which case, the string is interpreted the same as\nBACK when SAVE-MATCHES is non-nil. If MATCH-NAME is not specified,\nthe regions are unnamed. Regions with the same name are considered\npart of the same chunk of code, and formatted as such, while unnamed\nregions are not grouped with any others.\n\nAs a special optimization for insertion, if SKEL-NAME is non-nil, the\ninsertion code will use the user-prompted string value as the region\nname, instead of going through the normal matching procedure.\n\nPRIVATE, if supplied and non-nil, means that this class is a private\nor internal class, usually one invoked by another class via :classes,\nand is not for the user to see.\")\n\n(defun mmm-add-classes (classes)\n \"Add the submode classes CLASSES to `mmm-classes-alist'.\"\n (dolist (class classes)\n (add-to-list 'mmm-classes-alist class)))\n\n(defun mmm-add-group (group classes)\n \"Add CLASSES and a \\\"grouping class\\\" named GROUP which calls them all.\nThe CLASSES are all made private, i.e. non-user-visible.\"\n (mmm-add-classes (mapcar #'(lambda (class)\n\t\t\t (append class\n\t\t\t\t '(:private t)))\n\t\t\t classes))\n (add-to-list 'mmm-classes-alist\n\t (list group :classes (mapcar #'first classes))))\n\n(defun mmm-add-to-group (group classes)\n \"Add CLASSES to the \\\"grouping class\\\" named GROUP.\nThe CLASSES are all made private, i.e. non-user-visible.\"\n (mmm-add-classes (mapcar #'(lambda (class)\n\t\t\t (append class\n\t\t\t\t '(:private t)))\n\t\t\t classes))\n (mmm-set-class-parameter group :classes\n\t\t\t (append (mmm-get-class-parameter group :classes)\n\t\t\t\t (mapcar #'first classes))))\n\n;;}}}\n;;{{{ Version Number\n\n(defconst mmm-version \"0.4.8\"\n \"Current version of MMM Mode.\")\n\n(defun mmm-version ()\n (interactive)\n (message \"MMM Mode version %s by Michael Abraham Shulman\" mmm-version))\n\n;;}}}\n;;{{{ Temp Buffer Name\n\n(defvar mmm-temp-buffer-name \" *mmm-temp*\"\n \"Name for temporary buffers created by MMM Mode.\")\n\n;;}}}\n;;{{{ Interactive History\n\n(defvar mmm-interactive-history nil\n \"History of interactive mmm-ification in the current buffer.\nElements are either submode class symbols or class specifications. See\n`mmm-classes-alist' for more information.\")\n(make-variable-buffer-local 'mmm-interactive-history)\n\n(defun mmm-add-to-history (class)\n (add-to-list 'mmm-interactive-history class))\n\n(defun mmm-clear-history ()\n \"Clears history of interactive mmm-ification in current buffer.\"\n (interactive)\n (setq mmm-interactive-history nil))\n\n;;}}}\n;;{{{ Mode\/Ext Manipulation\n\n(defvar mmm-mode-ext-classes ()\n \"List of classes associated with current buffer by mode and filename.\nSet automatically from `mmm-mode-ext-classes-alist'.\")\n(make-variable-buffer-local 'mmm-mode-ext-classes)\n\n(defun mmm-get-mode-ext-classes ()\n \"Return classes for current buffer from major mode and filename.\nUses `mmm-mode-ext-classes-alist' to find submode classes.\"\n (or mmm-mode-ext-classes\n (setq mmm-mode-ext-classes\n\t (mapcar #'third\n\t\t (remove-if-not #'mmm-mode-ext-applies\n\t\t\t\t mmm-mode-ext-classes-alist)))))\n\n(defun mmm-clear-mode-ext-classes ()\n \"Clear classes added by major mode and filename.\"\n (setq mmm-mode-ext-classes nil))\n\n(defun mmm-mode-ext-applies (element)\n (destructuring-bind (mode ext class) element\n (and (if mode\n\t (eq mode\n\t\t ;; If MMM is on in this buffer, use the primary mode,\n\t\t ;; otherwise use the normal indicator.\n\t\t (or mmm-primary-mode major-mode))\n\t t)\n\t (if ext\n\t (and (buffer-file-name)\n\t\t (save-match-data\n\t\t (string-match ext (buffer-file-name))))\n\t t))))\n\n(defun mmm-get-all-classes (global)\n \"Return a list of all classes applicable to the current buffer.\nThese come from mode\/ext associations, `mmm-classes', and interactive\nhistory, as well as `mmm-global-classes' if GLOBAL is non-nil.\"\n (append mmm-interactive-history\n\t (if (listp mmm-classes) mmm-classes (list mmm-classes))\n\t (if global mmm-global-classes ())\n\t (mmm-get-mode-ext-classes)))\n\n;;}}}\n\n(provide 'mmm-vars)\n\n;;; mmm-vars.el ends here\n","avg_line_length":36.5804924242,"max_line_length":74,"alphanum_fraction":0.7314970618} {"size":695,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";; Install required packages if not installed.\n(mapc #'(lambda (package)\n (unless (package-installed-p package)\n (package-install package)))\n '(elpy poetry tox)\n)\n\n;; Elpy for python development.\n(require 'elpy)\n(elpy-enable)\n(setenv \"WORKON_HOME\" \"~\/.virtualenvs\")\n\n;; Set python version to use.\n(setq py-python-command 'python3)\n\n;; Set python version for elpy.\n(setq python-shell-interpreter \"python3\"\n python-shell-interpreter-args \"-i\")\n(setq elpy-test-runner (quote elpy-test-pytest-runner))\n\n;; Tox.\n(setq tox-runner 'py.test-3)\n\n;; Default enviroment for running tox (same as tox.ini).\n(defvar tox-default-env \"py37\" \"Default argument for Tox\")\n\n;; Poetry.\n(require 'poetry)\n","avg_line_length":23.9655172414,"max_line_length":58,"alphanum_fraction":0.7079136691} {"size":2602,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; lang\/csharp\/config.el -*- lexical-binding: t; -*-\n\n(after! csharp-mode\n (add-hook 'csharp-mode-hook #'rainbow-delimiters-mode)\n\n (when (featurep! +lsp)\n (add-hook 'csharp-mode-local-vars-hook #'lsp!))\n\n (set-electric! 'csharp-mode :chars '(?\\n ?\\}))\n (set-rotate-patterns! 'csharp-mode\n :symbols '((\"public\" \"protected\" \"private\")\n (\"class\" \"struct\")))\n (sp-local-pair 'csharp-mode \"<\" \">\"\n :when '(+csharp-sp-point-in-type-p)\n :post-handlers '((\"| \" \"SPC\"))))\n\n\n(use-package! omnisharp\n :unless (featurep! +lsp)\n :hook (csharp-mode . omnisharp-mode)\n :commands omnisharp-install-server\n :preface\n (setq omnisharp-auto-complete-want-documentation nil\n omnisharp-cache-directory (concat doom-cache-dir \"omnisharp\"))\n :config\n (defun +csharp-cleanup-omnisharp-server-h ()\n \"Clean up the omnisharp server once you kill the last csharp-mode buffer.\"\n (unless (doom-buffers-in-mode 'csharp-mode (buffer-list))\n (omnisharp-stop-server)))\n (add-hook! 'csharp-mode-hook\n (add-hook 'kill-buffer-hook #'+csharp-cleanup-omnisharp-server-h nil t))\n\n (set-company-backend! 'csharp-mode 'company-omnisharp)\n (set-lookup-handlers! 'csharp-mode\n :definition #'omnisharp-go-to-definition\n :references #'omnisharp-find-usages\n :documentation #'omnisharp-current-type-documentation)\n\n (map! :localleader\n :map omnisharp-mode-map\n \"b\" #'omnisharp-recompile\n (:prefix \"r\"\n \"u\" #'omnisharp-fix-usings\n \"r\" #'omnisharp-rename\n \"a\" #'omnisharp-show-last-auto-complete-result\n \"o\" #'omnisharp-show-overloads-at-point)\n (:prefix \"f\"\n \"u\" #'omnisharp-find-usages\n \"i\" #'omnisharp-find-implementations\n \"f\" #'omnisharp-navigate-to-current-file-member\n \"m\" #'omnisharp-navigate-to-solution-member\n \"M\" #'omnisharp-navigate-to-solution-file-then-file-member\n \"F\" #'omnisharp-navigate-to-solution-file\n \"r\" #'omnisharp-navigate-to-region\n \"ti\" #'omnisharp-current-type-information\n \"td\" #'omnisharp-current-type-documentation)\n (:prefix \"t\"\n \"s\" #'omnisharp-unit-test-at-point\n \"l\" #'omnisharp-unit-test-last\n \"b\" #'omnisharp-unit-test-buffer)))\n\n\n;;;###package shader-mode\n(when (featurep! +unity)\n ;; Unity shaders\n (add-to-list 'auto-mode-alist '(\"\\\\.shader\\\\'\" . shader-mode))\n\n (def-project-mode! +csharp-unity-mode\n :modes '(csharp-mode shader-mode)\n :files (and \"Assets\" \"Library\/MonoManager.asset\" \"Library\/ScriptMapper\")))\n","avg_line_length":36.6478873239,"max_line_length":78,"alphanum_fraction":0.6272098386} {"size":17348,"ext":"el","lang":"Emacs Lisp","max_stars_count":1.0,"content":";;; seq-24.el --- seq.el implementation for Emacs 24.x -*- lexical-binding: t -*-\n\n;; Copyright (C) 2014-2016 Free Software Foundation, Inc.\n\n;; Author: Nicolas Petton \n;; Keywords: sequences\n\n;; Maintainer: emacs-devel@gnu.org\n\n;; This file is part of GNU Emacs.\n\n;; GNU Emacs is free software: you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; GNU Emacs is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs. If not, see .\n\n;;; Commentary:\n\n;; Sequence-manipulation functions that complement basic functions\n;; provided by subr.el.\n;;\n;; All functions are prefixed with \"seq-\".\n;;\n;; All provided functions work on lists, strings and vectors.\n;;\n;; Functions taking a predicate or iterating over a sequence using a\n;; function as argument take the function as their first argument and\n;; the sequence as their second argument. All other functions take\n;; the sequence as their first argument.\n\n;;; Code:\n\n(defmacro seq-doseq (spec &rest body)\n \"Loop over a sequence.\nSimilar to `dolist' but can be applied to lists, strings, and vectors.\n\nEvaluate BODY with VAR bound to each element of SEQ, in turn.\n\n\\(fn (VAR SEQ) BODY...)\"\n (declare (indent 1) (debug ((symbolp form &optional form) body)))\n (let ((length (make-symbol \"length\"))\n (seq (make-symbol \"seq\"))\n (index (make-symbol \"index\")))\n `(let* ((,seq ,(cadr spec))\n (,length (if (listp ,seq) nil (seq-length ,seq)))\n (,index (if ,length 0 ,seq)))\n (while (if ,length\n (< ,index ,length)\n (consp ,index))\n (let ((,(car spec) (if ,length\n (prog1 (seq-elt ,seq ,index)\n (setq ,index (+ ,index 1)))\n (pop ,index))))\n ,@body)))))\n\n;; Implementation of `seq-let' compatible with Emacs<25.1.\n(defmacro seq-let (args sequence &rest body)\n \"Bind the variables in ARGS to the elements of SEQUENCE then evaluate BODY.\n\nARGS can also include the `&rest' marker followed by a variable\nname to be bound to the rest of SEQUENCE.\"\n (declare (indent 2) (debug t))\n (let ((seq-var (make-symbol \"seq\")))\n `(let* ((,seq-var ,sequence)\n ,@(seq--make-bindings args seq-var))\n ,@body)))\n\n(defun seq-drop (sequence n)\n \"Return a subsequence of SEQUENCE without its first N elements.\nThe result is a sequence of the same type as SEQUENCE.\n\nIf N is a negative integer or zero, SEQUENCE is returned.\"\n (if (<= n 0)\n sequence\n (if (listp sequence)\n (seq--drop-list sequence n)\n (let ((length (seq-length sequence)))\n (seq-subseq sequence (min n length) length)))))\n\n(defun seq-take (sequence n)\n \"Return a subsequence of SEQUENCE with its first N elements.\nThe result is a sequence of the same type as SEQUENCE.\n\nIf N is a negative integer or zero, an empty sequence is\nreturned.\"\n (if (listp sequence)\n (seq--take-list sequence n)\n (seq-subseq sequence 0 (min (max n 0) (seq-length sequence)))))\n\n(defun seq-drop-while (predicate sequence)\n \"Return a sequence from the first element for which (PREDICATE element) is nil in SEQUENCE.\nThe result is a sequence of the same type as SEQUENCE.\"\n (if (listp sequence)\n (seq--drop-while-list predicate sequence)\n (seq-drop sequence (seq--count-successive predicate sequence))))\n\n(defun seq-take-while (predicate sequence)\n \"Return the successive elements for which (PREDICATE element) is non-nil in SEQUENCE.\nThe result is a sequence of the same type as SEQUENCE.\"\n (if (listp sequence)\n (seq--take-while-list predicate sequence)\n (seq-take sequence (seq--count-successive predicate sequence))))\n\n(defun seq-filter (predicate sequence)\n \"Return a list of all the elements for which (PREDICATE element) is non-nil in SEQUENCE.\"\n (let ((exclude (make-symbol \"exclude\")))\n (delq exclude (seq-map (lambda (elt)\n (if (funcall predicate elt)\n elt\n exclude))\n sequence))))\n\n(defun seq-map-indexed (function sequence)\n \"Return the result of applying FUNCTION to each element of SEQUENCE.\nUnlike `seq-map', FUNCTION takes two arguments: the element of\nthe sequence, and its index within the sequence.\"\n (let ((index 0))\n (seq-map (lambda (elt)\n (prog1\n (funcall function elt index)\n (setq index (1+ index))))\n sequence)))\n\n(defun seq-remove (predicate sequence)\n \"Return a list of all the elements for which (PREDICATE element) is nil in SEQUENCE.\"\n (seq-filter (lambda (elt) (not (funcall predicate elt)))\n sequence))\n\n(defun seq-reduce (function sequence initial-value)\n \"Reduce the function FUNCTION across SEQUENCE, starting with INITIAL-VALUE.\n\nReturn the result of calling FUNCTION with INITIAL-VALUE and the\nfirst element of SEQUENCE, then calling FUNCTION with that result and\nthe second element of SEQUENCE, then with that result and the third\nelement of SEQUENCE, etc.\n\nIf SEQUENCE is empty, return INITIAL-VALUE and FUNCTION is not called.\"\n (if (seq-empty-p sequence)\n initial-value\n (let ((acc initial-value))\n (seq-doseq (elt sequence)\n (setq acc (funcall function acc elt)))\n acc)))\n\n(defun seq-some (predicate sequence)\n \"Return the first value for which if (PREDICATE element) is non-nil for in SEQUENCE.\"\n (catch 'seq--break\n (seq-doseq (elt sequence)\n (let ((result (funcall predicate elt)))\n (when result\n (throw 'seq--break result))))\n nil))\n\n(defun seq-find (predicate sequence &optional default)\n \"Return the first element for which (PREDICATE element) is non-nil in SEQUENCE.\nIf no element is found, return DEFAULT.\n\nNote that `seq-find' has an ambiguity if the found element is\nidentical to DEFAULT, as it cannot be known if an element was\nfound or not.\"\n (catch 'seq--break\n (seq-doseq (elt sequence)\n (when (funcall predicate elt)\n (throw 'seq--break elt)))\n default))\n\n(defun seq-every-p (predicate sequence)\n \"Return non-nil if (PREDICATE element) is non-nil for all elements of the sequence SEQUENCE.\"\n (catch 'seq--break\n (seq-doseq (elt sequence)\n (or (funcall predicate elt)\n (throw 'seq--break nil)))\n t))\n\n(defun seq-count (predicate sequence)\n \"Return the number of elements for which (PREDICATE element) is non-nil in SEQUENCE.\"\n (let ((count 0))\n (seq-doseq (elt sequence)\n (when (funcall predicate elt)\n (setq count (+ 1 count))))\n count))\n\n(defun seq-empty-p (sequence)\n \"Return non-nil if the sequence SEQUENCE is empty, nil otherwise.\"\n (if (listp sequence)\n (null sequence)\n (= 0 (seq-length sequence))))\n\n(defun seq-sort (predicate sequence)\n \"Return a sorted sequence comparing using PREDICATE the elements of SEQUENCE.\nThe result is a sequence of the same type as SEQUENCE.\"\n (if (listp sequence)\n (sort (seq-copy sequence) predicate)\n (let ((result (seq-sort predicate (append sequence nil))))\n (seq-into result (type-of sequence)))))\n\n(defun seq-sort-by (function pred sequence)\n \"Sort SEQUENCE using PRED as a comparison function.\nElements of SEQUENCE are transformed by FUNCTION before being\nsorted. FUNCTION must be a function of one argument.\"\n (seq-sort (lambda (a b)\n (funcall pred\n (funcall function a)\n (funcall function b)))\n sequence))\n\n(defun seq-contains (sequence elt &optional testfn)\n \"Return the first element in SEQUENCE that equals to ELT.\nEquality is defined by TESTFN if non-nil or by `equal' if nil.\"\n (seq-some (lambda (e)\n (funcall (or testfn #'equal) elt e))\n sequence))\n\n(defun seq-position (sequence elt &optional testfn)\n \"Return the index of the first element in SEQUENCE that is equal to ELT.\nEquality is defined by TESTFN if non-nil or by `equal' if nil.\"\n (let ((index 0))\n (catch 'seq--break\n (seq-doseq (e sequence)\n (when (funcall (or testfn #'equal) e elt)\n (throw 'seq--break index))\n (setq index (1+ index)))\n nil)))\n\n(defun seq-uniq (sequence &optional testfn)\n \"Return a list of the elements of SEQUENCE with duplicates removed.\nTESTFN is used to compare elements, or `equal' if TESTFN is nil.\"\n (let ((result '()))\n (seq-doseq (elt sequence)\n (unless (seq-contains result elt testfn)\n (setq result (cons elt result))))\n (nreverse result)))\n\n(defun seq-subseq (sequence start &optional end)\n \"Return the subsequence of SEQUENCE from START to END.\nIf END is omitted, it defaults to the length of the sequence.\nIf START or END is negative, it counts from the end.\"\n (cond ((or (stringp sequence) (vectorp sequence)) (substring sequence start end))\n ((listp sequence)\n (let (len (errtext (format \"Bad bounding indices: %s, %s\" start end)))\n (and end (< end 0) (setq end (+ end (setq len (seq-length sequence)))))\n (if (< start 0) (setq start (+ start (or len (setq len (seq-length sequence))))))\n (when (> start 0)\n (setq sequence (nthcdr (1- start) sequence))\n (or sequence (error \"%s\" errtext))\n (setq sequence (cdr sequence)))\n (if end\n (let ((res nil))\n (while (and (>= (setq end (1- end)) start) sequence)\n (push (pop sequence) res))\n (or (= (1+ end) start) (error \"%s\" errtext))\n (nreverse res))\n (seq-copy sequence))))\n (t (error \"Unsupported sequence: %s\" sequence))))\n\n(defun seq-concatenate (type &rest seqs)\n \"Concatenate, into a sequence of type TYPE, the sequences SEQS.\nTYPE must be one of following symbols: vector, string or list.\n\n\\n(fn TYPE SEQUENCE...)\"\n (pcase type\n (`vector (apply #'vconcat seqs))\n (`string (apply #'concat seqs))\n (`list (apply #'append (append seqs '(nil))))\n (_ (error \"Not a sequence type name: %S\" type))))\n\n(defun seq-mapcat (function sequence &optional type)\n \"Concatenate the result of applying FUNCTION to each element of SEQUENCE.\nThe result is a sequence of type TYPE, or a list if TYPE is nil.\"\n (apply #'seq-concatenate (or type 'list)\n (seq-map function sequence)))\n\n(defun seq-mapn (function sequence &rest seqs)\n \"Like `seq-map' but FUNCTION is mapped over all SEQS.\nThe arity of FUNCTION must match the number of SEQS, and the\nmapping stops on the shortest sequence.\nReturn a list of the results.\n\n\\(fn FUNCTION SEQS...)\"\n (let ((result nil)\n (seqs (seq-map (lambda (s) (seq-into s 'list))\n (cons sequence seqs))))\n (while (not (memq nil seqs))\n (push (apply function (seq-map #'car seqs)) result)\n (setq seqs (seq-map #'cdr seqs)))\n (nreverse result)))\n\n(defun seq-partition (sequence n)\n \"Return a list of the elements of SEQUENCE grouped into sub-sequences of length N.\nThe last sequence may contain less than N elements. If N is a\nnegative integer or 0, nil is returned.\"\n (unless (< n 1)\n (let ((result '()))\n (while (not (seq-empty-p sequence))\n (push (seq-take sequence n) result)\n (setq sequence (seq-drop sequence n)))\n (nreverse result))))\n\n(defun seq-intersection (seq1 seq2 &optional testfn)\n \"Return a list of the elements that appear in both SEQ1 and SEQ2.\nEquality is defined by TESTFN if non-nil or by `equal' if nil.\"\n (seq-reduce (lambda (acc elt)\n (if (seq-contains seq2 elt testfn)\n (cons elt acc)\n acc))\n (seq-reverse seq1)\n '()))\n\n(defun seq-difference (seq1 seq2 &optional testfn)\n \"Return a list of the elements that appear in SEQ1 but not in SEQ2.\nEquality is defined by TESTFN if non-nil or by `equal' if nil.\"\n (seq-reduce (lambda (acc elt)\n (if (not (seq-contains seq2 elt testfn))\n (cons elt acc)\n acc))\n (seq-reverse seq1)\n '()))\n\n(defun seq-group-by (function sequence)\n \"Apply FUNCTION to each element of SEQUENCE.\nSeparate the elements of SEQUENCE into an alist using the results as\nkeys. Keys are compared using `equal'.\"\n (seq-reduce\n (lambda (acc elt)\n (let* ((key (funcall function elt))\n (cell (assoc key acc)))\n (if cell\n (setcdr cell (push elt (cdr cell)))\n (push (list key elt) acc))\n acc))\n (seq-reverse sequence)\n nil))\n\n(defalias 'seq-reverse\n (if (ignore-errors (reverse [1 2]))\n #'reverse\n (lambda (sequence)\n \"Return the reversed copy of list, vector, or string SEQUENCE.\nSee also the function `nreverse', which is used more often.\"\n (let ((result '()))\n (seq-map (lambda (elt) (push elt result))\n sequence)\n (if (listp sequence)\n result\n (seq-into result (type-of sequence)))))))\n\n(defun seq-into (sequence type)\n \"Convert the sequence SEQUENCE into a sequence of type TYPE.\nTYPE can be one of the following symbols: vector, string or list.\"\n (pcase type\n (`vector (vconcat sequence))\n (`string (concat sequence))\n (`list (append sequence nil))\n (_ (error \"Not a sequence type name: %S\" type))))\n\n(defun seq-min (sequence)\n \"Return the smallest element of SEQUENCE.\nSEQUENCE must be a sequence of numbers or markers.\"\n (apply #'min (seq-into sequence 'list)))\n\n(defun seq-max (sequence)\n \"Return the largest element of SEQUENCE.\nSEQUENCE must be a sequence of numbers or markers.\"\n (apply #'max (seq-into sequence 'list)))\n\n(defun seq--drop-list (list n)\n \"Return a list from LIST without its first N elements.\nThis is an optimization for lists in `seq-drop'.\"\n (nthcdr n list))\n\n(defun seq--take-list (list n)\n \"Return a list from LIST made of its first N elements.\nThis is an optimization for lists in `seq-take'.\"\n (let ((result '()))\n (while (and list (> n 0))\n (setq n (1- n))\n (push (pop list) result))\n (nreverse result)))\n\n(defun seq--drop-while-list (predicate list)\n \"Return a list from the first element for which (PREDICATE element) is nil in LIST.\nThis is an optimization for lists in `seq-drop-while'.\"\n (while (and list (funcall predicate (car list)))\n (setq list (cdr list)))\n list)\n\n(defun seq--take-while-list (predicate list)\n \"Return the successive elements for which (PREDICATE element) is non-nil in LIST.\nThis is an optimization for lists in `seq-take-while'.\"\n (let ((result '()))\n (while (and list (funcall predicate (car list)))\n (push (pop list) result))\n (nreverse result)))\n\n(defun seq--count-successive (predicate sequence)\n \"Return the number of successive elements for which (PREDICATE element) is non-nil in SEQUENCE.\"\n (let ((n 0)\n (len (seq-length sequence)))\n (while (and (< n len)\n (funcall predicate (seq-elt sequence n)))\n (setq n (+ 1 n)))\n n))\n\n;; Helper function for the Backward-compatible version of `seq-let'\n;; for Emacs<25.1.\n(defun seq--make-bindings (args sequence &optional bindings)\n \"Return a list of bindings of the variables in ARGS to the elements of a sequence.\nif BINDINGS is non-nil, append new bindings to it, and return\nBINDINGS.\"\n (let ((index 0)\n (rest-marker nil))\n (seq-doseq (name args)\n (unless rest-marker\n (pcase name\n ((pred seq-p)\n (setq bindings (seq--make-bindings (seq--elt-safe args index)\n `(seq--elt-safe ,sequence ,index)\n bindings)))\n (`&rest\n (progn (push `(,(seq--elt-safe args (1+ index))\n (seq-drop ,sequence ,index))\n bindings)\n (setq rest-marker t)))\n (_\n (push `(,name (seq--elt-safe ,sequence ,index)) bindings))))\n (setq index (1+ index)))\n bindings))\n\n(defun seq--elt-safe (sequence n)\n \"Return element of SEQUENCE at the index N.\nIf no element is found, return nil.\"\n (when (or (listp sequence)\n (and (sequencep sequence)\n (> (seq-length sequence) n)))\n (seq-elt sequence n)))\n\n(defun seq--activate-font-lock-keywords ()\n \"Activate font-lock keywords for some symbols defined in seq.\"\n (font-lock-add-keywords 'emacs-lisp-mode\n '(\"\\\\\" \"\\\\\")))\n\n(defalias 'seq-copy #'copy-sequence)\n(defalias 'seq-elt #'elt)\n(defalias 'seq-length #'length)\n(defalias 'seq-do #'mapc)\n(defalias 'seq-each #'seq-do)\n(defalias 'seq-map #'mapcar)\n(defalias 'seq-p #'sequencep)\n\n(unless (fboundp 'elisp--font-lock-flush-elisp-buffers)\n ;; In Emacs\u226525, (via elisp--font-lock-flush-elisp-buffers and a few others)\n ;; we automatically highlight macros.\n (add-hook 'emacs-lisp-mode-hook #'seq--activate-font-lock-keywords))\n\n(provide 'seq-24)\n;;; seq-24.el ends here\n","avg_line_length":37.3075268817,"max_line_length":98,"alphanum_fraction":0.6394973484} {"size":308,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; jag-funcs-emacs-lisp.el --- Functions for emacs-lisp\n\n;;; Commentary:\n\n;;; Code:\n\n\n(evil-define-operator jag-lisp-eval (beg end &optional type)\n \"Evaluate the region\"\n :move-point nil\n (interactive \"\")\n (eval-region beg end))\n\n(provide 'jag-funcs-emacs-lisp)\n;;; jag-funcs-emacs-lisp.el ends here\n","avg_line_length":19.25,"max_line_length":60,"alphanum_fraction":0.6785714286} {"size":3555,"ext":"el","lang":"Emacs Lisp","max_stars_count":42.0,"content":";; Copyright (C) 2015-2016, 2018-2019 Free Software Foundation, Inc\n\n;; Author: Rocky Bernstein \n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n(require 'load-relative)\n(require-relative-list '(\"..\/common\/regexp\" \"..\/common\/loc\" \"..\/common\/track\")\n\t\t \"realgud-\")\n\n(declare-function realgud-goto-line-for-pt 'realgud-track)\n(declare-function make-realgud-loc-pat 'realgud-regexp)\n\n(defconst realgud:js-term-escape \"\u001b[[0-9]+[GKJ]\"\n \"Escape sequence regular expression pattern trepanjs often puts\n in around prompts\")\n\n(defconst realgud:js-file-regexp \"\\\\([^ \\t\\n]+\\\\)\\\\(?: \\\\[.*\\\\]\\\\)?\")\n\n\n\n(declare-function realgud-goto-line-for-pt 'realgud-track)\n\n;; Regular expression that describes a javascript backtrace line.\n;; at \/tmp\/foo.pl line 7\n;; \tmain::__ANON__('Illegal division by zero at \/tmp\/foo.pl line 4.\\x{a}') called at \/tmp\/foo.pl line 4\n;; \tmain::foo(3) called at \/tmp\/foo.pl line 8\n(defconst realgud:js-backtrace-loc-pat\n (make-realgud-loc-pat\n :regexp (format \"^\\\\(?:[<]?[\\t ]+at \\\\)?\\\\([^:]+\\\\) (\\\\(.*\\\\):%s:%s)\"\n\t\t realgud:regexp-captured-num realgud:regexp-captured-num)\n :file-group 2\n :line-group 3\n :char-offset-group 4)\n \"A realgud-loc-pat struct that describes a V8 backtrace location\")\n\n;; Regular expression that describes a javascript backtrace line.\n;; For example:\n;; 1 breakpoint y \/usr\/local\/lib\/node_modules\/trepanjs\/bin\/trepanjs:1\n;; \tbreakpoint already hit 1 time\n;; 2 breakpoint y \/usr\/local\/lib\/node_modules\/trepanjs\/bin\/trepanjs:5\n; 3 breakpoint y \/usr\/local\/lib\/node_modules\/trepanjs\/bin\/trepanjs:6\n(defconst realgud:js-debugger-backtrace-pat\n (make-realgud-loc-pat\n :regexp (format \"^%s[ \\t]+\\\\(breakpoint\\\\)[ \\t]+\\\\([yn]\\\\)[ \\t]+.*at \\\\(.+\\\\):%s\"\n\t\t realgud:regexp-captured-num realgud:regexp-captured-num)\n :num 1\n :text-group 2 ;; misnamed Is \"breakpoint\" or \"watchpoint\"\n :string 3 ;; misnamed. Is \"y\/n\"\n :file-group 4\n :line-group 5)\n \"A realgud-loc-pat struct that describes a V8 breakpoint location\")\n\n(defconst realgud:js-file-line-loc-pat\n (make-realgud-loc-pat\n :regexp (format \"^\\\\([^:]+\\\\):%s\" realgud:regexp-captured-num)\n :file-group 1\n :line-group 2)\n \"A realgud-loc-pat struct that describes a V8 file\/line location\")\n\n(defconst realgud:js-file-line-loc-pat\n (make-realgud-loc-pat\n :regexp (format \"^\\\\([^:]+\\\\):%s\" realgud:regexp-captured-num)\n :file-group 1\n :line-group 2)\n \"A realgud-loc-pat struct that describes a V8 file\/line location\")\n\n;; FIXME: there is probably a less redundant way to do the following\n;; FNS.\n(defun realgud:js-goto-file-line (pt)\n \"Display the location mentioned by the js file\/line warning or error.\"\n (interactive \"d\")\n (realgud-goto-line-for-pt pt \"file-line\"))\n\n(defun realgud:js-goto-syntax-error-line (pt)\n \"Display the location mentioned in a Syntax error line\ndescribed by PT.\"\n (interactive \"d\")\n (realgud-goto-line-for-pt pt \"syntax-error\"))\n\n\n(provide-me \"realgud-lang-\")\n","avg_line_length":37.8191489362,"max_line_length":103,"alphanum_fraction":0.69395218} {"size":15209,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; core\/core-packages.el -*- lexical-binding: t; -*-\n\n;; Emacs package management is opinionated, and so is Doom. Doom uses `straight'\n;; to create a declarative, lazy-loaded and optionally rolling-release package\n;; management system. We use `straight' over `package' because the latter is\n;; tempermental. ELPA sources suffer downtime occasionally, and often fail at\n;; building some packages when GNU Tar is unavailable (e.g. MacOS users start\n;; with BSD tar). There are also known gnutls errors in the current stable\n;; release of Emacs (26.x) which bork TLS handshakes with ELPA repos (mainly\n;; gnu.elpa.org). See https:\/\/debbugs.gnu.org\/cgi\/bugreport.cgi?bug=3434.\n;;\n;; What's worse, you can only get the latest version of packages through ELPA.\n;; In an ecosystem that is constantly changing, this is more frustrating than\n;; convenient. Straight (and Doom) can do rolling release, but it is optional\n;; (and will eventually be opt-in).\n;;\n;; ANyhow, interacting with this package management system is done through the\n;; bin\/doom script included with Doom Emacs. You'll find more about it by\n;; running 'doom help' (I highly recommend you add it to your PATH), but here\n;; are the highlights:\n;;\n;; + `bin\/doom install`: a wizard that guides you through setting up Doom and\n;; your private config for the first time.\n;; + `bin\/doom refresh`: your go-to command for making sure Doom is in optimal\n;; condition. It ensures all unneeded packages are removed, all needed ones\n;; are installed, and all metadata associated with them is generated.\n;; + `bin\/doom upgrade`: upgrades Doom Emacs and your packages to the latest\n;; versions. There's also 'bin\/doom update' for updating only your packages.\n;;\n;; How this works is: the system reads packages.el files located in each\n;; activated module, your private directory (`doom-private-dir'), and one in\n;; `doom-core-dir'. These contain `package!' declarations that tell DOOM what\n;; plugins to install and where from.\n;;\n;; All that said, you can still use package.el's commands, but 'bin\/doom\n;; refresh' will purge ELPA packages.\n\n(defvar doom-init-packages-p nil\n \"If non-nil, Doom's package management system has been initialized.\")\n\n(defvar doom-packages ()\n \"A list of enabled packages. Each element is a sublist, whose CAR is the\npackage's name as a symbol, and whose CDR is the plist supplied to its\n`package!' declaration. Set by `doom-initialize-packages'.\")\n\n(defvar doom-pinned-packages nil\n \"An alist mapping package names to commit hashes; both strings.\n\nWe avoid straight's lockfiles because we want to pin packages straight from\ntheir `package!' declarations, which is simpler than lockfiles, where version\nmanagement would be done in a whole new file that users shouldn't have to deal\nwith.\")\n\n(defvar doom-core-packages '(straight use-package)\n \"A list of packages that must be installed (and will be auto-installed if\nmissing) and shouldn't be deleted.\")\n\n(defvar doom-core-package-sources\n '((org-elpa :local-repo nil)\n (melpa\n :type git :host github\n :repo \"melpa\/melpa\"\n :no-build t)\n (gnu-elpa-mirror\n :type git :host github\n :repo \"emacs-straight\/gnu-elpa-mirror\"\n :no-build t)\n (emacsmirror-mirror\n :type git :host github\n :repo \"emacs-straight\/emacsmirror-mirror\"\n :no-build t))\n \"A list of recipes for straight's recipe repos.\")\n\n(defvar doom-disabled-packages ()\n \"A list of packages that should be ignored by `use-package!' and `after!'.\")\n\n\n;;\n;;; Package managers\n\n;; Ensure that, if we do need package.el, it is configured correctly. You really\n;; shouldn't be using it, but it may be convenient for quick package testing.\n(setq package-enable-at-startup nil\n package-user-dir (concat doom-local-dir \"elpa\/\")\n package-gnupghome-dir (expand-file-name \"gpg\" package-user-dir)\n ;; I omit Marmalade because its packages are manually submitted rather\n ;; than pulled, so packages are often out of date with upstream.\n package-archives\n (let ((proto (if gnutls-verify-error \"https\" \"http\")))\n `((\"gnu\" . ,(concat proto \":\/\/elpa.gnu.org\/packages\/\"))\n (\"melpa\" . ,(concat proto \":\/\/melpa.org\/packages\/\"))\n (\"org\" . ,(concat proto \":\/\/orgmode.org\/elpa\/\")))))\n\n(advice-add #'package--ensure-init-file :override #'ignore)\n\n;; Don't save `package-selected-packages' to `custom-file'\n(defadvice! doom--package-inhibit-custom-file-a (&optional value)\n :override #'package--save-selected-packages\n (if value (setq package-selected-packages value)))\n\n;; Refresh package.el the first time you call `package-install'\n(add-transient-hook! 'package-install (package-refresh-contents))\n\n;;; straight\n(setq straight-base-dir doom-local-dir\n straight-repository-branch \"develop\"\n straight-cache-autoloads nil ; we already do this, and better.\n ;; Doom doesn't encourage you to modify packages in place. Disabling this\n ;; makes 'doom refresh' instant (once everything set up), which is much\n ;; nicer UX than the several seconds modification checks.\n straight-check-for-modifications nil\n ;; We handle package.el ourselves (and a little more comprehensively)\n straight-enable-package-integration nil\n ;; Before switching to straight, `doom-local-dir' would average out at\n ;; around 100mb with half Doom's modules at ~230 packages. Afterwards, at\n ;; around 1gb. With shallow cloning, that is reduced to ~400mb. This\n ;; imposes an issue with packages that require their git history for\n ;; certain things to work (like magit and org), but we can deal with that\n ;; when we cross that bridge.\n straight-vc-git-default-clone-depth 1\n ;; Prefix declarations are unneeded bulk added to our autoloads file. Best\n ;; we just don't have to deal with them at all.\n autoload-compute-prefixes nil\n ;; We handle it ourselves\n straight-fix-org nil)\n\n(defadvice! doom--read-pinned-packages-a (orig-fn &rest args)\n \"Read from `doom-pinned-packages' on top of straight's lockfiles.\"\n :around #'straight--lockfile-read-all\n (append (apply orig-fn args) doom-pinned-packages))\n\n\n;;\n;;; Bootstrapper\n\n(defun doom-initialize-packages (&optional force-p)\n \"Ensures that Doom's package system and straight.el are initialized.\n\nIf FORCE-P is non-nil, do it anyway.\n\nThis ensure `doom-packages' is populated, if isn't aren't already. Use this\nbefore any of straight's or Doom's package management's API to ensure all the\nnecessary package metadata is initialized and available for them.\"\n (unless doom-init-packages-p\n (setq force-p t))\n (when (or force-p (not (bound-and-true-p package--initialized)))\n (doom-log \"Initializing package.el\")\n (require 'package)\n (package-initialize))\n (when (or force-p (not doom-packages))\n (doom-log \"Initializing straight\")\n (setq doom-init-packages-p t)\n (doom-ensure-straight)\n (mapc #'straight-use-package doom-core-packages)\n (doom-log \"Initializing doom-packages\")\n (setq doom-disabled-packages nil\n doom-pinned-packages nil\n doom-packages (doom-package-list))\n (dolist (package doom-packages)\n (let ((name (car package)))\n (with-plist! (cdr package) (recipe modules disable ignore pin)\n (if ignore\n (doom-log \"Ignoring package %S\" name)\n (if (not disable)\n (with-demoted-errors \"Package error: %s\"\n (when recipe\n (straight-override-recipe (cons name recipe)))\n (straight-register-package name))\n (doom-log \"Disabling package %S\" name)\n (cl-pushnew name doom-disabled-packages)\n ;; Warn about disabled core packages\n (when (cl-find :core modules :key #'car)\n (print! (warn \"%s\\n%s\")\n (format \"You've disabled %S\" name)\n (indent 2 (concat \"This is a core package. Disabling it will cause errors, as Doom assumes\\n\"\n \"core packages are always available. Disable their minor-modes or hooks instead.\")))))\n (when pin\n (let ((realname\n (if-let* ((recipe (cdr (straight-recipes-retrieve name)))\n (repo (straight-vc-local-repo-name recipe)))\n repo\n (symbol-name name))))\n (doom-log \"Pinning package %S to %S\" realname pin)\n (setf (alist-get realname doom-pinned-packages\n nil nil #'equal)\n pin)))))))))\n\n(defun doom-ensure-straight ()\n \"Ensure `straight' is installed and was compiled with this version of Emacs.\"\n (unless (fboundp 'straight--reset-caches)\n (defvar bootstrap-version)\n (let* (;; Force straight to install into ~\/.emacs.d\/.local\/straight instead of\n ;; ~\/.emacs.d\/straight by pretending `doom-local-dir' is our .emacs.d.\n (user-emacs-directory straight-base-dir)\n (bootstrap-file (doom-path straight-base-dir \"straight\/repos\/straight.el\/straight.el\"))\n (bootstrap-version 5))\n (make-directory (doom-path straight-base-dir \"straight\/build\") 'parents)\n (or (require 'straight nil t)\n (file-readable-p bootstrap-file)\n (with-current-buffer\n (url-retrieve-synchronously\n (format \"https:\/\/raw.githubusercontent.com\/raxod502\/straight.el\/%s\/install.el\"\n straight-repository-branch)\n 'silent 'inhibit-cookies)\n (goto-char (point-max))\n (eval-print-last-sexp)))\n (load bootstrap-file nil t))\n (require 'straight))\n (straight--reset-caches)\n (setq straight-recipe-repositories nil\n straight-recipe-overrides nil)\n (mapc #'straight-use-recipes doom-core-package-sources)\n (straight-register-package\n `(straight :type git :host github\n :repo ,(format \"%s\/straight.el\" straight-repository-user)\n :files (\"straight*.el\")\n :branch ,straight-repository-branch\n :no-byte-compile t)))\n\n\n;;\n;;; Module package macros\n\n(cl-defmacro package!\n (name &rest plist &key built-in recipe ignore _pin _disable)\n \"Declares a package and how to install it (if applicable).\n\nThis macro is declarative and does not load nor install packages. It is used to\npopulate `doom-packages' with metadata about the packages Doom needs to keep\ntrack of.\n\nOnly use this macro in a module's packages.el file.\n\nAccepts the following properties:\n\n :recipe RECIPE\n Specifies a straight.el recipe to allow you to acquire packages from external\n sources. See https:\/\/github.com\/raxod502\/straight.el#the-recipe-format for\n details on this recipe.\n :disable BOOL\n Do not install or update this package AND disable all of its `use-package!'\n and `after!' blocks.\n :ignore FORM\n Do not install this package.\n :pin STR|nil\n Pin this package to commit hash STR. Setting this to nil will unpin this\n package if previously pinned.\n :built-in BOOL|'prefer\n Same as :ignore if the package is a built-in Emacs package. This is more to\n inform help commands like `doom\/help-packages' that this is a built-in\n package. If set to 'prefer, the package will not be installed if it is\n already provided by Emacs.\n\nReturns t if package is successfully registered, and nil if it was disabled\nelsewhere.\"\n (declare (indent defun))\n (when (and recipe (keywordp (car-safe recipe)))\n (plist-put! plist :recipe `(quote ,recipe)))\n ;; :built-in t is basically an alias for :ignore (locate-library NAME)\n (when built-in\n (when (and (not ignore)\n (equal built-in '(quote prefer)))\n (setq built-in `(locate-library ,(symbol-name name) nil doom--initial-load-path)))\n (plist-delete! plist :built-in)\n (plist-put! plist :ignore built-in))\n `(let* ((name ',name)\n (plist (cdr (assq name doom-packages))))\n ;; Record what module this declaration was found in\n (let ((module-list (plist-get plist :modules))\n (module ',(doom-module-from-path)))\n (unless (member module module-list)\n (plist-put! plist :modules\n (append module-list\n (list module)\n nil))))\n ;; Merge given plist with pre-existing one\n (doplist! ((prop val) (list ,@plist) plist)\n (unless (null val)\n (plist-put! plist prop val)))\n ;; Some basic key validation; error if you're not using a valid key\n (condition-case e\n (when-let (recipe (plist-get plist :recipe))\n (cl-destructuring-bind\n (&key local-repo _files _flavor\n _no-build _no-byte-compile _no-autoloads\n _type _repo _host _branch _remote _nonrecursive _fork _depth)\n recipe\n ;; Expand :local-repo from current directory\n (when local-repo\n (plist-put! plist :recipe\n (plist-put recipe :local-repo\n (expand-file-name local-repo ,(dir!)))))))\n (error\n (signal 'doom-package-error\n (cons ,(symbol-name name)\n (error-message-string e)))))\n ;; This is the only side-effect of this macro!\n (setf (alist-get name doom-packages) plist)\n (with-no-warnings\n (not (plist-get plist :disable)))))\n\n(defmacro disable-packages! (&rest packages)\n \"A convenience macro for disabling packages in bulk.\nOnly use this macro in a module's (or your private) packages.el file.\"\n (macroexp-progn\n (cl-loop for p in packages\n collect `(package! ,p :disable t))))\n\n(defmacro unpin! (&rest targets)\n \"Unpin packages in TARGETS.\n\nThis unpins packages, so that 'doom upgrade' downloads their latest version. It\ncan be used one of five ways:\n\n+ To disable pinning wholesale: (unpin! t)\n+ To unpin individual packages: (unpin! packageA packageB ...)\n+ To unpin all packages in a group of modules: (unpin! :lang :tools ...)\n+ To unpin packages in individual modules:\n (unpin! (:lang python javascript) (:tools docker))\n\nOr any combination of the above.\"\n `(let ((targets ',targets))\n (put 'doom-pinned-packages 'modified\n (delete-dups (append targets (get 'doom-pinned-packages 'modified))))\n (dolist (target targets)\n (cond\n ((eq target t)\n (setq doom-pinned-packages nil))\n ((or (keywordp target)\n (listp target))\n (cl-destructuring-bind (category . modules) (doom-enlist target)\n (dolist (pkg doom-packages)\n (let ((pkg-modules (plist-get (cdr pkg) :modules)))\n (and (assq category pkg-modules)\n (or (null modules)\n (cl-loop for module in modules\n if (member (cons category module) pkg-modules)\n return t))\n (assq-delete-all (car pkg) doom-pinned-packages))))))\n ((symbolp target)\n (assq-delete-all target doom-pinned-packages))))))\n\n(provide 'core-packages)\n;;; core-packages.el ends here\n","avg_line_length":44.084057971,"max_line_length":128,"alphanum_fraction":0.6535603919} {"size":3676,"ext":"emacs","lang":"Emacs Lisp","max_stars_count":null,"content":"\n;;-----------------------Basic View Settings-------------------------;;\n\n;; Setting to inhibit toolbar, menubar and scrollbars.\n(tool-bar-mode -1)\n(menu-bar-mode -1)\n(scroll-bar-mode -1) \n\n;; Setting to inhibit the Splash Screen and Echo Area Message\n;; when starting Emacs\n(setq inhibit-startup-message 1)\n(setq inhibit-startup-echo-area-message 1)\n\n;; Setiings to display Row and Column numbers in the Echo Area.\n(line-number-mode 1)\n(column-number-mode 1)\n\n;; Setting To show Line Numbers in all buffers\n;; linum-mode does not enable in all buffers.\n;; It just toggles the linum-mode in the active buffer.\n(global-linum-mode 1)\n\n;; Toggle line highlighting in all buffers (Global Hl-Line mode).\n;; http:\/\/www.jesshamrick.com\/2012\/09\/18\/emacs-as-a-python-ide\/\n(global-hl-line-mode 1)\n\n\n;;-----------------------General Settings----------------------------;;\n\n;; Removing Backup Files\n;; http:\/\/stackoverflow.com\/questions\/151945\/how-do-i-control-how-emacs-makes-backup-files\n(defvar --backup-directory (concat user-emacs-directory \"Backups\"))\n(if (not (file-exists-p --backup-directory))\n (make-directory --backup-directory t))\n(setq backup-directory-alist `((\".\" . ,--backup-directory)))\n(setq make-backup-files 1 ; backup of a file the first time it is saved.\n backup-by-copying 1 ; don't clobber symlinks\n version-control 1 ; version numbers for backup files\n delete-old-versions 1 ; delete excess backup files silently\n auto-save-default 1 ; auto-save every buffer that visits a file\n auto-save-timeout 20 ; number of seconds idle time before auto-save (default: 30)\n auto-save-interval 200 ; number of keystrokes between auto-saves (default: 300)\n )\n\n;; Adding Melpa and Elpa packages list to install packages\n;; http:\/\/melpa.org\/getting-started\n(require 'package)\n(add-to-list 'package-archives\n '(\"melpa\" . \"http:\/\/melpa.org\/packages\/\") 1)\n(add-to-list 'package-archives\n\t '(\"gnu\" . \"http:\/\/elpa.gnu.org\/packages\/\") 1)\n(package-initialize)\n\n;; Make Text mode the default mode for new buffers \n(setq default-major-mode 'text-mode)\n\n;; New Key Binding for Save all Buffers and Close Emacs\n(global-set-key (kbd \"C-M-c\") 'save-buffers-kill-emacs)\n\n;; Set my default Email Address\n(setq user-mail-address \"ankitgoyal.bpl@hotmail.com\")\n\n;; Replacing \"yes or no\" prompt with \"y\/n\"\n(fset 'yes-or-no-p 'y-or-n-p)\n\n; Ignore case when searching\n(setq-default case-fold-search 1)\n\n;; Turn on mouse wheel support for scrolling\n(require 'mwheel)\n(mouse-wheel-mode 1)\n\n;; Language Settings\n(setq current-language-environment \"English\")\n\n;; Always use spaces, not tabs, when indenting\n(setq-default indent-tabs-mode -1)\n\n;; Set Tab Width to be 5\n;; http:\/\/www.emacswiki.org\/emacs\/IndentationBasics\n(setq-default tab-width 5) ; or any other preferred value\n(defvaralias 'c-basic-offset 'tab-width)\n(defvaralias 'cperl-indent-level 'tab-width)\n\n\n;;-----------------------IDO Setting---------------------------------;;\n\n;; http:\/\/emacswiki.org\/emacs\/InteractivelyDoThings\n(require 'ido)\n(ido-mode 1)\n(require 'ido-ubiquitous)\n(ido-ubiquitous-mode 1)\n;; M-x interface with Ido-style fuzzy matching.\n(require 'smex)\n(global-set-key (kbd \"M-x\") 'smex)\n(require 'ido-vertical-mode)\n(ido-vertical-mode 1)\n\n\n;;-----------------------Auto-Complete Settings----------------------;;\n(add-to-list 'load-path \"~\/.emacs.d\/elpa\/\")\n(require 'company)\n(add-hook 'after-init-hook 'global-company-mode)\n;;(global-set-key \"m-\/\" 'company-complete-common)\n(setq company-idle-delay 0)\n\n(require 'autopair)\n(autopair-global-mode 1)\n(setq autopair-autowrap 1)\n","avg_line_length":33.4181818182,"max_line_length":100,"alphanum_fraction":0.6632208923} {"size":3506,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(+ 2 2)\r\n;;C+j insert result\r\n;;C+x C+e display result\r\n;;C+x C+s write to file\r\n(+ 2 (* 3 4))\r\n;;C+g same to ESC in vim\r\n;;C+h t open tutorial\r\n(setq my-name \"lynn\")\r\n;;C+\/ undo\r\n;;C+s search forward vim:\/ C+r search backward vim:?\r\n;;C+r in bash\r\n(insert \"hello!\")\r\n(insert \"hello, I am \" my-name)\r\n(defun hello () (insert \"hello , I am \" my-name))\r\n(hello)\r\n(defun hello (name) (insert \"hello\" name))\r\n(hello \"you\")\r\n(switch-to-buffer-other-window \"*test*\")\r\n(progn\r\n (switch-to-buffer-other-window \"*test*\")\r\n (hello \"you\"))\r\n;;let me think of vim. vim can toggle a new buffer and show thing new\r\n(progn\r\n (switch-to-buffer-other-window \"*test*\")\r\n (erase-buffer)\r\n (hello \"there\"))\r\n(progn\r\n (switch-to-buffer-other-window \"*test*\")\r\n (erase-buffer)\r\n (hello \"you\")\r\n (other-window 1))\r\n(let ((local-name \"local\"))\r\n (switch-to-buffer-other-window \"*test*\")\r\n (erase-buffer)\r\n (hello local-name)\r\n (other-window 1))\r\n;;other-windows change *test* to a real message window. because cursor will back\r\n(format \"hello %s!\\n\" \"visitor\")\r\n\r\n(defun hello (name)\r\n (insert (format \"hello %s!\\n\" name)))\r\n(hello \"great\")\r\n(defun greating (name)\r\n (let ((your-name \"lynn\"))\r\n (insert (format \"hello %s!\\n\\nI am %s\"\r\n name\r\n your-name\r\n ))))\r\n(defun greeting (from-name)\r\n (let ((your-name (read-from-minibuffer \"Enter your name \")))\r\n (insert (format \"hello \\n\\nI am %s and you are %s\"\r\n from-name\r\n your-name\r\n ))))\r\n(greeting \"lynn\")\r\n(defun greating (from-name)\r\n (let ((your-name (read-from-minibuffer \"Enter your name: \")))\r\n (switch-to-buffer-other-window \"*message*\")\r\n (insert (format \"hello %s!\\n\\nI am %s\"\r\n from-name\r\n your-name\r\n ))\r\n (other-window 1)\r\n ))\r\n(greating \"master\")\r\n;;lisp can very easy to achieve new feature\r\n(setq list-of-names '(\"Tom\" \"lynn\" \"sherylynn\"))\r\n(car list-of-names)\r\n(cdr list-of-names)\r\n(push \"sherython\" list-of-names)\r\n(mapcar 'hello list-of-names)\r\n;;\u5f3a\u608d\u7684lisp\u5f00\u59cb\u5c55\u9732\u51fa\u6765\r\n(defun greeting ()\r\n (switch-to-buffer-other-window \"*test*\")\r\n (erase-buffer)\r\n (mapcar 'hello list-of-names)\r\n (other-window 1))\r\n(greeting)\r\n(defun replace-hello-by-bonjour ()\r\n (switch-to-buffer-other-window \"*test*\")\r\n (goto-char (point-min))\r\n (while (search-forward \"hello\")\r\n (replace-match \"bonjour\"))\r\n (other-window 1))\r\n(replace-hello-by-bonjour)\r\n(defun hello-to-bonjour ()\r\n (switch-to-buffer-other-window \"*test*\")\r\n (erase-buffer)\r\n (mapcar 'hello list-of-names)\r\n (goto-char (point-min))\r\n (while (search-forward \"hello\" nil 't)\r\n (replace-match \"bonjour\"))\r\n (other-window 1))\r\n(hello-to-bonjour)\r\n(defun boldify-names ()\r\n (switch-to-buffer-other-window \"*test*\")\r\n (goto-char (point-min))\r\n (while (re-search-forward \"bonjour \\\\(.+\\\\)!\" nil 't)\r\n (add-text-properties (match-beginning 1)\r\n (match-end 1)\r\n (list 'face 'bold)))\r\n (other-widow 1))\r\n(boldify-names)\r\n;;-----------------------------------------\r\n(defun show-hello-world ()\r\n (interactive);;\u4ea4\u4e92\u5f0f\u51fd\u6570\r\n (switch-to-buffer-other-window \"*message*\")\r\n (erase-buffer)\r\n (insert \"hello world\")\r\n (other-window 1))\r\n(show-hello-world)\r\n(global-set-key (kbd \"\") 'show-hello-world);;\u7b80\u5355\u7684\u7ed1\u5b9a\u4e86\u6309\u952e\r\n(defun define (fuck)\r\n (defun 'fuck ()\r\n (message \"1\")))\r\n(define fuck_you ())\r\n(defun yes (a b)\r\n (insert a)\r\n (insert b))\r\n(yes 1 2)\r\n(a)\r\n","avg_line_length":28.737704918,"max_line_length":81,"alphanum_fraction":0.5772960639} {"size":563,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(when (maybe-require-package 'projectile)\n (add-hook 'after-init-hook 'projectile-mode)\n\n ;; Shorter modeline\n (setq-default projectile-mode-line-prefix \" Proj\")\n\n (after-load 'projectile\n (setq projectile-globally-ignored-directories (append '(\"log\") projectile-globally-unignored-directories))\n (setq projectile-globally-ignored-files (append '(\"*.log\" \"*.json\") projectile-globally-ignored-files))\n (define-key projectile-mode-map (kbd \"C-c p\") 'projectile-command-map))\n\n (maybe-require-package 'ibuffer-projectile))\n\n(provide 'init-projectile)\n","avg_line_length":37.5333333333,"max_line_length":110,"alphanum_fraction":0.7335701599} {"size":193,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; Directory Local Variables\n;;; For more information see (info \"(emacs) Directory Variables\")\n\n((java-mode\n (flycheck-gradle-java-compile-function . flycheck-gradle-java-compile->android)))\n","avg_line_length":32.1666666667,"max_line_length":83,"alphanum_fraction":0.7461139896} {"size":2416,"ext":"el","lang":"Emacs Lisp","max_stars_count":5.0,"content":";;; edts-start.el --- EDTS auto-activation and starting.\n\n;; Copyright 2012-2013 Thomas J\u00e4rvstrand \n\n;; Author: Thomas J\u00e4rvstrand \n;; Keywords: erlang\n;; This file is not part of GNU Emacs.\n\n;;\n;; This file is part of EDTS.\n;;\n;; EDTS is free software: you can redistribute it and\/or modify\n;; it under the terms of the GNU Lesser General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n;;\n;; EDTS is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU Lesser General Public License for more details.\n;;\n;; You should have received a copy of the GNU Lesser General Public License\n;; along with EDTS. If not, see .\n\n(require 'erlang)\n(require 'f)\n\n(defcustom edts-inhibit-package-check nil\n \"If non-nil, don't check whether EDTS was installed as a package.\"\n :type 'boolean\n :group 'edts)\n\n(unless (or edts-inhibit-package-check\n (and (boundp 'package-alist)\n (assoc 'edts package-alist)))\n (warn (concat\n\"EDTS was not installed as a package.\\n\"\n\"\\n\"\n\"Please see the README for details on installing EDTS from MELPA.\\n\"\n\"\\n\"\n\"If you know what you're doing and have all the necessary dependencies\\n\"\n\"installed (see edts-pkg.el) you can disable this check by setting\\n\"\n\"`edts-inhibit-package-check' to a non-nil value.\"))\n (when (y-or-n-p \"Do you want to disable package check now?\")\n (customize-save-variable 'edts-inhibit-package-check t)))\n\n(let* ((top-dir (f-dirname (f-this-file)))\n (dirs (f-directories (f-expand \"elisp\" top-dir))))\n (-each dirs (lambda (d) (add-to-list 'load-path d t))))\n\n(require 'edts-mode)\n\n(defun edts-erlang-mode-hook ()\n (when (buffer-file-name)\n (edts-mode t)))\n\n(add-hook 'erlang-mode-hook 'edts-erlang-mode-hook)\n\n(defcustom edts-erlang-mode-regexps\n '(\"^\\\\.erlang$\"\n \"\\\\.app$\"\n \"\\\\.app.src$\"\n \"\\\\.erl$\"\n \"\\\\.es$\"\n \"\\\\.escript$\"\n \"\\\\.eterm$\"\n \"\\\\.script$\"\n \"\\\\.yaws$\")\n \"File-name patterns for which to auto-activate edts-mode.\"\n :type '(repeat regexp)\n :group 'edts)\n\n(mapc #'(lambda(re) (add-to-list 'auto-mode-alist (cons re 'erlang-mode)))\n edts-erlang-mode-regexps)\n\n(provide 'edts-start)\n","avg_line_length":31.3766233766,"max_line_length":78,"alphanum_fraction":0.678807947} {"size":10879,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; spacemacs-purpose-popwin.el --- Purpose extension to act like Popwin -*- lexical-binding: t -*-\n\n;;; Commentary:\n\n;;; Code:\n\n(require 'window-purpose)\n\n(defcustom pupo-split-active-window nil\n \"Non-nil if Pupo splits the active window.\nNil if Pupo splits the entire frame.\"\n :type '(boolean)\n :group 'pupo)\n\n(defconst pupo--direction-to-purpose '((left . popl)\n (right . popr)\n (top . popt)\n (bottom . popb))\n \"Mapping of popwin positions to purposes.\")\n\n(defconst pupo--purposes\n (loop for (direction . purpose) in pupo--direction-to-purpose collect purpose)\n \"List of purposes used to present popwin positions.\")\n\n(defvar pupo--windows nil\n \"List of popup windows.\")\n(defvar pupo--auto-windows nil\n \"List of popup windows that should be closed automatically.\")\n(defvar pupo--saved-buffers nil\n \"Temporary list of displayed popup buffers.\")\n(defvar pupo--saved-auto-buffers nil\n \"Temporary list of non-sticky displayed popup buffers.\")\n\n(defun pupo\/\/popup-function (position size)\n \"Generate a display function to create a popup window.\nPOSITION should be one of bottom, top, left and right.\nSIZE should be either a positive number of nil. Size is interpreted as\nwidth or height depending on POSITION.\"\n (let* ((size (cl-case position\n ('left (purpose--normalize-width (or size\n popwin:popup-window-width)))\n ('right (purpose--normalize-width (or size\n popwin:popup-window-width)))\n ('top (purpose--normalize-height (or size\n popwin:popup-window-height)))\n ('bottom (purpose--normalize-height (or size\n popwin:popup-window-height)))))\n (size (when size (- size)))\n (side (cl-case position\n ('left 'left)\n ('right 'right)\n ('top 'above)\n ('bottom 'below))))\n (lambda (buffer alist)\n (let* ((main-window (if pupo-split-active-window\n (selected-window)\n (frame-root-window)))\n (window (ignore-errors (split-window main-window size side))))\n (when window\n (purpose-change-buffer buffer window 'window alist))))))\n\n(defun pupo\/\/position-to-display-function (position width height)\n \"Generate a display function for creating a popup window.\nPOSITION defaults to bottom.\nWIDTH and HEIGHT should be either a positive number or nil.\"\n (cl-case (or position 'bottom)\n ((left right) (pupo\/\/popup-function position width))\n ((top bottom) (pupo\/\/popup-function position height))))\n\n(defun pupo\/\/position-to-purpose (position)\n \"Translate POSITION to a purpose.\nDirection -> purpose:\nleft -> popl\nright -> popr\ntop -> popt\nbottom -> popb\nPOSITION defaults to bottom.\"\n (cl-case (or position 'bottom)\n ;; names are short so they don't take much room in the mode-line\n ('left 'popl)\n ('right 'popr)\n ('top 'popt)\n ('bottom 'popb)))\n\n(defun pupo\/\/actions (settings)\n \"Generate list of display functions for displaying a popup window.\nSETTINGS is the settings for the popup buffer, and corresponds to what\npopwin calls \\\"config keywords\\\".\"\n (delq nil\n (list #'purpose-display-reuse-window-buffer\n (unless (plist-get settings :dedicated)\n #'purpose-display-reuse-window-purpose)\n (pupo\/\/position-to-display-function (plist-get settings :position)\n (plist-get settings :width)\n (plist-get settings :height)))))\n\n(defun pupo\/display-condition (_purpose buffer _alist)\n \"A condition to be used in `purpose-special-action-sequences'.\nReturn non-nil if BUFFER is a popup buffer, according to the settings in\n`popwin:special-display-config'.\n\nSee `purpose-special-action-sequences' for a description of _PURPOSE,\nBUFFER and _ALIST.\"\n (popwin:match-config buffer))\n\n(defun pupo\/display-function (buffer alist)\n \"A display function to be used in `purpose-special-action-sequences'.\nDisplay BUFFER as a popup buffer, according to the settings in\n`popwin:special-display-config'.\n\nSee `purpose-special-action-sequences' for a description of BUFFER and\nALIST.\"\n (do ((display-fns (pupo\/\/actions (cdr (popwin:match-config buffer)))\n (cdr display-fns))\n (window nil (and display-fns (funcall (car display-fns) buffer alist))))\n ((or window (null display-fns)) window)))\n\n(defun pupo\/after-display (window)\n \"Additional initialization for popup windows.\nSets properties for WINDOW and updates some variables, if WINDOW is a\npopup window.\n\nThis function should be hooked to `purpose-display-buffer-functions'.\"\n (let* ((buffer (window-buffer window))\n (config (popwin:match-config buffer))\n (settings (cdr (popwin:listify config))))\n (when config\n (setq pupo--windows (delete window pupo--windows))\n (push window pupo--windows)\n (when (plist-get settings :dedicated)\n (set-window-dedicated-p window t))\n (unless (plist-get settings :stick)\n (push window pupo--auto-windows))\n (unless (or (minibuffer-window-active-p (selected-window))\n (plist-get settings :noselect))\n ;; popwin selects window unless :noselect is t\n ;; in contrast, popwin doesn't prevent selection when :noselect is nil\n (select-window window))\n ;; make \\\\[C-g] delete last popup window\n (global-set-key [remap keyboard-quit] #'pupo\/close-window))))\n\n(defun pupo\/\/safe-delete-window (&optional window)\n \"Delete WINDOW if possible.\nReturn t if successful, nil otherwise.\nWINDOW defaults to the selected window.\"\n (ignore-errors (delete-window window) t))\n\n(defun pupo\/auto-delete-windows (window)\n \"Delete all non-sticky popup windows, unless WINDOW is a popup window.\nThis function should be hooked to `purpose-display-buffer-functions'.\"\n (unless (member (purpose-window-purpose window) pupo--purposes)\n (mapc #'pupo\/\/safe-delete-window pupo--auto-windows)\n (setq pupo--auto-windows nil)))\n\n(defun pupo\/close-window ()\n \"Close most recent popup window.\nThis command can be used repeatedly to close all popup windows.\"\n (interactive)\n (let ((searching t))\n (while (and pupo--windows searching)\n (when (window-live-p (car pupo--windows))\n (pupo\/\/safe-delete-window (car pupo--windows))\n (setq searching nil))\n (pop pupo--windows))\n (unless pupo--windows\n ;; no more popup windows, revert \\\\[C-g] to `keyboard-quit'\n (global-set-key [remap keyboard-quit] nil))))\n\n(defun pupo\/close-all-windows ()\n \"Close all popup windows.\"\n (interactive)\n (dolist (purpose pupo--purposes)\n (mapc #'pupo\/\/safe-delete-window (purpose-windows-with-purpose purpose))))\n\n(defun pupo\/popwin-config-to-purpose-config ()\n \"Create a purpose configuration matching current popwin's settings.\nReturn a `purpose-conf' object.\nPopwin's settings are taken from `popwin:special-display-config'.\"\n (let (mode-purposes name-purposes regexp-purposes)\n (loop for config-entry in popwin:special-display-config\n for (pattern . settings) = (popwin:listify config-entry)\n do\n (push (cons pattern\n (pupo\/\/position-to-purpose (plist-get settings :position)))\n (cond ((symbolp pattern) mode-purposes)\n ((plist-get settings :regexp) regexp-purposes)\n (t name-purposes))))\n ;; \"pupo\" argument is obsolete in Emacs 25, but still mandatory in 24.5 (see\n ;; https:\/\/github.com\/syl20bnr\/spacemacs\/issues\/9583)\n (purpose-conf \"pupo\"\n :mode-purposes mode-purposes\n :name-purposes name-purposes\n :regexp-purposes regexp-purposes)))\n\n(defun pupo\/update-purpose-config ()\n \"Update purpose configuration according to current popwin's settings.\nPopwin's settings are taken from `popwin:special-display-config'.\"\n (purpose-set-extension-configuration :pupo (pupo\/popwin-config-to-purpose-config)))\n\n(define-minor-mode pupo-mode\n \"Minor mode for combining `purpose-mode' and `popwin-mode'.\"\n :global t\n (if pupo-mode\n (progn\n (pupo\/update-purpose-config)\n (push '(pupo\/display-condition pupo\/display-function)\n purpose-special-action-sequences)\n (add-hook 'purpose-display-buffer-functions #'pupo\/after-display)\n (add-hook 'purpose-display-buffer-functions #'pupo\/auto-delete-windows))\n (purpose-del-extension-configuration :pupo)\n (setq purpose-special-action-sequences\n (delete '(pupo\/display-condition pupo\/display-function)\n purpose-special-action-sequences))\n (remove-hook 'purpose-display-buffer-functions #'pupo\/after-display)\n (remove-hook 'purpose-display-buffer-functions #'pupo\/auto-delete-windows)))\n\n(defadvice popwin:create-popup-window (before pupo\/before-popwin-create)\n \"Save current popup windows for later restoration.\nThe windows are restored in `pupo\/after-popwin-create'.\nNote that the windows themselves aren't saved, but some internal\nvariables are updated instead.\"\n (setq pupo--saved-buffers (mapcar #'window-buffer pupo--windows))\n (setq pupo--saved-auto-buffers (mapcar #'window-buffer pupo--auto-windows)))\n\n(defadvice popwin:create-popup-window (after pupo\/after-popwin-create)\n \"Restore popup windows.\nThe windows were saved in `pupo\/before-popwin-create'.\nNote that the windows themselves aren't restored, but some internal\nvariables are updated instead.\"\n (setq pupo--windows nil)\n (loop for buffer in pupo--saved-buffers\n do (setq pupo--windows\n (append pupo--windows\n (get-buffer-window-list buffer))))\n (setq pupo--auto-windows nil)\n (loop for buffer in pupo--saved-auto-buffers\n do (setq pupo--auto-windows\n (append pupo--auto-windows\n (get-buffer-window-list buffer)))))\n\n(defun pupo\/sync-advices ()\n (if pupo-mode\n (progn\n (ad-enable-advice 'popwin:create-popup-window 'before 'pupo\/before-popwin-create)\n (ad-enable-advice 'popwin:create-popup-window 'after 'pupo\/after-popwin-create)\n (ad-update 'popwin:create-popup-window)\n (ad-activate 'popwin:create-popup-window))\n (ad-disable-advice 'popwin:create-popup-window 'before 'pupo\/before-popwin-create)\n (ad-disable-advice 'popwin:create-popup-window 'after 'pupo\/after-popwin-create)\n (ad-update 'popwin:create-popup-window)))\n(add-hook 'pupo-mode-hook #'pupo\/sync-advices)\n\n(provide 'spacemacs-purpose-popwin)\n\n;;; spacemacs-purpose-popwin.el ends here\n","avg_line_length":42.49609375,"max_line_length":99,"alphanum_fraction":0.6548395992} {"size":809,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; app\/email\/autoload\/email.el -*- lexical-binding: t; -*-\n\n(defvar +email-workspace-name \"*mu4e*\"\n \"TODO\")\n\n(add-hook 'mu4e-main-mode-hook #'+email|init)\n\n;;;###autoload\n(defun =email ()\n \"Start email client.\"\n (interactive)\n (require 'mu4e)\n (+workspace-switch +email-workspace-name t)\n (mu4e~start 'mu4e~main-view)\n ;; (save-selected-window\n ;; (prolusion-mail-show))\n )\n\n;;;###autoload\n(defun +email\/compose ()\n \"Compose a new email.\"\n (interactive)\n ;; TODO Interactively select email account\n (call-interactively #'mu4e-compose-new))\n\n\n;;\n;; Hooks\n;;\n\n(defun +email|init ()\n (add-hook 'kill-buffer-hook #'+email|kill-mu4e nil t))\n\n(defun +email|kill-mu4e ()\n ;; (prolusion-mail-hide)\n (when (+workspace-exists-p +email-workspace-name)\n (+workspace\/delete +email-workspace-name)))\n\n","avg_line_length":20.7435897436,"max_line_length":59,"alphanum_fraction":0.6538936959} {"size":255,"ext":"el","lang":"Emacs Lisp","max_stars_count":1.0,"content":"(define-package \"switch-window\" \"20170718.1932\" \"A *visual* way to choose a window to switch to\"\n '((cl-lib \"0.5\"))\n :url \"https:\/\/github.com\/dimitri\/switch-window\" :keywords\n '(\"window\" \"navigation\"))\n;; Local Variables:\n;; no-byte-compile: t\n;; End:\n","avg_line_length":31.875,"max_line_length":96,"alphanum_fraction":0.6666666667} {"size":3009,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; solarized-theme-utils.el --- Utilities for solarized theme development\n\n;; Copyright (C) 2012 Thomas Fr\u00f6ssman\n\n;; Author: Thomas Fr\u00f6ssman \n;; URL: http:\/\/github.com\/bbatsov\/solarized-emacs\n\n;; This program is free software; you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; This program is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with this program. If not, see .\n\n;;; Commentary:\n;;\n;; Development utilities, these are not needed for normal theme usage\n;;\n\n;;;; Code:\n(require 'cl)\n(require 'solarized)\n\n(defun solarized-import-faces (&optional regexp already-defined)\n \"Imports current effective face definitions by regular expression\nin the format of solarized-theme.el.\"\n (interactive (list (read-regexp \"List faces matching regexp\")))\n (let*\n ((all-faces (zerop (length regexp)))\n (faces\n (delq nil\n (mapcar (lambda (face)\n (let ((s (symbol-name face)))\n (when (or all-faces (string-match regexp s))\n face)))\n (sort (face-list) #'string-lessp)))))\n (mapc (lambda(face)\n (when (or (not (get face 'theme-face)) already-defined)\n (insert (format\n \"`(%s ((,class %s)))%s\n\"\n face\n (let (result)\n (dolist (entry face-attribute-name-alist result)\n (let* ((attribute (car entry))\n (value (face-attribute face attribute)))\n (unless (eq value 'unspecified)\n (setq result\n (nconc (list attribute\n (cond\n ((member* attribute\n '(\":background\"\n \":foreground\")\n :test 'string=)\n (format \"\\\"%s\\\"\" value))\n (t value))) result))))))\n (if (get face 'theme-face)\n (format \" ;; Already set by current theme!\")\n \"\")))))\n\t faces)))\n\n;; Local Variables:\n;; byte-compile-warnings: (not cl-functions)\n;; End:\n(provide 'solarized-theme-utils)\n;;; solarized-theme-utils.el ends here\n","avg_line_length":41.2191780822,"max_line_length":77,"alphanum_fraction":0.5054835494} {"size":208,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":"(define-package \"go-guru\" \"20170718.1046\" \"Integration of the Go 'guru' analysis tool into Emacs.\" '((go-mode \"1.3.1\") (cl-lib \"0.5\")) :commit \"7eb5b3dd0ac31d176e9d56da4172f66aef8fae47\" :keywords '(\"tools\"))\n","avg_line_length":104.0,"max_line_length":207,"alphanum_fraction":0.7163461538} {"size":91722,"ext":"el","lang":"Emacs Lisp","max_stars_count":null,"content":";;; completion.el --- dynamic word-completion code\n\n;; Copyright (C) 1990, 1993, 1995, 1997, 2001-2015 Free Software\n;; Foundation, Inc.\n\n;; Maintainer: emacs-devel@gnu.org\n;; Keywords: abbrev convenience\n;; Author: Jim Salem of Thinking Machines Inc.\n;; (ideas suggested by Brewster Kahle)\n\n;; This file is part of GNU Emacs.\n\n;; GNU Emacs is free software: you can redistribute it and\/or modify\n;; it under the terms of the GNU General Public License as published by\n;; the Free Software Foundation, either version 3 of the License, or\n;; (at your option) any later version.\n\n;; GNU Emacs is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n;; GNU General Public License for more details.\n\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs. If not, see .\n\n;;; Commentary:\n\n;; What to put in .emacs\n;;-----------------------\n;; (dynamic-completion-mode)\n\f\n;;---------------------------------------------------------------------------\n;; Documentation [Slightly out of date]\n;;---------------------------------------------------------------------------\n;; (also check the documentation string of the functions)\n;;\n;; Introduction\n;;---------------\n;;\n;; After you type a few characters, pressing the \"complete\" key inserts\n;; the rest of the word you are likely to type.\n;;\n;; This watches all the words that you type and remembers them. When\n;; typing a new word, pressing \"complete\" (meta-return) \"completes\" the\n;; word by inserting the most recently used word that begins with the\n;; same characters. If you press meta-return repeatedly, it cycles\n;; through all the words it knows about.\n;;\n;; If you like the completion then just continue typing, it is as if you\n;; entered the text by hand. If you want the inserted extra characters\n;; to go away, type control-w or delete. More options are described below.\n;;\n;; The guesses are made in the order of the most recently \"used\". Typing\n;; in a word and then typing a separator character (such as a space) \"uses\"\n;; the word. So does moving a cursor over the word. If no words are found,\n;; it uses an extended version of the dabbrev style completion.\n;;\n;; You automatically save the completions you use to a file between\n;; sessions.\n;;\n;; Completion enables programmers to enter longer, more descriptive\n;; variable names while typing fewer keystrokes than they normally would.\n;;\n;;\n;; Full documentation\n;;---------------------\n;;\n;; A \"word\" is any string containing characters with either word or symbol\n;; syntax. [E.G. Any alphanumeric string with hyphens, underscores, etc.]\n;; Unless you change the constants, you must type at least three characters\n;; for the word to be recognized. Only words longer than 6 characters are\n;; saved.\n;;\n;; When you load this file, completion will be on. I suggest you use the\n;; compiled version (because it is noticeably faster).\n;;\n;; M-x completion-mode toggles whether or not new words are added to the\n;; database by changing the value of enable-completion.\n;;\n;; SAVING\/LOADING COMPLETIONS\n;; Completions are automatically saved from one session to another\n;; (unless save-completions-flag or enable-completion is nil).\n;; Activating this minor-mode (calling completion-initialize) loads\n;; a completions database for a saved completions file\n;; (default: ~\/.completions). When you exit, Emacs saves a copy of the\n;; completions that you often use. When you next start, Emacs loads in\n;; the saved completion file.\n;;\n;; The number of completions saved depends loosely on\n;; *saved-completions-decay-factor*. Completions that have never been\n;; inserted via \"complete\" are not saved. You are encouraged to experiment\n;; with different functions (see compute-completion-min-num-uses).\n;;\n;; Some completions are permanent and are always saved out. These\n;; completions have their num-uses slot set to T. Use\n;; add-permanent-completion to do this\n;;\n;; Completions are saved only if enable-completion is T. The number of old\n;; versions kept of the saved completions file is controlled by\n;; completions-file-versions-kept.\n;;\n;; COMPLETE KEY OPTIONS\n;; The complete function takes a numeric arguments.\n;; control-u :: leave the point at the beginning of the completion rather\n;; than the middle.\n;; a number :: rotate through the possible completions by that amount\n;; `-' :: same as -1 (insert previous completion)\n;;\n;; HOW THE DATABASE IS MAINTAINED\n;; \n;;\n;; UPDATING THE DATABASE MANUALLY\n;; m-x kill-completion\n;; kills the completion at point.\n;; m-x add-completion\n;; m-x add-permanent-completion\n;;\n;; UPDATING THE DATABASE FROM A SOURCE CODE FILE\n;; m-x add-completions-from-buffer\n;; Parses all the definition names from a C or LISP mode buffer and\n;; adds them to the completion database.\n;;\n;; m-x add-completions-from-lisp-file\n;; Parses all the definition names from a C or Lisp mode file and\n;; adds them to the completion database.\n;;\n;; UPDATING THE DATABASE FROM A TAGS TABLE\n;; m-x add-completions-from-tags-table\n;; Adds completions from the current tags-table-buffer.\n;;\n;; HOW A COMPLETION IS FOUND\n;; \n;;\n;; STRING CASING\n;; Completion is string case independent if case-fold-search has its\n;; normal default of T. Also when the completion is inserted the case of the\n;; entry is coerced appropriately.\n;; [E.G. APP --> APPROPRIATELY app --> appropriately\n;; App --> Appropriately]\n;;\n;; INITIALIZATION\n;; The form `(completion-initialize)' initializes the completion system by\n;; trying to load in the user's completions. After the first call, further\n;; calls have no effect so one should be careful not to put the form in a\n;; site's standard site-init file.\n;;\n;;---------------------------------------------------------------------------\n;;\n;;\n\f\n;;---------------------------------------------------------------------------\n;; Functions you might like to call\n;;---------------------------------------------------------------------------\n;;\n;; add-completion string &optional num-uses\n;; Adds a new string to the database\n;;\n;; add-permanent-completion string\n;; Adds a new string to the database with num-uses = T\n;;\n\n;; kill-completion string\n;; Kills the completion from the database.\n;;\n;; clear-all-completions\n;; Clears the database\n;;\n;; list-all-completions\n;; Returns a list of all completions.\n;;\n;;\n;; next-completion string &optional index\n;; Returns a completion entry that starts with string.\n;;\n;; find-exact-completion string\n;; Returns a completion entry that exactly matches string.\n;;\n;; complete\n;; Inserts a completion at point\n;;\n;; completion-initialize\n;; Loads the completions file and sets up so that exiting emacs will\n;; save them.\n;;\n;; save-completions-to-file &optional filename\n;; load-completions-from-file &optional filename\n;;\n;;-----------------------------------------------\n;; Other functions\n;;-----------------------------------------------\n;;\n;; get-completion-list string\n;;\n;; These things are for manipulating the structure\n;; make-completion string num-uses\n;; completion-num-uses completion\n;; completion-string completion\n;; set-completion-num-uses completion num-uses\n;; set-completion-string completion string\n;;\n;;\n\f\n;;-----------------------------------------------\n;; To Do :: (anybody ?)\n;;-----------------------------------------------\n;;\n;; Implement Lookup and keyboard interface in C\n;; Add package prefix smarts (for Common Lisp)\n;; Add autoprompting of possible completions after every keystroke (fast\n;; terminals only !)\n;; Add doc. to texinfo\n;;\n;;\n;;-----------------------------------------------\n;;; Change Log:\n;;-----------------------------------------------\n;; Sometime in '84 Brewster implemented a somewhat buggy version for\n;; Symbolics LISPMs.\n;; Jan. '85 Jim became enamored of the idea and implemented a faster,\n;; more robust version.\n;; With input from many users at TMC, (rose, craig, and gls come to mind),\n;; the current style of interface was developed.\n;; 9\/87, Jim and Brewster took terminals home. Yuck. After\n;; complaining for a while Brewster implemented a subset of the current\n;; LISPM version for GNU Emacs.\n;; 8\/88 After complaining for a while (and with sufficient\n;; promised rewards), Jim reimplemented a version of GNU completion\n;; superior to that of the LISPM version.\n;;\n;;-----------------------------------------------\n;; Acknowledgments\n;;-----------------------------------------------\n;; Cliff Lasser (cal@think.com), Kevin Herbert (kph@cisco.com),\n;; eero@media-lab, kgk@cs.brown.edu, jla@ai.mit.edu,\n;;\n;;-----------------------------------------------\n;; Change Log\n;;-----------------------------------------------\n;; From version 9 to 10\n;; - Allowance for non-integral *completion-version* nos.\n;; - Fix cmpl-apply-as-top-level for keyboard macros\n;; - Fix broken completion merging (in save-completions-to-file)\n;; - More misc. fixes for version 19.0 of emacs\n;;\n;; From Version 8 to 9\n;; - Ported to version 19.0 of emacs (backcompatible with version 18)\n;; - Added add-completions-from-tags-table (with thanks to eero@media-lab)\n;;\n;; From Version 7 to 8\n;; - Misc. changes to comments\n;; - new completion key bindings: c-x o, M->, M-<, c-a, c-e\n;; - cdabbrev now checks all the visible window buffers and the \"other buffer\"\n;; - `%' is now a symbol character rather than a separator (except in C mode)\n;;\n;; From Version 6 to 7\n;; - Fixed bug with saving out .completion file the first time\n;;\n;; From Version 5 to 6\n;; - removed statistics recording\n;; - reworked advise to handle autoloads\n;; - Fixed fortran mode support\n;; - Added new cursor motion triggers\n;;\n;; From Version 4 to 5\n;; - doesn't bother saving if nothing has changed\n;; - auto-save if haven't used for a 1\/2 hour\n;; - save period extended to two weeks\n;; - minor fix to capitalization code\n;; - added *completion-auto-save-period* to variables recorded.\n;; - added reenter protection to cmpl-record-statistics-filter\n;; - added backup protection to save-completions-to-file (prevents\n;; problems with disk full errors)\n\f\n;;; Code:\n\n;;---------------------------------------------------------------------------\n;; User changeable parameters\n;;---------------------------------------------------------------------------\n\n(defgroup completion nil\n \"Dynamic word-completion code.\"\n :group 'matching\n :group 'convenience)\n\n\n(defcustom enable-completion t\n \"Non-nil means enable recording and saving of completions.\nIf nil, no new words are added to the database or saved to the init file.\"\n :type 'boolean\n :group 'completion)\n\n(defcustom save-completions-flag t\n \"Non-nil means save most-used completions when exiting Emacs.\nSee also `save-completions-retention-time'.\"\n :type 'boolean\n :group 'completion)\n\n(defcustom save-completions-file-name\n (locate-user-emacs-file \"completions\" \".completions\")\n \"The filename to save completions to.\"\n :type 'file\n :group 'completion)\n\n(defcustom save-completions-retention-time 336\n \"Discard a completion if unused for this many hours.\n\\(1 day = 24, 1 week = 168). If this is 0, non-permanent completions\nwill not be saved unless these are used. Default is two weeks.\"\n :type 'integer\n :group 'completion)\n\n(defcustom completion-on-separator-character nil\n \"Non-nil means separator characters mark previous word as used.\nThis means the word will be saved as a completion.\"\n :type 'boolean\n :group 'completion)\n\n(defcustom completions-file-versions-kept kept-new-versions\n \"Number of versions to keep for the saved completions file.\"\n :type 'integer\n :group 'completion)\n\n(defcustom completion-prompt-speed-threshold 4800\n \"Minimum output speed at which to display next potential completion.\"\n :type 'integer\n :group 'completion)\n\n(defcustom completion-cdabbrev-prompt-flag nil\n \"If non-nil, the next completion prompt does a cdabbrev search.\nThis can be time consuming.\"\n :type 'boolean\n :group 'completion)\n\n(defcustom completion-search-distance 15000\n \"How far to search in the buffer when looking for completions.\nIn number of characters. If nil, search the whole buffer.\"\n :type 'integer\n :group 'completion)\n\n(defcustom completions-merging-modes '(lisp c)\n \"List of modes {`c' or `lisp'} for automatic completions merging.\nDefinitions from visited files which have these modes\nare automatically added to the completion database.\"\n :type '(set (const lisp) (const c))\n :group 'completion)\n\n;;(defvar *completion-auto-save-period* 1800\n;; \"The period in seconds to wait for emacs to be idle before autosaving\n;;the completions. Default is a 1\/2 hour.\")\n\n(defvar completion-min-length 6\n \"The minimum length of a stored completion.\nDON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.\")\n\n(defvar completion-max-length 200\n \"The maximum length of a stored completion.\nDON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.\")\n\n(defvar completion-prefix-min-length 3\n \"The minimum length of a completion search string.\nDON'T CHANGE WITHOUT RECOMPILING ! This is used by macros.\")\n\n;;---------------------------------------------------------------------------\n;; Internal Variables\n;;---------------------------------------------------------------------------\n\n(defvar cmpl-initialized-p nil\n \"Set to t when the completion system is initialized.\nIndicates that the old completion file has been read in.\")\n\n(defvar cmpl-completions-accepted-p nil\n \"Set to t as soon as the first completion has been accepted.\nUsed to decide whether to save completions.\")\n\n(defvar cmpl-preceding-syntax)\n\n(defvar completion-string)\n\f\n;;---------------------------------------------------------------------------\n;; Low level tools\n;;---------------------------------------------------------------------------\n\n;;-----------------------------------------------\n;; String case coercion\n;;-----------------------------------------------\n\n(defun cmpl-string-case-type (string)\n \"Return :capitalized, :up, :down, :mixed, or :neither for case of STRING.\"\n (let ((case-fold-search nil))\n (cond ((string-match \"[[:lower:]]\" string)\n\t (cond ((string-match \"[[:upper:]]\" string)\n\t\t (cond ((and (> (length string) 1)\n\t\t\t (null (string-match \"[[:upper:]]\" string 1)))\n\t\t\t :capitalized)\n\t\t\t(t\n\t\t\t :mixed)))\n\t\t (t :down)))\n\t (t\n\t (cond ((string-match \"[[:upper:]]\" string)\n\t\t :up)\n\t\t (t :neither))))))\n\n;; Tests -\n;; (cmpl-string-case-type \"123ABCDEF456\") --> :up\n;; (cmpl-string-case-type \"123abcdef456\") --> :down\n;; (cmpl-string-case-type \"123aBcDeF456\") --> :mixed\n;; (cmpl-string-case-type \"123456\") --> :neither\n;; (cmpl-string-case-type \"Abcde123\") --> :capitalized\n\n(defun cmpl-coerce-string-case (string case-type)\n (cond ((eq case-type :down) (downcase string))\n\t((eq case-type :up) (upcase string))\n\t((eq case-type :capitalized)\n\t (setq string (downcase string))\n\t (aset string 0 (logand ?\\337 (aref string 0)))\n\t string)\n\t(t string)))\n\n(defun cmpl-merge-string-cases (string-to-coerce given-string)\n (let ((string-case-type (cmpl-string-case-type string-to-coerce)))\n (cond ((memq string-case-type '(:down :up :capitalized))\n\t ;; Found string is in a standard case. Coerce to a type based on\n\t ;; the given string\n\t (cmpl-coerce-string-case string-to-coerce\n\t\t\t (cmpl-string-case-type given-string)))\n\t (t\n\t ;; If the found string is in some unusual case, just insert it\n\t ;; as is\n\t string-to-coerce))))\n\n;; Tests -\n;; (cmpl-merge-string-cases \"AbCdEf456\" \"abc\") --> AbCdEf456\n;; (cmpl-merge-string-cases \"abcdef456\" \"ABC\") --> ABCDEF456\n;; (cmpl-merge-string-cases \"ABCDEF456\" \"Abc\") --> Abcdef456\n;; (cmpl-merge-string-cases \"ABCDEF456\" \"abc\") --> abcdef456\n\n\f\n(defun cmpl-hours-since-origin ()\n (let ((time (current-time)))\n (floor (+ (* 65536.0 (nth 0 time)) (nth 1 time)) 3600)))\n\f\n;;---------------------------------------------------------------------------\n;; \"Symbol\" parsing functions\n;;---------------------------------------------------------------------------\n;; The functions symbol-before-point, symbol-under-point, etc. quickly return\n;; an appropriate symbol string. The strategy is to temporarily change\n;; the syntax table to enable fast symbol searching. There are three classes\n;; of syntax in these \"symbol\" syntax tables ::\n;;\n;; syntax (?_) - \"symbol\" chars (e.g. alphanumerics)\n;; syntax (?w) - symbol chars to ignore at end of words (e.g. period).\n;; syntax (? ) - everything else\n;;\n;; Thus by judicious use of scan-sexps and forward-word, we can get\n;; the word we want relatively fast and without consing.\n;;\n;; Why do we need a separate category for \"symbol chars to ignore at ends\" ?\n;; For example, in LISP we want starting :'s trimmed\n;; so keyword argument specifiers also define the keyword completion. And,\n;; for example, in C we want `.' appearing in a structure ref. to\n;; be kept intact in order to store the whole structure ref.; however, if\n;; it appears at the end of a symbol it should be discarded because it is\n;; probably used as a period.\n\n;; Here is the default completion syntax ::\n;; Symbol chars :: A-Z a-z 0-9 @ \/ \\ * + ~ $ < > %\n;; Symbol chars to ignore at ends :: _ : . -\n;; Separator chars. :: ! ^ & ( ) = ` | { } [ ] ; \" ' #\n;; , ? \n\n;; Mode specific differences and notes ::\n;; LISP diffs ->\n;; Symbol chars :: ! & ? = ^\n;;\n;; C diffs ->\n;; Separator chars :: + * \/ : %\n;; A note on the hyphen (`-'). Perhaps the hyphen should also be a separator\n;; char., however, we wanted to have completion symbols include pointer\n;; references. For example, \"foo->bar\" is a symbol as far as completion is\n;; concerned.\n;;\n;; FORTRAN diffs ->\n;; Separator chars :: + - * \/ :\n;;\n;; Pathname diffs ->\n;; Symbol chars :: .\n;; Of course there is no pathname \"mode\" and in fact we have not implemented\n;; this table. However, if there was such a mode, this is what it would look\n;; like.\n\n;;-----------------------------------------------\n;; Table definitions\n;;-----------------------------------------------\n\n(defconst completion-standard-syntax-table\n (let ((table (make-syntax-table))\n\ti)\n ;; Default syntax is whitespace.\n (setq i 0)\n (while (< i 256)\n (modify-syntax-entry i \" \" table)\n (setq i (1+ i)))\n ;; alpha chars\n (setq i 0)\n (while (< i 26)\n (modify-syntax-entry (+ ?a i) \"_\" table)\n (modify-syntax-entry (+ ?A i) \"_\" table)\n (setq i (1+ i)))\n ;; digit chars.\n (setq i 0)\n (while (< i 10)\n (modify-syntax-entry (+ ?0 i) \"_\" table)\n (setq i (1+ i)))\n ;; Other ones\n (let ((symbol-chars '(?@ ?\/ ?\\\\ ?* ?+ ?~ ?$ ?< ?> ?%))\n\t (symbol-chars-ignore '(?_ ?- ?: ?.)))\n (dolist (char symbol-chars)\n\t(modify-syntax-entry char \"_\" table))\n (dolist (char symbol-chars-ignore)\n\t(modify-syntax-entry char \"w\" table)))\n table))\n\n(defvar completion-syntax-table completion-standard-syntax-table\n \"This variable holds the current completion syntax table.\")\n(make-variable-buffer-local 'completion-syntax-table)\n\n;;-----------------------------------------------\n;; Symbol functions\n;;-----------------------------------------------\n(defvar cmpl-symbol-start nil\n \"Holds first character of symbol, after any completion symbol function.\")\n(defvar cmpl-symbol-end nil\n \"Holds last character of symbol, after any completion symbol function.\")\n\n(defun symbol-under-point ()\n \"Return the symbol that the point is currently on.\nBut only if it is longer than `completion-min-length'.\"\n (with-syntax-table completion-syntax-table\n (when (memq (char-syntax (following-char)) '(?w ?_))\n ;; Cursor is on following-char and after preceding-char\n (let ((saved-point (point)))\n (setq cmpl-symbol-start (scan-sexps (1+ saved-point) -1)\n cmpl-symbol-end (scan-sexps saved-point 1))\n ;; Remove chars to ignore at the start.\n (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)\n (goto-char cmpl-symbol-start)\n (forward-word 1)\n (setq cmpl-symbol-start (point))\n (goto-char saved-point)))\n ;; Remove chars to ignore at the end.\n (cond ((= (char-syntax (char-after (1- cmpl-symbol-end))) ?w)\n (goto-char cmpl-symbol-end)\n (forward-word -1)\n (setq cmpl-symbol-end (point))\n (goto-char saved-point)))\n ;; Return completion if the length is reasonable.\n (if (and (<= completion-min-length\n (- cmpl-symbol-end cmpl-symbol-start))\n (<= (- cmpl-symbol-end cmpl-symbol-start)\n completion-max-length))\n (buffer-substring-no-properties\n cmpl-symbol-start cmpl-symbol-end))))))\n\n;; tests for symbol-under-point\n;; `^' indicates cursor pos. where value is returned\n;; simple-word-test\n;; ^^^^^^^^^^^^^^^^ --> simple-word-test\n;; _harder_word_test_\n;; ^^^^^^^^^^^^^^^^^^ --> harder_word_test\n;; .___.______.\n;; --> nil\n;; \/foo\/bar\/quux.hello\n;; ^^^^^^^^^^^^^^^^^^^ --> \/foo\/bar\/quux.hello\n;;\n\n(defun symbol-before-point ()\n \"Return a string of the symbol immediately before point.\nReturns nil if there isn't one longer than `completion-min-length'.\"\n ;; This is called when a word separator is typed so it must be FAST !\n (with-syntax-table completion-syntax-table\n ;; Cursor is on following-char and after preceding-char\n (cond ((= (setq cmpl-preceding-syntax (char-syntax (preceding-char))) ?_)\n ;; Number of chars to ignore at end.\n (setq cmpl-symbol-end (point)\n cmpl-symbol-start (scan-sexps cmpl-symbol-end -1))\n ;; Remove chars to ignore at the start.\n (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)\n (goto-char cmpl-symbol-start)\n (forward-word 1)\n (setq cmpl-symbol-start (point))\n (goto-char cmpl-symbol-end)))\n ;; Return value if long enough.\n (if (>= cmpl-symbol-end\n (+ cmpl-symbol-start completion-min-length))\n (buffer-substring-no-properties\n cmpl-symbol-start cmpl-symbol-end)))\n ((= cmpl-preceding-syntax ?w)\n ;; chars to ignore at end\n (let ((saved-point (point)))\n (setq cmpl-symbol-start (scan-sexps saved-point -1))\n ;; take off chars. from end\n (forward-word -1)\n (setq cmpl-symbol-end (point))\n ;; remove chars to ignore at the start\n (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)\n (goto-char cmpl-symbol-start)\n (forward-word 1)\n (setq cmpl-symbol-start (point))))\n ;; Restore state.\n (goto-char saved-point)\n ;; Return completion if the length is reasonable\n (if (and (<= completion-min-length\n (- cmpl-symbol-end cmpl-symbol-start))\n (<= (- cmpl-symbol-end cmpl-symbol-start)\n completion-max-length))\n (buffer-substring-no-properties\n cmpl-symbol-start cmpl-symbol-end)))))))\n\n;; tests for symbol-before-point\n;; `^' indicates cursor pos. where value is returned\n;; simple-word-test\n;; ^ --> nil\n;; ^ --> nil\n;; ^ --> simple-w\n;; ^ --> simple-word-test\n;; _harder_word_test_\n;; ^ --> harder_word_test\n;; ^ --> harder_word_test\n;; ^ --> harder\n;; .___....\n;; --> nil\n\n(defun symbol-under-or-before-point ()\n ;; This could be made slightly faster but it is better to avoid\n ;; copying all the code.\n ;; However, it is only used by the completion string prompter.\n ;; If it comes into common use, it could be rewritten.\n (if (memq (with-syntax-table completion-syntax-table\n (char-syntax (following-char)))\n '(?w ?_))\n (symbol-under-point)\n (symbol-before-point)))\n\n\n(defun symbol-before-point-for-complete ()\n ;; \"Returns a string of the symbol immediately before point\n ;; or nil if there isn't one. Like symbol-before-point but doesn't trim the\n ;; end chars.\"\n ;; Cursor is on following-char and after preceding-char\n (with-syntax-table completion-syntax-table\n (cond ((memq (setq cmpl-preceding-syntax (char-syntax (preceding-char)))\n '(?_ ?w))\n (setq cmpl-symbol-end (point)\n cmpl-symbol-start (scan-sexps cmpl-symbol-end -1))\n ;; Remove chars to ignore at the start.\n (cond ((= (char-syntax (char-after cmpl-symbol-start)) ?w)\n (goto-char cmpl-symbol-start)\n (forward-word 1)\n (setq cmpl-symbol-start (point))\n (goto-char cmpl-symbol-end)))\n ;; Return completion if the length is reasonable.\n (if (and (<= completion-prefix-min-length\n (- cmpl-symbol-end cmpl-symbol-start))\n (<= (- cmpl-symbol-end cmpl-symbol-start)\n completion-max-length))\n (buffer-substring-no-properties\n cmpl-symbol-start cmpl-symbol-end))))))\n\n;; tests for symbol-before-point-for-complete\n;; `^' indicates cursor pos. where value is returned\n;; simple-word-test\n;; ^ --> nil\n;; ^ --> nil\n;; ^ --> simple-w\n;; ^ --> simple-word-test\n;; _harder_word_test_\n;; ^ --> harder_word_test\n;; ^ --> harder_word_test_\n;; ^ --> harder_\n;; .___....\n;; --> nil\n\n\n\f\n;;---------------------------------------------------------------------------\n;; Statistics Recording\n;;---------------------------------------------------------------------------\n\n;; Note that the guts of this has been turned off. The guts\n;; are in completion-stats.el.\n\n;;-----------------------------------------------\n;; Completion Sources\n;;-----------------------------------------------\n\n;; ID numbers\n(defconst cmpl-source-unknown 0)\n(defconst cmpl-source-init-file 1)\n(defconst cmpl-source-file-parsing 2)\n(defconst cmpl-source-separator 3)\n(defconst cmpl-source-cursor-moves 4)\n(defconst cmpl-source-interactive 5)\n(defconst cmpl-source-cdabbrev 6)\n(defconst num-cmpl-sources 7)\n(defvar current-completion-source cmpl-source-unknown)\n\n\n\f\n;;---------------------------------------------------------------------------\n;; Completion Method #2: dabbrev-expand style\n;;---------------------------------------------------------------------------\n;;\n;; This method is used if there are no useful stored completions. It is\n;; based on dabbrev-expand with these differences :\n;; 1) Faster (we don't use regexps)\n;; 2) case coercion handled correctly\n;; This is called cdabbrev to differentiate it.\n;; We simply search backwards through the file looking for words which\n;; start with the same letters we are trying to complete.\n;;\n\n(defvar cdabbrev-completions-tried nil)\n;; \"A list of all the cdabbrev completions since the last reset.\")\n\n(defvar cdabbrev-current-point 0)\n;; \"The current point position the cdabbrev search is at.\")\n\n(defvar cdabbrev-current-window nil)\n;; \"The current window we are looking for cdabbrevs in.\n;; Return t if looking in (other-buffer), nil if no more cdabbrevs.\")\n\n(defvar cdabbrev-wrapped-p nil)\n;; \"Return t if the cdabbrev search has wrapped around the file.\")\n\n(defvar cdabbrev-abbrev-string \"\")\n(defvar cdabbrev-start-point 0)\n(defvar cdabbrev-stop-point)\n\n;; Test strings for cdabbrev\n;; cdat-upcase ;;same namestring\n;; CDAT-UPCASE ;;ok\n;; cdat2 ;;too short\n;; cdat-1-2-3-4 ;;ok\n;; a-cdat-1 ;;doesn't start correctly\n;; cdat-simple ;;ok\n\n\n(defun reset-cdabbrev (abbrev-string &optional initial-completions-tried)\n \"Reset the cdabbrev search to search for ABBREV-STRING.\nINITIAL-COMPLETIONS-TRIED is a list of downcased strings to ignore\nduring the search.\"\n (setq cdabbrev-abbrev-string abbrev-string\n\tcdabbrev-completions-tried\n\t(cons (downcase abbrev-string) initial-completions-tried))\n (reset-cdabbrev-window t))\n\n(defun set-cdabbrev-buffer ()\n ;; cdabbrev-current-window must not be nil\n (set-buffer (if (eq cdabbrev-current-window t)\n\t\t (other-buffer)\n\t\t (window-buffer cdabbrev-current-window))))\n\n\n(defun reset-cdabbrev-window (&optional initializep)\n \"Reset the cdabbrev search to search for abbrev-string.\"\n ;; Set the window\n (cond (initializep\n\t (setq cdabbrev-current-window (selected-window)))\n\t((eq cdabbrev-current-window t)\n\t ;; Everything has failed\n\t (setq cdabbrev-current-window nil))\n\t(cdabbrev-current-window\n\t (setq cdabbrev-current-window (next-window cdabbrev-current-window))\n\t (if (eq cdabbrev-current-window (selected-window))\n\t ;; No more windows, try other buffer.\n\t (setq cdabbrev-current-window t))))\n (if cdabbrev-current-window\n (save-excursion\n\t(set-cdabbrev-buffer)\n\t(setq cdabbrev-current-point (point)\n\t cdabbrev-start-point cdabbrev-current-point\n\t cdabbrev-stop-point\n\t (if completion-search-distance\n\t\t (max (point-min)\n\t\t (- cdabbrev-start-point completion-search-distance))\n\t\t (point-min))\n\t cdabbrev-wrapped-p nil))))\n\n(defun next-cdabbrev ()\n \"Return the next possible cdabbrev expansion or nil if there isn't one.\n`reset-cdabbrev' must've been called already.\nThis is sensitive to `case-fold-search'.\"\n ;; note that case-fold-search affects the behavior of this function\n ;; Bug: won't pick up an expansion that starts at the top of buffer\n (if cdabbrev-current-window\n (let (saved-point\n\t saved-syntax\n\t (expansion nil)\n\t downcase-expansion tried-list syntax saved-point-2)\n\t(save-excursion\n\t (unwind-protect\n\t (progn\n\t\t;; Switch to current completion buffer\n\t\t(set-cdabbrev-buffer)\n\t\t;; Save current buffer state\n\t\t(setq saved-point (point)\n\t\t saved-syntax (syntax-table))\n\t\t;; Restore completion state\n\t\t(set-syntax-table completion-syntax-table)\n\t\t(goto-char cdabbrev-current-point)\n\t\t;; Loop looking for completions\n\t\t(while\n\t\t ;; This code returns t if it should loop again\n\t\t (cond\n\t\t (;; search for the string\n\t\t (search-backward cdabbrev-abbrev-string cdabbrev-stop-point t)\n\t\t ;; return nil if the completion is valid\n\t\t (not\n\t\t\t(and\n\t\t\t ;; does it start with a separator char ?\n\t\t\t (or (= (setq syntax (char-syntax (preceding-char))) ? )\n\t\t\t (and (= syntax ?w)\n\t\t\t\t ;; symbol char to ignore at end. Are we at end ?\n\t\t\t\t (progn\n\t\t\t\t (setq saved-point-2 (point))\n\t\t\t\t (forward-word -1)\n\t\t\t\t (prog1\n\t\t\t\t (= (char-syntax (preceding-char)) ? )\n\t\t\t\t (goto-char saved-point-2)))))\n\t\t\t ;; is the symbol long enough ?\n\t\t\t (setq expansion (symbol-under-point))\n\t\t\t ;; have we not tried this one before\n\t\t\t (progn\n\t\t\t ;; See if we've already used it\n\t\t\t (setq tried-list cdabbrev-completions-tried\n\t\t\t\t downcase-expansion (downcase expansion))\n\t\t\t (while (and tried-list\n\t\t\t\t (not (string-equal downcase-expansion\n\t\t\t\t\t\t\t (car tried-list))))\n\t\t\t ;; Already tried, don't choose this one\n\t\t\t (setq tried-list (cdr tried-list)))\n\t\t\t ;; at this point tried-list will be nil if this\n\t\t\t ;; expansion has not yet been tried\n\t\t\t (if tried-list\n\t\t\t (setq expansion nil)\n\t\t\t t)))))\n\t\t ;; search failed\n\t\t (cdabbrev-wrapped-p\n\t\t ;; If already wrapped, then we've failed completely\n\t\t nil)\n\t\t (t\n\t\t ;; need to wrap\n\t\t (goto-char (setq cdabbrev-current-point\n\t\t\t\t\t(if completion-search-distance\n\t\t\t\t\t (min (point-max) (+ cdabbrev-start-point completion-search-distance))\n\t\t\t\t\t (point-max))))\n\n\t\t (setq cdabbrev-wrapped-p t))))\n\t\t;; end of while loop\n\t\t(cond (expansion\n\t\t ;; successful\n\t\t (setq cdabbrev-completions-tried\n\t\t\t (cons downcase-expansion cdabbrev-completions-tried)\n\t\t\t cdabbrev-current-point (point)))))\n\t (set-syntax-table saved-syntax)\n\t (goto-char saved-point)))\n\t;; If no expansion, go to next window\n\t(cond (expansion)\n\t (t (reset-cdabbrev-window)\n\t\t (next-cdabbrev))))))\n\n;; The following must be eval'd in the minibuffer ::\n;; (reset-cdabbrev \"cdat\")\n;; (next-cdabbrev) --> \"cdat-simple\"\n;; (next-cdabbrev) --> \"cdat-1-2-3-4\"\n;; (next-cdabbrev) --> \"CDAT-UPCASE\"\n;; (next-cdabbrev) --> \"cdat-wrapping\"\n;; (next-cdabbrev) --> \"cdat_start_sym\"\n;; (next-cdabbrev) --> nil\n;; (next-cdabbrev) --> nil\n;; (next-cdabbrev) --> nil\n\n;; _cdat_start_sym\n;; cdat-wrapping\n\n\f\n;;---------------------------------------------------------------------------\n;; Completion Database\n;;---------------------------------------------------------------------------\n\n;; We use two storage modes for the two search types ::\n;; 1) Prefix {cmpl-prefix-obarray} for looking up possible completions\n;; Used by search-completion-next\n;; the value of the symbol is nil or a cons of head and tail pointers\n;; 2) Interning {cmpl-obarray} to see if it's in the database\n;; Used by find-exact-completion, completion-in-database-p\n;; The value of the symbol is the completion entry\n\n;; bad things may happen if this length is changed due to the way\n;; GNU implements obarrays\n(defconst cmpl-obarray-length 511)\n\n(defvar cmpl-prefix-obarray (make-vector cmpl-obarray-length 0)\n \"An obarray used to store the downcased completion prefixes.\nEach symbol is bound to a list of completion entries.\")\n\n(defvar cmpl-obarray (make-vector cmpl-obarray-length 0)\n \"An obarray used to store the downcased completions.\nEach symbol is bound to a single completion entry.\")\n\n;;-----------------------------------------------\n;; Completion Entry Structure Definition\n;;-----------------------------------------------\n\n;; A completion entry is a LIST of string, prefix-symbol num-uses, and\n;; last-use-time (the time the completion was last used)\n;; last-use-time is t if the string should be kept permanently\n;; num-uses is incremented every time the completion is used.\n\n;; We chose lists because (car foo) is faster than (aref foo 0) and the\n;; creation time is about the same.\n\n;; READER MACROS\n\n(defmacro completion-string (completion-entry)\n (list 'car completion-entry))\n\n(defmacro completion-num-uses (completion-entry)\n ;; \"The number of times it has used. Used to decide whether to save\n ;; it.\"\n (list 'car (list 'cdr completion-entry)))\n\n(defmacro completion-last-use-time (completion-entry)\n ;; \"The time it was last used. In hours since origin. Used to decide\n ;; whether to save it. t if one should always save it.\"\n (list 'nth 2 completion-entry))\n\n(defmacro completion-source (completion-entry)\n (list 'nth 3 completion-entry))\n\n;; WRITER MACROS\n(defmacro set-completion-string (completion-entry string)\n (list 'setcar completion-entry string))\n\n(defmacro set-completion-num-uses (completion-entry num-uses)\n (list 'setcar (list 'cdr completion-entry) num-uses))\n\n(defmacro set-completion-last-use-time (completion-entry last-use-time)\n (list 'setcar (list 'cdr (list 'cdr completion-entry)) last-use-time))\n\n;; CONSTRUCTOR\n(defun make-completion (string)\n \"Return a completion entry.\"\n (list string 0 nil current-completion-source))\n\n;; Obsolete\n;;(defmacro cmpl-prefix-entry-symbol (completion-entry)\n;; (list 'car (list 'cdr completion-entry)))\n\n\n\f\n;;-----------------------------------------------\n;; Prefix symbol entry definition\n;;-----------------------------------------------\n;; A cons of (head . tail)\n\n;; READER Macros\n\n(defalias 'cmpl-prefix-entry-head 'car)\n\n(defalias 'cmpl-prefix-entry-tail 'cdr)\n\n;; WRITER Macros\n\n(defmacro set-cmpl-prefix-entry-head (prefix-entry new-head)\n (list 'setcar prefix-entry new-head))\n\n(defmacro set-cmpl-prefix-entry-tail (prefix-entry new-tail)\n (list 'setcdr prefix-entry new-tail))\n\n;; Constructor\n\n(defun make-cmpl-prefix-entry (completion-entry-list)\n \"Make a new prefix entry containing only completion-entry.\"\n (cons completion-entry-list completion-entry-list))\n\n;;-----------------------------------------------\n;; Completion Database - Utilities\n;;-----------------------------------------------\n\n(defun clear-all-completions ()\n \"Initialize the completion storage. All existing completions are lost.\"\n (interactive)\n (setq cmpl-prefix-obarray (make-vector cmpl-obarray-length 0))\n (setq cmpl-obarray (make-vector cmpl-obarray-length 0)))\n\n(defvar completions-list-return-value)\n\n(defun list-all-completions ()\n \"Return a list of all the known completion entries.\"\n (let ((completions-list-return-value nil))\n (mapatoms 'list-all-completions-1 cmpl-prefix-obarray)\n completions-list-return-value))\n\n(defun list-all-completions-1 (prefix-symbol)\n (if (boundp prefix-symbol)\n (setq completions-list-return-value\n\t (append (cmpl-prefix-entry-head (symbol-value prefix-symbol))\n\t\t completions-list-return-value))))\n\n(defun list-all-completions-by-hash-bucket ()\n \"Return list of lists of known completion entries, organized by hash bucket.\"\n (let ((completions-list-return-value nil))\n (mapatoms 'list-all-completions-by-hash-bucket-1 cmpl-prefix-obarray)\n completions-list-return-value))\n\n(defun list-all-completions-by-hash-bucket-1 (prefix-symbol)\n (if (boundp prefix-symbol)\n (setq completions-list-return-value\n\t (cons (cmpl-prefix-entry-head (symbol-value prefix-symbol))\n\t\t completions-list-return-value))))\n\n\f\n;;-----------------------------------------------\n;; Updating the database\n;;-----------------------------------------------\n;;\n;; These are the internal functions used to update the datebase\n;;\n;;\n(defvar completion-to-accept nil\n \"Set to a string that is pending its acceptance.\")\n ;; this checked by the top level reading functions\n\n(defvar cmpl-db-downcase-string nil\n \"Setup by `find-exact-completion', etc. The given string, downcased.\")\n(defvar cmpl-db-symbol nil\n \"The interned symbol corresponding to `cmpl-db-downcase-string'.\nSet up by `cmpl-db-symbol'.\")\n(defvar cmpl-db-prefix-symbol nil\n \"The interned prefix symbol corresponding to `cmpl-db-downcase-string'.\")\n(defvar cmpl-db-entry nil)\n(defvar cmpl-db-debug-p nil\n \"Set to t if you want to debug the database.\")\n\n;; READS\n(defun find-exact-completion (string)\n \"Return the completion entry for STRING or nil.\nSets up `cmpl-db-downcase-string' and `cmpl-db-symbol'.\"\n (and (boundp (setq cmpl-db-symbol\n\t\t (intern (setq cmpl-db-downcase-string (downcase string))\n\t\t\t cmpl-obarray)))\n (symbol-value cmpl-db-symbol)))\n\n(defun find-cmpl-prefix-entry (prefix-string)\n \"Return the prefix entry for string.\nSets `cmpl-db-prefix-symbol'.\nPrefix-string must be exactly `completion-prefix-min-length' long\nand downcased. Sets up `cmpl-db-prefix-symbol'.\"\n (and (boundp (setq cmpl-db-prefix-symbol\n\t\t (intern prefix-string cmpl-prefix-obarray)))\n (symbol-value cmpl-db-prefix-symbol)))\n\n(defvar inside-locate-completion-entry nil)\n;; used to trap lossage in silent error correction\n\n(defun locate-completion-entry (completion-entry prefix-entry)\n \"Locate the completion entry.\nReturns a pointer to the element before the completion entry or nil if\nthe completion entry is at the head.\nMust be called after `find-exact-completion'.\"\n (let ((prefix-list (cmpl-prefix-entry-head prefix-entry))\n\t next-prefix-list)\n (cond\n ((not (eq (car prefix-list) completion-entry))\n ;; not already at head\n (while (and prefix-list\n\t\t (not (eq completion-entry\n\t\t\t (car (setq next-prefix-list (cdr prefix-list))))))\n\t (setq prefix-list next-prefix-list))\n (cond (;; found\n\t prefix-list)\n\t ;; Didn't find it. Database is messed up.\n\t (cmpl-db-debug-p\n\t ;; not found, error if debug mode\n\t (error \"Completion entry exists but not on prefix list - %s\"\n\t\t completion-string))\n\t (inside-locate-completion-entry\n\t ;; recursive error: really scrod\n\t (locate-completion-db-error))\n\t (t\n\t ;; Patch out\n\t (set cmpl-db-symbol nil)\n\t ;; Retry\n\t (locate-completion-entry-retry completion-entry)))))))\n\n(defun locate-completion-entry-retry (old-entry)\n (let ((inside-locate-completion-entry t))\n (add-completion (completion-string old-entry)\n\t\t (completion-num-uses old-entry)\n\t\t (completion-last-use-time old-entry))\n (let* ((cmpl-entry (find-exact-completion (completion-string old-entry)))\n\t (pref-entry\n\t (if cmpl-entry\n\t\t(find-cmpl-prefix-entry\n\t\t (substring cmpl-db-downcase-string\n\t\t\t 0 completion-prefix-min-length)))))\n (if (and cmpl-entry pref-entry)\n\t ;; try again\n\t (locate-completion-entry cmpl-entry pref-entry)\n\t ;; still losing\n\t (locate-completion-db-error)))))\n\n(defun locate-completion-db-error ()\n ;; recursive error: really scrod\n (error \"Completion database corrupted. Try M-x clear-all-completions. Send bug report\"))\n\n;; WRITES\n(defun add-completion-to-tail-if-new (string)\n \"If STRING is not in the database add it to appropriate prefix list.\nSTRING is added to the end of the appropriate prefix list with\nnum-uses = 0. The database is unchanged if it is there. STRING must be\nlonger than `completion-prefix-min-length'.\nThis must be very fast.\nReturns the completion entry.\"\n (or (find-exact-completion string)\n ;; not there\n (let (;; create an entry\n\t (entry (list (make-completion string)))\n\t ;; setup the prefix\n\t (prefix-entry (find-cmpl-prefix-entry\n\t\t\t (substring cmpl-db-downcase-string 0\n\t\t\t\t completion-prefix-min-length))))\n\t;; The next two forms should happen as a unit (atomically) but\n\t;; no fatal errors should result if that is not the case.\n\t(cond (prefix-entry\n\t ;; These two should be atomic, but nothing fatal will happen\n\t ;; if they're not.\n\t (setcdr (cmpl-prefix-entry-tail prefix-entry) entry)\n\t (set-cmpl-prefix-entry-tail prefix-entry entry))\n\t (t\n\t (set cmpl-db-prefix-symbol (make-cmpl-prefix-entry entry))))\n\t;; set symbol\n\t(set cmpl-db-symbol (car entry)))))\n\n(defun add-completion-to-head (completion-string)\n \"If COMPLETION-STRING is not in the database, add it to prefix list.\nWe add COMPLETION-STRING to the head of the appropriate prefix list,\nor to the head of the list.\nCOMPLETION-STRING must be longer than `completion-prefix-min-length'.\nUpdates the saved string with the supplied string.\nThis must be very fast.\nReturns the completion entry.\"\n ;; Handle pending acceptance\n (if completion-to-accept (accept-completion))\n ;; test if already in database\n (if (setq cmpl-db-entry (find-exact-completion completion-string))\n ;; found\n (let* ((prefix-entry (find-cmpl-prefix-entry\n\t\t\t (substring cmpl-db-downcase-string 0\n\t\t\t\t\tcompletion-prefix-min-length)))\n\t (splice-ptr (locate-completion-entry cmpl-db-entry prefix-entry))\n\t (cmpl-ptr (cdr splice-ptr)))\n\t;; update entry\n\t(set-completion-string cmpl-db-entry completion-string)\n\t;; move to head (if necessary)\n\t(cond (splice-ptr\n\t ;; These should all execute atomically but it is not fatal if\n\t ;; they don't.\n\t ;; splice it out\n\t (or (setcdr splice-ptr (cdr cmpl-ptr))\n\t\t ;; fix up tail if necessary\n\t\t (set-cmpl-prefix-entry-tail prefix-entry splice-ptr))\n\t ;; splice in at head\n\t (setcdr cmpl-ptr (cmpl-prefix-entry-head prefix-entry))\n\t (set-cmpl-prefix-entry-head prefix-entry cmpl-ptr)))\n\tcmpl-db-entry)\n ;; not there\n (let (;; create an entry\n\t (entry (list (make-completion completion-string)))\n\t ;; setup the prefix\n\t (prefix-entry (find-cmpl-prefix-entry\n\t\t\t (substring cmpl-db-downcase-string 0\n\t\t\t\t completion-prefix-min-length))))\n (cond (prefix-entry\n\t ;; Splice in at head\n\t (setcdr entry (cmpl-prefix-entry-head prefix-entry))\n\t (set-cmpl-prefix-entry-head prefix-entry entry))\n\t (t\n\t ;; Start new prefix entry\n\t (set cmpl-db-prefix-symbol (make-cmpl-prefix-entry entry))))\n ;; Add it to the symbol\n (set cmpl-db-symbol (car entry)))))\n\n(defun delete-completion (completion-string)\n \"Delete the completion from the database.\nString must be longer than `completion-prefix-min-length'.\"\n ;; Handle pending acceptance\n (if completion-to-accept (accept-completion))\n (if (setq cmpl-db-entry (find-exact-completion completion-string))\n ;; found\n (let* ((prefix-entry (find-cmpl-prefix-entry\n\t\t\t (substring cmpl-db-downcase-string 0\n\t\t\t\t\tcompletion-prefix-min-length)))\n\t (splice-ptr (locate-completion-entry cmpl-db-entry prefix-entry)))\n\t ;; delete symbol reference\n\t (set cmpl-db-symbol nil)\n\t ;; remove from prefix list\n\t (cond (splice-ptr\n\t\t;; not at head\n\t\t(or (setcdr splice-ptr (cdr (cdr splice-ptr)))\n\t\t ;; fix up tail if necessary\n\t\t (set-cmpl-prefix-entry-tail prefix-entry splice-ptr)))\n\t (t\n\t\t;; at head\n\t\t(or (set-cmpl-prefix-entry-head\n\t\t prefix-entry (cdr (cmpl-prefix-entry-head prefix-entry)))\n\t\t ;; List is now empty\n\t\t (set cmpl-db-prefix-symbol nil)))))\n (error \"Unknown completion `%s'\" completion-string)))\n\n;; Tests --\n;; - Add and Find -\n;; (add-completion-to-head \"banana\") --> (\"banana\" 0 nil 0)\n;; (find-exact-completion \"banana\") --> (\"banana\" 0 nil 0)\n;; (find-exact-completion \"bana\") --> nil\n;; (car (find-cmpl-prefix-entry \"ban\")) --> ((\"banana\" ...))\n;; (cdr (find-cmpl-prefix-entry \"ban\")) --> ((\"banana\" ...))\n;; (add-completion-to-head \"banish\") --> (\"banish\" 0 nil 0)\n;; (find-exact-completion \"banish\") --> (\"banish\" 0 nil 0)\n;; (car (find-cmpl-prefix-entry \"ban\")) --> ((\"banish\" ...) (\"banana\" ...))\n;; (cdr (find-cmpl-prefix-entry \"ban\")) --> ((\"banana\" ...))\n;; (add-completion-to-head \"banana\") --> (\"banana\" 0 nil 0)\n;; (car (find-cmpl-prefix-entry \"ban\")) --> ((\"banana\" ...) (\"banish\" ...))\n;; (cdr (find-cmpl-prefix-entry \"ban\")) --> ((\"banish\" ...))\n;;\n;; - Deleting -\n;; (add-completion-to-head \"banner\") --> (\"banner\" 0 nil 0)\n;; (delete-completion \"banner\")\n;; (find-exact-completion \"banner\") --> nil\n;; (car (find-cmpl-prefix-entry \"ban\")) --> ((\"banana\" ...) (\"banish\" ...))\n;; (cdr (find-cmpl-prefix-entry \"ban\")) --> ((\"banish\" ...))\n;; (add-completion-to-head \"banner\") --> (\"banner\" 0 nil 0)\n;; (delete-completion \"banana\")\n;; (car (find-cmpl-prefix-entry \"ban\")) --> ((\"banner\" ...) (\"banish\" ...))\n;; (cdr (find-cmpl-prefix-entry \"ban\")) --> ((\"banish\" ...))\n;; (delete-completion \"banner\")\n;; (delete-completion \"banish\")\n;; (find-cmpl-prefix-entry \"ban\") --> nil\n;; (delete-completion \"banner\") --> error\n;;\n;; - Tail -\n;; (add-completion-to-tail-if-new \"banana\") --> (\"banana\" 0 nil 0)\n;; (car (find-cmpl-prefix-entry \"ban\")) --> ((\"banana\" ...))\n;; (cdr (find-cmpl-prefix-entry \"ban\")) --> ((\"banana\" ...))\n;; (add-completion-to-tail-if-new \"banish\") --> (\"banish\" 0 nil 0)\n;; (car (find-cmpl-prefix-entry \"ban\")) -->((\"banana\" ...) (\"banish\" ...))\n;; (cdr (find-cmpl-prefix-entry \"ban\")) -->((\"banish\" ...))\n;;\n\n\f\n;;---------------------------------------------------------------------------\n;; Database Update :: Interface level routines\n;;---------------------------------------------------------------------------\n;;\n;; These lie on top of the database ref. functions but below the standard\n;; user interface level\n\n\n(defun interactive-completion-string-reader (prompt)\n (let* ((default (symbol-under-or-before-point))\n\t (new-prompt\n\t (if default\n\t (format \"%s (default %s): \" prompt default)\n\t (format \"%s: \" prompt)))\n\t (read (completing-read new-prompt cmpl-obarray)))\n (if (zerop (length read)) (setq read (or default \"\")))\n (list read)))\n\n(defun check-completion-length (string)\n (if (< (length string) completion-min-length)\n (user-error \"The string `%s' is too short to be saved as a completion\"\n string)\n (list string)))\n\n(defun add-completion (string &optional num-uses last-use-time)\n \"Add STRING to completion list, or move it to head of list.\nThe completion is altered appropriately if NUM-USES and\/or LAST-USE-TIME\nare specified.\"\n (interactive (interactive-completion-string-reader \"Completion to add\"))\n (check-completion-length string)\n (let* ((current-completion-source (if (called-interactively-p 'interactive)\n\t\t\t\t\tcmpl-source-interactive\n\t\t\t\t\tcurrent-completion-source))\n\t (entry (add-completion-to-head string)))\n\n (if num-uses (set-completion-num-uses entry num-uses))\n (if last-use-time\n\t(set-completion-last-use-time entry last-use-time))))\n\n(defun add-permanent-completion (string)\n \"Add STRING if it isn't already listed, and mark it permanent.\"\n (interactive\n (interactive-completion-string-reader \"Completion to add permanently\"))\n (let ((current-completion-source (if (called-interactively-p 'interactive)\n\t\t\t\t cmpl-source-interactive\n\t\t\t\t current-completion-source)))\n (add-completion string nil t)))\n\n(defun kill-completion (string)\n (interactive (interactive-completion-string-reader \"Completion to kill\"))\n (check-completion-length string)\n (delete-completion string))\n\n(defun accept-completion ()\n \"Accepts the pending completion in `completion-to-accept'.\nThis bumps num-uses. Called by `add-completion-to-head' and\n`completion-search-reset'.\"\n (let ((string completion-to-accept)\n\t;; if this is added afresh here, then it must be a cdabbrev\n\t(current-completion-source cmpl-source-cdabbrev)\n\tentry)\n (setq completion-to-accept nil)\n (setq entry (add-completion-to-head string))\n (set-completion-num-uses entry (1+ (completion-num-uses entry)))\n (setq cmpl-completions-accepted-p t)))\n\n(defun use-completion-under-point ()\n \"Add the completion symbol underneath the point into the completion buffer.\"\n (let ((string (and enable-completion (symbol-under-point)))\n\t(current-completion-source cmpl-source-cursor-moves))\n (if string (add-completion-to-head string))))\n\n(defun use-completion-before-point ()\n \"Add the completion symbol before point into the completion buffer.\"\n (let ((string (and enable-completion (symbol-before-point)))\n\t(current-completion-source cmpl-source-cursor-moves))\n (if string (add-completion-to-head string))))\n\n(defun use-completion-under-or-before-point ()\n \"Add the completion symbol before point into the completion buffer.\"\n (let ((string (and enable-completion (symbol-under-or-before-point)))\n\t(current-completion-source cmpl-source-cursor-moves))\n (if string (add-completion-to-head string))))\n\n(defun use-completion-before-separator ()\n \"Add the completion symbol before point into the completion buffer.\nCompletions added this way will automatically be saved if\n`completion-on-separator-character' is non-nil.\"\n (let ((string (and enable-completion (symbol-before-point)))\n\t(current-completion-source cmpl-source-separator)\n\tentry)\n (cond (string\n\t (setq entry (add-completion-to-head string))\n\t (if (and completion-on-separator-character\n\t\t (zerop (completion-num-uses entry)))\n\t (progn\n\t\t (set-completion-num-uses entry 1)\n\t\t (setq cmpl-completions-accepted-p t)))))))\n\n;; Tests --\n;; - Add and Find -\n;; (add-completion \"banana\" 5 10)\n;; (find-exact-completion \"banana\") --> (\"banana\" 5 10 0)\n;; (add-completion \"banana\" 6)\n;; (find-exact-completion \"banana\") --> (\"banana\" 6 10 0)\n;; (add-completion \"banish\")\n;; (car (find-cmpl-prefix-entry \"ban\")) --> ((\"banish\" ...) (\"banana\" ...))\n;;\n;; - Accepting -\n;; (setq completion-to-accept \"banana\")\n;; (accept-completion)\n;; (find-exact-completion \"banana\") --> (\"banana\" 7 10)\n;; (car (find-cmpl-prefix-entry \"ban\")) --> ((\"banana\" ...) (\"banish\" ...))\n;; (setq completion-to-accept \"banish\")\n;; (add-completion \"banner\")\n;; (car (find-cmpl-prefix-entry \"ban\"))\n;; --> ((\"banner\" ...) (\"banish\" 1 ...) (\"banana\" 7 ...))\n;;\n;; - Deleting -\n;; (kill-completion \"banish\")\n;; (car (find-cmpl-prefix-entry \"ban\")) --> ((\"banner\" ...) (\"banana\" ...))\n\n\f\n;;---------------------------------------------------------------------------\n;; Searching the database\n;;---------------------------------------------------------------------------\n;; Functions outside this block must call completion-search-reset followed\n;; by calls to completion-search-next or completion-search-peek\n;;\n\n;; Status variables\n;; Commented out to improve loading speed\n(defvar cmpl-test-string \"\")\n;; \"The current string used by completion-search-next.\"\n(defvar cmpl-test-regexp \"\")\n;; \"The current regexp used by completion-search-next.\n;; (derived from cmpl-test-string)\"\n(defvar cmpl-last-index 0)\n;; \"The last index that completion-search-next was called with.\"\n(defvar cmpl-cdabbrev-reset-p nil)\n;; \"Set to t when cdabbrevs have been reset.\"\n(defvar cmpl-next-possibilities nil)\n;; \"A pointer to the element BEFORE the next set of possible completions.\n;; cadr of this is the cmpl-next-possibility\"\n(defvar cmpl-starting-possibilities nil)\n;; \"The initial list of starting possibilities.\"\n(defvar cmpl-next-possibility nil)\n;; \"The cached next possibility.\"\n(defvar cmpl-tried-list nil)\n;; \"A downcased list of all the completions we have tried.\"\n\n\n(defun completion-search-reset (string)\n \"Set up the for completion searching for STRING.\nSTRING must be longer than `completion-prefix-min-length'.\"\n (if completion-to-accept (accept-completion))\n (setq cmpl-starting-possibilities\n\t(cmpl-prefix-entry-head\n\t (find-cmpl-prefix-entry\n\t (downcase (substring string 0 completion-prefix-min-length))))\n\tcmpl-test-string string\n\tcmpl-test-regexp (concat (regexp-quote string) \".\"))\n (completion-search-reset-1))\n\n(defun completion-search-reset-1 ()\n (setq cmpl-next-possibilities cmpl-starting-possibilities\n\tcmpl-next-possibility nil\n\tcmpl-cdabbrev-reset-p nil\n\tcmpl-last-index -1\n\tcmpl-tried-list nil))\n\n(defun completion-search-next (index)\n \"Return the next completion entry.\nIf INDEX is out of sequence, reset and start from the top.\nIf there are no more entries, try cdabbrev and return only a string.\"\n (cond\n ((= index (setq cmpl-last-index (1+ cmpl-last-index)))\n (completion-search-peek t))\n ((< index 0)\n (completion-search-reset-1)\n (setq cmpl-last-index index)\n ;; reverse the possibilities list\n (setq cmpl-next-possibilities (reverse cmpl-starting-possibilities))\n ;; do a \"normal\" search\n (while (and (completion-search-peek nil)\n\t\t (< (setq index (1+ index)) 0))\n (setq cmpl-next-possibility nil))\n (cond ((not cmpl-next-possibilities))\n\t ;; If no more possibilities, leave it that way\n\t ((= -1 cmpl-last-index)\n\t ;; next completion is at index 0. reset next-possibility list\n\t ;; to start at beginning\n\t (setq cmpl-next-possibilities cmpl-starting-possibilities))\n\t (t\n\t ;; otherwise point to one before current\n\t (setq cmpl-next-possibilities\n\t\t (nthcdr (- (length cmpl-starting-possibilities)\n\t\t\t (length cmpl-next-possibilities))\n\t\t\t cmpl-starting-possibilities)))))\n (t\n ;; non-negative index, reset and search\n ;;(prin1 'reset)\n (completion-search-reset-1)\n (setq cmpl-last-index index)\n (while (and (completion-search-peek t)\n\t\t (not (< (setq index (1- index)) 0)))\n (setq cmpl-next-possibility nil))))\n (prog1\n cmpl-next-possibility\n (setq cmpl-next-possibility nil)))\n\n\n(defun completion-search-peek (use-cdabbrev)\n \"Return the next completion entry without actually moving the pointers.\nCalling this again or calling `completion-search-next' results in the same\nstring being returned. Depends on `case-fold-search'.\nIf there are no more entries, try cdabbrev and then return only a string.\"\n (cond\n ;; return the cached value if we have it\n (cmpl-next-possibility)\n ((and cmpl-next-possibilities\n\t ;; still a few possibilities left\n\t (progn\n\t (while\n\t\t(and (not (eq 0 (string-match cmpl-test-regexp\n\t\t\t\t\t (completion-string (car cmpl-next-possibilities)))))\n\t\t (setq cmpl-next-possibilities (cdr cmpl-next-possibilities))))\n\t cmpl-next-possibilities))\n ;; successful match\n (setq cmpl-next-possibility (car cmpl-next-possibilities)\n\t cmpl-tried-list (cons (downcase (completion-string cmpl-next-possibility))\n\t\t\t\t cmpl-tried-list)\n\t cmpl-next-possibilities (cdr cmpl-next-possibilities))\n cmpl-next-possibility)\n (use-cdabbrev\n ;; unsuccessful, use cdabbrev\n (cond ((not cmpl-cdabbrev-reset-p)\n\t (reset-cdabbrev cmpl-test-string cmpl-tried-list)\n\t (setq cmpl-cdabbrev-reset-p t)))\n (setq cmpl-next-possibility (next-cdabbrev)))\n ;; Completely unsuccessful, return nil\n ))\n\n;; Tests --\n;; - Add and Find -\n;; (add-completion \"banana\")\n;; (completion-search-reset \"ban\")\n;; (completion-search-next 0) --> \"banana\"\n;;\n;; - Discrimination -\n;; (add-completion \"cumberland\")\n;; (add-completion \"cumberbund\")\n;; cumbering\n;; (completion-search-reset \"cumb\")\n;; (completion-search-peek t) --> \"cumberbund\"\n;; (completion-search-next 0) --> \"cumberbund\"\n;; (completion-search-peek t) --> \"cumberland\"\n;; (completion-search-next 1) --> \"cumberland\"\n;; (completion-search-peek nil) --> nil\n;; (completion-search-next 2) --> \"cumbering\" {cdabbrev}\n;; (completion-search-next 3) --> nil or \"cumming\"{depends on context}\n;; (completion-search-next 1) --> \"cumberland\"\n;; (completion-search-peek t) --> \"cumbering\" {cdabbrev}\n;;\n;; - Accepting -\n;; (completion-search-next 1) --> \"cumberland\"\n;; (setq completion-to-accept \"cumberland\")\n;; (completion-search-reset \"foo\")\n;; (completion-search-reset \"cum\")\n;; (completion-search-next 0) --> \"cumberland\"\n;;\n;; - Deleting -\n;; (kill-completion \"cumberland\")\n;; cummings\n;; (completion-search-reset \"cum\")\n;; (completion-search-next 0) --> \"cumberbund\"\n;; (completion-search-next 1) --> \"cummings\"\n;;\n;; - Ignoring Capitalization -\n;; (completion-search-reset \"CuMb\")\n;; (completion-search-next 0) --> \"cumberbund\"\n\n\n\f\n;;-----------------------------------------------\n;; COMPLETE\n;;-----------------------------------------------\n\n(defun completion-mode ()\n \"Toggle whether or not to add new words to the completion database.\"\n (interactive)\n (setq enable-completion (not enable-completion))\n (message \"Completion mode is now %s.\" (if enable-completion \"ON\" \"OFF\")))\n\n(defvar cmpl-current-index 0)\n(defvar cmpl-original-string nil)\n(defvar cmpl-last-insert-location -1)\n(defvar cmpl-leave-point-at-start nil)\n\n(defun complete (&optional arg)\n \"Fill out a completion of the word before point.\nPoint is left at end. Consecutive calls rotate through all possibilities.\nPrefix args ::\n control-u :: leave the point at the beginning of the completion rather\n than at the end.\n a number :: rotate through the possible completions by that amount\n `-' :: same as -1 (insert previous completion)\n {See the comments at the top of `completion.el' for more info.}\"\n (interactive \"*p\")\n ;;; Set up variables\n (cond ((eq last-command this-command)\n\t ;; Undo last one\n\t (delete-region cmpl-last-insert-location (point))\n\t ;; get next completion\n\t (setq cmpl-current-index (+ cmpl-current-index (or arg 1))))\n\t(t\n\t (if (not cmpl-initialized-p)\n\t (completion-initialize)) ;; make sure everything's loaded\n\t (cond ((consp current-prefix-arg) ;; control-u\n\t\t(setq arg 0)\n\t\t(setq cmpl-leave-point-at-start t))\n\t (t\n\t\t(setq cmpl-leave-point-at-start nil)))\n\t ;; get string\n\t (setq cmpl-original-string (symbol-before-point-for-complete))\n\t (cond ((not cmpl-original-string)\n\t\t(setq this-command 'failed-complete)\n\t\t(error \"To complete, point must be after a symbol at least %d character long\"\n\t\t completion-prefix-min-length)))\n\t ;; get index\n\t (setq cmpl-current-index (if current-prefix-arg arg 0))\n\t ;; reset database\n\t (completion-search-reset cmpl-original-string)\n\t ;; erase what we've got\n\t (delete-region cmpl-symbol-start cmpl-symbol-end)))\n\n ;; point is at the point to insert the new symbol\n ;; Get the next completion\n (let* ((print-status-p\n\t (and (>= baud-rate completion-prompt-speed-threshold)\n\t (not (window-minibuffer-p))))\n\t (insert-point (point))\n\t (entry (completion-search-next cmpl-current-index))\n\t string)\n ;; entry is either a completion entry or a string (if cdabbrev)\n\n ;; If found, insert\n (cond (entry\n\t ;; Setup for proper case\n\t (setq string (if (stringp entry)\n\t\t\t entry (completion-string entry)))\n\t (setq string (cmpl-merge-string-cases\n\t\t\t string cmpl-original-string))\n\t ;; insert\n\t (insert string)\n\t ;; accept it\n\t (setq completion-to-accept string)\n\t ;; fixup and cache point\n\t (cond (cmpl-leave-point-at-start\n\t\t (setq cmpl-last-insert-location (point))\n\t\t (goto-char insert-point))\n\t\t (t;; point at end,\n\t\t (setq cmpl-last-insert-location insert-point)))\n\t ;; Done ! cmpl-stat-complete-successful\n\t ;;display the next completion\n\t (cond\n\t ((and print-status-p\n\t\t ;; This updates the display and only prints if there\n\t\t ;; is no typeahead\n\t\t (sit-for 0)\n\t\t (setq entry\n\t\t\t (completion-search-peek\n\t\t\t completion-cdabbrev-prompt-flag)))\n\t (setq string (if (stringp entry)\n\t\t\t entry (completion-string entry)))\n\t (setq string (cmpl-merge-string-cases\n\t\t\t string cmpl-original-string))\n\t (message \"Next completion: %s\" string))))\n\t (t;; none found, insert old\n\t (insert cmpl-original-string)\n\t ;; Don't accept completions\n\t (setq completion-to-accept nil)\n\t ;; print message\n\t ;; This used to call cmpl19-sit-for, an undefined function.\n\t ;; I hope that sit-for does the right thing; I don't know -- rms.\n\t (if (and print-status-p (sit-for 0))\n\t (message \"No %scompletions.\"\n\t\t\t(if (eq this-command last-command) \"more \" \"\")))\n\t ;; Pretend that we were never here\n\t (setq this-command 'failed-complete)))))\n\f\n;;---------------------------------------------------------------------------\n;; Parsing definitions from files into the database\n;;---------------------------------------------------------------------------\n\n;;-----------------------------------------------\n;; Top Level functions ::\n;;-----------------------------------------------\n\n;; User interface\n(defun add-completions-from-file (file)\n \"Parse possible completions from a FILE and add them to database.\"\n (interactive \"fFile: \")\n (setq file (expand-file-name file))\n (let* ((buffer (get-file-buffer file))\n\t (buffer-already-there-p buffer))\n (if (not buffer-already-there-p)\n\t(let ((completions-merging-modes nil))\n\t (setq buffer (find-file-noselect file))))\n (unwind-protect\n (with-current-buffer buffer\n (add-completions-from-buffer))\n (if (not buffer-already-there-p)\n\t (kill-buffer buffer)))))\n\n(defun add-completions-from-buffer ()\n (interactive)\n (let ((current-completion-source cmpl-source-file-parsing))\n (cond ((memq major-mode '(emacs-lisp-mode lisp-mode))\n\t (add-completions-from-lisp-buffer))\n\t ((memq major-mode '(c-mode))\n\t (add-completions-from-c-buffer))\n\t (t\n\t (error \"Cannot parse completions in %s buffers\"\n\t\t major-mode)))))\n\n;; Find file hook\n(defun completion-find-file-hook ()\n (cond (enable-completion\n\t (cond ((and (memq major-mode '(emacs-lisp-mode lisp-mode))\n\t\t (memq 'lisp completions-merging-modes))\n\t\t(add-completions-from-buffer))\n\t ((and (memq major-mode '(c-mode))\n\t\t (memq 'c completions-merging-modes))\n\t\t(add-completions-from-buffer))))))\n\n;;-----------------------------------------------\n;; Tags Table Completions\n;;-----------------------------------------------\n\n(defun add-completions-from-tags-table ()\n ;; Inspired by eero@media-lab.media.mit.edu\n \"Add completions from the current tags table.\"\n (interactive)\n (visit-tags-table-buffer)\t\t;this will prompt if no tags-table\n (save-excursion\n (goto-char (point-min))\n (let (string)\n (condition-case nil\n\t (while t\n\t (search-forward \"\\177\")\n\t (backward-char 3)\n\t (and (setq string (symbol-under-point))\n\t\t (add-completion-to-tail-if-new string))\n\t (forward-char 3))\n\t (search-failed)))))\n\n\f\n;;-----------------------------------------------\n;; Lisp File completion parsing\n;;-----------------------------------------------\n;; This merely looks for phrases beginning with (def.... or\n;; (package:def ... and takes the next word.\n;;\n;; We tried using forward-lines and explicit searches but the regexp technique\n;; was faster. (About 100K characters per second)\n;;\n(defconst *lisp-def-regexp*\n \"\\n(\\\\(\\\\w*:\\\\)?def\\\\(\\\\w\\\\|\\\\s_\\\\)*\\\\s +(*\"\n \"A regexp that searches for Lisp definition form.\")\n\n;; Tests -\n;; (and (string-match *lisp-def-regexp* \"\\n(defun foo\") (match-end 0)) -> 8\n;; (and (string-match *lisp-def-regexp* \"\\n(si:def foo\") (match-end 0)) -> 9\n;; (and (string-match *lisp-def-regexp* \"\\n(def-bar foo\")(match-end 0)) -> 10\n;; (and (string-match *lisp-def-regexp* \"\\n(defun (foo\") (match-end 0)) -> 9\n\n;; Parses all the definition names from a Lisp mode buffer and adds them to\n;; the completion database.\n(defun add-completions-from-lisp-buffer ()\n ;;; Benchmarks\n ;;; Sun-3\/280 - 1500 to 3000 lines of lisp code per second\n (let (string)\n (save-excursion\n (goto-char (point-min))\n (condition-case nil\n\t (while t\n\t (re-search-forward *lisp-def-regexp*)\n\t (and (setq string (symbol-under-point))\n\t\t (add-completion-to-tail-if-new string)))\n\t (search-failed)))))\n\n\f\n;;-----------------------------------------------\n;; C file completion parsing\n;;-----------------------------------------------\n;; C :\n;; Looks for #define or [] [] {,}\n;; or structure, array or pointer defs.\n;; It gets most of the definition names.\n;;\n;; As you might suspect by now, we use some symbol table hackery\n;;\n;; Symbol separator chars (have whitespace syntax) --> , ; * = (\n;; Opening char --> [ {\n;; Closing char --> ] }\n;; opening and closing must be skipped over\n;; Whitespace chars (have symbol syntax)\n;; Everything else has word syntax\n\n(defconst completion-c-def-syntax-table\n (let ((table (make-syntax-table))\n\t(whitespace-chars '(? ?\\n ?\\t ?\\f ?\\v ?\\r))\n\t;; unfortunately the ?( causes the parens to appear unbalanced\n\t(separator-chars '(?, ?* ?= ?\\( ?\\;))\n\ti)\n ;; default syntax is whitespace\n (setq i 0)\n (while (< i 256)\n (modify-syntax-entry i \"w\" table)\n (setq i (1+ i)))\n (dolist (char whitespace-chars)\n (modify-syntax-entry char \"_\" table))\n (dolist (char separator-chars)\n (modify-syntax-entry char \" \" table))\n (modify-syntax-entry ?\\[ \"(]\" table)\n (modify-syntax-entry ?\\{ \"(}\" table)\n (modify-syntax-entry ?\\] \")[\" table)\n (modify-syntax-entry ?\\} \"){\" table)\n table))\n\n;; Regexps\n(defconst *c-def-regexp*\n ;; This stops on lines with possible definitions\n \"\\n[_a-zA-Z#]\"\n ;; This stops after the symbol to add.\n ;;\"\\n\\\\(#define\\\\s +.\\\\|\\\\(\\\\(\\\\w\\\\|\\\\s_\\\\)+\\\\b\\\\s *\\\\)+[(;,[*{=]\\\\)\"\n ;; This stops before the symbol to add. {Test cases in parens. below}\n ;;\"\\n\\\\(\\\\(\\\\w\\\\|\\\\s_\\\\)+\\\\s *(\\\\|\\\\(\\\\(#define\\\\|auto\\\\|extern\\\\|register\\\\|static\\\\|int\\\\|long\\\\|short\\\\|unsigned\\\\|char\\\\|void\\\\|float\\\\|double\\\\|enum\\\\|struct\\\\|union\\\\|typedef\\\\)\\\\s +\\\\)+\\\\)\"\n ;; this simple version picks up too much extraneous stuff\n ;; \"\\n\\\\(\\\\w\\\\|\\\\s_\\\\|#\\\\)\\\\B\"\n \"A regexp that searches for a definition form.\")\n;\n;(defconst *c-cont-regexp*\n; \"\\\\(\\\\w\\\\|\\\\s_\\\\)+\\\\b\\\\s *\\\\({\\\\|\\\\(\\\\[[0-9\\t ]*\\\\]\\\\s *\\\\)*,\\\\(*\\\\|\\\\s \\\\)*\\\\b\\\\)\"\n; \"This regexp should be used in a looking-at to parse for lists of variables.\")\n;\n;(defconst *c-struct-regexp*\n; \"\\\\(*\\\\|\\\\s \\\\)*\\\\b\"\n; \"This regexp should be used to test whether a symbol follows a structure definition.\")\n\n;(defun test-c-def-regexp (regexp string)\n; (and (eq 0 (string-match regexp string)) (match-end 0))\n; )\n\n;; Tests -\n;; (test-c-def-regexp *c-def-regexp* \"\\n#define foo\") -> 10 (9)\n;; (test-c-def-regexp *c-def-regexp* \"\\nfoo (x, y) {\") -> 6 (6)\n;; (test-c-def-regexp *c-def-regexp* \"\\nint foo (x, y)\") -> 10 (5)\n;; (test-c-def-regexp *c-def-regexp* \"\\n int foo (x, y)\") -> nil\n;; (test-c-def-regexp *c-cont-regexp* \"oo, bar\") -> 4\n;; (test-c-def-regexp *c-cont-regexp* \"oo, *bar\") -> 5\n;; (test-c-def-regexp *c-cont-regexp* \"a [5][6], bar\") -> 10\n;; (test-c-def-regexp *c-cont-regexp* \"oo(x,y)\") -> nil\n;; (test-c-def-regexp *c-cont-regexp* \"a [6] ,\\t bar\") -> 9\n;; (test-c-def-regexp *c-cont-regexp* \"oo {trout =1} my_carp;\") -> 14\n;; (test-c-def-regexp *c-cont-regexp* \"truct_p complex foon\") -> nil\n\n;; Parses all the definition names from a C mode buffer and adds them to the\n;; completion database.\n(defun add-completions-from-c-buffer ()\n ;; Benchmark --\n ;; Sun 3\/280-- 1250 lines\/sec.\n\n (let (string next-point char)\n (save-excursion\n (goto-char (point-min))\n (catch 'finish-add-completions\n (with-syntax-table completion-c-def-syntax-table\n (while t\n ;; we loop here only when scan-sexps fails\n ;; (i.e. unbalance exps.)\n (condition-case e\n (while t\n (re-search-forward *c-def-regexp*)\n (cond\n ((= (preceding-char) ?#)\n ;; preprocessor macro, see if it's one we handle\n (cond ((looking-at \"\\\\(define\\\\|ifdef\\\\)\\\\>\")\n ;; skip forward over definition symbol\n ;; and add it to database\n (and (forward-word 2)\n (setq string (symbol-before-point))\n ;;(push string foo)\n (add-completion-to-tail-if-new string)))))\n (t\n ;; C definition\n (setq next-point (point))\n (while (and\n next-point\n ;; scan to next separator char.\n (setq next-point (scan-sexps next-point 1)))\n ;; position the point on the word we want to add\n (goto-char next-point)\n (while (= (setq char (following-char)) ?*)\n ;; handle pointer ref\n ;; move to next separator char.\n (goto-char\n (setq next-point (scan-sexps (point) 1))))\n (forward-word -1)\n ;; add to database\n (if (setq string (symbol-under-point))\n ;; (push string foo)\n (add-completion-to-tail-if-new string)\n ;; Local TMC hack (useful for parsing paris.h)\n (if (and (looking-at \"_AP\") ;; \"ansi prototype\"\n (progn\n (forward-word -1)\n (setq string\n (symbol-under-point))))\n (add-completion-to-tail-if-new string)))\n ;; go to next\n (goto-char next-point)\n ;; (push (format \"%c\" (following-char)) foo)\n (if (= (char-syntax char) ?\\()\n ;; if on an opening delimiter, go to end\n (while (= (char-syntax char) ?\\()\n (setq next-point (scan-sexps next-point 1)\n char (char-after next-point)))\n (or (= char ?,)\n ;; Current char is an end char.\n (setq next-point nil)))))))\n (search-failed ;;done\n (throw 'finish-add-completions t))\n (error\n ;; Check for failure in scan-sexps\n (if (member (nth 1 e)\n '(\"Containing expression ends prematurely\"\n \"Unbalanced parentheses\"))\n ;; unbalanced paren., keep going\n ;;(ding)\n (forward-line 1)\n (message \"Error parsing C buffer for completions--please send bug report\")\n (throw 'finish-add-completions t))))))))))\n\n\f\n;;---------------------------------------------------------------------------\n;; Init files\n;;---------------------------------------------------------------------------\n\n;; The version of save-completions-to-file called at kill-emacs time.\n(defun kill-emacs-save-completions ()\n (if (and save-completions-flag enable-completion cmpl-initialized-p)\n (cond\n\t((not cmpl-completions-accepted-p)\n\t (message \"Completions database has not changed - not writing.\"))\n\t(t\n\t (save-completions-to-file)))))\n\n;; There is no point bothering to change this again\n;; unless the package changes so much that it matters\n;; for people that have saved completions.\n(defconst completion-version \"11\")\n\n(defconst saved-cmpl-file-header\n \";;; Completion Initialization file.\n;; Version = %s\n;; Format is ( . )\n;; is the completion\n;; is the time the completion was last used\n;; If it is t, the completion will never be pruned from the file.\n;; Otherwise it is in hours since origin.\n\\n\")\n\n(defun completion-backup-filename (filename)\n (concat filename \".BAK\"))\n\n(defun save-completions-to-file (&optional filename)\n \"Save completions in init file FILENAME.\nIf file name is not specified, use `save-completions-file-name'.\"\n (interactive)\n (setq filename (expand-file-name (or filename save-completions-file-name)))\n (if (file-writable-p filename)\n (progn\n\t(if (not cmpl-initialized-p)\n\t (completion-initialize)) ;; make sure everything's loaded\n\t(message \"Saving completions to file %s\" filename)\n\n\t(let* ((delete-old-versions t)\n\t (kept-old-versions 0)\n\t (kept-new-versions completions-file-versions-kept)\n\t last-use-time\n\t (current-time (cmpl-hours-since-origin))\n\t (total-in-db 0)\n\t (total-perm 0)\n\t (total-saved 0)\n\t (backup-filename (completion-backup-filename filename)))\n\n\t (with-current-buffer (get-buffer-create \" *completion-save-buffer*\")\n\t (setq buffer-file-name filename)\n\n\t (if (not (verify-visited-file-modtime (current-buffer)))\n\t\t(progn\n\t\t ;; file has changed on disk. Bring us up-to-date\n\t\t (message \"Completion file has changed. Merging. . .\")\n\t\t (load-completions-from-file filename t)\n\t\t (message \"Merging finished. Saving completions to file %s\" filename)))\n\n\t ;; prepare the buffer to be modified\n\t (clear-visited-file-modtime)\n\t (erase-buffer)\n\t ;; (\/ 1 0)\n\t (insert (format saved-cmpl-file-header completion-version))\n\t (dolist (completion (list-all-completions))\n\t (setq total-in-db (1+ total-in-db))\n\t (setq last-use-time (completion-last-use-time completion))\n\t ;; Update num uses and maybe write completion to a file\n\t (cond ((or;; Write to file if\n\t\t ;; permanent\n\t\t (and (eq last-use-time t)\n\t\t\t (setq total-perm (1+ total-perm)))\n\t\t ;; or if\n\t\t (if (> (completion-num-uses completion) 0)\n\t\t\t ;; it's been used\n\t\t\t (setq last-use-time current-time)\n\t\t\t;; or it was saved before and\n\t\t\t(and last-use-time\n\t\t\t ;; save-completions-retention-time is nil\n\t\t\t (or (not save-completions-retention-time)\n\t\t\t\t ;; or time since last use is < ...retention-time*\n\t\t\t\t (< (- current-time last-use-time)\n\t\t\t\t save-completions-retention-time)))))\n\t\t ;; write to file\n\t\t (setq total-saved (1+ total-saved))\n\t\t (insert (prin1-to-string (cons (completion-string completion)\n\t\t\t\t\t\t last-use-time)) \"\\n\"))))\n\n\t ;; write the buffer\n\t (condition-case nil\n\t\t(let ((file-exists-p (file-exists-p filename)))\n\t\t (if file-exists-p\n\t\t (progn\n\t\t\t;; If file exists . . .\n\t\t\t;; Save a backup(so GNU doesn't screw us when we're out of disk)\n\t\t\t;; (GNU leaves a 0 length file if it gets a disk full error!)\n\n\t\t\t;; If backup doesn't exit, Rename current to backup\n\t\t\t;; {If backup exists the primary file is probably messed up}\n\t\t\t(or (file-exists-p backup-filename)\n\t\t\t (rename-file filename backup-filename))\n\t\t\t;; Copy the backup back to the current name\n\t\t\t;; (so versioning works)\n\t\t\t(copy-file backup-filename filename t)))\n\t\t ;; Save it\n\t\t (save-buffer)\n\t\t (if file-exists-p\n\t\t ;; If successful, remove backup\n\t\t (delete-file backup-filename)))\n\t (error\n\t (set-buffer-modified-p nil)\n\t (message \"Couldn't save completion file `%s'\" filename)))\n\t ;; Reset accepted-p flag\n\t (setq cmpl-completions-accepted-p nil) )))))\n\n;;(defun auto-save-completions ()\n;; (if (and save-completions-flag enable-completion cmpl-initialized-p\n;;\t *completion-auto-save-period*\n;;\t (> cmpl-emacs-idle-time *completion-auto-save-period*)\n;;\t cmpl-completions-accepted-p)\n;; (save-completions-to-file)))\n\n;;(add-hook 'cmpl-emacs-idle-time-hooks 'auto-save-completions)\n\n(defun load-completions-from-file (&optional filename no-message-p)\n \"Load a completion init file FILENAME.\nIf file is not specified, then use `save-completions-file-name'.\"\n (interactive)\n (setq filename (expand-file-name (or filename save-completions-file-name)))\n (let* ((backup-filename (completion-backup-filename filename))\n\t (backup-readable-p (file-readable-p backup-filename)))\n (if backup-readable-p (setq filename backup-filename))\n (if (file-readable-p filename)\n\t(progn\n\t (if (not no-message-p)\n\t (message \"Loading completions from %sfile %s . . .\"\n\t\t (if backup-readable-p \"backup \" \"\") filename))\n\t (with-current-buffer (get-buffer-create \" *completion-save-buffer*\")\n\t (setq buffer-file-name filename)\n\t ;; prepare the buffer to be modified\n\t (clear-visited-file-modtime)\n\t (erase-buffer)\n\n\t (let ((insert-okay-p nil)\n\t\t (buffer (current-buffer))\n\t\t string entry last-use-time\n\t\t cmpl-entry cmpl-last-use-time\n\t\t (current-completion-source cmpl-source-init-file)\n\t\t (total-in-file 0) (total-perm 0))\n\t ;; insert the file into a buffer\n\t (condition-case nil\n\t\t (progn (insert-file-contents filename t)\n\t\t\t (setq insert-okay-p t))\n\n\t\t(file-error\n\t\t (message \"File error trying to load completion file %s.\"\n\t\t\t filename)))\n\t ;; parse it\n\t (if insert-okay-p\n\t\t (progn\n\t\t (goto-char (point-min))\n\n\t\t (condition-case nil\n\t\t\t(while t\n\t\t\t (setq entry (read buffer))\n\t\t\t (setq total-in-file (1+ total-in-file))\n\t\t\t (cond\n\t\t\t ((and (consp entry)\n\t\t\t\t (stringp (setq string (car entry)))\n\t\t\t\t (cond\n\t\t\t\t ((eq (setq last-use-time (cdr entry)) 'T)\n\t\t\t\t ;; handle case sensitivity\n\t\t\t\t (setq total-perm (1+ total-perm))\n\t\t\t\t (setq last-use-time t))\n\t\t\t\t ((eq last-use-time t)\n\t\t\t\t (setq total-perm (1+ total-perm)))\n\t\t\t\t ((integerp last-use-time))))\n\t\t\t ;; Valid entry\n\t\t\t ;; add it in\n\t\t\t (setq cmpl-last-use-time\n\t\t\t\t (completion-last-use-time\n\t\t\t\t (setq cmpl-entry\n\t\t\t\t\t (add-completion-to-tail-if-new string))))\n\t\t\t (if (or (eq last-use-time t)\n\t\t\t\t (and (> last-use-time 1000);;backcompatibility\n\t\t\t\t\t (not (eq cmpl-last-use-time t))\n\t\t\t\t\t (or (not cmpl-last-use-time)\n\t\t\t\t\t ;; more recent\n\t\t\t\t\t (> last-use-time cmpl-last-use-time))))\n\t\t\t\t;; update last-use-time\n\t\t\t\t(set-completion-last-use-time cmpl-entry last-use-time)))\n\t\t\t (t\n\t\t\t ;; Bad format\n\t\t\t (message \"Error: invalid saved completion - %s\"\n\t\t\t\t (prin1-to-string entry))\n\t\t\t ;; try to get back in sync\n\t\t\t (search-forward \"\\n(\"))))\n\t\t (search-failed\n\t\t (message \"End of file while reading completions.\"))\n\t\t (end-of-file\n\t\t (if (= (point) (point-max))\n\t\t\t (if (not no-message-p)\n\t\t\t (message \"Loading completions from file %s . . . Done.\"\n\t\t\t\t\tfilename))\n\t\t\t (message \"End of file while reading completions.\"))))))\n))))))\n\n(defun completion-initialize ()\n \"Load the default completions file.\nAlso sets up so that exiting Emacs will automatically save the file.\"\n (interactive)\n (unless cmpl-initialized-p\n (load-completions-from-file)\n (setq cmpl-initialized-p t)))\n\f\n;;-----------------------------------------------\n;; Kill region patch\n;;-----------------------------------------------\n\n(defun completion-kill-region (&optional beg end)\n \"Kill between point and mark.\nThe text is deleted but saved in the kill ring.\nThe command \\\\[yank] can retrieve it from there.\n\/(If you want to kill and then yank immediately, use \\\\[copy-region-as-kill].)\n\nThis is the primitive for programs to kill text (as opposed to deleting it).\nSupply two arguments, character positions indicating the stretch of text\n to be killed.\nAny command that calls this function is a \\\"kill command\\\".\nIf the previous command was also a kill command,\nthe text killed this time appends to the text killed last time\nto make one entry in the kill ring.\nPatched to remove the most recent completion.\"\n (interactive \"r\")\n (cond ((eq last-command 'complete)\n\t (delete-region (point) cmpl-last-insert-location)\n\t (insert cmpl-original-string)\n\t (setq completion-to-accept nil))\n\t(t\n\t (kill-region beg end))))\n\n\f\n;;-----------------------------------------------\n;; Patches to self-insert-command.\n;;-----------------------------------------------\n\n;; Need 2 versions: generic separator chars. and space (to get auto fill\n;; to work)\n\n;; All common separators (eg. space \"(\" \")\" \"\"\") characters go through a\n;; function to add new words to the list of words to complete from:\n;; COMPLETION-SEPARATOR-SELF-INSERT-COMMAND (arg).\n;; If the character before this was an alpha-numeric then this adds the\n;; symbol before point to the completion list (using ADD-COMPLETION).\n\n(defun completion-separator-self-insert-command (arg)\n (interactive \"p\")\n (if (command-remapping 'self-insert-command)\n (funcall (command-remapping 'self-insert-command) arg)\n (use-completion-before-separator)\n (self-insert-command arg)))\n\n(defun completion-separator-self-insert-autofilling (arg)\n (interactive \"p\")\n (if (command-remapping 'self-insert-command)\n (funcall (command-remapping 'self-insert-command) arg)\n (use-completion-before-separator)\n (self-insert-command arg)\n (and auto-fill-function\n\t (funcall auto-fill-function))))\n\n;;-----------------------------------------------\n;; Wrapping Macro\n;;-----------------------------------------------\n\n;; Note that because of the way byte compiling works, none of\n;; the functions defined with this macro get byte compiled.\n\n(defun completion-def-wrapper (function-name type)\n \"Add a call to update the completion database before function execution.\nTYPE is the type of the wrapper to be added. Can be :before or :under.\"\n (put function-name 'completion-function\n (cdr (assq type\n '((:separator . use-completion-before-separator)\n (:before . use-completion-before-point)\n (:backward-under . use-completion-backward-under)\n (:backward . use-completion-backward)\n (:under . use-completion-under-point)\n (:under-or-before . use-completion-under-or-before-point)\n (:minibuffer-separator\n\t\t . use-completion-minibuffer-separator))))))\n\n(defun use-completion-minibuffer-separator ()\n (let ((completion-syntax-table completion-standard-syntax-table))\n (use-completion-before-separator)))\n\n(defun use-completion-backward-under ()\n (use-completion-under-point))\n\n(defun use-completion-backward ()\n nil)\n\n(defun completion-before-command ()\n (funcall (or (and (symbolp this-command)\n\t\t (get this-command 'completion-function))\n\t 'use-completion-under-or-before-point)))\n\f\n;; Lisp mode diffs.\n\n(defconst completion-lisp-syntax-table\n (let ((table (copy-syntax-table completion-standard-syntax-table))\n\t(symbol-chars '(?! ?& ?? ?= ?^)))\n (dolist (char symbol-chars)\n (modify-syntax-entry char \"_\" table))\n table))\n\n(defun completion-lisp-mode-hook ()\n (setq completion-syntax-table completion-lisp-syntax-table)\n ;; Lisp Mode diffs\n (local-set-key \"!\" 'self-insert-command)\n (local-set-key \"&\" 'self-insert-command)\n (local-set-key \"%\" 'self-insert-command)\n (local-set-key \"?\" 'self-insert-command)\n (local-set-key \"=\" 'self-insert-command)\n (local-set-key \"^\" 'self-insert-command))\n\n;; C mode diffs.\n\n(defconst completion-c-syntax-table\n (let ((table (copy-syntax-table completion-standard-syntax-table))\n\t(separator-chars '(?+ ?* ?\/ ?: ?%)))\n (dolist (char separator-chars)\n (modify-syntax-entry char \" \" table))\n table))\n\n(completion-def-wrapper 'electric-c-semi :separator)\n(defun completion-c-mode-hook ()\n (setq completion-syntax-table completion-c-syntax-table)\n (local-set-key \"+\" 'completion-separator-self-insert-command)\n (local-set-key \"*\" 'completion-separator-self-insert-command)\n (local-set-key \"\/\" 'completion-separator-self-insert-command))\n\n;; FORTRAN mode diffs. (these are defined when fortran is called)\n\n(defconst completion-fortran-syntax-table\n (let ((table (copy-syntax-table completion-standard-syntax-table))\n\t(separator-chars '(?+ ?- ?* ?\/ ?:)))\n (dolist (char separator-chars)\n (modify-syntax-entry char \" \" table))\n table))\n\n(defun completion-setup-fortran-mode ()\n (setq completion-syntax-table completion-fortran-syntax-table)\n (local-set-key \"+\" 'completion-separator-self-insert-command)\n (local-set-key \"-\" 'completion-separator-self-insert-command)\n (local-set-key \"*\" 'completion-separator-self-insert-command)\n (local-set-key \"\/\" 'completion-separator-self-insert-command))\n\f\n;; Enable completion mode.\n\n(defvar fortran-mode-hook)\n\n(defvar completion-saved-bindings nil)\n\n;;;###autoload\n(define-minor-mode dynamic-completion-mode\n \"Toggle dynamic word-completion on or off.\nWith a prefix argument ARG, enable the mode if ARG is positive,\nand disable it otherwise. If called from Lisp, enable the mode\nif ARG is omitted or nil.\"\n :global t\n :group 'completion\n ;; This is always good, not specific to dynamic-completion-mode.\n (define-key function-key-map [C-return] [?\\C-\\r])\n\n (dolist (x '((find-file-hook\t\t. completion-find-file-hook)\n (pre-command-hook\t. completion-before-command)\n ;; Save completions when killing Emacs.\n (kill-emacs-hook\t\t. kill-emacs-save-completions)\n\n ;; Install the appropriate mode tables.\n (lisp-mode-hook\t\t. completion-lisp-mode-hook)\n (c-mode-hook\t\t. completion-c-mode-hook)\n (fortran-mode-hook\t. completion-setup-fortran-mode)))\n (if dynamic-completion-mode\n (add-hook (car x) (cdr x))\n (remove-hook (car x) (cdr x))))\n\n ;; \"Complete\" Key Keybindings. We don't want to use a minor-mode\n ;; map because these have too high a priority. We could\/should\n ;; probably change the interpretation of minor-mode-map-alist such\n ;; that a map has lower precedence if the symbol is not buffer-local.\n (while completion-saved-bindings\n (let ((binding (pop completion-saved-bindings)))\n (global-set-key (car binding) (cdr binding))))\n (when dynamic-completion-mode\n (dolist (binding\n '((\"\\M-\\r\" . complete)\n ([?\\C-\\r] . complete)\n\n ;; Tests -\n ;; (add-completion \"cumberland\")\n ;; (add-completion \"cumberbund\")\n ;; cum\n ;; Cumber\n ;; cumbering\n ;; cumb\n\n ;; Patches to standard keymaps insert completions\n ([remap kill-region] . completion-kill-region)\n\n ;; Separators\n ;; We've used the completion syntax table given as a guide.\n ;;\n ;; Global separator chars.\n ;; We left out because there are too many special\n ;; cases for it. Also, in normal coding it's rarely typed\n ;; after a word.\n (\" \" . completion-separator-self-insert-autofilling)\n (\"!\" . completion-separator-self-insert-command)\n (\"%\" . completion-separator-self-insert-command)\n (\"^\" . completion-separator-self-insert-command)\n (\"&\" . completion-separator-self-insert-command)\n (\"(\" . completion-separator-self-insert-command)\n (\")\" . completion-separator-self-insert-command)\n (\"=\" . completion-separator-self-insert-command)\n (\"`\" . completion-separator-self-insert-command)\n (\"|\" . completion-separator-self-insert-command)\n (\"{\" . completion-separator-self-insert-command)\n (\"}\" . completion-separator-self-insert-command)\n (\"[\" . completion-separator-self-insert-command)\n (\"]\" . completion-separator-self-insert-command)\n (\";\" . completion-separator-self-insert-command)\n (\"\\\"\". completion-separator-self-insert-command)\n (\"'\" . completion-separator-self-insert-command)\n (\"#\" . completion-separator-self-insert-command)\n (\",\" . completion-separator-self-insert-command)\n (\"?\" . completion-separator-self-insert-command)\n\n ;; We include period and colon even though they are symbol\n ;; chars because :\n ;; - in text we want to pick up the last word in a sentence.\n ;; - in C pointer refs. we want to pick up the first symbol\n ;; - it won't make a difference for lisp mode (package names\n ;; are short)\n (\".\" . completion-separator-self-insert-command)\n (\":\" . completion-separator-self-insert-command)))\n (push (cons (car binding) (lookup-key global-map (car binding)))\n completion-saved-bindings)\n (global-set-key (car binding) (cdr binding)))\n\n ;; Tests --\n ;; foobarbiz\n ;; foobar\n ;; fooquux\n ;; fooper\n\n (completion-initialize)))\n\n;;-----------------------------------------------\n;; End of line chars.\n;;-----------------------------------------------\n(completion-def-wrapper 'newline :separator)\n(completion-def-wrapper 'newline-and-indent :separator)\n(completion-def-wrapper 'comint-send-input :separator)\n(completion-def-wrapper 'exit-minibuffer :minibuffer-separator)\n(completion-def-wrapper 'eval-print-last-sexp :separator)\n(completion-def-wrapper 'eval-last-sexp :separator)\n;;(completion-def-wrapper 'minibuffer-complete-and-exit :minibuffer)\n\n;;-----------------------------------------------\n;; Cursor movement\n;;-----------------------------------------------\n\n(completion-def-wrapper 'next-line :under-or-before)\n(completion-def-wrapper 'previous-line :under-or-before)\n(completion-def-wrapper 'beginning-of-buffer :under-or-before)\n(completion-def-wrapper 'end-of-buffer :under-or-before)\n(completion-def-wrapper 'beginning-of-line :under-or-before)\n(completion-def-wrapper 'end-of-line :under-or-before)\n(completion-def-wrapper 'forward-char :under-or-before)\n(completion-def-wrapper 'forward-word :under-or-before)\n(completion-def-wrapper 'forward-sexp :under-or-before)\n(completion-def-wrapper 'backward-char :backward-under)\n(completion-def-wrapper 'backward-word :backward-under)\n(completion-def-wrapper 'backward-sexp :backward-under)\n\n(completion-def-wrapper 'delete-backward-char :backward)\n(completion-def-wrapper 'delete-backward-char-untabify :backward)\n\n;; Old names, non-namespace-clean.\n(defvaralias 'cmpl-syntax-table 'completion-syntax-table)\n(defalias 'initialize-completions 'completion-initialize)\n\n(provide 'completion)\n\n;;; completion.el ends here\n","avg_line_length":38.1063564603,"max_line_length":198,"alphanum_fraction":0.6204509278} {"size":25006,"ext":"el","lang":"Emacs Lisp","max_stars_count":1.0,"content":";;; wisent-csharp-wy.el --- Generated parser support file\n\n;; Copyright (C) 2003 David Shilvock\n\n;; Author: \n;; Created: 2011-03-17 15:00:45+0800\n;; Keywords: syntax\n;; X-RCS: $Id$\n\n;; This file is not part of GNU Emacs.\n;;\n;; This program is free software; you can redistribute it and\/or\n;; modify it under the terms of the GNU General Public License as\n;; published by the Free Software Foundation; either version 2, or (at\n;; your option) any later version.\n;;\n;; This software is distributed in the hope that it will be useful,\n;; but WITHOUT ANY WARRANTY; without even the implied warranty of\n;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n;; General Public License for more details.\n;;\n;; You should have received a copy of the GNU General Public License\n;; along with GNU Emacs; see the file COPYING. If not, write to the\n;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,\n;; Boston, MA 02110-1301, USA.\n\n;;; Commentary:\n;;\n;; PLEASE DO NOT MANUALLY EDIT THIS FILE! It is automatically\n;; generated from the grammar file wisent-csharp.wy.\n\n;;; Code:\n\f\n;;; Prologue\n;;\n\f\n;;; Declarations\n;;\n(defconst wisent-csharp-wy--keyword-table\n (semantic-lex-make-keyword-table\n '((\"abstract\" . ABSTRACT)\n (\"add\" . ADD)\n (\"as\" . AS)\n (\"base\" . BASE)\n (\"bool\" . BOOL)\n (\"break\" . BREAK)\n (\"byte\" . BYTE)\n (\"case\" . CASE)\n (\"catch\" . CATCH)\n (\"char\" . CHAR)\n (\"checked\" . CHECKED)\n (\"class\" . CLASS)\n (\"const\" . CONST)\n (\"continue\" . CONTINUE)\n (\"decimal\" . DECIMAL)\n (\"default\" . DEFAULT)\n (\"delegate\" . DELEGATE)\n (\"do\" . DO)\n (\"double\" . DOUBLE)\n (\"else\" . ELSE)\n (\"enum\" . ENUM)\n (\"event\" . EVENT)\n (\"explicit\" . EXPLICIT)\n (\"extern\" . EXTERN)\n (\"finally\" . FINALLY)\n (\"fixed\" . FIXED)\n (\"float\" . FLOAT)\n (\"for\" . FOR)\n (\"foreach\" . FOREACH)\n (\"get\" . GET)\n (\"goto\" . GOTO)\n (\"if\" . IF)\n (\"implicit\" . IMPLICIT)\n (\"in\" . IN)\n (\"int\" . INT)\n (\"interface\" . INTERFACE)\n (\"internal\" . INTERNAL)\n (\"is\" . IS)\n (\"lock\" . LOCK)\n (\"long\" . LONG)\n (\"namespace\" . NAMESPACE)\n (\"new\" . NEW)\n (\"object\" . OBJECT)\n (\"operator\" . OPERATOR)\n (\"out\" . OUT)\n (\"override\" . OVERRIDE)\n (\"params\" . PARAMS)\n (\"private\" . PRIVATE)\n (\"protected\" . PROTECTED)\n (\"public\" . PUBLIC)\n (\"readonly\" . READONLY)\n (\"ref\" . REF)\n (\"remove\" . REMOVE)\n (\"return\" . RETURN)\n (\"sbyte\" . SBYTE)\n (\"sealed\" . SEALED)\n (\"set\" . SET)\n (\"short\" . SHORT)\n (\"sizeof\" . SIZEOF)\n (\"stackalloc\" . STACKALLOC)\n (\"static\" . STATIC)\n (\"string\" . STRING)\n (\"struct\" . STRUCT)\n (\"switch\" . SWITCH)\n (\"this\" . THIS)\n (\"throw\" . THROW)\n (\"try\" . TRY)\n (\"typeof\" . TYPEOF)\n (\"unit\" . UINT)\n (\"ulong\" . ULONG)\n (\"unchecked\" . UNCHECKED)\n (\"unsafe\" . UNSAFE)\n (\"ushort\" . USHORT)\n (\"using\" . USING)\n (\"virtual\" . VIRTUAL)\n (\"void\" . VOID)\n (\"volatile\" . VOLATILE)\n (\"while\" . WHILE))\n '((\"while\" summary \"while () | do while ();\")\n (\"volatile\" summary \"Field declaration modifier: volatile ...\")\n (\"void\" summary \"Method return type: void ...\")\n (\"virtual\" summary \"\")\n (\"using\" summary \"Namespace import: using | using = ;\")\n (\"ushort\" summary \"\")\n (\"unsafe\" summary \"\")\n (\"unchecked\" summary \"\")\n (\"ulong\" summary \"\")\n (\"unit\" summary \"\")\n (\"typeof\" summary \"\")\n (\"try\" summary \"try {} [catch() {} ...] [finally {}]\")\n (\"throw\" summary \"throw ;\")\n (\"switch\" summary \"switch() {[case : ...] [default: ]}\")\n (\"struct\" summary \"\")\n (\"string\" summary \"\")\n (\"static\" summary \"Declaration modifier: static {class|interface|} ...\")\n (\"stackalloc\" summary \"\")\n (\"sizeof\" summary \"\")\n (\"short\" summary \"Integral primitive type (-32768 to 32767)\")\n (\"set\" summary \"\")\n (\"sealed\" summary \"\")\n (\"sbyte\" summary \"\")\n (\"return\" summary \"return [] ;\")\n (\"remove\" summary \"\")\n (\"ref\" summary \"\")\n (\"readonly\" summary \"\")\n (\"public\" summary \"Access level modifier: public {class|interface|} ...\")\n (\"protected\" summary \"Access level modifier: protected {class|interface|} ...\")\n (\"private\" summary \"Access level modifier: private {class|interface|} ...\")\n (\"params\" summary \"\")\n (\"override\" summary \"\")\n (\"out\" summary \"\")\n (\"operator\" summary \"\")\n (\"object\" summary \"\")\n (\"namespace\" summary \"\")\n (\"long\" summary \"Integral primitive type (-9223372036854775808 to 9223372036854775807)\")\n (\"lock\" summary \"\")\n (\"is\" summary \"\")\n (\"internal\" summary \"\")\n (\"interface\" summary \"Interface declaration: interface \")\n (\"int\" summary \"Integral primitive type (-2147483648 to 2147483647)\")\n (\"in\" summary \"\")\n (\"implicit\" summary \"\")\n (\"if\" summary \"if () [else ]\")\n (\"goto\" summary \"Unused reserved word\")\n (\"get\" summary \"\")\n (\"foreach\" summary \"\")\n (\"for\" summary \"for ([]; []; []) \")\n (\"float\" summary \"Primitive floating-point type (single-precision 32-bit IEEE 754)\")\n (\"fixed\" summary \"\")\n (\"finally\" summary \"try {} ... finally {}\")\n (\"extern\" summary \"\")\n (\"explicit\" summary \"\")\n (\"event\" summary \"\")\n (\"enum\" summary \"\")\n (\"else\" summary \"if () else \")\n (\"double\" summary \"Primitive floating-point type (double-precision 64-bit IEEE 754)\")\n (\"do\" summary \"do while ();\")\n (\"delegate\" summary \"\")\n (\"default\" summary \"switch() { ... default: }\")\n (\"decimal\" summary \"\")\n (\"continue\" summary \"continue [