1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536 |
- ;;; filesets.el --- handle group of files -*- coding: utf-8 -*-
- ;; Copyright (C) 2002-2015 Free Software Foundation, Inc.
- ;; Author: Thomas Link <sanobast-emacs@yahoo.de>
- ;; Maintainer: emacs-devel@gnu.org
- ;; Keywords: filesets convenience
- ;; This file is part of GNU Emacs.
- ;; GNU Emacs is free software: you can redistribute it and/or modify
- ;; it under the terms of the GNU General Public License as published by
- ;; the Free Software Foundation, either version 3 of the License, or
- ;; (at your option) any later version.
- ;; GNU Emacs is distributed in the hope that it will be useful,
- ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ;; GNU General Public License for more details.
- ;; You should have received a copy of the GNU General Public License
- ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
- ;;; Code:
- (defvar filesets-version "1.8.4")
- (defvar filesets-homepage
- "http://members.a1.net/t.link/CompEmacsFilesets.html")
- ;;; Commentary:
- ;; Define filesets, which can be opened or saved with the power of one or
- ;; two mouse clicks only. A fileset is either a list of files, a file
- ;; pattern, a base directory and a search pattern (for files), or an
- ;; inclusion group (i.e. a base file including other files).
- ;; Usage:
- ;; 1. Put (require 'filesets) and (filesets-init) in your init file.
- ;; 2. Type ;; M-x filesets-edit or choose "Edit Filesets" from the menu.
- ;; 3. Save your customizations.
- ;; Caveat: Fileset names have to be unique.
- ;; Filesets.el adds a nifty filesets menu to your menubar. If you change
- ;; your filesets on the fly, don't forget to select "Save Filesets" from
- ;; the menu.
- ;; Pressing on the first item in the submenu will open all files at once.
- ;; Define your own function, e.g. browse-url, for opening a fileset's
- ;; files. Or define external viewers for opening files with other
- ;; programs. See `filesets-external-viewers'.
- ;; BTW, if you close a fileset, files, which have been changed, will
- ;; be silently saved. Change this behavior by setting
- ;; `filesets-save-buffer-fn'.
- ;;; Supported modes for inclusion groups (`filesets-ingroup-patterns'):
- ;; - Elisp
- ;; - Emacs-Wiki (simple names only)
- ;; - LaTeX
- ;;; Known bugs:
- ;;; To do:
- ;;- better handling of different customization scenarios
- ;; Data gathering should be better separated from building the menu
- ;; so that one could (1) use filesets without installing the menu
- ;; and (2) create new "frontends" to speedbar and others.
- ;; The functionality to call external viewers should be isolated in
- ;; an extra package and possibly integrated with the MIME
- ;; handling.
- ;;; Credits:
- ;; Helpful suggestions (but no significant code) were contributed by
- ;;- Christoph Conrad (at gmx de)
- ;;- Christian Ohler (at Informatik Uni-Oldenburg DE)
- ;;- Richard Stallman aka RMS (at gnu org)
- ;;- Per Abrahamsen aka abraham (at dina kvl dk)
- ;;; Code:
- (eval-when-compile (require 'cl-lib))
- ;;; Some variables
- (defvar filesets-menu-cache nil
- "The whole filesets menu.")
- (defvar filesets-cache-version nil
- "Filesets' cached version number.")
- (defvar filesets-cache-hostname nil
- "Filesets' cached system name.")
- (defvar filesets-ingroup-cache nil
- "A plist containing files and their ingroup data.")
- (defvar filesets-ingroup-files nil
- "List of files already processed when searching for included files.")
- (defvar filesets-has-changed-flag t
- "Non-nil means some fileset definition has changed.")
- (defvar filesets-submenus nil
- "An association list with filesets menu data.")
- (defvar filesets-updated-buffers nil
- "A list of buffers with updated menu bars.")
- (defvar filesets-menu-use-cached-flag nil
- "Use cached data. See `filesets-menu-ensure-use-cached' for details.")
- (defvar filesets-update-cache-file-flag nil
- "Non-nil means the cache needs updating.")
- (defvar filesets-ignore-next-set-default nil
- "List of custom variables for which the next `set-default' will be ignored.")
- (defvar filesets-output-buffer-flag nil
- "Non-nil means the current buffer is an output buffer created by filesets.
- Is buffer local variable.")
- (defvar filesets-verbosity 1
- "An integer defining the level of verbosity.
- 0 means no messages at all.")
- (defvar filesets-menu-ensure-use-cached
- (and (featurep 'xemacs)
- (if (fboundp 'emacs-version>=)
- (not (emacs-version>= 21 5))))
- "Make sure (X)Emacs uses filesets' cache.
- Well, if you use XEmacs (prior to 21.5?) custom.el is loaded after
- init.el. This means that settings saved in the cache file (see
- `filesets-menu-cache-file') will be overwritten by custom.el. In order
- to ensure the use of the cache file, set this variable to t -- which is
- the default for XEmacs prior to 21.5. If you want to change this value
- put \"(setq filesets-menu-ensure-use-cached VALUE)\" into your startup
- file -- before loading filesets.el.
- So, when should you think about setting this value to t? If filesets.el
- is loaded before user customizations. Thus, if (require 'filesets)
- precedes the `custom-set-variables' command or, for XEmacs, if init.el
- is loaded before custom.el, set this variable to t.")
- ;;; utils
- (defun filesets-filter-list (lst cond-fn)
- "Remove all elements not conforming to COND-FN from list LST.
- COND-FN takes one argument: the current element."
- ; (cl-remove 'dummy lst :test (lambda (dummy elt)
- ; (not (funcall cond-fn elt)))))
- (let ((rv nil))
- (dolist (elt lst rv)
- (when (funcall cond-fn elt)
- (setq rv (append rv (list elt)))))))
- (defun filesets-ormap (fsom-pred lst)
- "Return the tail of LST for the head of which FSOM-PRED is non-nil."
- (let ((fsom-lst lst)
- (fsom-rv nil))
- (while (and (not (null fsom-lst))
- (null fsom-rv))
- (if (funcall fsom-pred (car fsom-lst))
- (setq fsom-rv fsom-lst)
- (setq fsom-lst (cdr fsom-lst))))
- fsom-rv))
- (defun filesets-some (fss-pred fss-lst)
- "Return non-nil if FSS-PRED is non-nil for any element of FSS-LST.
- Like `some', return the first value of FSS-PRED that is non-nil."
- (catch 'exit
- (dolist (fss-this fss-lst nil)
- (let ((fss-rv (funcall fss-pred fss-this)))
- (when fss-rv
- (throw 'exit fss-rv))))))
- ;(fset 'filesets-some 'cl-some) ;; or use the cl function
- (defun filesets-member (fsm-item fsm-lst &rest fsm-keys)
- "Find the first occurrence of FSM-ITEM in FSM-LST.
- It is supposed to work like cl's `member*'. At the moment only the :test
- key is supported."
- (let ((fsm-test (or (plist-get fsm-keys ':test)
- (function equal))))
- (filesets-ormap (lambda (fsm-this)
- (funcall fsm-test fsm-item fsm-this))
- fsm-lst)))
- ;(fset 'filesets-member 'cl-member) ;; or use the cl function
- (defun filesets-sublist (lst beg &optional end)
- "Get the sublist of LST from BEG to END - 1."
- (let ((rv nil)
- (i beg)
- (top (or end
- (length lst))))
- (while (< i top)
- (setq rv (append rv (list (nth i lst))))
- (setq i (+ i 1)))
- rv))
- (defun filesets-select-command (cmd-list)
- "Select one command from CMD-LIST -- a string with space separated names."
- (let ((this (shell-command-to-string
- (format "which --skip-alias %s 2> /dev/null | head -n 1"
- cmd-list))))
- (if (equal this "")
- nil
- (file-name-nondirectory (substring this 0 (- (length this) 1))))))
- (defun filesets-which-command (cmd)
- "Call \"which CMD\"."
- (shell-command-to-string (format "which %s" cmd)))
- (defun filesets-which-command-p (cmd)
- "Call \"which CMD\" and return non-nil if the command was found."
- (when (string-match-p (format "\\(/[^/]+\\)?/%s" cmd)
- (filesets-which-command cmd))
- cmd))
- (defun filesets-message (level &rest args)
- "Show a message only if LEVEL is greater or equal then `filesets-verbosity'."
- (when (<= level (abs filesets-verbosity))
- (apply 'message args)))
- ;;; config file
- (defun filesets-save-config ()
- "Save filesets' customizations."
- (interactive)
- (customize-save-customized))
- (defun filesets-reset-fileset (&optional fileset no-cache)
- "Reset the cached values for one or all filesets."
- (if fileset
- (setq filesets-submenus (lax-plist-put filesets-submenus fileset nil))
- (setq filesets-submenus nil))
- (setq filesets-has-changed-flag t)
- (setq filesets-update-cache-file-flag (or filesets-update-cache-file-flag
- (not no-cache))))
- (defun filesets-set-config (fileset var val)
- "Set-default wrapper function."
- (filesets-reset-fileset fileset)
- (set-default var val))
- ; (customize-set-variable var val))
- ; (filesets-build-menu))
- ;; It seems this is a workaround for the XEmacs issue described in the
- ;; doc-string of filesets-menu-ensure-use-cached. Under Emacs this is
- ;; essentially just `set-default'.
- (defun filesets-set-default (sym val &optional init-flag)
- "Set-default wrapper function used in conjunction with `defcustom'.
- If SYM is in the list `filesets-ignore-next-set-default', delete
- it from that list, and return nil. Otherwise, set the value of
- SYM to VAL and return t. If INIT-FLAG is non-nil, set with
- `custom-initialize-set', otherwise with `set-default'."
- (let ((ignore-flag (member sym filesets-ignore-next-set-default)))
- (if ignore-flag
- (setq filesets-ignore-next-set-default
- (delete sym filesets-ignore-next-set-default))
- (if init-flag
- (custom-initialize-set sym val)
- (set-default sym val)))
- (not ignore-flag)))
- (defun filesets-set-default! (sym val)
- "Call `filesets-set-default' and reset cached data (i.e. rebuild menu)."
- (when (filesets-set-default sym val)
- (filesets-reset-fileset)))
- (defun filesets-set-default+ (sym val)
- "Call `filesets-set-default' and reset filesets' standard menu."
- (when (filesets-set-default sym val)
- (setq filesets-has-changed-flag t)))
- ; (filesets-reset-fileset nil t)))
- (defvar filesets-data)
- (defun filesets-data-set-default (sym val)
- "Set the default for `filesets-data'."
- (if filesets-menu-use-cached-flag
- (setq filesets-menu-use-cached-flag nil)
- (when (default-boundp 'filesets-data)
- (let ((modified-filesets
- (filesets-filter-list val
- (lambda (x)
- (let ((name (car x))
- (data (cdr x)))
- (let ((elt (assoc name filesets-data)))
- (or (not elt)
- (not (equal data (cdr elt))))))))))
- (dolist (x modified-filesets)
- (filesets-reset-fileset (car x))))))
- (filesets-set-default sym val))
- ;;; configuration
- (defgroup filesets nil
- "The fileset swapper."
- :prefix "filesets-"
- :group 'convenience
- :version "22.1")
- (defcustom filesets-menu-name "Filesets"
- "Filesets' menu name."
- :set (function filesets-set-default)
- :type 'string
- :group 'filesets)
- (defcustom filesets-menu-path '("File") ; cf recentf-menu-path
- "The menu under which the filesets menu should be inserted.
- See `add-submenu' for documentation."
- :set (function filesets-set-default)
- :type '(choice (const :tag "Top Level" nil)
- (sexp :tag "Menu Path"))
- :version "23.1" ; was nil
- :group 'filesets)
- (defcustom filesets-menu-before "Open File..." ; cf recentf-menu-before
- "The name of a menu before which this menu should be added.
- See `add-submenu' for documentation."
- :set (function filesets-set-default)
- :type '(choice (string :tag "Name")
- (const :tag "Last" nil))
- :version "23.1" ; was "File"
- :group 'filesets)
- (defcustom filesets-menu-in-menu nil
- "Use that instead of `current-menubar' as the menu to change.
- See `add-submenu' for documentation."
- :set (function filesets-set-default)
- :type 'sexp
- :group 'filesets)
- (defcustom filesets-menu-shortcuts-flag t
- "Non-nil means to prepend menus with hopefully unique shortcuts."
- :set (function filesets-set-default!)
- :type 'boolean
- :group 'filesets)
- (defcustom filesets-menu-shortcuts-marker "%_"
- "String for marking menu shortcuts."
- :set (function filesets-set-default!)
- :type 'string
- :group 'filesets)
- ;;(defcustom filesets-menu-cnvfp-flag nil
- ;; "Non-nil means show \"Convert :pattern to :files\" entry for :pattern menus."
- ;; :set (function filesets-set-default!)
- ;; :type 'boolean
- ;; :group 'filesets)
- (defcustom filesets-menu-cache-file
- (locate-user-emacs-file "filesets-cache.el")
- "File to be used for saving the filesets menu between sessions.
- Set this to \"\", to disable caching of menus.
- Don't forget to check out `filesets-menu-ensure-use-cached'."
- :set (function filesets-set-default)
- :type 'file
- :group 'filesets)
- (put 'filesets-menu-cache-file 'risky-local-variable t)
- (defcustom filesets-menu-cache-contents
- '(filesets-be-docile-flag
- filesets-submenus
- filesets-menu-cache
- filesets-ingroup-cache)
- "Stuff we want to save in `filesets-menu-cache-file'.
- Possible uses: don't save configuration data in the main startup files
- but in filesets's own cache. In this case add `filesets-data' to this
- list.
- There is a second reason for putting `filesets-data' on this list. If
- you frequently add and remove buffers on the fly to :files filesets, you
- don't need to save your customizations if `filesets-data' is being
- mirrored in the cache file. In this case the version in the cache file
- is the current one, and the version in your startup file will be
- silently updated later on.
- If you want caching to work properly, at least `filesets-submenus',
- `filesets-menu-cache', and `filesets-ingroup-cache' should be in this
- list.
- Don't forget to check out `filesets-menu-ensure-use-cached'."
- :set (function filesets-set-default)
- :type '(repeat
- (choice :tag "Variable"
- (const :tag "filesets-submenus"
- :value filesets-submenus)
- (const :tag "filesets-menu-cache"
- :value filesets-menu-cache)
- (const :tag "filesets-ingroup-cache"
- :value filesets-ingroup-cache)
- (const :tag "filesets-data"
- :value filesets-data)
- (const :tag "filesets-external-viewers"
- :value filesets-external-viewers)
- (const :tag "filesets-ingroup-patterns"
- :value filesets-ingroup-patterns)
- (const :tag "filesets-be-docile-flag"
- :value filesets-be-docile-flag)
- (sexp :tag "Other" :value nil)))
- :group 'filesets)
- (define-obsolete-variable-alias 'filesets-cache-fill-content-hooks
- 'filesets-cache-fill-content-hook "24.3")
- (defcustom filesets-cache-fill-content-hook nil
- "Hook run when writing the contents of filesets' cache file.
- The hook is called with the cache file as current buffer and the cursor
- at the last position. I.e. each hook has to make sure that the cursor is
- at the last position.
- Possible uses: If you don't want to save `filesets-data' in your normal
- configuration file, you can add a something like this
- \(lambda ()
- \(insert (format \"(setq-default filesets-data \\='%S)\"
- filesets-data))
- \(newline 2))
- to this hook.
- Don't forget to check out `filesets-menu-ensure-use-cached'."
- :set (function filesets-set-default)
- :type 'hook
- :group 'filesets)
- (defcustom filesets-cache-hostname-flag nil
- "Non-nil means cache the hostname.
- If the current name differs from the cached one,
- rebuild the menu and create a new cache file."
- :set (function filesets-set-default)
- :type 'boolean
- :group 'filesets)
- (defcustom filesets-cache-save-often-flag nil
- "Non-nil means save buffer on every change of the filesets menu.
- If this variable is set to nil and if Emacs crashes, the cache and
- filesets-data could get out of sync. Set this to t if this happens from
- time to time or if the fileset cache causes troubles."
- :set (function filesets-set-default)
- :type 'boolean
- :group 'filesets)
- (defcustom filesets-max-submenu-length 25
- "Maximum length of submenus.
- Set this value to 0 to turn menu splitting off. BTW, parts of submenus
- will not be rewrapped if their length exceeds this value."
- :set (function filesets-set-default)
- :type 'integer
- :group 'filesets)
- (defcustom filesets-max-entry-length 50
- "Truncate names of split submenus to this length."
- :set (function filesets-set-default)
- :type 'integer
- :group 'filesets)
- (defcustom filesets-browse-dir-function 'dired
- "A function or command used for browsing directories.
- When using an external command, \"%s\" will be replaced with the
- directory's name.
- Note: You have to manually rebuild the menu if you change this value."
- :set (function filesets-set-default)
- :type '(choice :tag "Function:"
- (const :tag "dired"
- :value dired)
- (list :tag "Command"
- :value ("" "%s")
- (string :tag "Name")
- (string :tag "Arguments"))
- (function :tag "Function"
- :value nil))
- :group 'filesets)
- (defcustom filesets-open-file-function 'filesets-find-or-display-file
- "The function used for opening files.
- `filesets-find-or-display-file' ... Filesets' default function for
- visiting files. This function checks if an external viewer is defined
- for a specific file type. Either this viewer, if defined, or
- `find-file' will be used to visit a file.
- `filesets-find-file' ... An alternative function that always uses
- `find-file'. If `filesets-be-docile-flag' is true, a file, which isn't
- readable, will not be opened.
- Caveat: Changes will take effect only after rebuilding the menu."
- :set (function filesets-set-default)
- :type '(choice :tag "Function:"
- (const :tag "filesets-find-or-display-file"
- :value filesets-find-or-display-file)
- (const :tag "filesets-find-file"
- :value filesets-find-file)
- (function :tag "Function"
- :value nil))
- :group 'filesets)
- (defcustom filesets-save-buffer-function 'save-buffer
- "The function used to save a buffer.
- Caveat: Changes will take effect after rebuilding the menu."
- :set (function filesets-set-default)
- :type '(choice :tag "Function:"
- (const :tag "save-buffer"
- :value save-buffer)
- (function :tag "Function"
- :value nil))
- :group 'filesets)
- (defcustom filesets-find-file-delay
- (if (and (featurep 'xemacs) gutter-buffers-tab-visible-p)
- 0.5
- 0)
- "Delay before calling `find-file'.
- This is for calls via `filesets-find-or-display-file'
- or `filesets-find-file'.
- Set this to 0, if you don't use XEmacs's buffer tabs."
- :set (function filesets-set-default)
- :type 'number
- :group 'filesets)
- (defcustom filesets-be-docile-flag nil
- "Non-nil means don't complain if a file or a directory doesn't exist.
- This is useful if you want to use the same startup files in different
- computer environments."
- :set (function filesets-set-default)
- :type 'boolean
- :group 'filesets)
- (defcustom filesets-sort-menu-flag t
- "Non-nil means sort the filesets menu alphabetically."
- :set (function filesets-set-default)
- :type 'boolean
- :group 'filesets)
- (defcustom filesets-sort-case-sensitive-flag t
- "Non-nil means sorting of the filesets menu is case sensitive."
- :set (function filesets-set-default)
- :type 'boolean
- :group 'filesets)
- (defcustom filesets-tree-max-level 3
- "Maximum scan depth for directory trees.
- A :tree fileset is defined by a base directory the contents of which
- will be recursively added to the menu. `filesets-tree-max-level' tells up
- to which level the directory structure should be scanned/listed,
- i.e. how deep the menu should be. Try something like
- \(\"HOME -- only one level\"
- \(:tree \"~\" \"^[^.].*[^~]$\")
- \(:tree-max-level 1)
- \(:filter-dirs-flag t))
- \(\"HOME -- up to 3 levels\"
- \(:tree \"~\" \"^[^.].*[^~]$\")
- \(:tree-max-level 3)
- \(:filter-dirs-flag t))
- and it should become clear what this option is about. In any case,
- including directory trees to the menu can take a lot of memory."
- :set (function filesets-set-default)
- :type 'integer
- :group 'filesets)
- (defcustom filesets-commands
- `(("Isearch"
- multi-isearch-files
- (filesets-cmd-isearch-getargs))
- ("Isearch (regexp)"
- multi-isearch-files-regexp
- (filesets-cmd-isearch-getargs))
- ("Query Replace"
- perform-replace
- (filesets-cmd-query-replace-getargs))
- ("Query Replace (regexp)"
- perform-replace
- (filesets-cmd-query-replace-regexp-getargs))
- ("Grep <<selection>>"
- "grep"
- ("-n " filesets-get-quoted-selection " " "<<file-name>>"))
- ("Run Shell Command"
- filesets-cmd-shell-command
- (filesets-cmd-shell-command-getargs)))
- "Commands to run on filesets.
- An association list of names, functions, and an argument list (or a
- function that returns one) to be run on a filesets' files.
- The argument <file-name> or <<file-name>> (quoted) will be replaced with
- the filename."
- :set (function filesets-set-default+)
- :type '(repeat :tag "Commands"
- (list :tag "Definition" :value ("")
- (string "Name")
- (choice :tag "Command"
- (string :tag "String")
- (function :tag "Function"))
- (repeat :tag "Argument List"
- (choice :tag "Arguments"
- (sexp :tag "Sexp"
- :value nil)
- (string :tag "File Name"
- :value "<file-name>")
- (string :tag "Quoted File Name"
- :value "<<file-name>>")
- (function :tag "Function"
- :value nil)))))
- :group 'filesets)
- (put 'filesets-commands 'risky-local-variable t)
- (defcustom filesets-external-viewers
- (let
- ;; ((ps-cmd (or (and (boundp 'my-ps-viewer) my-ps-viewer)
- ;; (filesets-select-command "ggv gv")))
- ;; (pdf-cmd (or (and (boundp 'my-ps-viewer) my-pdf-viewer)
- ;; (filesets-select-command "xpdf acroread")))
- ;; (dvi-cmd (or (and (boundp 'my-ps-viewer) my-dvi-viewer)
- ;; (filesets-select-command "xdvi tkdvi")))
- ;; (doc-cmd (or (and (boundp 'my-ps-viewer) my-doc-viewer)
- ;; (filesets-select-command "antiword")))
- ;; (pic-cmd (or (and (boundp 'my-ps-viewer) my-pic-viewer)
- ;; (filesets-select-command "gqview ee display"))))
- ((ps-cmd "ggv")
- (pdf-cmd "xpdf")
- (dvi-cmd "xdvi")
- (doc-cmd "antiword")
- (pic-cmd "gqview"))
- `(("^.+\\..?html?$" browse-url
- ((:ignore-on-open-all t)))
- ("^.+\\.pdf$" ,pdf-cmd
- ((:ignore-on-open-all t)
- (:ignore-on-read-text t)
- (:constraint-flag ,pdf-cmd)))
- ("^.+\\.e?ps\\(.gz\\)?$" ,ps-cmd
- ((:ignore-on-open-all t)
- (:ignore-on-read-text t)
- (:constraint-flag ,ps-cmd)))
- ("^.+\\.dvi$" ,dvi-cmd
- ((:ignore-on-open-all t)
- (:ignore-on-read-text t)
- (:constraint-flag ,dvi-cmd)))
- ("^.+\\.doc$" ,doc-cmd
- ((:capture-output t)
- (:ignore-on-read-text t)
- (:constraint-flag ,doc-cmd)))
- ("^.+\\.\\(tiff\\|xpm\\|gif\\|pgn\\)$" ,pic-cmd
- ((:ignore-on-open-all t)
- (:ignore-on-read-text t)
- (:constraint-flag ,pic-cmd)))))
- "Association list of file patterns and external viewers for use with
- `filesets-find-or-display-file'.
- Has the form ((FILE-PATTERN VIEWER PROPERTIES) ...), VIEWER being either a
- function or a command name as string.
- Properties is an association list determining filesets' behavior in
- several conditions. Choose one from this list:
- :ignore-on-open-all ... Don't open files of this type automatically --
- i.e. on open-all-files-events or when running commands
- :capture-output ... capture an external viewer output
- :constraintp FUNCTION ... use this viewer only if FUNCTION returns non-nil
- :constraint-flag SEXP ... use this viewer only if SEXP evaluates to non-nil
- :open-hook HOOK ... run hooks after spawning the viewer -- mainly useful
- in conjunction with :capture-output
- :args (FORMAT-STRING or SYMBOL or FUNCTION) ... a list of arguments
- \(defaults to (list \"%S\")) when using shell commands
- Avoid modifying this variable and achieve minor speed-ups by setting the
- variables my-ps-viewer, my-pdf-viewer, my-dvi-viewer, my-pic-viewer.
- In order to view pdf or rtf files in an Emacs buffer, you could use these:
- \(\"^.+\\\\.pdf\\\\'\" \"pdftotext\"
- \((:capture-output t)
- \(:args (\"%S - | fmt -w \" window-width))
- \(:ignore-on-read-text t)
- \(:constraintp (lambda ()
- \(and \(filesets-which-command-p \"pdftotext\")
- \(filesets-which-command-p \"fmt\"))))))
- \(\"^.+\\\\.rtf\\\\'\" \"rtf2htm\"
- \((:capture-output t)
- \(:args (\"%S 2> /dev/null | w3m -dump -T text/html\"))
- \(:ignore-on-read-text t)
- \(:constraintp (lambda ()
- \(and (filesets-which-command-p \"rtf2htm\")
- \(filesets-which-command-p \"w3m\"))))))"
- :set (function filesets-set-default)
- :type '(repeat :tag "Viewer"
- (list :tag "Definition"
- :value ("^.+\\.suffix$" "")
- (regexp :tag "Pattern")
- (choice :tag "Viewer"
- (symbol :tag "Function" :value nil)
- (string :tag "Program" :value ""))
- (repeat :tag "Properties"
- (choice
- (list :tag ":constraintp"
- :value (:constraintp)
- (const :format ""
- :value :constraintp)
- (function :tag "Function"))
- (list :tag ":constraint-flag"
- :value (:constraint-flag)
- (const :format ""
- :value :constraint-flag)
- (sexp :tag "Symbol"))
- (list :tag ":ignore-on-open-all"
- :value (:ignore-on-open-all t)
- (const :format ""
- :value :ignore-on-open-all)
- (boolean :tag "Boolean"))
- (list :tag ":ignore-on-read-text"
- :value (:ignore-on-read-text t)
- (const :format ""
- :value :ignore-on-read-text)
- (boolean :tag "Boolean"))
- (list :tag ":args"
- :value (:args)
- (const :format ""
- :value :args)
- (repeat :tag "List"
- (choice :tag "Arguments"
- (string :tag "String"
- :value "")
- (symbol :tag "Symbol"
- :value nil)
- (function :tag "Function"
- :value nil))))
- (list :tag ":open-hook"
- :value (:open-hook)
- (const :format ""
- :value :open-hook)
- (hook :tag "Hook"))
- ; (list :tag ":close-hook"
- ; :value (:close-hook)
- ; (const :format ""
- ; :value :close-hook)
- ; (hook :tag "Hook"))
- (list :tag ":capture-output"
- :value (:capture-output t)
- (const :format ""
- :value :capture-output)
- (boolean :tag "Boolean"))))))
- :group 'filesets)
- (put 'filesets-external-viewers 'risky-local-variable t)
- (defcustom filesets-ingroup-patterns
- '(("^.+\\.tex$" t
- (((:name "Package")
- (:pattern "\\\\usepackage\\W*\\(\\[[^\]]*\\]\\W*\\)?{\\W*\\(.+\\)\\W*}")
- (:match-number 2)
- (:stub-flag t)
- (:get-file-name (lambda (master file)
- (filesets-which-file master
- (concat file ".sty")
- (filesets-convert-path-list
- (or (getenv "MY_TEXINPUTS")
- (getenv "TEXINPUTS")))))))
- ((:name "Include")
- (:pattern "\\\\include\\W*{\\W*\\(.+\\)\\W*}")
- (:get-file-name (lambda (master file)
- (filesets-which-file master
- (concat file ".tex")
- (filesets-convert-path-list
- (or (getenv "MY_TEXINPUTS")
- (getenv "TEXINPUTS"))))))
- (:scan-depth 5))
- ((:name "Input")
- (:pattern "\\\\input\\W*{\\W*\\(.+\\)\\W*}")
- (:stubp (lambda (a b) (not (filesets-files-in-same-directory-p a b))))
- (:get-file-name (lambda (master file)
- (filesets-which-file master
- (concat file ".tex")
- (filesets-convert-path-list
- (or (getenv "MY_TEXINPUTS")
- (getenv "TEXINPUTS"))))))
- (:scan-depth 5))
- ((:name "Bibliography")
- (:pattern "\\\\bibliography\\W*{\\W*\\(.+\\)\\W*}")
- (:get-file-name (lambda (master file)
- (filesets-which-file master
- (concat file ".bib")
- (filesets-convert-path-list
- (or (getenv "MY_BIBINPUTS")
- (getenv "BIBINPUTS")))))))))
- ("^.+\\.el$" t
- (((:name "Require")
- (:pattern "(require\\W+'\\(.+\\))")
- (:stubp (lambda (a b) (not (filesets-files-in-same-directory-p a b))))
- (:get-file-name (lambda (master file)
- (filesets-which-file master
- (concat file ".el")
- load-path))))
- ((:name "Load")
- (:pattern "(load\\(-library\\)?\\W+\"\\(.+\\)\")")
- (:match-number 2)
- (:get-file-name (lambda (master file)
- (filesets-which-file master file load-path))))))
- ("^\\([A-ZÄÖÜ][a-zäöüß]+\\([A-ZÄÖÜ][a-zäöüß]+\\)+\\)$" t
- (((:pattern "\\<\\([A-ZÄÖÜ][a-zäöüß]+\\([A-ZÄÖÜ][a-zäöüß]+\\)+\\)\\>")
- (:scan-depth 5)
- (:stubp (lambda (a b) (not (filesets-files-in-same-directory-p a b))))
- (:case-sensitive t)
- (:get-file-name (lambda (master file)
- (filesets-which-file
- master
- file
- (if (boundp 'emacs-wiki-directories)
- emacs-wiki-directories
- nil))))))))
- "Inclusion group definitions.
- Define how to find included file according to a file's mode (being
- defined by a file pattern).
- A valid entry has the form (FILE-PATTERN REMOVE-DUPLICATES-FLAG
- CMD-DEF1 ...), CMD-DEF1 being a plist containing the fields :pattern
- \(mandatory), :name, :get-file-name, :match-number, :scan-depth,
- :preprocess, :case-sensitive.
- File Pattern ... A regexp matching the file's name for which the
- following rules should be applied.
- Remove Duplicates ... If t, only the first occurrence of an included
- file is retained. (See below for a full explanation.)
- :name STRING ... This pattern's name.
- :pattern REGEXP ... A regexp matching the command. This regexp has to
- include a group that holds the name of the included file.
- :get-file-name FUNCTION (default: `filesets-which-file') ... A function
- that takes two arguments (the path of the master file and the name
- of the included file) and returns a valid path or nil -- if the
- subfile can't be found.
- :match-number INTEGER (default: 1) ... The number of the match/group
- in the pattern holding the subfile's name. 0 refers the whole
- match, 1 to the first group.
- :stubp FUNCTION ... If (FUNCTION MASTER INCLUDED-FILE) returns non-nil,
- INCLUDED-FILE is a stub -- see below.
- :stub-flag ... Files of this type are stubs -- see below.
- :scan-depth INTEGER (default: 0) ... Whether included files should be
- rescanned. Set this to 0 to disable re-scanning of included file.
- :preprocess FUNCTION ... A function modifying a buffer holding the
- master file so that pattern matching becomes easier. This is usually
- used to narrow a buffer to the relevant region. This function could also
- be destructive and simply delete non-relevant text.
- :case-sensitive BOOLEAN (default: nil) ... Whether a pattern is
- case-sensitive or not.
- Stubs:
- First, a stub is a file that shows up in the menu but will not be
- included in an ingroup's file listing -- i.e. filesets will never
- operate on this file automatically. Secondly, in opposition to normal
- files stubs are not scanned for new inclusion groups. This is useful if
- you want to have quick access to library headers.
- In the menu, an asterisk is appended to the stub's name.
- Remove Duplicates:
- E.g. File A and file B refer to file X; X refers to A. If
- you choose not to remove duplicates the tree would look like:
- M + A - X - A ...
- B - X - A ...
- As you can see, there is some chance that you run in circles.
- Nevertheless, up to some degree this could still be what you want.
- With duplicates removed, it would be:
- M + A - X
- B"
- :set (function filesets-set-default)
- :type '(repeat
- :tag "Include"
- (list
- :tag "Definition" :value ("^.+\\.suffix$" t)
- (regexp :tag "File Pattern" :value "^.+\\.suffix$")
- (boolean :tag "Remove Duplicates" :value t)
- (repeat :tag "Commands"
- (repeat :tag "Command"
- (choice
- :tag "Definition"
- (list :tag ":name"
- :value (:name "")
- (const :format "" :value :name)
- (string :tag "String"))
- (list :tag ":pattern"
- :value (:pattern "\\<CMD\\W*\\(.+\\)\\>")
- (const :format "" :value :pattern)
- (regexp :tag "RegExp"))
- (list :tag ":get-file-name"
- :value (:get-file-name)
- (const :format "" :value :get-file-name)
- (function :tag "Function"))
- (list :tag ":match-number"
- :value (:match-number 1)
- (const :format "" :value :match-number)
- (integer :tag "Integer"))
- (list :tag ":stub-flag"
- :value (:stub-flag t)
- (const :format "" :value :stub-flag)
- (boolean :tag "Boolean"))
- (list :tag ":stubp"
- :value (:stubp)
- (const :format "" :value :stubp)
- (function :tag "Function"))
- (list :tag ":scan-depth"
- :value (:scan-depth 0)
- (const :format "" :value :scan-depth)
- (integer :tag "Integer"))
- (list :tag ":case-sensitive"
- :value (:case-sensitive)
- (const :format "" :value :case-sensitive)
- (boolean :tag "Boolean"))
- (list :tag ":preprocess"
- :value (:preprocess)
- (const :format "" :value :preprocess)
- (function :tag "Function")))))))
- :group 'filesets)
- (put 'filesets-ingroup-patterns 'risky-local-variable t)
- (defcustom filesets-data nil
- "Fileset definitions.
- A fileset is either a list of files, a file pattern, a base directory
- and a search pattern (for files), or a base file. Changes to this
- variable will take effect after rebuilding the menu.
- Caveat: Fileset names have to be unique.
- Example definition:
- '\(\(\"My Wiki\"
- \(:ingroup \"~/Etc/My-Wiki/WikiContents\"))
- \(\"My Homepage\"
- \(:pattern \"~/public_html/\" \"^.+\\\\.html$\")
- \(:open filesets-find-file))
- \(\"User Configuration\"
- \(:files \"~/.xinitrc\"
- \"~/.bashrc\"
- \"~/.bash_profile\"))
- \(\"HOME\"
- \(:tree \"~\" \"^[^.].*[^~]$\")
- \(:filter-dirs-flag t)))
- `filesets-data' is a list of (NAME-AS-STRING . DEFINITION), DEFINITION
- being an association list with the fields:
- :files FILE-1 .. FILE-N ... a list of files belonging to a fileset
- :ingroup FILE-NAME ... an inclusion group's base file.
- :tree ROOT-DIR PATTERN ... a base directory and a file pattern
- :pattern DIR PATTERN ... a base directory and a regexp matching
- files in that directory. Usually,
- PATTERN has the form `^REGEXP$'. Unlike
- :tree, this form does not descend
- recursively into subdirectories.
- :filter-dirs-flag BOOLEAN ... is only used in conjunction with :tree.
- :tree-max-level INTEGER ... recurse into directories this many levels
- \(see `filesets-tree-max-level' for a full explanation)
- :dormant-flag BOOLEAN ... non-nil means don't show this item in the
- menu; dormant filesets can still be manipulated via commands available
- from the minibuffer -- e.g. `filesets-open', `filesets-close', or
- `filesets-run-cmd'
- :dormant-p FUNCTION ... a function returning :dormant-flag
- :open FUNCTION ... the function used to open file belonging to this
- fileset. The function takes a file name as argument
- :save FUNCTION ... the function used to save file belonging to this
- fileset; it takes no arguments, but works on the current buffer.
- Either :files, :pattern, :tree, or :ingroup must be supplied. :files
- overrules :tree, :tree overrules :pattern, :pattern overrules :ingroup,
- i.e. these tags are mutually exclusive. The fields :open and :save are
- optional.
- In conjunction with the :tree tag, :save is void. :open refers to the
- function used for opening files in a directory, not for opening the
- directory. For browsing directories, `filesets-browse-dir-function' is used.
- Before using :ingroup, make sure that the file type is already
- defined in `filesets-ingroup-patterns'."
- :group 'filesets
- :set (function filesets-data-set-default)
- :type '(repeat
- (cons :tag "Fileset"
- (string :tag "Name" :value "")
- (repeat :tag "Data"
- (choice
- :tag "Type" :value nil
- (list :tag "Pattern"
- :value (:pattern "~/" "^.+\\.suffix$")
- (const :format "" :value :pattern)
- (directory :tag "Dir")
- (regexp :tag "Pattern"))
- (cons :tag "Files"
- :value (:files)
- (const :format "" :value :files)
- (repeat :tag "Files" file))
- (list :tag "Single File"
- :value (:file "~/")
- (const :format "" :value :file)
- (file :tag "File"))
- (list :tag "Inclusion group"
- :value (:ingroup "~/")
- (const :format "" :value :ingroup)
- (file :tag "File" :value "~/"))
- (list :tag "Directory Tree"
- :value (:tree "~/" "^.+\\.suffix$")
- (const :format "" :value :tree)
- (directory :tag "Dir")
- (regexp :tag "Pattern"))
- (list :tag "Filter directories"
- :value (:filter-dirs-flag)
- (const :format "" :value :filter-dirs-flag)
- (boolean :tag "Boolean" :value nil))
- (list :tag "Scanning depth"
- :value (:tree-max-level 3)
- (const :format "" :value :tree-max-level)
- (integer :tag "Integer"))
- (list :tag "Verbosity"
- :value (:verbosity 1)
- (const :format "" :value :verbosity)
- (integer :tag "Integer"))
- (list :tag "Conceal fileset (Flag)"
- :value (:dormant-flag)
- (const :format "" :value :dormant-flag)
- (boolean :tag "Boolean"))
- (list :tag "Conceal fileset (Function)"
- :value (:dormant-p)
- (const :format "" :value :dormant-p)
- (function :tag "Function"))
- (list :tag "Save function"
- :value (:save)
- (const :format "" :value :save)
- (function :tag "Function"))
- (list :tag "Open function"
- :value (:open)
- (const :format "" :value :open)
- (function :tag "Function")))))))
- (put 'filesets-data 'risky-local-variable t)
- (defcustom filesets-query-user-limit 15
- "Query the user before opening a fileset with that many files."
- :set (function filesets-set-default)
- :type 'integer
- :group 'filesets)
- ;;; Emacs compatibility
- (eval-and-compile
- (if (featurep 'xemacs)
- (fset 'filesets-error 'error)
- (require 'easymenu)
- (defun filesets-error (_class &rest args)
- "`error' wrapper."
- (error "%s" (mapconcat 'identity args " ")))
- ))
- (defun filesets-filter-dir-names (lst &optional negative)
- "Remove non-directory names from a list of strings.
- If NEGATIVE is non-nil, remove all directory names."
- (filesets-filter-list lst
- (lambda (x)
- (and (not (string-match-p "^\\.+/$" x))
- (if negative
- (not (string-match-p "[:/\\]$" x))
- (string-match-p "[:/\\]$" x))))))
- (defun filesets-conditional-sort (lst &optional access-fn)
- "Return a sorted copy of LST, LST being a list of strings.
- If `filesets-sort-menu-flag' is nil, return LST itself.
- ACCESS-FN ... function to get the string value of LST's elements."
- (if filesets-sort-menu-flag
- (let* ((fni (or access-fn
- (function identity)))
- (fn (if filesets-sort-case-sensitive-flag
- (lambda (a b)
- (string< (funcall fni a)
- (funcall fni b)))
- (lambda (a b)
- (string< (upcase (funcall fni a))
- (upcase (funcall fni b)))))))
- (sort (copy-sequence lst) fn))
- lst))
- (defun filesets-directory-files (dir &optional
- pattern what full-flag match-dirs-flag)
- "Get WHAT (:files or :dirs) in DIR.
- If PATTERN is provided return only those entries matching this
- regular expression.
- If MATCH-DIRS-FLAG is non-nil, also match directory entries.
- Return full path if FULL-FLAG is non-nil."
- (filesets-message 2 "Filesets: scanning %S" dir)
- (cond
- ((file-exists-p dir)
- (let ((files nil)
- (dirs nil))
- (dolist (this (file-name-all-completions "" dir))
- (cond
- ((string-match-p "^\\.+/$" this)
- nil)
- ((string-match-p "[:/\\]$" this)
- (when (or (not match-dirs-flag)
- (not pattern)
- (string-match-p pattern this))
- (filesets-message 5 "Filesets: matched dir %S with pattern %S"
- this pattern)
- (setq dirs (cons this dirs))))
- (t
- (when (or (not pattern)
- (string-match-p pattern this))
- (filesets-message 5 "Filesets: matched file %S with pattern %S"
- this pattern)
- (setq files (cons (if full-flag
- (concat (file-name-as-directory dir) this)
- this)
- files))))))
- (cond
- ((equal what ':dirs)
- (filesets-conditional-sort dirs))
- ((equal what ':files)
- (filesets-conditional-sort files))
- (t
- (append (filesets-conditional-sort files)
- (filesets-conditional-sort dirs))))))
- (filesets-be-docile-flag
- (filesets-message 1 "Filesets: %S doesn't exist" dir)
- nil)
- (t
- (filesets-error 'error "Filesets: " dir " does not exist"))))
- (defun filesets-quote (txt)
- "Return TXT in quotes."
- (concat "\"" txt "\""))
- (defun filesets-get-selection ()
- "Get the text between mark and point -- i.e. the selection or region."
- (let ((m (mark))
- (p (point)))
- (if m
- (buffer-substring (min m p) (max m p))
- (filesets-error 'error "No selection."))))
- (defun filesets-get-quoted-selection ()
- "Return the currently selected text in quotes."
- (filesets-quote (filesets-get-selection)))
- (defun filesets-get-shortcut (n)
- "Create menu shortcuts based on number N."
- (let ((n (mod (- n 1) 51)))
- (cond
- ((not filesets-menu-shortcuts-flag)
- "")
- ((<= n 9)
- (concat (number-to-string n) " "))
- ((<= n 35)
- (format "%c " (+ 87 n)))
- ((<= n 51)
- (format "%c " (+ -3 n))))))
- (defun filesets-files-equalp (a b)
- "Compare two filenames A and B after expansion."
- (equal (expand-file-name a) (expand-file-name b)))
- (defun filesets-files-in-same-directory-p (a b)
- "Compare two filenames A and B after expansion."
- (let ((ad (file-name-directory (expand-file-name a)))
- (bd (file-name-directory (expand-file-name b))))
- (equal ad bd)))
- (defun filesets-convert-path-list (string)
- "Return a path-list given as STRING as list."
- (if string
- (mapcar (lambda (x) (file-name-as-directory x))
- (split-string string path-separator))
- nil))
- (defun filesets-which-file (master filename &optional path-list)
- "Search for a FILENAME relative to a MASTER file in PATH-LIST."
- (let ((f (concat (file-name-directory master)
- filename)))
- (if (file-exists-p f)
- f
- (filesets-some
- (lambda (dir)
- (let ((dir (file-name-as-directory dir))
- (files (if (file-exists-p dir)
- (filesets-directory-files dir nil ':files)
- nil)))
- (filesets-some (lambda (file)
- (if (equal filename (file-name-nondirectory file))
- (concat dir file)
- nil))
- files)))
- path-list))))
- (defun filesets-eviewer-get-props (entry)
- "Get ENTRY's (representing an external viewer) properties."
- (nth 2 entry))
- (defun filesets-eviewer-constraint-p (entry)
- (let* ((props (filesets-eviewer-get-props entry))
- (constraint (assoc ':constraintp props))
- (constraint-flag (assoc ':constraint-flag props)))
- (cond
- (constraint
- (funcall (cadr constraint)))
- (constraint-flag
- (eval (cadr constraint-flag)))
- (t
- t))))
- (defun filesets-get-external-viewer (file)
- "Find an external viewer for FILE."
- (let ((filename (file-name-nondirectory file)))
- (filesets-some
- (lambda (entry)
- (when (and (string-match-p (nth 0 entry) filename)
- (filesets-eviewer-constraint-p entry))
- entry))
- filesets-external-viewers)))
- (defun filesets-get-external-viewer-by-name (name)
- "Get the external viewer definition called NAME."
- (when name
- (filesets-some
- (lambda (entry)
- (when (and (string-equal (nth 1 entry) name)
- (filesets-eviewer-constraint-p entry))
- entry))
- filesets-external-viewers)))
- (defun filesets-filetype-property (filename event &optional entry)
- "Return non-nil if a file of a specific type has special flags/tags.
- Events (corresponding tag):
- on-open-all (:ignore-on-open-all) ... Exclude files of this when opening
- a fileset
- on-grep (:ignore-on-read-text) ... Exclude files of this when running
- the \"Grep <<selection>>\" command
- on-capture-output (:capture-output) ... Capture output of an external viewer
- on-ls ... Not used
- on-cmd ... Not used
- on-close-all ... Not used"
- (let ((def (filesets-eviewer-get-props
- (or entry
- (filesets-get-external-viewer filename)))))
- (filesets-alist-get def
- (pcase event
- (`on-open-all ':ignore-on-open-all)
- (`on-grep ':ignore-on-read-text)
- (`on-cmd nil)
- (`on-close-all nil))
- nil t)))
- (defun filesets-filetype-get-prop (property filename &optional entry)
- "Return PROPERTY for filename -- use ENTRY if provided."
- (let ((def (filesets-eviewer-get-props
- (or entry
- (filesets-get-external-viewer filename)))))
- (when def
- (filesets-alist-get def property nil t))))
- (defun filesets-reset-filename-on-change ()
- "Reset a buffer's filename if the buffer is being modified."
- (when filesets-output-buffer-flag
- (set-visited-file-name nil t)))
- (defun filesets-spawn-external-viewer (file &optional ev-entry)
- "Start an external viewer for FILE.
- Use the viewer defined in EV-ENTRY (a valid element of
- `filesets-external-viewers') if provided."
- (let* ((file (expand-file-name file))
- (entry (or ev-entry
- (filesets-get-external-viewer file))))
- (if entry
- (let* ((vwr (cadr entry))
- (co-flag (filesets-filetype-get-prop ':capture-output file entry))
- (oh (filesets-filetype-get-prop ':open-hook file entry))
- (args (let ((fmt (filesets-filetype-get-prop ':args file entry)))
- (if fmt
- (let ((rv ""))
- (dolist (this fmt rv)
- (setq rv (concat rv
- (cond
- ((stringp this)
- (format this file))
- ((and (symbolp this)
- (fboundp this))
- (format "%S" (funcall this)))
- (t
- (format "%S" this)))))))
- (format "%S" file))))
- (output
- (cond
- ((and (functionp vwr) co-flag)
- (funcall vwr file))
- ((functionp vwr)
- (funcall vwr file)
- nil)
- (co-flag
- (shell-command-to-string (format "%s %s" vwr args)))
- (t
- (shell-command (format "%s %s&" vwr args))
- nil))))
- (if co-flag
- (progn
- (switch-to-buffer (format "Filesets: %s %s" vwr file))
- (insert output)
- (make-local-variable 'filesets-output-buffer-flag)
- (setq filesets-output-buffer-flag t)
- (set-visited-file-name file t)
- (when oh
- (run-hooks 'oh))
- (set-buffer-modified-p nil)
- (setq buffer-read-only t)
- (goto-char (point-min)))
- (when oh
- (run-hooks 'oh))))
- (filesets-error 'error
- "Filesets: general error when spawning external viewer"))))
- (defun filesets-find-file (file)
- "Call `find-file' after a possible delay (see `filesets-find-file-delay').
- If `filesets-be-docile-flag' is true, a file, which isn't readable, will
- not be opened."
- ; (sleep-for filesets-find-file-delay)
- (when (or (file-readable-p file)
- (not filesets-be-docile-flag))
- (sit-for filesets-find-file-delay)
- (find-file file)))
- (defun filesets-find-or-display-file (&optional file viewer)
- "Visit FILE using an external VIEWER or open it in an Emacs buffer."
- (interactive)
- (let* ((file (or file
- (read-file-name "Find file: " nil nil viewer)))
- (external-viewer-def (or
- (filesets-get-external-viewer-by-name viewer)
- (filesets-get-external-viewer file))))
- (filesets-message 3 "Filesets: view %S using %s" file external-viewer-def)
- (if external-viewer-def
- (filesets-spawn-external-viewer file external-viewer-def)
- (filesets-find-file file))))
- (defun filesets-find-file-using ()
- "Select a viewer and call `filesets-find-or-display-file'."
- (interactive)
- (let* ((lst (mapcar (lambda (this)
- (let ((a (cadr this)))
- (list (format "%s" a) a)))
- filesets-external-viewers))
- (viewer (completing-read "Using viewer: " lst nil t)))
- (when viewer
- (filesets-find-or-display-file nil (cadr (assoc viewer lst))))))
- (defun filesets-browser-name ()
- "Get the directory browser's name as defined in `filesets-browse-dir-function'."
- (cond
- ((listp filesets-browse-dir-function)
- (car filesets-browse-dir-function))
- (t
- filesets-browse-dir-function)))
- (defun filesets-browse-dir (dir)
- "Browse DIR using `filesets-browse-dir-function'."
- (if (functionp filesets-browse-dir-function)
- (funcall filesets-browse-dir-function dir)
- (let ((name (car filesets-browse-dir-function))
- (args (format (cadr filesets-browse-dir-function) (expand-file-name dir))))
- (with-temp-buffer
- (start-process (concat "Filesets:" name)
- "*Filesets external directory browser*"
- name args)))))
- (defun filesets-get-fileset-name (something)
- "Get SOMETHING's name (Don't ask)."
- (cond
- ((listp something)
- (car something))
- (t
- something)))
- (defun filesets-data-get-name (entry)
- "Access to `filesets-data'. Get the ENTRY's name."
- (car entry))
- (defun filesets-data-get-data (entry)
- "Access to `filesets-data'. Get the ENTRY's data section."
- (cdr entry))
- (defun filesets-alist-get (alist key &optional default carp)
- "Get KEY's value in the association list ALIST.
- Return DEFAULT if not found. Return (car VALUE) if CARP is non-nil."
- (let ((elt (assoc key alist)))
- (cond
- (elt
- (if carp
- (cadr elt)
- (cdr elt)))
- (default default)
- (t nil))))
- (defun filesets-data-get (entry key &optional default carp)
- "Extract the value for KEY in the data part of fileset ENTRY.
- Return DEFAULT if not found. Return (car VALUE) if CARP is non-nil."
- (filesets-alist-get (filesets-data-get-data entry) key default carp))
- (defun filesets-data-set (entry key value)
- "Set the VALUE for KEY in the data part of fileset ENTRY."
- (let* ((alist (filesets-data-get-data entry))
- (elt (assoc key alist)))
- (if elt
- (setcdr elt value)
- (setcdr entry (cons (cons key value) alist)))))
- (defun filesets-entry-mode (entry)
- "Return fileset ENTRY's mode: :files, :file, :tree, :pattern, or :ingroup.
- See `filesets-data'."
- (let ((data (filesets-data-get-data entry)))
- (filesets-some
- (lambda (x)
- (if (assoc x data)
- x))
- '(:files :tree :pattern :ingroup :file))))
- (defun filesets-entry-get-open-fn (fileset-name &optional fileset-entry)
- "Get the open-function for FILESET-NAME.
- Use FILESET-ENTRY for finding the open function, if provided."
- (filesets-data-get (or fileset-entry
- (filesets-get-fileset-from-name fileset-name))
- ':open filesets-open-file-function t))
- (defun filesets-entry-get-save-fn (fileset-name &optional fileset-entry)
- "Get the save-function for FILESET-NAME.
- Use FILESET-ENTRY for finding the save function, if provided."
- (filesets-data-get (or fileset-entry
- (filesets-get-fileset-from-name fileset-name))
- ':save filesets-save-buffer-function t))
- (defun filesets-entry-get-files (entry)
- "Get the file list for fileset ENTRY."
- (filesets-data-get entry ':files))
- (defun filesets-entry-set-files (entry data &optional anyways)
- "Set the file list for fileset ENTRY."
- (let ((files (filesets-entry-get-files entry)))
- (if (or anyways files)
- (filesets-data-set entry ':files data))))
- (defun filesets-entry-get-verbosity (entry)
- "Get verbosity level for fileset ENTRY."
- (filesets-data-get entry ':verbosity 1 t))
- (defun filesets-entry-get-file (entry)
- "Get the single file for fileset ENTRY."
- (filesets-data-get entry ':file nil t))
- (defun filesets-entry-get-pattern (entry)
- "Get the base directory + file pattern for fileset ENTRY."
- ; (filesets-data-get entry ':pattern nil t))
- (filesets-data-get entry ':pattern))
- (defun filesets-entry-get-pattern--pattern (list)
- "Get the file pattern for LIST."
- (if (= (length list) 1) ;; for compatibility with filesets < v1.5.5
- (file-name-nondirectory (car list))
- (cadr list)))
- (defun filesets-entry-get-pattern--dir (list)
- "Get a file pattern's base directory for LIST."
- (if (= (length list) 1) ;; for compatibility with filesets < v1.5.5
- (file-name-directory (car list))
- (car list)))
- (defun filesets-entry-get-tree (entry)
- "Get the tree pattern for fileset ENTRY."
- (filesets-data-get entry ':tree))
- (defun filesets-entry-get-dormant-flag (entry)
- "Get dormant flag for fileset ENTRY."
- (let ((fn (filesets-data-get entry ':dormant-p nil t)))
- (if fn
- (funcall fn)
- (filesets-data-get entry ':dormant-flag nil t))))
- (defun filesets-entry-get-filter-dirs-flag (entry)
- "Get filter-dirs-flag for fileset ENTRY."
- (filesets-data-get entry ':filter-dirs-flag nil t))
- (defun filesets-entry-get-tree-max-level (entry)
- "Get maximal tree scanning depth for fileset ENTRY."
- (filesets-data-get entry ':tree-max-level nil t))
- (defun filesets-entry-get-master (entry)
- "Get the base file for fileset ENTRY."
- (filesets-data-get entry ':ingroup nil t))
- (defun filesets-file-open (open-function file-name &optional fileset-name)
- "Open FILE-NAME using OPEN-FUNCTION.
- If OPEN-FUNCTION is nil, its value will be deduced from FILESET-NAME."
- (let ((open-function (or open-function
- (filesets-entry-get-open-fn fileset-name))))
- (if (file-readable-p file-name)
- (funcall open-function file-name)
- (message "Filesets: Couldn't open `%s'" file-name))))
- (defun filesets-file-close (save-function buffer)
- "Close BUFFER.
- First, save the buffer's contents using SAVE-FUNCTION. Then, kill buffer
- if `buffer-modified-p' returns nil.
- SAVE-FUNCTION takes no argument, but works on the current buffer."
- (with-current-buffer buffer
- (if (buffer-modified-p)
- (funcall save-function))
- (if (not (buffer-modified-p))
- (kill-buffer buffer))))
- (defun filesets-get-fileset-from-name (name &optional mode)
- "Get fileset definition for NAME."
- (pcase mode
- ((or `:ingroup `:tree) name)
- (_ (assoc name filesets-data))))
- ;;; commands
- (defun filesets-cmd-get-def (cmd-name)
- "Get `filesets-commands' entry for CMD-NAME."
- (assoc cmd-name filesets-commands))
- (defun filesets-cmd-get-args (cmd-name)
- (let ((args (let ((def (filesets-cmd-get-def cmd-name)))
- (nth 2 def)))
- (rv nil))
- (dolist (this args rv)
- (cond
- ((and (symbolp this) (fboundp this))
- (let ((x (funcall this)))
- (setq rv (append rv (if (listp x) x (list x))))))
- (t
- (setq rv (append rv (list this))))))))
- (defun filesets-cmd-get-fn (cmd-name)
- (let ((def (filesets-cmd-get-def cmd-name)))
- (nth 1 def)))
- (defun filesets-cmd-show-result (cmd output)
- "Show OUTPUT of CMD (a shell command)."
- (pop-to-buffer "*Filesets: Shell Command Output*")
- (with-no-warnings
- (end-of-buffer))
- (insert "*** ")
- (insert cmd)
- (newline)
- (insert output)
- (newline))
- (defun filesets-run-cmd--repl-fn (arg &optional format-fn)
- "Helper function for `filesets-run-cmd'. Apply FORMAT-FN to arg.
- Replace <file-name> or <<file-name>> with filename."
- (funcall format-fn (cond
- ((equal arg "<file-name>")
- (buffer-file-name))
- ((equal arg "<<file-name>>")
- (shell-quote-argument (buffer-file-name)))
- (t
- arg))))
- (defun filesets-run-cmd (&optional cmd-name fileset mode)
- "Run CMD-NAME (see `filesets-commands') on FILESET."
- (interactive)
- (let* ((cmd-name (or cmd-name
- (completing-read "Select command: " filesets-commands
- nil t)))
- (name (or fileset
- (completing-read "Select fileset: " filesets-data nil t))))
- (when (and cmd-name name)
- (let* ((event (if (equal cmd-name "Grep <<selection>>")
- 'on-grep
- 'on-cmd))
- (files (if (and fileset
- (or (equal mode ':ingroup)
- (equal mode ':tree)))
- (filesets-get-filelist fileset mode event)
- (filesets-get-filelist
- (filesets-get-fileset-from-name name)
- mode event))))
- (when files
- (let ((fn (filesets-cmd-get-fn cmd-name))
- (args (filesets-cmd-get-args cmd-name)))
- (if (memq fn '(multi-isearch-files multi-isearch-files-regexp))
- (apply fn args)
- (dolist (this files nil)
- (save-excursion
- (save-restriction
- (let ((buffer (filesets-find-file this)))
- (when buffer
- (goto-char (point-min))
- (progn
- (cond
- ((stringp fn)
- (let* ((args
- (let ((txt ""))
- (dolist (this args txt)
- (setq txt
- (concat txt
- (filesets-run-cmd--repl-fn
- this
- (lambda (this)
- (if (equal txt "") "" " ")
- (format "%s" this))))))))
- (cmd (concat fn " " args)))
- (filesets-cmd-show-result
- cmd (shell-command-to-string cmd))))
- ((symbolp fn)
- (let ((args
- (let ((argl nil))
- (dolist (this args argl)
- (setq argl
- (append argl
- (filesets-run-cmd--repl-fn
- this
- 'list)))))))
- (apply fn args)))))))))))))))))
- (defun filesets-get-cmd-menu ()
- "Create filesets command menu."
- `("+ Commands"
- . ,(mapcar (lambda (this)
- (let ((name (car this)))
- `[,name (filesets-run-cmd ,name)]))
- filesets-commands)))
- ;;; sample commands
- (defun filesets-cmd-query-replace-getargs ()
- "Get arguments for `query-replace' and `query-replace-regexp'."
- (let ((common (query-replace-read-args "Filesets query replace" nil t)))
- (list (nth 0 common) (nth 1 common) t nil (nth 2 common) nil
- multi-query-replace-map)))
- (defun filesets-cmd-query-replace-regexp-getargs ()
- "Get arguments for `query-replace' and `query-replace-regexp'."
- (let ((common (query-replace-read-args "Filesets query replace" t t)))
- (list (nth 0 common) (nth 1 common) t t (nth 2 common) nil
- multi-query-replace-map)))
- (defun filesets-cmd-isearch-getargs ()
- "Get arguments for `multi-isearch-files' and `multi-isearch-files-regexp'."
- (and (boundp 'files) (list files)))
- (defun filesets-cmd-shell-command-getargs ()
- "Get arguments for `filesets-cmd-shell-command'."
- (let* ((arg (read-string "Shell command (%s = file): "
- "%s"
- 'shell-command-history)))
- arg))
- (defun filesets-cmd-shell-command (txt)
- "Wrapper function for `shell-command'."
- (let ((ok (if (buffer-modified-p)
- (let ((ok (y-or-n-p "Save buffer? ")))
- (when ok
- (save-buffer))
- ok)
- t)))
- (when ok
- (let ((cmd (format txt (shell-quote-argument (buffer-file-name)))))
- (message "Filesets: %s" cmd)
- (filesets-cmd-show-result cmd
- (shell-command-to-string cmd))))))
- ;;; body
- (defun filesets-get-filelist (entry &optional mode event)
- "Get all files for fileset ENTRY.
- Assume MODE (see `filesets-entry-mode'), if provided."
- (let* ((mode (or mode
- (filesets-entry-mode entry)))
- (fl (pcase mode
- (:files
- (filesets-entry-get-files entry))
- (:file
- (list (filesets-entry-get-file entry)))
- (:ingroup
- (let ((entry (expand-file-name
- (if (stringp entry)
- entry
- (filesets-entry-get-master entry)))))
- (cons entry (filesets-ingroup-cache-get entry))))
- (:tree
- (let ((dir (nth 0 entry))
- (patt (nth 1 entry)))
- (filesets-directory-files dir patt ':files t)))
- (:pattern
- (let ((dirpatt (filesets-entry-get-pattern entry)))
- (if dirpatt
- (let ((dir (filesets-entry-get-pattern--dir dirpatt))
- (patt (filesets-entry-get-pattern--pattern dirpatt)))
- ;;(filesets-message 3 "Filesets: scanning %s" dirpatt)
- (filesets-directory-files dir patt ':files t))
- ;; (message "Filesets: malformed entry: %s" entry)))))))
- (filesets-error 'error "Filesets: malformed entry: "
- entry)))))))
- (filesets-filter-list fl
- (lambda (file)
- (not (filesets-filetype-property file event))))))
- (defun filesets-open (&optional mode name lookup-name)
- "Open the fileset called NAME.
- Use LOOKUP-NAME for searching additional data if provided."
- (interactive)
- (let* ((name (or name
- (completing-read "Open fileset: " filesets-data nil t)))
- (fileset (filesets-get-fileset-from-name name mode))
- (lookup-fs (if lookup-name
- (filesets-get-fileset-from-name lookup-name)
- fileset))
- (mode (or mode (filesets-entry-mode lookup-fs))))
- (if fileset
- (let* ((files (filesets-get-filelist fileset mode 'on-open-all))
- (n (length files))
- (open-function (filesets-entry-get-open-fn nil lookup-fs)))
- (if (or (<= n filesets-query-user-limit)
- (y-or-n-p (format "Filesets: Open all %d files in %s? "
- n name)))
- (dolist (this files nil)
- (filesets-file-open open-function this))
- (message "Filesets: canceled")))
- (filesets-error 'error "Filesets: Unknown fileset: " name))))
- (defun filesets-close (&optional mode name lookup-name)
- "Close all buffers belonging to the fileset called NAME.
- Use LOOKUP-NAME for deducing the save-function, if provided."
- (interactive)
- (let* ((name (or name
- (completing-read "Close fileset: " filesets-data nil t)))
- (fileset (filesets-get-fileset-from-name name mode))
- (lookup-fs (if lookup-name
- (filesets-get-fileset-from-name lookup-name)
- fileset))
- (mode (or mode (filesets-entry-mode lookup-fs))))
- (if fileset
- (let ((files (filesets-get-filelist fileset mode 'on-close-all))
- (save-function (filesets-entry-get-save-fn nil lookup-fs)))
- (dolist (file-name files nil)
- (let* ((buffer (get-file-buffer file-name)))
- (if buffer
- (filesets-file-close save-function buffer)))))
- ; (message "Filesets: Unknown fileset: `%s'" name))))
- (filesets-error 'error "Filesets: Unknown fileset: " name))))
- (defun filesets-add-buffer (&optional name buffer)
- "Add BUFFER (or current buffer) to the fileset called NAME.
- User will be queried, if no fileset name is provided."
- (interactive)
- (let* ((buffer (or buffer
- (current-buffer)))
- (name (or name
- (completing-read
- (format-message "Add ‘%s’ to fileset: " buffer)
- filesets-data nil)))
- (entry (or (assoc name filesets-data)
- (when (y-or-n-p
- (format "Fileset %s does not exist. Create it? "
- name))
- (progn
- (add-to-list 'filesets-data (list name '(:files)))
- (message
- (substitute-command-keys
- "Fileset %s created. Call `\\[filesets-save-config]' to save.")
- name)
- (car filesets-data))))))
- (if entry
- (let* ((files (filesets-entry-get-files entry))
- (this (buffer-file-name buffer))
- (inlist (filesets-member this files
- :test 'filesets-files-equalp)))
- (cond
- (inlist
- (message "Filesets: ‘%s’ is already in ‘%s’" this name))
- ((and (equal (filesets-entry-mode entry) ':files)
- this)
- (filesets-entry-set-files entry (cons this files) t)
- (filesets-set-config name 'filesets-data filesets-data))
- (t
- (message "Filesets: Can't add ‘%s’ to fileset ‘%s’" this name)))))))
- (defun filesets-remove-buffer (&optional name buffer)
- "Remove BUFFER (or current buffer) to fileset NAME.
- User will be queried, if no fileset name is provided."
- (interactive)
- (let* ((buffer (or buffer
- (current-buffer)))
- (name (or name
- (completing-read
- (format-message "Remove ‘%s’ from fileset: " buffer)
- filesets-data nil t)))
- (entry (assoc name filesets-data)))
- (if entry
- (let* ((files (filesets-entry-get-files entry))
- (this (buffer-file-name buffer))
- (inlist (filesets-member this files
- :test 'filesets-files-equalp)))
- ;;(message "%s %s %s" files this inlist)
- (if (and files this inlist)
- (let ((new (list (cons ':files (delete (car inlist) files)))))
- (setcdr entry new)
- (filesets-set-config name 'filesets-data filesets-data))
- (message "Filesets: Can't remove ‘%s’ from fileset ‘%s’"
- this
- name))))))
- (defun filesets-convert-patterns (name)
- "Change fileset NAME's mode from :pattern to :files."
- (interactive)
- (let ((entry (assoc name filesets-data)))
- (if entry
- (let ((pattern (filesets-entry-get-pattern entry))
- (patfiles (filesets-get-filelist entry ':pattern)))
- (if pattern
- (progn
- (filesets-entry-set-files entry patfiles t)
- (filesets-set-config name 'filesets-data filesets-data)))))))
- (defun filesets-edit ()
- "Customize `filesets-data'."
- (interactive)
- (customize-variable 'filesets-data))
- (defun filesets-customize ()
- "Customize the filesets group."
- (interactive)
- (customize-group 'filesets))
- (defun filesets-info ()
- "Display filesets's version information."
- (interactive)
- (if (y-or-n-p (format "Filesets v%s: visit homepage? " filesets-version))
- (filesets-goto-homepage)))
- (defun filesets-goto-homepage ()
- "Show filesets's homepage."
- (interactive)
- (browse-url filesets-homepage))
- (defun filesets-remake-shortcut (count submenu)
- "Remake a submenu's shortcut when wrapping long menus."
- (let* ((name (concat (filesets-get-shortcut count)
- (substring (elt submenu 0) 2))))
- (if (listp submenu)
- (cons name (cdr submenu))
- (apply 'vector (list name (cdr (append submenu nil)))))))
- ; (vconcat `[,name] (subseq submenu 1)))))
- (defun filesets-wrap-submenu (submenu-body)
- "Split long submenus."
- (let ((bl (length submenu-body)))
- (if (or (= filesets-max-submenu-length 0)
- (<= bl filesets-max-submenu-length))
- submenu-body
- (let* ((result nil)
- (factor (ceiling (/ (float bl)
- filesets-max-submenu-length))))
- (cl-do ((data submenu-body (cdr data))
- (n 1 (+ n 1))
- (count 0 (+ count factor)))
- ((or (> count bl)
- (null data)))
- ;; (let ((sl (subseq submenu-body count
- (let ((sl (filesets-sublist submenu-body count
- (let ((x (+ count factor)))
- (if (>= bl x)
- x
- nil)))))
- (when sl
- (setq result
- (append
- result
- (if (= (length sl) 1)
- (if filesets-menu-shortcuts-flag
- (list (filesets-remake-shortcut n (car sl)))
- sl)
- `((,(concat
- (filesets-get-shortcut n)
- (let ((rv ""))
- (cl-do ((x sl (cdr x)))
- ((null x))
- (let ((y (concat (elt (car x) 0)
- (if (null (cdr x))
- ""
- ", "))))
- (setq rv
- (concat
- rv
- (if filesets-menu-shortcuts-flag
- (substring y 2)
- y)))))
- (if (> (length rv)
- filesets-max-entry-length)
- (concat
- (substring rv 0 filesets-max-entry-length)
- " ...")
- rv)))
- ,@sl))))))))
- result))))
- (defun filesets-get-menu-epilog (something &optional
- mode lookup-name rebuild-flag)
- "Get submenu epilog for SOMETHING (usually a fileset).
- If mode is :tree or :ingroup, SOMETHING is some weird construct and
- LOOKUP-NAME is used as lookup name for retrieving fileset specific settings."
- (pcase mode
- (:tree
- `("---"
- ["Close all files" (filesets-close ',mode ',something ',lookup-name)]
- ["Run Command" (filesets-run-cmd nil ',something ',mode)]
- [,(format "Browse with `%s'" (filesets-browser-name))
- (filesets-browse-dir ',(car something))]
- ,@(when rebuild-flag
- `(["Rebuild this submenu"
- (filesets-rebuild-this-submenu ',lookup-name)]))))
- (:ingroup
- `("---"
- ["Close all files" (filesets-close ',mode ',something ',lookup-name)]
- ["Run Command" (filesets-run-cmd nil ',something ',mode)]
- ,@(when rebuild-flag
- `(["Rebuild this submenu"
- (filesets-rebuild-this-submenu ',lookup-name)]))))
- (:pattern
- `("---"
- ["Close all files" (filesets-close ',mode ',something)]
- ["Run Command" (filesets-run-cmd nil ',something ',mode)]
- [,(format "Browse with `%s'" (filesets-browser-name))
- ,(list 'filesets-browse-dir
- (filesets-entry-get-pattern--dir
- (filesets-entry-get-pattern
- (filesets-get-fileset-from-name something ':pattern))))]
- ; [,(concat (if filesets-menu-shortcuts-flag
- ; (concat "Con" filesets-menu-shortcuts-marker "vert")
- ; "Convert")
- ; " :pattern to :files")
- ; ,(list (function filesets-convert-patterns) something)]
- ,@(when rebuild-flag
- `(["Rebuild this submenu"
- (filesets-rebuild-this-submenu ',lookup-name)]))))
- (:files
- `("---"
- [,(concat "Close all files") (filesets-close ',mode ',something)]
- ["Run Command" (filesets-run-cmd nil ',something ',mode)]
- ["Add current buffer"
- (filesets-add-buffer ',something (current-buffer))]
- ["Remove current buffer"
- (filesets-remove-buffer ',something (current-buffer))]
- ,@(when rebuild-flag
- `(["Rebuild this submenu"
- (filesets-rebuild-this-submenu ',lookup-name)]))))
- (_
- (filesets-error 'error "Filesets: malformed definition of " something))))
- (defun filesets-ingroup-get-data (master pos &optional fun)
- "Access to `filesets-ingroup-patterns'. Extract data section."
- (let ((masterfile (file-name-nondirectory master))
- (fn (or fun (lambda (a b)
- (and (stringp a)
- (stringp b)
- (string-match-p a b))))))
- (filesets-some (lambda (x)
- (if (funcall fn (car x) masterfile)
- (nth pos x)
- nil))
- filesets-ingroup-patterns)))
- (defun filesets-ingroup-get-pattern (master)
- "Access to `filesets-ingroup-patterns'. Extract patterns."
- (filesets-ingroup-get-data master 2))
- (defun filesets-ingroup-get-remdupl-p (master)
- "Access to `filesets-ingroup-patterns'. Extract remove-duplicates-flag."
- (filesets-ingroup-get-data master 1))
- (defun filesets-ingroup-collect-finder (patt case-sensitivep)
- "Helper function for `filesets-ingroup-collect'. Find pattern PATT."
- (let ((cfs case-fold-search)
- (rv (progn
- (setq case-fold-search (not case-sensitivep))
- (re-search-forward patt nil t))))
- (setq case-fold-search cfs)
- rv))
- (defun filesets-ingroup-cache-get (master)
- "Access to `filesets-ingroup-cache'."
- (lax-plist-get filesets-ingroup-cache master))
- (defun filesets-ingroup-cache-put (master file)
- "Access to `filesets-ingroup-cache'."
- (let* ((emaster (expand-file-name master))
- (this (if file
- (cons file (filesets-ingroup-cache-get emaster))
- nil)))
- (setq filesets-ingroup-cache
- (lax-plist-put filesets-ingroup-cache emaster this))))
- (defun filesets-ingroup-collect-files (fs &optional remdupl-flag master depth)
- "Helper function for `filesets-ingroup-collect'. Collect file names."
- (let* ((master (or master
- (filesets-entry-get-master fs)))
- (remdupl-flag (or remdupl-flag
- (filesets-ingroup-get-remdupl-p master))))
- (filesets-ingroup-cache-put master nil)
- (filesets-message 2 "Filesets: parsing %S" master)
- (let ((cmdpatts (filesets-ingroup-get-pattern master))
- (count 0)
- (rv nil))
- (if cmdpatts
- (dolist (this-def cmdpatts rv)
- (let* ((this-patt (filesets-alist-get this-def ':pattern nil t))
- (this-name (filesets-alist-get this-def ':name "" t))
- (this-pp (filesets-alist-get this-def ':preprocess nil t))
- (this-mn (filesets-alist-get this-def ':match-number 1 t))
- (this-sd (or depth
- (filesets-alist-get this-def ':scan-depth 0 t)))
- (this-csp (filesets-alist-get this-def ':case-sensitive nil t))
- (this-fn (filesets-alist-get
- this-def ':get-file-name 'filesets-which-file t))
- (this-stubp (filesets-alist-get this-def ':stubp nil t))
- (this-stub-flag (filesets-alist-get this-def ':stub-flag nil t))
- (flist nil)
- (lst nil))
- (cond
- ((not this-patt)
- (filesets-error 'error "Filesets: malformed :ingroup definition "
- this-def))
- ((< this-sd 0)
- nil)
- (t
- (with-temp-buffer
- (insert-file-contents master)
- (goto-char (point-min))
- (when this-pp
- (funcall this-pp))
- (while (filesets-ingroup-collect-finder this-patt this-csp)
- (let* ((txt (match-string this-mn))
- (f (funcall this-fn master txt)))
- (when (and f
- (not (member f flist))
- (or (not remdupl-flag)
- (not (filesets-member
- f filesets-ingroup-files
- :test 'filesets-files-equalp))))
- (let ((no-stub-flag
- (and (not this-stub-flag)
- (if this-stubp
- (not (funcall this-stubp master f))
- t))))
- (setq count (+ count 1))
- (setq flist (cons f flist))
- (setq filesets-ingroup-files
- (cons f filesets-ingroup-files))
- (when no-stub-flag
- (filesets-ingroup-cache-put master f))
- (setq lst (append lst (list f))))))))
- (when lst
- (setq rv
- (nconc rv
- (mapcar (lambda (this)
- `((,this ,this-name)
- ,@(filesets-ingroup-collect-files
- fs remdupl-flag this
- (- this-sd 1))))
- lst))))))))
- (filesets-message 2 "Filesets: no patterns defined for %S" master)))))
- (defun filesets-ingroup-collect-build-menu (fs flist &optional other-count)
- "Helper function for `filesets-ingroup-collect'. Build the menu.
- FS is a fileset's name. FLIST is a list returned by
- `filesets-ingroup-collect-files'."
- (if (null flist)
- nil
- (let ((count 0)
- (fsn fs)
- (rv nil))
- (dolist (this flist rv)
- (setq count (+ count 1))
- (let* ((def (if (listp this) (car this) (list this "")))
- (files (if (listp this) (cdr this) nil))
- (master (nth 0 def))
- (name (nth 1 def))
- (nm (concat (filesets-get-shortcut (if (or (not other-count) files)
- count other-count))
- (if (or (null name) (equal name ""))
- ""
- (format "%s: " name))
- (file-name-nondirectory master))))
- (setq rv
- (append rv
- (if files
- `((,nm
- [,(concat "Inclusion Group: "
- (file-name-nondirectory master))
- (filesets-open ':ingroup ',master ',fsn)]
- "---"
- [,master (filesets-file-open nil ',master ',fsn)]
- "---"
- ,@(let ((count 0))
- (mapcar
- (lambda (this)
- (setq count (+ count 1))
- (let ((ff (filesets-ingroup-collect-build-menu
- fs (list this) count)))
- (if (= (length ff) 1)
- (car ff)
- ff)))
- files))
- ,@(filesets-get-menu-epilog master ':ingroup fsn)))
- `([,nm (filesets-file-open nil ',master ',fsn)])))))))))
- (defun filesets-ingroup-collect (fs remdupl-flag master)
- "Collect names of included files and build submenu."
- (filesets-ingroup-cache-put master nil)
- (filesets-message 2 "Filesets: parsing %S" master)
- (filesets-ingroup-collect-build-menu
- fs
- (filesets-ingroup-collect-files fs remdupl-flag master)))
- (defun filesets-build-ingroup-submenu (lookup-name master)
- "Build a :ingroup submenu for file MASTER."
- (if (file-readable-p master)
- (let ((remdupl-flag (filesets-ingroup-get-remdupl-p master)))
- (setq filesets-ingroup-files (list master))
- (filesets-ingroup-collect lookup-name remdupl-flag master))
- (if filesets-be-docile-flag
- (progn
- (message "Filesets: can't parse %s" master)
- nil)
- (filesets-error 'error "Filesets: can't parse " master))))
- (defun filesets-build-dir-submenu-now (level depth entry lookup-name dir patt fd
- &optional rebuild-flag)
- "Helper function for `filesets-build-dir-submenu'."
- ;;(filesets-message 3 "Filesets: scanning %s" dir)
- (if (or (= depth 0)
- (< level depth))
- (let* ((dir (file-name-as-directory dir))
- (header `([,(concat "Tree: "
- (if (= level 0)
- dir
- (concat ".../"
- (file-name-as-directory
- (file-name-nondirectory
- (directory-file-name dir))))))
- ,(list (function filesets-open)
- ':tree
- `(quote (,dir ,patt))
- lookup-name)]
- "---"))
- (dirlist (filesets-directory-files dir patt nil nil fd))
- (subdirs (filesets-filter-dir-names dirlist))
- (count 0)
- (dirsmenu (mapcar
- (lambda (x)
- (setq count (+ count 1))
- (let* ((x (file-name-as-directory x))
- (xx (concat dir x))
- (dd (filesets-build-dir-submenu-now
- (+ level 1) depth entry
- lookup-name xx patt fd))
- (nm (concat (filesets-get-shortcut count)
- x)))
- (if dd
- `(,nm ,@dd)
- `[,nm ,(list 'filesets-browse-dir xx)])))
- subdirs))
- (files (filesets-filter-dir-names dirlist t))
- (filesmenu (mapcar (lambda (x)
- (setq count (+ count 1))
- `[,(concat (filesets-get-shortcut count)
- x)
- (filesets-file-open nil
- (quote ,(concat dir x))
- (quote ,lookup-name))])
- files)))
- (append header
- (filesets-wrap-submenu
- (append
- dirsmenu
- filesmenu))
- (filesets-get-menu-epilog `(,dir ,patt) ':tree
- lookup-name rebuild-flag)))
- nil))
- (defun filesets-build-dir-submenu (entry lookup-name dir patt)
- "Build a :tree submenu named LOOKUP-NAME with base directory DIR including
- all files matching PATT for filesets ENTRY."
- (let ((fd (filesets-entry-get-filter-dirs-flag entry))
- (depth (or (filesets-entry-get-tree-max-level entry)
- filesets-tree-max-level)))
- (filesets-build-dir-submenu-now 0 depth entry lookup-name dir patt fd t)))
- (defun filesets-build-submenu (count lookup-name entry)
- "Build submenu for the fileset ENTRY named LOOKUP-NAME.
- Construct a shortcut from COUNT."
- (let ((lookup-name (or lookup-name
- (filesets-data-get-name entry))))
- (message "Filesets: %s" lookup-name)
- (let ((mode (filesets-entry-mode entry))
- (filesets-verbosity (filesets-entry-get-verbosity entry))
- (this-lookup-name (concat (filesets-get-shortcut count)
- lookup-name)))
- (pcase mode
- (:file
- (let* ((file (filesets-entry-get-file entry)))
- `[,this-lookup-name
- (filesets-file-open nil ',file ',lookup-name)]))
- (_
- `(,this-lookup-name
- ,@(pcase mode
- (:pattern
- (let* ((files (filesets-get-filelist entry mode 'on-ls))
- (dirpatt (filesets-entry-get-pattern entry))
- (pattname (apply 'concat (cons "Pattern: " dirpatt)))
- (count 0))
- ;;(filesets-message 3 "Filesets: scanning %S" pattname)
- `([,pattname
- ,(list (function filesets-open) mode lookup-name)]
- "---"
- ,@(filesets-wrap-submenu
- (mapcar
- (lambda (x)
- (setq count (+ count 1))
- `[,(concat (filesets-get-shortcut count)
- (file-name-nondirectory x))
- (filesets-file-open nil ',x ',lookup-name)])
- files))
- ,@(filesets-get-menu-epilog lookup-name mode
- lookup-name t))))
- (:ingroup
- (let* ((master (filesets-entry-get-master entry)))
- ;;(filesets-message 3 "Filesets: parsing %S" master)
- `([,(concat "Inclusion Group: "
- (file-name-nondirectory master))
- (filesets-open ',mode ',master ',lookup-name)]
- "---"
- [,master (filesets-file-open nil ',master ',lookup-name)]
- "---"
- ,@(filesets-wrap-submenu
- (filesets-build-ingroup-submenu lookup-name master))
- ,@(filesets-get-menu-epilog master mode lookup-name t))))
- (:tree
- (let* ((dirpatt (filesets-entry-get-tree entry))
- (dir (car dirpatt))
- (patt (cadr dirpatt)))
- (filesets-build-dir-submenu entry lookup-name dir patt)))
- (:files
- (let ((files (filesets-get-filelist entry mode 'on-open-all))
- (count 0))
- `([,(concat "Files: " lookup-name)
- (filesets-open ',mode ',lookup-name)]
- "---"
- ,@(filesets-wrap-submenu
- (mapcar
- (lambda (x)
- (setq count (+ count 1))
- `[,(concat (filesets-get-shortcut count)
- (file-name-nondirectory x))
- (filesets-file-open nil ',x ',lookup-name)])
- (filesets-conditional-sort
- files
- (function file-name-nondirectory))))
- ,@(filesets-get-menu-epilog lookup-name mode
- lookup-name t)))))))))))
- (defun filesets-remove-from-ubl (&optional buffer)
- "BUFFER or current buffer require update of the filesets menu."
- (let ((b (or buffer
- (current-buffer))))
- (if (member b filesets-updated-buffers)
- (setq filesets-updated-buffers
- (delete b filesets-updated-buffers)))))
- (defun filesets-build-menu-now (from-scratch-flag)
- "Update the filesets menu.
- Build all new if FROM-SCRATCH-FLAG is non-nil. (To really build from the
- bottom up, set `filesets-submenus' to nil, first.)"
- (when (or from-scratch-flag
- filesets-has-changed-flag
- (not filesets-menu-cache))
- (setq filesets-menu-cache nil)
- (setq filesets-has-changed-flag nil)
- (setq filesets-updated-buffers nil)
- (setq filesets-update-cache-file-flag t)
- (cl-do ((data (filesets-conditional-sort filesets-data (function car))
- (cdr data))
- (count 1 (+ count 1)))
- ((null data))
- (let* ((this (car data))
- (name (filesets-data-get-name this))
- (cached (lax-plist-get filesets-submenus name))
- (submenu (or cached
- (filesets-build-submenu count name this))))
- (unless cached
- (setq filesets-submenus
- (lax-plist-put filesets-submenus name submenu)))
- (unless (filesets-entry-get-dormant-flag this)
- (setq filesets-menu-cache
- (append filesets-menu-cache (list submenu))))))
- (when filesets-cache-save-often-flag
- (filesets-menu-cache-file-save-maybe)))
- (let ((cb (current-buffer)))
- (when (not (member cb filesets-updated-buffers))
- (add-submenu
- filesets-menu-path
- `(,filesets-menu-name
- ("# Filesets"
- ["Edit Filesets" filesets-edit]
- ["Save Filesets" filesets-save-config]
- ["Save Menu Cache" filesets-menu-cache-file-save]
- ["Rebuild Menu" filesets-build-menu]
- ["Customize" filesets-customize]
- ["About" filesets-info])
- ,(filesets-get-cmd-menu)
- "---"
- ,@filesets-menu-cache)
- filesets-menu-before
- filesets-menu-in-menu)
- (setq filesets-updated-buffers
- (cons cb filesets-updated-buffers))
- ;; This wipes out other messages in the echo area.
- ;; (message nil)
- ;;(message "Filesets updated: %s" cb)
- )))
- (defun filesets-build-menu-maybe ()
- "Update the filesets menu."
- (interactive)
- (filesets-build-menu-now nil))
- (defun filesets-build-menu ()
- "Force rebuild of the filesets menu."
- (interactive)
- ;(setq filesets-submenus nil)
- (filesets-reset-fileset)
- (filesets-build-menu-now t)
- (filesets-menu-cache-file-save-maybe))
- (defun filesets-rebuild-this-submenu (fileset)
- "Force rebuild of FILESET submenu."
- (filesets-reset-fileset fileset)
- (filesets-build-menu-now t))
- (defun filesets-menu-cache-file-save-maybe (&optional simply-do-it)
- "Write filesets' cache file.
- If SIMPLY-DO-IT is non-nil, the cache file will be written no matter if
- fileset thinks this is necessary or not."
- (when (and (not (equal filesets-menu-cache-file ""))
- (or simply-do-it
- filesets-update-cache-file-flag))
- (when (file-exists-p filesets-menu-cache-file)
- (delete-file filesets-menu-cache-file))
- ;;(message "Filesets: saving menu cache")
- (with-temp-buffer
- (dolist (this filesets-menu-cache-contents)
- (if (get this 'custom-type)
- (progn
- (insert (format "(setq-default %s '%S)" this (eval this)))
- (when filesets-menu-ensure-use-cached
- (newline)
- (insert (format "(setq %s (cons '%s %s))"
- 'filesets-ignore-next-set-default
- this
- 'filesets-ignore-next-set-default))))
- (insert (format "(setq %s '%S)" this (eval this))))
- (newline 2))
- (insert (format "(setq filesets-cache-version %S)" filesets-version))
- (newline 2)
- (when filesets-cache-hostname-flag
- (insert (format "(setq filesets-cache-hostname %S)" (system-name)))
- (newline 2))
- (run-hooks 'filesets-cache-fill-content-hook)
- (write-file filesets-menu-cache-file))
- (setq filesets-has-changed-flag nil)
- (setq filesets-update-cache-file-flag nil)))
- (defun filesets-menu-cache-file-save ()
- "Save filesets' menu cache file."
- (interactive)
- (filesets-menu-cache-file-save-maybe t))
- (defun filesets-update-cleanup ()
- "Rebuild the menu and save the cache file after updating user data."
- (interactive)
- (message "Filesets v%s: updating menu & cache from version %s"
- filesets-version (or filesets-cache-version "???"))
- (filesets-build-menu)
- (filesets-menu-cache-file-save-maybe)
- (filesets-menu-cache-file-load))
- (defun filesets-update-pre010505 ()
- (let ((msg (format-message
- "Filesets: manual editing of user data required!
- Filesets has detected that you were using an older version before,
- which requires some manual updating. Type ‘y’ for editing the startup
- file now.
- The layout of ‘filesets-data’ has changed. Please delete your cache file
- and edit your startup file as shown below:
- 1. ‘filesets-data’: Edit all :pattern filesets in your startup file and
- transform all entries as shown in this example:
- \(\"Test\" (:pattern \"~/dir/^pattern$\"))
- --> \(\"Test\" (:pattern \"~/dir/\" \"^pattern$\"))
- 2. ‘filesets-data’: Change all occurrences of \":document\" to \":ingroup\":
- \(\(\"Test\" \(:document \"~/dir/file\"))
- --> \(\(\"Test\" \(:ingroup \"~/dir/file\"))
- 3. ‘filesets-subdocument-patterns’: If you already modified the variable
- previously called ‘filesets-subdocument-patterns’, change its name to
- ‘filesets-ingroup-patterns’.
- 4. ‘filesets-menu-cache-contents’: If you already modified this
- variable, change the entry ‘filesets-subdocument--cache’ to
- ‘filesets-ingroup-cache’.
- 5. Type M-x filesets-update-cleanup and restart Emacs.
- We apologize for the inconvenience.")))
- (let* ((cf (or custom-file user-init-file)))
- (switch-to-buffer-other-frame "*Filesets update*")
- (insert msg)
- (when (y-or-n-p (format "Edit startup (%s) file now? " cf))
- (find-file-other-window cf))
- (filesets-error 'error msg))))
- (defun filesets-update (cached-version)
- "Do some cleanup after updating filesets.el."
- (cond
- ((or (not cached-version)
- (string< cached-version "1.5.5")
- (boundp 'filesets-subdocument-patterns))
- (filesets-update-pre010505)))
- (filesets-update-cleanup))
- (defun filesets-menu-cache-file-load ()
- "Load filesets' menu cache file."
- (cond
- ((and (not (equal filesets-menu-cache-file ""))
- (file-readable-p filesets-menu-cache-file))
- (load-file filesets-menu-cache-file)
- (if (and (equal filesets-cache-version filesets-version)
- (if filesets-cache-hostname-flag
- (equal filesets-cache-hostname (system-name))
- t))
- (progn
- (setq filesets-update-cache-file-flag nil)
- t)
- (filesets-update filesets-cache-version)))
- (t
- (setq filesets-update-cache-file-flag t)
- nil)))
- (defun filesets-exit ()
- (filesets-menu-cache-file-save-maybe))
- ;;;###autoload
- (defun filesets-init ()
- "Filesets initialization.
- Set up hooks, load the cache file -- if existing -- and build the menu."
- (add-hook (if (featurep 'xemacs) 'activate-menubar-hook 'menu-bar-update-hook)
- (function filesets-build-menu-maybe))
- (add-hook 'kill-buffer-hook (function filesets-remove-from-ubl))
- (add-hook 'first-change-hook (function filesets-reset-filename-on-change))
- (add-hook 'kill-emacs-hook (function filesets-exit))
- (if (filesets-menu-cache-file-load)
- (progn
- (filesets-build-menu-maybe)
- ;;Well, normally when we use XEmacs <= 21.4, custom.el is loaded
- ;;after init.el. This more or less ignores the next
- ;;`filesets-data-set-default'
- (if filesets-menu-ensure-use-cached
- (setq filesets-menu-use-cached-flag t)))
- (filesets-build-menu)))
- (provide 'filesets)
- ;; Local Variables:
- ;; sentence-end-double-space:t
- ;; End:
- ;;; filesets.el ends here
|