From 19853445e669052da5ae27ef784fdac4ce0eefbe Mon Sep 17 00:00:00 2001 From: Jonas Bernoulli Date: Sun, 14 Oct 2018 15:53:36 +0200 Subject: fix indentation and remove excessive whitespace --- apt-sources.el | 128 ++++++++++++++++++++++----------------------------------- 1 file changed, 50 insertions(+), 78 deletions(-) (limited to 'apt-sources.el') diff --git a/apt-sources.el b/apt-sources.el index e6458f2..bb36e40 100644 --- a/apt-sources.el +++ b/apt-sources.el @@ -12,18 +12,18 @@ ;; Copyright (C) 2001-2003, Dr. Rafael Sepúlveda ;; Copyright (C) 2009 Peter S. Galbraith -;; 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. +;; 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. -;; 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. +;; 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. +;; 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. ;;; Commentary: @@ -180,7 +180,6 @@ inserted." "\\([^ ]+\\)" "A regexp that matches the distribution name part of the source line.") - (defvar apt-sources-font-lock-keywords (list ;; Comments @@ -254,8 +253,6 @@ inserted." (define-key map [menu-bar apt-sources new-source] '("Add new source" . apt-sources-new-source)))) - - ;;;###autoload (defun apt-sources-mode () "Major mode for editing apt's sources.list file. @@ -263,23 +260,17 @@ Sets up command `font-lock-mode'. \\{apt-sources-mode-map}" (interactive) - ;; (kill-all-local-variables) (setq mode-name "apt-sources") (setq major-mode 'apt-sources-mode) (use-local-map apt-sources-mode-map) - ;; (set (make-local-variable 'comment-start) "#") (set (make-local-variable 'comment-start-skip) "#+ *") (set-syntax-table apt-sources-mode-syntax-table) - ;; (make-local-variable 'font-lock-defaults) (setq font-lock-defaults '(apt-sources-font-lock-keywords)) - ;; (run-hooks 'apt-sources-mode-hook)) - - (defun apt-sources-new-source (name) "Insert interactively a new source line into the current buffer. This will insert a new source in the current line. @@ -290,20 +281,19 @@ NAME is the name you want to this source line; it will be a comment. You should read sources.list documentation for further explanation of the format." (interactive "*sName of new source: ") - (let ((source-type (completing-read "Source type: " '(("deb" 1) ("deb-src" 2)) nil t)) (uri-type (completing-read "URI type: " ;type used to retrieve the URI, like http, ftp, etc. - '(("cdrom:/" 1) - ("copy://" 2) - ("file://" 3) - ("ftp://" 4) - ("http://" 5) - ("https://" 6) - ("rsh://" 7) - ("ssh://" 8)) nil t)) + '(("cdrom:/" 1) + ("copy://" 2) + ("file://" 3) + ("ftp://" 4) + ("http://" 5) + ("https://" 6) + ("rsh://" 7) + ("ssh://" 8)) nil t)) (uri-address (read-from-minibuffer "URI address: ")) ;URI that will be used to specify the base - ;of the Debian distribution, from which APT - ;will find the information it needs. + ;of the Debian distribution, from which APT + ;will find the information it needs. (distribution (completing-read "Distribution: " ;specific arquitecture or an exact path. '(("unstable" 1) ("testing" 2) @@ -321,21 +311,19 @@ of the format." ("contrib non-free") ("non-free")))) (blank-line (if apt-sources-around-lines "\n" ""))) - (save-excursion (beginning-of-line) - (insert blank-line) ;insert line if `apt-sources-around-lines' + (insert blank-line) ; insert line if `apt-sources-around-lines' (and (< 0 (length name)) (insert (format apt-sources-source-name name))) - (insert ;insert rest of arguments except components + (insert ; insert rest of arguments except components (format "%s %s%s %s" source-type uri-type uri-address distribution)) - ;if `distribution' ends in '/', then don't process components. + ;; if `distribution' ends in '/', then don't process components. (if (string-match "/$" distribution) distribution (insert " " components) - (insert blank-line))))) ;insert line if `apt-sources-around-lines' - + (insert blank-line))))) ; insert line if `apt-sources-around-lines' (defun apt-sources-around-lines () "Toggle insertion of newlines around a future creation of source lines. @@ -345,7 +333,6 @@ This modifies the state of variable `apt-sources-around-lines'." (message "Surrounding blank lines %s" (if apt-sources-around-lines "On" "Off"))) - (defun apt-sources-insert-local-vars () "Insert the current values of buffer local variables." (interactive) @@ -357,7 +344,6 @@ This modifies the state of variable `apt-sources-around-lines'." comment-start " mode: " (format "%s\n" (or mode-name "apt-sources")) comment-start " End:\n")) - (defun apt-sources-next-source-line (arg) "Go to the next source line. @@ -372,14 +358,12 @@ ARG is the prefix argument." '("^\\(deb \\|deb-src \\)" nil)) (beginning-of-line)))) - (defun apt-sources-previous-source-line () "Go to the previous source line." (interactive) (apt-sources-next-source-line -1)) - -;;Modifying functions +;; Modifying functions (defun apt-sources-source-line-p () "Return t if we are in an apt source line." (save-excursion @@ -389,45 +373,42 @@ ARG is the prefix argument." (message "Not in a source line!") nil))) ;return nil if we aren't in an apt source line - (defun apt-sources-change-source-type () "Change the type of the source line. TYPE is either 'd' or 's' to change the type to 'deb' or 'deb-src'. This function will rise an error if we are not in a source line." (interactive) - (and (apt-sources-source-line-p) - ;type used to retrieve the URI, like http, ftp, etc. - (let ((new-type (completing-read "'deb' or 'deb-src': " '(("deb" 1) ("deb-src" 2)) nil t))) - (save-excursion - (beginning-of-line) - (delete-region (point) (re-search-forward "^deb[^ ]*" (line-end-position) nil 1)) - (insert new-type))))) - + (and (apt-sources-source-line-p) + ;; type used to retrieve the URI, like http, ftp, etc. + (let ((new-type (completing-read "'deb' or 'deb-src': " '(("deb" 1) ("deb-src" 2)) nil t))) + (save-excursion + (beginning-of-line) + (delete-region (point) (re-search-forward "^deb[^ ]*" (line-end-position) nil 1)) + (insert new-type))))) (defun apt-sources-change-uri-type () "Change the URI type of the source line. This function will rise an error if we are not in a source line." (interactive) - (and (apt-sources-source-line-p) - (let ((uri-type (completing-read "URI type: " ;type used to retrieve the URI, like http, ftp, etc. - '(("cdrom:/" 1) - ("copy://" 2) - ("file://" 3) - ("ftp://" 4) - ("http://" 5) - ("https://" 6) - ("rsh://" 7) - ("ssh://" 8)) nil t))) + ;; type used to retrieve the URI, like http, ftp, etc. + (let ((uri-type (completing-read "URI type: " + '(("cdrom:/" 1) + ("copy://" 2) + ("file://" 3) + ("ftp://" 4) + ("http://" 5) + ("https://" 6) + ("rsh://" 7) + ("ssh://" 8)) nil t))) (save-excursion (beginning-of-line) (delete-region (re-search-forward "^deb[^ ]*." (line-end-position) nil 1) (re-search-forward ":/*" (line-end-position) nil 1)) (insert uri-type))))) - (defun apt-sources-change-uri-address (uri-address) "Change the URI address of the source line. String URI-ADDRESS is the address (without the type of address, @@ -435,21 +416,18 @@ ex: 'http://'). This function will rise an error if we are not in a source line." (interactive "sURI address: ") - - (and (apt-sources-source-line-p) - (save-excursion - (beginning-of-line) - (delete-region (re-search-forward ":/*" (line-end-position) nil 1) - (re-search-forward "[^ ]*" (line-end-position) nil 1)) - (insert uri-address)))) - + (and (apt-sources-source-line-p) + (save-excursion + (beginning-of-line) + (delete-region (re-search-forward ":/*" (line-end-position) nil 1) + (re-search-forward "[^ ]*" (line-end-position) nil 1)) + (insert uri-address)))) (defun apt-sources-change-distribution () "Change the distribution of the source line. This function will rise an error if we are not in a source line." (interactive) - (and (apt-sources-source-line-p) (let ((distribution (completing-read "Distribution: " ;specific arquitecture or an exact path. '(("unstable" 1) @@ -466,13 +444,11 @@ This function will rise an error if we are not in a source line." (re-search-forward "[^ ]*" (line-end-position) t 1)) (insert distribution))))) - (defun apt-sources-change-components () "Change the components of the source line. This function will rise an error if we are not in a source line." (interactive) - (and (apt-sources-source-line-p) (let ((components (completing-read "Components: " ;list of componenst used by APT. '(("main") @@ -490,18 +466,15 @@ This function will rise an error if we are not in a source line." (looking-at "[^ ]")) (insert " ")) (insert components))))) - - (defun apt-sources-deb-or-src-replicate () "Copy the source line and change the 'deb' to 'deb-src' or viceversa. This function will rise an error if we are not on a source line." (interactive) - (and (apt-sources-source-line-p) (let ((copy (buffer-substring (line-beginning-position) - (line-end-position)))) + (line-end-position)))) (save-excursion (end-of-line) (insert (concat "\n" copy)) @@ -514,11 +487,10 @@ This function will rise an error if we are not on a source line." (re-search-forward "^deb[^ ]*" (line-end-position) t 1)) (insert "deb")))))) - - (run-hooks 'apt-sources-load-hook) (add-to-list 'auto-mode-alist '("sources\\.list\\'" . apt-sources-mode)) (add-to-list 'auto-mode-alist '("sources\\.list\\.d/.*\\.list\\'" . apt-sources-mode)) + (provide 'apt-sources) ;;; apt-sources.el ends here -- cgit v1.2.3