quilt-el-0.48.0/0000755000175000017500000000000011612547305011503 5ustar satsatquilt-el-0.48.0/Makefile0000644000175000017500000000075111612547305013146 0ustar satsatVERSION := 0.48.0 RELEASE_FILES := quilt.el COPYING README changelog Makefile RELEASEDIR_NAME := quilt-el-$(VERSION) ARCHIVE_NAME := $(RELEASEDIR_NAME).tar.gz default: clean: rm -rf *~ patches/*~ $(RELEASEDIR_NAME) $(ARCHIVE_NAME) release: clean mkdir $(RELEASEDIR_NAME) cp -r $(RELEASE_FILES) $(RELEASEDIR_NAME) tar zcf $(ARCHIVE_NAME) $(RELEASEDIR_NAME) md5sum $(ARCHIVE_NAME) >$(ARCHIVE_NAME).md5sum mv $(ARCHIVE_NAME) $(ARCHIVE_NAME).md5sum ../ .PHONY: default clean release quilt-el-0.48.0/README0000644000175000017500000000133311612547305012363 0ustar satsatIntroduction ============ quilt-el minor mode is toggled by `M-x quilt-mode'. It provides following features: - You can issue many quilt sub-commands by shortcut keys. By using these keys, quilt-el can also detect moving the patch stack and can refresh corresponding buffers automatically. - If a buffer is associated with the file which is not included in the topmost patch, the buffer becomes read-only. So you can avoid editing wrong files accidentally. - After quilt-el is once enabled, all files which you open are checked whether it is in a quilt hierarchy or not. If so, corresponding buffer becomes quilt-mode automatically. -- Satoru Takeuchi , Sun, 14 Jan 2007 23:57:29 +0900 quilt-el-0.48.0/changelog0000644000175000017500000000562611612547305013366 0ustar satsatquilt-el (0.48.0) * conform to upstream version 0.48 * make it checkdoc clean * make it byte-compile clean * change upstream URL. -- Satoru Takeuchi Sat, 23 Jul 2011 22:37:51 +0900 quilt-el (0.46.2) * fix bad file permissions * remove unnecessary files on patches/ * clean patches directory on `make clean' -- Satoru Takeuchi Fri, 03 Jul 2009 15:34:40 +0900 quilt-el (0.46.1) * honor quilt patches directory * return to cd if shell command is failure * fix colliding name space by nested function * introduce quilt-cmd-to-list * support multiple quilt tree -- Satoru Takeuchi Mon, 22 Jun 2009 20:13:57 +0900 quilt-el (0.45.5) * simplify quilt-revert * fix quilt-dir if default directory is nil * optimize quilt-revert * change maintainer's email address -- Satoru Takeuchi Thu, 28 Feb 2008 23:27:45 +0900 quilt-el (0.45.4) * fixing import subcommand * fixing no patch cases * fixing QUILT_PATCHES_PREFIX variable * moving quilt-mode-line definition quilt-el (0.45.3) * support editing patch header * replace unnecesary `let*' to `let' * simplify push and pop code * change default quilt-edit-series keybind from `C-c . s' to `C-c . S' * support series subcommand * fixing the following edit-patch bugs - Show strange message between `new' and `refresh' subcommands - Opened patch file read-only -- Satoru Takeuchi Sat, 14 Apr 2007 18:52:55 +0900 quilt-el (0.45.2) * support header subcommand * support delete subcommand -- Satoru Takeuchi Sat, 31 Mar 2007 01:36:11 +0900 quilt-el (0.45.1) * handle some special cases and put some error messages as followings. 1. Take into consideration the special cases as described below. - quilt tree is existed, but no patche is applied. - no files in the topmost patch - user inputs null string.on quilt-new() and quilt-find-file() - current buffer is not associated with any existed file 2. When error has occured, print suitable messages instead of just quiting. handle some special cases and put some error messages. * follow emacs minormode keybind convention. * fix modeline update on reverting buffers. * fix quilt-edit-series on buffers which are not associated with any files. * add this changelog and README. -- Satoru Takeuchi Sun, 14 Jan 2007 23:54:07 +0900 quilt-el (0.45) * Satoru Takeuchi took over this package from Matt Mackall. This version is based on Matt's mercurial tree by issuing following command. hg clone -r 9 http://www.selenic.com/repo/quilt-el quilt-el -- Satoru Takeuchi Sun, 14 Jan 2007 23:32:43 +0900 quilt-el (0.4) * initial release. -- Matt Mackall Mon, 31 Jan 2005 20:42:37 -0800 quilt-el-0.48.0/COPYING0000644000175000017500000004311011612547305012535 0ustar satsat GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. quilt-el-0.48.0/quilt.el0000644000175000017500000004320611612547305013170 0ustar satsat;;; quilt.el --- a minor mode for working with files in quilt ;; Copyright 2005-2007 Matt Mackall ;; Satoru Takeuchi took over this package ;; from Matt Mackall. ;; Author: Saotru takeuchi ;; Version: 0.48.0 ;; URL: http://satoru-takeuchi.org/dev/quilt-el ;; ;; This software may be used and distributed according to the terms ;; of the GNU General Public License, incorporated herein by reference. ;;; Commentary: ;; ;; Add (load "~/quilt.el") to your .emacs file ;;; History: ;; ;;; Code: (defun quilt-buffer-file-name-safe () "Return buffer file name. If buffer is not associated with any file, return nil." (let ((fn buffer-file-name)) (if (and fn (file-exists-p fn)) fn))) (defun quilt-bottom-p () "Return t if there is on the bottom of patch stack, return nil if otherwise." (if (> (call-process "quilt" nil nil nil "applied") 0) 1)) (defun quilt-patches-directory () "Return the location of patch files." (or (with-current-buffer (generate-new-buffer " *cmd") (shell-command (concat "test -f ~/.quiltrc && . ~/.quiltrc ;" "echo -n $QUILT_PATCHES") t) (unwind-protect (let ((v (buffer-string))) (if (string= "" (buffer-string)) nil v)) (kill-buffer (current-buffer)))) (or (getenv "QUILT_PATCHES") "patches"))) (defun quilt-find-dir (fn) "Return the top level dir of quilt from FN." (if (or (not fn) (equal fn "/")) nil (let ((d (file-name-directory fn))) (if (file-accessible-directory-p (concat d "/.pc")) d (quilt-find-dir (directory-file-name d)))))) (defun quilt-dir (&optional fn) "Return the top level dir of quilt from FN. FN is just a hint and find from other way if FN is nil." (quilt-find-dir (if fn fn (let ((fn2 (quilt-buffer-file-name-safe))) (if fn2 fn2 (if default-directory (expand-file-name default-directory))))))) (defun quilt-drop-dir (fn) "Return the relative path of FN based on quilt top directory." (let ((d (quilt-find-dir fn))) (substring fn (length d) (length fn)))) (defun quilt-p (&optional fn) "Check if FN is in a quilt tree." (if (quilt-dir fn) 't nil)) (defun quilt-save () "Save all buffers associated with current quilt tree." (save-some-buffers nil 'quilt-p)) (defun quilt-owned-p (fn) "Check if FN is a file which quilt handles." (if (not fn) nil (let ((pd (file-name-nondirectory (directory-file-name (file-name-directory fn))))) (and (not (string-match "\\(~$\\|\\.rej$\\)" fn)) (not (equal pd (quilt-patches-directory))) (not (equal pd ".pc")) (quilt-p fn))))) (defun quilt-cmd (cmd &optional buf) "Execute CMD, a quilt subcommand, at the top of quilt tree associated with BUF." (let ((d default-directory) (qd (quilt-dir))) (if (not qd) (shell-command (concat "quilt " cmd) buf) (cd qd) (unwind-protect ; make sure to cd back even if an erro occurs. (shell-command (concat "quilt " cmd) buf) (cd d))))) (defun quilt-cmd-to-string (cmd) "Execute CMD, a quilt subcommand, at the top of quilt tree associated with BUF and return its output string." (let ((d default-directory) (qd (quilt-dir))) (if (not qd) nil (cd qd) (unwind-protect ; make sure to cd back even if an error occurs. (shell-command-to-string (concat "quilt " cmd)) (cd d))))) (defun quilt-cmd-to-list (cmd) "Execute CMD, a quilt sumcommand at the top of quilt tree associated with BUF.." "Return the lines of the command output as elements of a list." (let ((s (quilt-cmd-to-string cmd))) (if s (split-string s "\n" t)))) (defun quilt-applied-list () "Return the list of the applied patch names." (quilt-cmd-to-list "applied")) (defun quilt-file-list () "Return the list of the file names associated with current patch." (quilt-cmd-to-list "files")) (defun quilt-patch-list () "Return the list of the name of patches." (quilt-cmd-to-list "patches")) (defun quilt-files-affected (&optional first last) "Return the file names which modified from FIRST to LAST." "Omitted args are considered as current patch." (let ((qd (quilt-dir)) files fp) (when qd (setq files (quilt-cmd-to-list (if last (if (equal first last) (concat "files " first) (concat "files --combine " first last)) (if first (concat "files --combine " first) "files")))) (setq fp files) (while fp (setcar fp (concat qd (car fp))) (setq fp (cdr fp))) files))) (defun quilt-top-patch () "Return the top patch name. return nil if there is the bottom of patch stack." (if (quilt-bottom-p) nil (file-name-nondirectory (substring (quilt-cmd-to-string "top") 0 -1)))) (defun quilt-complete-list (p l) "Call 'completing-read' with prompt P and list L." "Convert L to an alist using indices as keys. Note that this function modifies L." (let ((list l) (n 0)) (while list (setcar list (cons (car list) n)) (setq list (cdr list)) (setq n (1+ n)))) (completing-read p l nil t)) (defun quilt-editable (f) "Return t if F is editable in terms of current patch. Return nil if otherwise." (let ((qd (quilt-dir)) (fn (quilt-drop-dir f)) dirs result) (if qd (if (quilt-bottom-p) (quilt-cmd "applied") ; to print error message (setq dirs (if quilt-edit-top-only (list (quilt-top-patch)) (cdr (cdr (directory-files (concat qd ".pc/")))))) (while (and (not result) dirs) (if (file-exists-p (concat qd ".pc/" (car dirs) "/" fn)) (setq result t) (setq dirs (cdr dirs)))) result)))) (defun quilt-short-patchname () "Return shortened name of top patch. Return nil if there is on the bottom of patch stack." (let ((p (quilt-top-patch))) (if (not p) "none" (let ((p2 (file-name-sans-extension p))) (if (< (length p2) 10) p2 (concat (substring p2 0 8) "..")))))) (defvar quilt-mode-line nil) (make-variable-buffer-local 'quilt-mode-line) (defun quilt-update-modeline () "Update mode line." (interactive) (setq quilt-mode-line (concat " Q:" (quilt-short-patchname))) (force-mode-line-update)) (defun quilt-revert (filelist) "Refresh contents, editability and modeline of FILESIT. FILELIST won't be touched unless their file is a child of the current quilt directory. Each elements in FILELIST should be the absolute file names of those files affected by the latest quilt operation. Associated buffers get reverted to update their contents. Other buffers will only get their modeline and editability adjusted." (let ((qd (quilt-dir)) fn) (dolist (buf (buffer-list)) (if (not (string-match "^ " (buffer-name buf))) (with-current-buffer buf (setq fn (quilt-buffer-file-name-safe)) (when (string-equal qd (quilt-dir)) (quilt-update-modeline) (when (and (not (buffer-modified-p)) (quilt-owned-p fn)) ;; If the file doesn't exist on disk it can't be reverted, but we ;; need the revert hooks to run anyway so that the buffer's ;; editability will update. Files not affected by the latest change ;; (as listed in filelist) don't need to get reverted either. (if (and (file-exists-p buffer-file-name) (member fn filelist)) (progn (revert-buffer t t t)) (run-hooks 'after-revert-hook))))))))) (defun quilt-push (arg) "Push next patch. It is forced if ARG is specified." (interactive "P") (quilt-save) (if arg (quilt-cmd "push -f" "*quilt*") (quilt-cmd "push -q")) (quilt-revert (quilt-files-affected))) (defun quilt-pop (arg) "Pop top patch. It is forced if ARG is specified." (interactive "P") (quilt-save) (if arg (quilt-cmd "pop -f") (quilt-cmd "pop -q")) (quilt-revert (quilt-files-affected))) (defun quilt-push-all (arg) "Push all remaining patches. It is forced if ARG is specified." (interactive "P") (quilt-save) (let ((next (car (quilt-cmd-to-list "next")))) (if arg (quilt-cmd "push -f" "*quilt*") (quilt-cmd "push -qa")) (quilt-revert (quilt-files-affected next)))) (defun quilt-pop-all (arg) "Pop all applied patches. It is forced if ARG is specified." (interactive "P") (quilt-save) (let ((fa (quilt-files-affected "-"))) (if arg (quilt-cmd "pop -af") (quilt-cmd "pop -qa")) (quilt-revert fa))) (defun quilt-goto () "Go to a specified patch." (interactive) (let ((qd (quilt-dir))) (if (not qd) (quilt-cmd "push") ; to print error message (let ((arg (quilt-complete-list "Goto patch: " (quilt-patch-list)))) (if (string-equal arg "") (message "no patch name is supplied") (quilt-save) (let (cmd first last) (if (file-exists-p (concat qd ".pc/" arg)) (progn (setq cmd "pop") (setq first (car (quilt-cmd-to-list (concat "next " arg)))) (setq last (quilt-top-patch))) (setq cmd "push") (setq last arg) (setq first (if (quilt-bottom-p) "-" (car (quilt-cmd-to-list "next"))))) (quilt-cmd (concat cmd " -q " arg) "*quilt*") (quilt-revert (quilt-files-affected first last)))))))) (defun quilt-top () "Display topmost patch." (interactive) (quilt-cmd "top")) (defun quilt-find-file () "Find a file in the topmost patch." (interactive) (let ((qd (quilt-dir))) (if (not qd) (quilt-cmd "push") ; to print error message (if (quilt-bottom-p) (quilt-cmd "applied") ; to print error message (let ((l (quilt-file-list))) (if (not l) (message "no file is existed in this patch") (let ((f (quilt-complete-list "File: " l))) (if (string-equal f "") (message "file name is not specified") (find-file (concat qd f)))))))))) (defun quilt-files () "Display files in topmost patch." (interactive) (quilt-cmd "files")) (defun quilt-import (fn pn) "Import external patch FN as PN.patch." (interactive "fPatch to import: \nsPatch name: ") (if (not pn) (message "no patch name supplied") (quilt-cmd (concat "import -p " pn ".patch " (if fn fn pn))))) (defun quilt-diff () "Display the diff of current change." (interactive) (quilt-save) (quilt-cmd "diff" "*diff*")) (defun quilt-new (f) "Create a new patch F.patch." (interactive "sPatch name: ") (if (string-equal f "") (message "no patch name is supplied") (quilt-save) (quilt-cmd (concat "new " f ".patch")) (quilt-revert nil))) (defun quilt-applied () "Show applied patches." (interactive) (quilt-cmd "applied" "*quilt*")) (defun quilt-add (arg) "Add ARG to the current patch." (interactive "b") (with-current-buffer arg (let ((fn (quilt-buffer-file-name-safe))) (cond ((not fn) (message "buffer %s is not associated with any buffer" (buffer-name))) ((not (quilt-dir)) (quilt-cmd (concat "push"))) ; to print error message (t (quilt-cmd (concat "add " (quilt-drop-dir fn))) (quilt-revert (list fn))))))) (defun quilt-edit-patch () "Edit the topmost patch." (interactive) (let ((qd (quilt-dir))) (if (not qd) (quilt-cmd "push") ; to print error message (let ((patch (quilt-top-patch))) (if (not patch) (quilt-cmd "applied") ; to print error message (quilt-save) (let ((pf (concat qd (format "/%s/" (quilt-patches-directory)) patch))) (if (file-exists-p pf) (progn (find-file pf) (toggle-read-only)) (message (format "%s doesn't exist yet." pf))))))))) (defun quilt-patches () "Show which patches modify the current buffer." (interactive) (let ((fn (quilt-buffer-file-name-safe))) (cond ((not fn) (message "buffer %s is not associated with any buffer" (buffer-name))) ((not (quilt-dir)) (quilt-cmd "push")) ; to print error message (t (quilt-cmd (concat "patches " (quilt-drop-dir fn))))))) (defun quilt-unapplied () "Display unapplied patch list." (interactive) (quilt-cmd "unapplied" "*quilt*")) (defun quilt-refresh () "Refresh the current patch." (interactive) (quilt-save) (quilt-cmd "refresh")) (defun quilt-remove () "Remove a file from the current patch and revert it." (interactive) (let ((f (quilt-buffer-file-name-safe))) (cond ((not f) (message "buffer %s is not associated with any patch" (buffer-name))) ((not (quilt-dir)) (quilt-cmd "push")) ; to print error message (t (if (quilt-bottom-p) (quilt-cmd "applied") ; to print error message (let ((dropped (quilt-drop-dir f))) (if (y-or-n-p (format "Really drop %s? " dropped)) (progn (quilt-cmd (concat "remove " dropped)) (quilt-revert (list f)))))))))) (defun quilt-edit-series () "Edit the patch series file." (interactive) (let ((qd (quilt-dir))) (if (not qd) (quilt-cmd "push") ; to print error message (let ((series (concat qd (format "/%s/series" (quilt-patches-directory))))) (if (file-exists-p series) (find-file series) (message (quilt-top-patch))))))) (defun quilt-header (arg) "Print the header of ARG." (interactive "P") (let ((qd (quilt-dir))) (if (not qd) (quilt-cmd "push") ; to print error message (if (not arg) (quilt-cmd "header") (let ((p (quilt-complete-list "Patch: " (quilt-patch-list)))) (if (string-equal p "") (message "no patch name is supplied") (quilt-cmd (concat "header " p)))))))) (defun quilt-delete (arg) "Delete ARG from the series file." (interactive "P") (let ((qd (quilt-dir))) (if (not qd) (quilt-cmd "push") ; to print error message (let ((p (if arg (quilt-complete-list "Delete patch: " (quilt-patch-list)) (quilt-top-patch)))) (if (string-equal p "") (message "no patch name is supplied") (if (not p) (quilt-cmd "applied") ; to print error message (if (y-or-n-p (format "Really delete %s? " p)) (let ((fa (quilt-files-affected p p))) (quilt-save) (quilt-cmd (concat "delete " p)) (quilt-revert fa))))))))) (defvar quilt-header-directory nil) (defun quilt-header-commit () "Commit to change patch header." (interactive) (let ((tmp (make-temp-file "quilt-header-"))) (set-visited-file-name tmp) (basic-save-buffer) (cd quilt-header-directory) (shell-command (concat "EDITOR=cat quilt -r header <" tmp)) (kill-buffer (current-buffer)) (delete-file tmp))) (defvar quilt-header-mode-map (make-keymap)) (define-key quilt-header-mode-map "\C-c\C-c" 'quilt-header-commit) (defun quilt-edit-header (arg) "Edit the header of ARG." (interactive "P") (let ((qd (quilt-dir))) (if (not qd) (quilt-cmd "push") ; to print error message (let ((p (if arg (quilt-complete-list "Edit patch: " (quilt-patch-list)) (quilt-top-patch)))) (if (string-equal p "") (message "no patch name is supplied") (if (not p) (quilt-cmd "applied") ; to print error message (let ((qb (get-buffer-create (format " *quilt-header(%s)*" p)))) (switch-to-buffer-other-window qb) (erase-buffer) (kill-all-local-variables) (make-local-variable 'quilt-header-directory) (setq quilt-header-directory default-directory) (use-local-map quilt-header-mode-map) (setq major-mode 'quilt-header-mode) (call-process "quilt" nil qb nil "header" p) (goto-char 0)))))))) (defun quilt-series (arg) "Show patche series. It can be verbose mode if ARG is specified." (interactive "P") (if arg (quilt-cmd "series -v") (quilt-cmd "series"))) (defvar quilt-mode-map (make-sparse-keymap)) (define-key quilt-mode-map "\C-c.t" 'quilt-top) (define-key quilt-mode-map "\C-c.f" 'quilt-find-file) (define-key quilt-mode-map "\C-c.F" 'quilt-files) (define-key quilt-mode-map "\C-c.d" 'quilt-diff) (define-key quilt-mode-map "\C-c.p" 'quilt-push) (define-key quilt-mode-map "\C-c.o" 'quilt-pop) (define-key quilt-mode-map "\C-c.P" 'quilt-push-all) (define-key quilt-mode-map "\C-c.O" 'quilt-pop-all) (define-key quilt-mode-map "\C-c.g" 'quilt-goto) (define-key quilt-mode-map "\C-c.A" 'quilt-applied) (define-key quilt-mode-map "\C-c.n" 'quilt-new) (define-key quilt-mode-map "\C-c.i" 'quilt-import) (define-key quilt-mode-map "\C-c.a" 'quilt-add) (define-key quilt-mode-map "\C-c.e" 'quilt-edit-patch) (define-key quilt-mode-map "\C-c.m" 'quilt-patches) (define-key quilt-mode-map "\C-c.u" 'quilt-unapplied) (define-key quilt-mode-map "\C-c.r" 'quilt-refresh) (define-key quilt-mode-map "\C-c.R" 'quilt-remove) (define-key quilt-mode-map "\C-c.s" 'quilt-series) (define-key quilt-mode-map "\C-c.S" 'quilt-edit-series) (define-key quilt-mode-map "\C-c.h" 'quilt-header) (define-key quilt-mode-map "\C-c.H" 'quilt-edit-header) (define-key quilt-mode-map "\C-c.D" 'quilt-delete) (defvar quilt-mode nil) (make-variable-buffer-local 'quilt-mode) (defvar quilt-edit-top-only 't) (defun quilt-mode (&optional arg) "Toggle 'quilt-mode'. Enable 'quilt-mode' if ARG is positive. \\{quilt-mode-map}" (interactive "P") (setq quilt-mode (if (null arg) (not quilt-mode) (> (prefix-numeric-value arg) 0))) (if quilt-mode (let ((f (quilt-buffer-file-name-safe))) (if (quilt-owned-p f) (if (not (quilt-editable f)) (toggle-read-only 1) (toggle-read-only 0))) (quilt-update-modeline)))) (defun quilt-hook () "Enable quilt mode for quilt-controlled files." (if (quilt-p) (quilt-mode 1))) (add-hook 'find-file-hooks 'quilt-hook) (add-hook 'after-revert-hook 'quilt-hook) (or (assq 'quilt-mode minor-mode-alist) (setq minor-mode-alist (cons '(quilt-mode quilt-mode-line) minor-mode-alist))) (or (assq 'quilt-mode-map minor-mode-map-alist) (setq minor-mode-map-alist (cons (cons 'quilt-mode quilt-mode-map) minor-mode-map-alist))) (provide 'quilt) ;;; quilt.el ends here