;;; naf-mode-insertion-utils.el --- insertion procedures for working in `naf-mode' buffer ;; -*- mode: EMACS-LISP; -*- ;;; ================================================================ ;;; DESCRIPTION: ;;; naf-insertion-utils common insertion procedures and miscellaneous ;;; tools for working in a `naf-mode' buffer. ;;; ;;; FUNCTIONS:▶▶▶ ;;; `naf-tab-region', `naf-comment-line', `naf-uncomment-line', ;;; `naf-comment-region', `naf-uncomment-region', `non-posting-source', `npps', ;;; `non-posting-wiki-source', `non-posting-ebay-source', ;;; `non-posting-imdb-source', `non-posting-benezit-source', ;;; `non-posting-internet-source', `mon-insert-naf-mode-constant-template', ;;; `mon-insert-naf-mode-face-template', `mon-insert-naf-mode-faces-as-displayed', ;;; `mon-insert-naf-file-in-dirs', ;;; `mon-insert-naf-mode-xref-template', `mon-build-naf-mode-xref' ;;; `mon-insert-naf-mode-var-const-template', `mon-insert-naf-mode-class-template' ;;; FUNCTIONS:◀◀◀ ;;; ;;; MACROS: ;;; ;;; CLASSES: ;;; ;;; CONSTANTS: ;;; `*naf-mode-faces-as-displayed*' ;;; ;;; VARIABLES: ;;; ;;; ALIASED/ADVISED/SUBST'D: ;;; `npes' -> `non-posting-ebay-source' ;;; `npps' -> `non-posting-philsp-source' ;;; `npws' -> `non-posting-wiki-src' ;;; `constance-insert-copyright' -> `mon-insert-copyright' ;;; `mon-insert-naf-mode-file-template' -> `mon-insert-file-template' ;;; ;;; DEPRECATED: ;;; `npps' -> `mon-cln-philsp' ;;; `mon-insert-naf-mode-constant-template' ;;; -> `mon-insert-mon-insert-naf-mode-var-const-template' ;;; ;;; RENAMED: ;;; `mon-insert-naf-mode-var-const-templt' -> `mon-insert-naf-mode-var-const-template' ;;; `mon-insert-face-as-displayed' -> `mon-insert-naf-mode-faces-as-displayed' ;;; ;;; MOVED: ;;; ;;; REQUIRES: ;;; ;;; TODO: ;;; ;;; NOTES: ;;; It appears the macro for toggling longlines mode was yanked in incorrectly as: ;;; `mon-is-naf-mode-and-llm-p' ;<-WRONG! ;;; it should have been: ;;; `mon-naf-mode-toggle-restore-llm' ;;; We are testing this again, AS-OF: ;;; ;;; ;;; SNIPPETS: ;;; ;;; THIRD PARTY CODE: ;;; ;;; AUTHOR: MON KEY ;;; MAINTAINER: MON KEY ;;; ;;; PUBLIC-LINK: ;;; (URL `http://www.emacswiki.org/emacs/naf-mode-insertion-utils.el') ;;; FIRST-PUBLISHED: ;;; ;;; FILE-CREATED: ;;; ;;; ================================================================ ;; This file is not part of GNU Emacs. ;; ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation; either version 3, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth ;; Floor, Boston, MA 02110-1301, USA. ;;; ================================================================ ;; Permission is granted to copy, distribute and/or modify this ;; document under the terms of the GNU Free Documentation License, ;; Version 1.3 or any later version published by the Free Software ;; Foundation; with no Invariant Sections, no Front-Cover Texts, ;; and no Back-Cover Texts. A copy of the license is included in ;; the section entitled ``GNU Free Documentation License''. ;; ;; A copy of the license is also available from the Free Software ;; Foundation Web site at: ;; (URL `http://www.gnu.org/licenses/fdl-1.3.txt'). ;;; ============================== ;; Copyright © 2009-2024 MON KEY ;;; ============================== ;;; CODE: (eval-when-compile (require 'cl) (require 'edmacro)) ;;; ============================== ;;; :CREATED (defvar *naf-mode-insertion-utils-xrefs* nil "*Xrefing list of functions and variables for naf-mode-insertion-utils.\n :EXAMPLE\n\*naf-mode-insertion-utils-xrefs*\n \(nth 3 *naf-mode-insertion-utils-xrefs*\)\n :SEE :FILE naf-mode-insertion-utils.el\n :SEE-ALSO `*naf-mode-xref-of-xrefs*'\n▶▶▶.") ;; (unless (bound-and-true-p *naf-mode-insertion-utils-xrefs*) (setq *naf-mode-insertion-utils-xrefs* '(naf-tab-region naf-comment-line naf-uncomment-line naf-comment-region naf-uncomment-region non-posting-source non-posting-wiki-source non-posting-ebay-source non-posting-philsp-source non-posting-imdb-source non-posting-benezit-source non-posting-internet-source mon-insert-naf-file-in-dirs mon-build-naf-mode-xref mon-insert-naf-mode-xref-template mon-insert-naf-mode-var-const-templ mon-insert-naf-mode-constant-template mon-insert-naf-mode-face-template mon-insert-naf-mode-faces-as-displayed *naf-mode-faces-as-displayed* *naf-mode-insertion-utils-xrefs*))) ;; ;;; :TEST-ME (symbol-value '*naf-mode-insertion-utils-xrefs*) ;;; :TEST-ME (nth 3 *naf-mode-insertion-utils-xrefs*) ;; ;;;(progn (makunbound '*naf-mode-insertion-utils-xrefs*) ;;; (unintern '*naf-mode-insertion-utils-xrefs*) ) ;;; ============================== (defun naf-tab-region (beg end &optional arg) "Indent region by one tab in a `naf-mode' buffer.\n :SEE-ALSO \n▶▶▶" (interactive "r\nP") (indent-rigidly beg end tab-width) (exchange-point-and-mark)) ;;; ======================= (defun naf-comment-line () "Comment line in a NAF file.\n :USED-IN `naf-mode'.\n :SEE-ALSO `naf-uncomment-line', `*naf-comment-prefix*', `naf-uncomment-region', `naf-comment-region'.\n▶▶▶" (interactive) (save-excursion (back-to-indentation) (insert *naf-comment-prefix*))) ;;; ======================= (defun naf-uncomment-line () "Uncomment line in a NAF file.\n :USED-IN `naf-mode'.\n :SEE-ALSO `*naf-comment-prefix*',`naf-uncomment-line', `naf-uncomment-region', `naf-comment-region'.\n▶▶▶" (interactive) (save-excursion (back-to-indentation) (while (eq (char-after) 59) (delete-char 1)))) ;;; ======================= (defun naf-comment-region (beg end &optional arg) "Comment out region in a NAF file.\n :USED-IN `naf-mode'.\n :SEE-ALSO `*naf-comment-prefix*', `naf-uncomment-region',`naf-comment-line', `naf-uncomment-line'.\n▶▶▶" (interactive "r\nP") (let ((comment-start *naf-comment-prefix*)) (comment-region beg end arg))) ;;; ======================= (defun naf-uncomment-region (beg end &optional arg) "Uncomment region in a NAF file.\n :USED-IN `naf-mode'.\n :SEE-ALSO `*naf-comment-prefix*', `naf-comment-region', `naf-comment-line', `naf-uncomment-line'.\n▶▶▶" (interactive "r\nP") (let ((comment-start *naf-comment-prefix*)) (comment-region beg end -1))) ;;; ============================== ;;; :MODIFICATIONS (defun non-posting-source (&optional insrtp intrp) "Return vanilla non-posting-source flag.\n When INSRTP is non-nil or called-interactively insert w/ newline after :(colon).\n :EXAMPLE\n\n\(non-posting-source\)\n :ALIASED-BY `nps'\n :USED-IN `naf-mode'.\n :SEE-ALSO `nps', `non-posting-internet-source', `non-posting-wiki-source', `non-posting-ebay-source', `non-posting-imdb-source', `non-posting-philsp-source', `non-posting-benezit-source', `benezit-naf-template'.\n▶▶▶" (interactive "i\np") (mon-naf-mode-toggle-restore-llm nil (let ((non-ps (format "\n-\nnon-posting-source:\n"))) (if (or insrtp intrp) (save-excursion (insert non-ps)) non-ps)))) ;; ;; :NOTE This defalias is probably better as an abrev. (defalias 'nps 'non-posting-source) ;; ;;; :TEST-ME (non-posting-source) ;;; :TEST-ME (non-posting-source t) ;;; :TEST-ME (call-interactively 'non-posting-source) ;;; ======================= ;;; :MODIFICATIONS ;;; :MODIFICATIONS ;;; :CREATED (defun non-posting-ebay-source (&optional insrtp intrp) "Return a non-posting ebay stamp.\n When INSRTP is non-nil or called-interactively insert return value at point. Does not move point.\n :EXAMPLE\n(non-posting-ebay-source)\n :ALIASED-BY `npes'\n :USED-IN `naf-mode'.\n :SEE-ALSO `non-posting-source', `non-posting-internet-source', `non-posting-wiki-source', `non-posting-imdb-source', `non-posting-philsp-source', `non-posting-benezit-source', `benezit-naf-template'.\n▶▶▶" (interactive "i\np") (mon-naf-mode-toggle-restore-llm nil (let ((non-pes (mapconcat #'identity `("-" "non-posting-ebay-source:" "ebay-item-number: " "ebay-item-seller: " "ebay-item-realized: " "ebay-item-ended: " ,(mon-accessed-stamp) "---") "\n"))) (if (or insrtp intrp) (save-excursion (insert non-pes)) non-pes)))) ;; ;; This defalias is probably better as an abbrev. (defalias 'npes 'non-posting-ebay-source) ;; ;;; :TEST-ME (non-posting-ebay-source) ;;; :TEST-ME (non-posting-ebay-source t) ;;; :TEST-ME (call-interactively 'non-posting-ebay-source) ;;; ============================== ;;; :MODIFICATIONS (defun non-posting-wiki-source (&optional insrtp intrp) "Return a non-posting Wikipedia source timestamp.\n When INSRTP is non-nil or called-interactively insert return value at point. Does not move point.\n :EXAMPLE\n\n(non-posting-wiki-source)\n :ALIASED-BY `npws'\n :USED-IN `naf-mode'.\n :SEE-ALSO `non-posting-source', `non-posting-internet-source', `non-posting-ebay-source', `non-posting-imdb-source', `non-posting-philsp-source', `non-posting-benezit-source', `non-posting-philsp-source', `benezit-naf-template'.\n▶▶▶" (interactive "i\np") (mon-naf-mode-toggle-restore-llm nil (let ((non-pws (mapconcat #'identity `("-" "non-posting-wiki-source:" ,(mon-accessed-stamp)) "\n"))) (if (or insrtp intrp) (save-excursion (insert non-pws)) non-pws)))) ;; ;;; :NOTE This defalias is probably better as an abbrev. (defalias 'npws 'non-posting-wiki-src) ;; ;;; :TEST-ME (non-posting-wiki-source) ;;; :TEST-ME (non-posting-wiki-source t) ;;; :TEST-ME (call-interactively 'non-posting-wiki-source) ;;; ============================== ;;; :WAS `npps' ;;; :MODIFICATIONS (defun non-posting-philsp-source (&optional insrtp intrp) "Return a philsp non-posting-source timestamp.\n When INSRTP is non-nil or called-interactively insert return value at point. Does not move point.\n :EXAMPLE\n\n(non-posting-philsp-source\)\n :DEPRECATED Should only be invoked after manual cleansing. :USE `mon-cln-philsp' which both replaces and stamps.\n :ALIASED-BY `npps'\n :USED-IN `naf-mode'.\n :SEE-ALSO `non-posting-source', `non-posting-wiki-source', `non-posting-internet-source', `non-posting-ebay-source', `non-posting-benezit-source', `benezit-naf-template' , `non-posting-imdb-source'.\n▶▶▶" (interactive "i\np") (mon-naf-mode-toggle-restore-llm nil (let ((non-pps (mapconcat #'identity `("-" "non-posting-philsp-source:" "(URL `http://www.philsp.com/homeville/FMI/a7.htm')" ,(mon-accessed-stamp) "---") "\n"))) (if (or insrtp intrp) (save-excursion (insert non-pps)) non-pps)))) ;; ;; :NOTE This defalias is probably better as an abbrev. (defalias 'npps 'non-posting-philsp-source) ;; ;;; :TEST-ME (non-posting-philsp-source) ;;; :TEST-ME (non-posting-philsp-source t) ;;; :TEST-ME (call-interactively 'non-posting-philsp-source) ;;(non-posting-imdb-source t) ;;; ============================== ;;; :CREATED (defun non-posting-imdb-source (&optional insrtp intrp) "Return an IMDB non-posting-source timestamp.\n When INSRTP is non-nil or called-interactively insert return value at point. Does not move point.\n Return value has the form: \"- non-posting-imdb-source: (URL `http://www.IMDB.com') accessed: #{YYYY-MM-DDTHH:MM:SS-NN:NNZ}#{10275} - \" :EXAMPLE\n\n\(non-posting-imdb-source\)\n :SEE-ALSO `non-posting-source', `non-posting-wiki-source', `non-posting-internet-source', `non-posting-ebay-source', `non-posting-benezit-source', `benezit-naf-template' `non-posting-philsp-source'.\n:USED-IN `naf-mode'.\n▶▶▶" (interactive "i\np") (mon-naf-mode-toggle-restore-llm nil (let ((npis (mapconcat #'identity `("" ;; preceding newline "-" "non-posting-imdb-source:" "(URL `http://www.IMDB.com')" ,(mon-accessed-stamp)) "\n"))) (if (or insrtp intrp) (save-excursion (insert npis)) npis)))) ;; ;;; :TEST-ME (non-posting-imdb-source) ;;; :TEST-ME (non-posting-imdb-source t) ;;; :TEST-ME (call-interactively 'non-posting-imdb-source) ;;; ============================== ;;; :MODIFICATIONS ;;; :CREATED (defun non-posting-benezit-source (benezit-name volume page &optional insrtp intrp) "Return Benezit non-posting-source timestamp with VOLUME and PAGE details.\n VOLUME is a Benezit volume PAGE is a page reference therein.\n When called-interactively prompt for VOLUME and PAGE.\n When INSRTP is non-nil or called-interactively insert return value at point. Does not move point.\n :EXAMPLE\n\n\(non-posting-benezit-source \"Cappiello, Leonetto\" 3 444\)\n \(non-posting-benezit-source \"Cappiello, Leonetto\" \"3\" \"444\"\)\n :SEE-ALSO `non-posting-source', `non-posting-wiki-source', `non-posting-internet-source', `non-posting-ebay-source', `non-posting-imdb-source', `benezit-naf-template'. :USED-IN `naf-mode'.\n▶▶▶" (interactive "sArtist Name (Lastname, Firstname):\nnVolume number:\nnPage number: \ni\np") (mon-naf-mode-toggle-restore-llm nil (let ((non-pbs (mapconcat #'identity `("" ;; preceding newline "-" "non-posting-benezit-source:" ,(concat benezit-name " - Benezit: Volume " (if (numberp volume) (number-to-string volume) volume) " page" (cond ((numberp page) (concat " " (number-to-string page))) ((not (eq (string-to-char (%mon-edmacro-subseq page 0 1)) 32)) (concat " " page)))) ,(mon-accessed-stamp) "-") "\n"))) (if (or insrtp intrp) (save-excursion (insert non-pbs)) non-pbs)))) ;; ;;; :TEST-ME (non-posting-benezit-source "Cappiello, Leonetto" 3 444) ;;; :TEST-ME (non-posting-benezit-source "Cappiello, Leonetto" "3" "444") ;;; :TEST-ME (non-posting-benezit-source "Cappiello, Leonetto" "3" "444" t) ;;; :TEST-ME (call-interactively 'non-posting-benezit-source) ;;; ============================== ;;; :MODIFICATIONS ;;; :CREATED (defun non-posting-internet-source (&optional non-posting-url insrtp intrp) "Return a timestamped Emacs style URL reference.\n Called interactively prompts for a URL name to wrap. When NON-POSTING-URL is non-nil wraps URL name. When INSRTP is non-nil or when called interactively inserts the wrapped url. When NON-POSTING-URL is nil defaults to \"(URL `')\".\n When INSRTP is non-nil or called-interactively insert return value at point. Does not move point.\n :EXAMPLE\n\(non-posting-internet-source \"http://www.emacswiki.com\")\n \(non-posting-internet-source)\n :SEE-ALSO `non-posting-source', `non-posting-wiki-source', `non-posting-imdb-source', `non-posting-benezit-source', `non-posting-ebay-source', `benezit-naf-template'.\n :USED-IN `naf-mode'.\n▶▶▶" (interactive "sURL:\ni\np") (mon-naf-mode-toggle-restore-llm nil (let ((non-pis (mapconcat #'identity `("" "-" "non-posting-internet-source:" ;; If conditional evaluates to nil assume that a URL is ;; an http prefixed resource, as this is expected by ;; `naf-mode-url-flag' and `naf-mode-url-wrapper-flag'. ,(cond (intrp (concat "(URL `" non-posting-url "')")) (insrtp (if non-posting-url (concat "(URL `" non-posting-url "')") "(URL `http:// { ... INSERT-URL-HERE ... } ')")) ((and non-posting-url (not insrtp) (not intrp)) (concat "(URL `" non-posting-url "')")) (t "(URL `http:// { ... INSERT-URL-HERE ... } ')")) ,(mon-accessed-stamp)) "\n"))) (if (or insrtp intrp) (save-excursion (insert non-pis)) non-pis)))) ;; ;;; :TEST-ME (non-posting-internet-source) ;;; :TEST-ME (non-posting-internet-source nil t) ;;; :TEST-ME (non-posting-internet-source "http://www.derbycityprints.com") ;;; :TEST-ME (non-posting-internet-source "http://www.derbycityprints.com" t) ;;; :TEST-ME (call-interactively 'non-posting-internet-source) ;;; ============================== ;;; :TODO Add optional STARTING-DIR arg to default-dir and possibly an alt. ;;; conditional insertion routine of file's text e.g. artist-naf, brand-naf, etc. ;;; :CREATED ;;; ============================== (defun mon-insert-naf-file-in-dirs (make-dir-list) ;&optional starting-dir "Each element in list MAKE-DIR-LIST inserts a directory and a file in directory. Directory's name and file's name are taken from elt in MAKE-DIR-LIST. Directory is created relative to current buffer's DEFAULT-DIRECTORY. File's contents are automatically inserted as:\n ;; -*- mode: NAF; -*-\n naf-name {a MAKE-DIR-LIST elt}\n ---\n ;;; naf EOF\n Format of list for MAKE-DIR-LIST should be as follows:\n \(setq make-my-dirs '(\"Lastname (Firstname Middlename Other)\" \"Lastname2 (Firstname2 Middlename2 Other2)\" \"Lastname3 (Firstname3 Middlename3 Other3)\" \"Lastname4 (Firstname4 Middlename4 Other4)\"))\n Invokation for creating dirname/filename. Assuming buffer's default directory is \"/home/my-dirs\" Invoking the form with symbol list 'make-my-dirs' as argument to MAKE-DIR-LIST:\n \(mon-insert-naf-file-in-dirs make-my-dirs)\n Or, interactively; M-x mon-insert-naf-file-in-dirs minibuffer-prompt: Give Symbol holind dir/file list :make-my-dirs\n Creates the following directorys and files in /home/my-dirs\n /home/my-dirs: |-- Lastname (Firstname Middlename Other) | `-- Lastname, Firstname Middlename Other.naf |-- Lastname2 (Firstname2 Middlename2 Other2) | `-- Lastname2, Firstname2 Middlename2 Other2.naf |-- Lastname3 (Firstname3 Middlename3 Other3) | `-- Lastname3, Firstname3 Middlename3 Other3.naf `-- Lastname4 (Firstname4 Middlename4 Other4) `-- Lastname4, Firstname4 Middlename4 Other4.naf\n▶▶▶" (interactive "XGive Symbol holind dir/file list :") (while make-dir-list (let* ((file-dir make-dir-list) (current-file (car make-dir-list)) (clean-it) (naf-name)) (setq clean-it current-file) (when (string-match " \(" clean-it) (setq clean-it (replace-match ", " nil nil clean-it))) (when (string-match ")" clean-it) (setq clean-it (replace-match "" nil nil clean-it))) ;;(while (string-match "\\^" clean-it) ;(replace-match ":" nil nil clean-it))) (setq naf-name clean-it) (make-directory current-file) (with-temp-file (concat default-directory current-file "/" clean-it ".naf") (insert (format ";; -*- mode: NAF; -*-\n\n%s\n---\n;;; naf EOF" naf-name)))) (pop make-dir-list))) ;;; ============================== ;;; :CREATED (defun mon-insert-naf-mode-class-template (&optional class-sfx slot-count insrtp intrp) "Return an eieio `defclass' template for use with `naf-mode'.\n When non-nil CLASS-SFX is a suffix to concatenate onto `naf-mode-'. Default is 'naf-mode-'. SLOT-COUNT is the number of slot templates returned. When INSRTP in non-nil or called-interactively insert template at point. Does not move point.\n\n:EXAMPLE\n\(mon-insert-naf-mode-class-template\)\n :SEE-ALSO `mon-insert-defclass-template', `mon-help-eieio-defclass'.\n▶▶▶" (interactive "P\ni\ni\np") (mon-insert-defclass-template (if class-sfx (cond (intrp (concat "naf-mode-" (read-string (concat ":FUNCTION `mon-insert-naf-mode-class-template'" "-- class-suffix to concatenate onto `naf-mode-': ")))) (t (concat "naf-mode-" (format "%s" class-sfx)))) "naf-mode-") slot-count insrtp intrp)) ;; ;;; :TEST-ME (mon-insert-naf-mode-class-template) ;;; :TEST-ME (mon-insert-naf-mode-class-template nil nil t) ;;; :TEST-ME (mon-insert-naf-mode-class-template "bubba" 3) ;;; :TEST-ME (mon-insert-naf-mode-class-template "bubba" 3 t) ;;; :TEST-ME (mon-insert-naf-mode-class-template "bubba" nil t) ;;; ============================== ;;; :CREATED (defun mon-build-naf-mode-xref () "Return a list suitable for naf-mode variable xref template creation.\n variable name is generated from current naf-mode filename. Signals an error if filename is void or not a filename with 'naf-mode-' prefix. Elements of list are returned as three strings:\n \(\"*naf-mode-insertion-utils-xrefs*\" ; <- :XREF-NAME \"naf-mode-insertion-utils\" ; <- :PKG-NAME \"naf-mode-insertion-utils.el\"\) ; <- :FILENAME\n :EXAMPLE\n\n\(let \(\(buffer-file-name \"naf-mode-xref-example.el\"\)\) \(mon-build-naf-mode-xref\)\)\n :CALLED-BY `mon-insert-naf-mode-xref-template' :CALLED-BY `mon-insert-naf-mode-var-const-template' :SEE-ALSO .\n▶▶▶" (if (buffer-file-name) (let* ((nm-match-str (file-name-nondirectory (file-name-sans-extension (buffer-file-name)))) (nm-match-on (string-match "naf-mode-" nm-match-str)) (the-nm-matched (if nm-match-on (match-string nm-match-on nm-match-str))) to-next-let) (when the-nm-matched (setq to-next-let `(,nm-match-str . ,(cadr (save-match-data (split-string nm-match-str the-nm-matched)))))) (let* ((xref-p (if to-next-let ;; (mon-build-naf-mode-xref) to-next-let ;; (mon-build-naf-mode-xref) (error (concat ":FUNCTION `mon-build-naf-mode-xref' " "-- not a naf-mode-file")))) (xref-fname (if xref-p (concat (car xref-p) ".el"))) (xref-pkg (if xref-p (car xref-p))) (xref-var (if xref-p (concat "*naf-mode-" (cdr xref-p) "-xrefs*"))) );; (test-xref-no-bnd (read xref-concat))) `(,xref-var ,xref-pkg ,xref-fname))) (error (concat ":FUNCTION `mon-build-naf-mode-xref' " "-- not a naf-mode-file")))) ;; ;;; :TEST-ME (mon-build-naf-mode-xref) ;;; :TEST-ME (let ((buffer-file-name "naf-mode-xref-example.el")) ;;; (mon-build-naf-mode-xref)) ;;; ============================== ;;; :CREATED (defun mon-insert-naf-mode-xref-template (&optional insrtp intrp) "Return a naf-mode variable template for xrefing variable names in current `naf-mode' file.\n When INSRTP is non-nil or called-interactively insert xref template at point. Does not move point.\n :EXAMPLE\n\n\(let \(\(buffer-file-name \"naf-mode-dir/naf-mode-xref-example.el\"\)\) \(mon-insert-naf-mode-xref-template\)\)\n :SEE-ALSO `mon-build-naf-mode-xref', `mon-insert-naf-mode-xref-template'.\n▶▶▶" (interactive "i\np") (let* ((xref-l (mon-build-naf-mode-xref)) (xref-sym (car xref-l)) (pkg-nm (cadr xref-l)) (fnm (caddr xref-l)) (xref-template (concat ";; Make sure we're using CL's `eval-when'\n" "(eval-when-compile (require 'cl))\n\n" (mon-lisp-stamp) "\n(eval-and-compile\n" "(defvar " xref-sym "\n" " '(" xref-sym "\n" " mon-help-naf-mode-faces)\n" " \"*List of symbol names of variables which xref each other in the\n" "`" pkg-nm"' package.\n:SEE :FILE " fnm "\"" "))\n" ";;\n;;; :TEST-ME " xref-sym "\n;;\n;;;(progn (makunbound '" xref-sym ")\n" ";;; (unintern '" xref-sym ") \)"))) (if (or insrtp intrp) (save-excursion (newline) (princ xref-template (current-buffer))) xref-template))) ;; ;;; :TEST-ME (mon-insert-naf-mode-xref-template) ;;; :TEST-ME (mon-insert-naf-mode-xref-template t) ;;; ============================== ;;; :RENAMED `mon-insert-naf-mode-var-const-templt' -> `mon-insert-naf-mode-var-const-template' ;;; :TODO Add subr to search backward for xref-name to see if it already exists. ;;; :CREATED (defun mon-insert-naf-mode-var-const-template (naf-symbol-name &optional insrtp intrp) "Return code building template for variable and constant with NAF-SYMBOL-NAME.\n NAF-SYMBOL-NAME - a string - should be suitable for concatenation as: *naf-* ;VARIABLE\nnaf-mode- ;CONSTANT Do not include `-', `*', etc. This function does not check the value given. When INSRTP is non-nil or called-interactively insert templates at point. Does not move point.\n :SEE-ALSO `mon-build-naf-mode-xref', `mon-insert-naf-mode-xref-template'.\n▶▶▶" (interactive "sSymbol name for template do not prefix with -, *, etc. :\np") (let* ((v-name (concat "*naf-" naf-symbol-name "*")) (c-name (concat "naf-mode-" naf-symbol-name)) (xref-name (car (mon-build-naf-mode-xref))) (v-c-template (concat (mon-lisp-stamp) "\n(eval-and-compile\n" "(defvar " v-name "\n" " '(\n" " ;; \n" " )\n" " \"*Keyword list of for `naf-mode' font-locking.\"))\n" ";;\n" "(eval-and-compile\n" "(defconst " c-name "\n" " (regexp-opt " v-name " 'paren)))\n" ";;\n" "(eval-and-compile\n" " (mon-help-swap-var-doc-const-val\n" " " v-name " " c-name "\n" " " xref-name " )) ;; \n" ";;\n" ";;(progn (makunbound '" v-name ") (unintern '" v-name ")\n" ";; (makunbound '" c-name ") (unintern '" c-name ") \)"))) (if (or insrtp intrp) (save-excursion (newline) (princ v-c-template (current-buffer))) v-c-template))) ;; ;;; :TEST-ME (mon-insert-naf-mode-var-const-template "test-template") ;;; :TEST-ME (mon-insert-naf-mode-var-const-template "test-template" t) ;;; ============================== ;;; :DEPRECATED :USE `mon-insert-naf-mode-var-const-template' ;;; :MODIFICATIONS ;;; :CREATED (defun mon-insert-naf-mode-constant-template (&optional constant-name insrtp intrp) "Insert elisp template for defining new font-lock constants for `naf-mode'.\n :EXAMPLE\n\n(mon-insert-naf-mode-constant-template \"some-constant\")\n :SEE-ALSO `*naf-mode-faces-as-displayed*', `mon-insert-naf-mode-faces-as-displayed', `mon-insert-naf-mode-face-template'.\n▶▶▶" (interactive "sGive the value for * naf-mode-*-flags: \ni\np") (let* ((cnst (if constant-name constant-name "!CONSTANT!")) (lcl (replace-regexp-in-string " " "-" (concat "naf-" cnst "-flags"))) (con (replace-regexp-in-string " " "-" (concat "naf-mode-" cnst "-flags"))) (naf-lcl (replace-regexp-in-string "--" "-" lcl)) ; Match on trailing whitespace. (naf-con (replace-regexp-in-string "--" "-" con)) (put-temp (concat "\n" (mon-lisp-stamp)"\n" "\(let \(\(" naf-lcl "\n" " \(list \n" " \"make\" \"a\" \"list\" \"of\"\n" " \"double-quoted\" \"strings\" \"here\"\n" " \)\)\)\n;;\n" "\(defconst "naf-con" ;{Choice one of three}\n" ";;; (concat \"\\\\(\" (regexp-opt " naf-lcl" 'paren) \"\\\\(,?\\\\)\\\\)\") ;Packs into a list\n" ";;; (concat \"^\" (regexp-opt " naf-lcl" 'paren) ) ;Anchors at head of line\n" ";;; (concat \"\\\\<\" \(regexp-opt " naf-lcl " 'paren) \"\\\\>\"\) ;Empty string word boundaries\n" " \"Keywords for {describe " naf-lcl "}.\n" ":USED-IN `naf-mode' for font-locking with `NAF-MODE-*-FFACE'.\"\)\)\n\n" ";;; :TEST-ME " naf-con "\n\n" ";;(progn (makunbound \'" naf-con"\)\n" ";; (unintern \'" naf-con "\) \)\n" ;; (mon-comment-divider-w-len 30) ";;; =============================="))) (when (or insrtp intrp) (save-excursion (insert put-temp))) put-temp)) ;; ;;; :TEST-ME (mon-insert-naf-mode-constant-template "some-constant") ;;; :TEST-ME (mon-insert-naf-mode-constant-template "some-constant" t) ;;; :TEST-ME (mon-insert-naf-mode-constant-template nil) ;;; :TEST-ME (mon-insert-naf-mode-constant-template nil t) ;;; :TEST-ME (call-interactively 'mon-insert-naf-mode-constant-template) ;;; ============================== (defun mon-insert-naf-mode-face-template (&optional face-name insrtp intrp) "Insert Elisp template for new face definitions and constants.\n Use to make face templates for fontlocking `naf-mode' keywords.\n :EXAMPLE\n\(mon-insert-naf-mode-face-template \"some-face-name\") :SEE-ALSO `*naf-mode-faces-as-displayed*',`mon-insert-naf-mode-faces-as-displayed' `mon-insert-naf-mode-constant-template'.\n▶▶▶" (interactive "sGive the value for * in naf-mode-*-face: \ni\np") (let* ((fc-nme (if face-name face-name "!FACE-NAME!")) (the-face (concat "naf-mode-" fc-nme "-face")) (the-fface (concat "naf-mode-" fc-nme "-fface")) (put-fc-temp (concat "\n" (mon-lisp-stamp) "\n" "\(defface " the-face "\n" " '(;;\(t \(:inherit naf-mode-*-face\)\)\)\n" " ;;OR:\n" " ;;\(\(\(class color\) \(background light\)\) \(:foreground \"SOME-COLOR\"\)\)\n" " ;; \(\(\(class color\) \(background dark\)\) \(:foreground \"SOME-COLOR\"\)\)\n" " ;; \(t \(:bold t :italic t\)\)\)\n" " \"*Face for font-locking of {DESCRIBE} in .naf files.\n" ":KEYWORD-REGEXPS-IN\n" ":KEYWORD-LISTS-IN\n" ":FACE-DOCUMENTED-IN `" the-fface"'.\n:SEE-ALSO\n:USED-IN `naf-mode'.\"\n" " :group \'naf-mode\n" " :group \'naf-mode-faces\)\n;;\n" "(defvar " the-fface " '" the-face "\n" " \"*Face for font-locking of {DESCRIBE} in `naf-mode'.\n" ":KEYWORD-REGEXPS-IN\n" ":KEYWORD-LISTS-IN\n" ":FACE-DEFINED-IN `" the-face "'.\n:SEE-ALSO\n.\")\n\n" ";;; :TEST-ME (describe-face '" the-face ")\n\n" ";;(progn (makunbound \'" the-face "\)\n" ";; (makunbound \'" the-fface"\)\n" ";; (unintern \'" the-face "\)\n" ";; (unintern \'" the-fface "\) \)\n\n" ;; (mon-comment-divider-w-len 30) ";;; =============================="))) (when (or insrtp intrp) (save-excursion (insert put-fc-temp))) put-fc-temp)) ;; ;;; :TEST-ME (mon-insert-naf-mode-face-template "some-face-name" t) ;;; :TEST-ME (mon-insert-naf-mode-face-template nil t) ;;; :TEST-ME (call-interactively 'mon-insert-naf-mode-face-template) ;;; :TEST-ME (mon-insert-naf-mode-face-template "some-face-name") ;;; ============================== ;;; :MODIFICATIONS ;;; :MODIFICATIONS (defun mon-insert-naf-mode-faces-as-displayed (&optional insrtp intrp) "Insert font-locked keywords to test fruitsaladness `naf-mode' face/constants.\n :SEE-ALSO `*naf-mode-faces-as-displayed*',`mon-insert-naf-mode-face-template', `mon-insert-naf-mode-constant-template'.\n▶▶▶" (interactive "i\np") (let ((i-fad (mapconcat #'identity *naf-mode-faces-as-displayed* "\n"))) (if (or insrtp intrp) (mon-naf-mode-toggle-restore-llm nil (save-excursion (insert i-fad))) i-fad))) ;; ;;; :TEST-ME (mon-insert-naf-mode-faces-as-displayed) ;;; :TEST-ME (mon-insert-naf-mode-faces-as-displayed t) ;;; :TEST-ME (call-interactively 'mon-insert-naf-mode-faces-as-displayed) ;;; ============================== ;;; :CREATED (defvar *naf-mode-faces-as-displayed* '(";;; ==============================" "---" ":NAF-MODE-FACE `naf-mode-field-face-db-entry'" "FRBNF14942139 " "---" ":NAF-MODE-FACE `naf-mode-field-face'" "Uploaded-by: " "---" ":NAF-MODE-FACE `naf-mode-db-entry-face'" "Artist-naf: " "---" ":NAF-MODE-FACE `naf-mode-group-period-style-face'" "Bauhaus " "---" ":NAF-MODE-FACE `naf-mode-event-face'" "Salon de " "---" ":NAF-MODE-FACE `naf-mode-institution-face'" "Royal Academy " "---" ":NAF-MODE-FACE `naf-mode-nationality-face'" "français " "---" ":NAF-MODE-FACE `naf-mode-name-divider-face'" "Lastname, Firstname | Fname Lname | F. Lname " "---" ":NAF-MODE-FACE `naf-mode-delim-face'" "---" "\n---" ":NAF-MODE-FACE " "Washington ;`naf-mode-place-face'" "---" ":NAF-MODE-FACE `naf-mode-date-face'" "\(1885-1940\)" "---" ":NAF-MODE-FACE `naf-mode-secondary-role-face'" "affichiste " "---" ":NAF-MODE-FACE `naf-mode-primary-role-face'" "Auteur " "---" ":NAF-MODE-FACE `naf-mode-art-keywords-role-face'" "illustrations " "---" ":NAF-MODE-FACE `naf-mode-benezit-face'" "VENTES PUBLIQUES :" "---" ":NAF-MODE-FACE `naf-mode-alternate-name-face'" "Portrait de " "---" ":NAF-MODE-FACE `naf-mode-publication-periodical-face'" "Berliner Illustrierte " "---" ":NAF-MODE-FACE `naf-mode-awards-prizes-face'" "Design Centre Awards Scheme " "---" ":NAF-MODE-FACE `naf-mode-timestamp-face'" "" "accessed: #{2009-09-01T16:31:39-04:00Z}#{09362} - MON KEY" "(URL `http://catalog.loc.gov/')" "(URL `http://authorities.loc.gov/')" "(URL `http://catalogue.bnf.fr/ark:/12148/cb123349648/PUBLIC')" "accessed:" "" "---" ":NAF-MODE-VARIABLE `naf-mode-field-names'" ":NAF-MODE-FACE `naf-mode-db-entry-face'" "---" "" ";; -\*- mode: NAF; -\*-" "BNF:" "DNB:" "LOC:" "LOC-P&P:" "ULAN:" "OCLC:" "OTHER-DB:" "COPAC:" "Bios:" "Artist-naf:" "Artist-doc:" "Book-naf:" "Book-doc:" "People-naf:" "People-doc:" "Author-naf:" "Author-doc:" "Brand-naf:" "Brand-doc:" "non-posting-source:" "non-posting-wiki-source:" "non-posting-ebay-source:" "non-posting-philsp-source:" "non-posting-imdb-source:" "non-posting-internet-source:" "non-posting-benezit-source:" "references:" "source:" "Source:" ";;; brand-naf EOF" ";;; artist-naf EOF" ";;; people-naf EOF" ";;; book-naf EOF" ";;; author-naf EOF" ";;; item-naf EOF" "" "---" ":NAF-MODE-VARIABLE `naf-mode-db-entry'" ":NAF-MODE-FACE `naf-mode-db-field-face'" "---" "" "Abbreviated Title:" "Accession No:" "Author(s):" "CALL NUMBER:" "CONTROL #:" "CREATED/PUBLISHED:" "CREATOR:" "Class Descriptors:" "Content-and-subjects:" "Continues:" "Corporate Name:" "Current Frequency:" "DIGITAL ID:" "Database:" "Description:" "Descriptor:" "Dewey Class No.:" "Display-name:" "Display-title:" "Document Type:" "Edition Information:" "Entry:" "FORMAT:" "Found In:" "Frequency:" "Genre/Form:" "Genre:" "Geographic Area Code:" "HEADING:" "Heading:" "ISSN:" "Identifier:" "Language:" "Location-country:" "" "---" ":NAF-MODE-FIELDS-MEDIUM" "---" "" "Main Title:" "Main author:" "Material Type:" "Movie-posters:" "NOTES:" "Named Person:" "Note(s):" "Note:" "Notes:" "Number-of-illustrations:" "Number-of-pages:" "Number-of-volumes:" "Other Edition Available:" "Other System No.:" "Other Titles:" "Other names:" "Other-roles:" "Personal Name:" "Physical desc\.:" "Preceding Title:" "Publication :" "Publication Dates:" "Publication:" "Published-by:" "Published/Created:" "Publisher Location:" "Quality Code:" "REPOSITORY:" "REPRODUCTION NUMBER:" "RIGHTS INFORMATION:" "Relevance:" "Repository:" "Reproduction No./Source:" "Responsibility:" "SUBJECTS:" "SUMMARY:" "Scope Note:" "Search Also Under:" "Series Title:" "Special Note:" "Special-notes:" "Standard No:" "Subjects:" "Succeeding Title:" "Summary:" "" "---" ":NAF-MODE-FIELDS-TITLE" "---" "" "Title details:" "Title:" "Type :" "Type of Material:" "Uniform Title:" "Update:" "Used For/See From:" "Year:" "" "---" ":NAF-MODE-FIELDS-NAF" "---" "" "Ads-for: ; :NAF-FIELD" "Appeared-in: ; :NAF-FIELD" "Artists-associated: ; :NAF-FIELD" "Auction-records: ; :NAF-FIELD" "Authors-associated: ; :NAF-FIELD" "Book-notes: ; :NAF-FIELD" "Brand-name: ; :NAF-FIELD" "Contents: ; :NAF-FIELD" "Date-founded: ; :NAF-FIELD" "Founded-by: ; :NAF-FIELD" "Full-title: ; :NAF-FIELD" "Location-published: ; :NAF-FIELD" "Products-associated: ; :NAF-FIELD" "Publisher: ; :NAF-FIELD" "Slogans: ; :NAF-FIELD" "Uploaded-by: ; :NAF-FIELD" "Used-for: ; :NAF-FIELD" "ebay-item-ended: ; :NAF-FIELD" "ebay-item-number: ; :NAF-FIELD" "ebay-item-realized: ; :NAF-FIELD" "ebay-item-seller: ; :NAF-FIELD" "" "---" ":NAF-MODE-FIELDS-SHARED" "---" "" "Born: ; :NAF-FIELD :ULAN-FIELD" "Died: ; :NAF-FIELD :ULAN-FIELD" "Roles: ; :NAF-FIELD :ULAN-FIELD" "" "---" ":NAF-MODE-FIELDS-ULAN" "---" "" "Biographies: ; :ULAN-FIELD" "Birth and Death Places: ; :ULAN-FIELD" "Events: ; :ULAN-FIELD" "Gender: ; :ULAN-FIELD" "ID: ; :ULAN-FIELD" "List/Hierarchical Position: ; :ULAN-FIELD" "Names: ; :ULAN-FIELD" "Nationalities: ; :ULAN-FIELD" "Record Type: ; :ULAN-FIELD" "Related Names:" "Related People and Corporate Bodies: ; :ULAN-FIELD" "Related People or Corporate Bodies: ; :ULAN-FIELD" "Sources and Contributors: ; :ULAN-FIELD" "Subject: ; :ULAN-FIELD" "education: ; :ULAN-FIELD :TRL-WSPC" "" "---" ":NAF-MODE-FIELDS-LOC" "---" "" "Biographical/Historical Note: ; :LOC-FIELD" "LC Class Number: ; :LOC-FIELD" "LC Classification: ; :LOC-FIELD" "LC Control No. ; :LOC-FIELD" "LC Control Number: ; :LOC-FIELD" "LC Copy: ; :LOC-FIELD" "LCCN Permalink:" "" "---" ":NAF-MODE-VARIABLE `naf-mode-field-names-bnf'" ":NAF-MODE-FACE `naf-mode-field-bnf-face'" "---" "" " Indicates (abstractly) the type of keyword. :NOTE The indication is intendend as an indication that the type may subclass one or more parent fields.\n ;; :ULAN-FIELD Indicates that font-locking is for an Unified List of Artist Names catalog field.\n ;; :ULAN-FIELD-ENTRY Indicates font-locking is for an Unified List of Artist Names catalog entry.\n ;; :BNF-FIELD Indicates font-locking is for a Bibliothèque nationale de France catalog field.\n ;; :BNF-FIELD-ENTRY Indicates font-locking is for a Bibliothèque nationale de France catalog entry.\n ;; :LOC-FIELD Indicates that font-locking is for a Library of Congress catalog field.\n ;; :TRL-WSPC Indicates that font-locking is reliant on the presence of trailing whitespace. ;; :NAF-MODE-FACE Inidicates the primary face that controls font-locking for a keyword.\n ;; :NAF-MODE-VARIABLE Inidicates a variable which either holds a list of associated keywords or holds a regexp for font-locking a set of keywords.\n ;; :NAF-MODE-VARIABLE-DATE Indicates that that font-locking is for a date, time, or event related temporal occurence which may have significance w/re Name Authority.\n :NOTE Dates are fundamental to establishing and maintaining Name Authority. Abstractly naf-mode recognizes (or is capable of identifying) broadly scoped temporal entities and the \"VARIABLE\" token is used here to incicate that multiple lisp variables may factor w/re to date font-locking.\n ;; :NAF-MODE-VARIABLE-DATE-PREFIX Indicates that font-locking is for a certain prefixes which commonly preceed a naf-mode date, time, or event related occurence.\n ;; :NAF-MODE-CURRENCY Indicates that font-locking is for a currency value. Currently these are only guaranteed to recognize for currencies formatted as per Benezit auction historys though in many other currency values appearing outside of a Benezit field also will be font-locked.\n ;; :BENEZIT-FIELD Indicates that font-locking is for a Benezit field.\n :CALLED-BY `mon-insert-naf-mode-faces-as-displayed'. :SEE-ALSO `mon-insert-naf-mode-face-template', `mon-insert-naf-mode-constant-template'.\n▶▶▶") ;; ;;; :TEST-ME *naf-mode-faces-as-displayed* ;;;(progn (makunbound '*naf-mode-faces-as-displayed*) ;;; (unintern '*naf-mode-faces-as-displayed*) ) ;;; ============================== (provide 'naf-mode-insertion-utils) ;;; ============================== ;; Local Variables: ;; generated-autoload-file: "./mon-loaddefs.el" ;; coding: utf-8 ;; End: ;;; ================================================================ ;;; naf-mode-insertion-utils.el ends here ;;; EOF