From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Arni Magnusson" Newsgroups: gmane.emacs.bugs Subject: bug#2887: Suggestions for simple.el Date: Sat, 4 Apr 2009 13:32:03 -0000 (GMT) Message-ID: <26172.194.144.135.59.1238851923.squirrel@www.hafro.is> Reply-To: Arni Magnusson , 2887@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20090404133203_61019" X-Trace: ger.gmane.org 1238852649 5080 80.91.229.12 (4 Apr 2009 13:44:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 4 Apr 2009 13:44:09 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 04 15:45:27 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lq6Ba-0002lI-5u for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Apr 2009 15:45:26 +0200 Original-Received: from localhost ([127.0.0.1]:47879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lq6AC-0007RZ-1G for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Apr 2009 09:44:00 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lq6A7-0007RS-1k for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2009 09:43:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lq6A2-0007RC-HL for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2009 09:43:54 -0400 Original-Received: from [199.232.76.173] (port=34570 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lq6A2-0007R9-BN for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2009 09:43:50 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:43110) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lq6A1-0004LF-Ny for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2009 09:43:50 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n34DhlYR008903; Sat, 4 Apr 2009 06:43:47 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n34De5sk007764; Sat, 4 Apr 2009 06:40:05 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: "Arni Magnusson" Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sat, 04 Apr 2009 13:40:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: report 2887 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12388519376065 (code B ref -1); Sat, 04 Apr 2009 13:40:04 +0000 Original-Received: (at submit) by emacsbugs.donarmstrong.com; 4 Apr 2009 13:32:17 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n34DWDqG006058 for ; Sat, 4 Apr 2009 06:32:14 -0700 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lq5ym-00088I-NG for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2009 09:32:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lq5yi-00083M-CI for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2009 09:32:12 -0400 Original-Received: from [199.232.76.173] (port=49655 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lq5yi-000836-8Z for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2009 09:32:08 -0400 Original-Received: from hafgarpur.hafro.is ([130.208.64.48]:36389) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lq5yh-0003Ld-Ln for bug-gnu-emacs@gnu.org; Sat, 04 Apr 2009 09:32:07 -0400 X-Virus-Scanned: amavisd-new at hafro.is Original-Received: from hafrun.hafro.is (hafrun.hafro.is [130.208.58.66]) by hafgarpur.hafro.is (8.14.2/8.14.2/hafro-2.45) with ESMTP id n34DW360010121 for ; Sat, 4 Apr 2009 13:32:03 GMT Original-Received: from www.hafro.is (localhost [127.0.0.1]) by hafrun.hafro.is (8.14.2/8.14.2/hafro-1.6) with ESMTP id n34DW3rk019922 for ; Sat, 4 Apr 2009 13:32:03 GMT Original-Received: from 194.144.135.59 (SquirrelMail authenticated user arnima) by www.hafro.is with HTTP; Sat, 4 Apr 2009 13:32:03 -0000 (GMT) User-Agent: SquirrelMail/1.4.10a X-Priority: 3 (Normal) Importance: Normal X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Sat, 04 Apr 2009 09:43:54 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:26905 Archived-At: ------=_20090404133203_61019 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Dear Emacs maintainers, I would like to suggest adding a few functions to the simple.el library. I do this with hesitation - since I know the idea is to keep it simple and let users write extensions to suit their preferences - but I believe a large number of Emacs users would appreciate having access to these functions out of the box. I just finished teaching an Emacs workshop, where I ended up distributing these functions to my colleagues, but I found it hard to explain whey they're not already in simple.el. Please see the attached file suggestions-simple.el. Instead of giving detailed reasons for including each function, I have only briefly commented on which functionality I'm extending, or which gap I'm bridging. I have used these functions a lot, but I am sure the Emacs maintainers can see ways to improve them in terms of robustness, speed, function names, documentation, etc. I would be happy to discuss any further details with you. All the best, Arni Magnusson ------=_20090404133203_61019 Content-Type: text/x-emacs-lisp; name="suggestions-simple.el" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="suggestions-simple.el" ;; simple::backward-kill-word ;; subr::backward-delete-char (defun backward-delete-word (N) "Delete previous N words." (interactive "*p")(delete-word (- N))) ;; simple::kill-word ;; C::delete-char (defun delete-word (N) "Delete following N words." (interactive "*p") (delete-region (point)(save-excursion (forward-word N)(point)))) ;; simple::kill-line ;; simple::kill-region (defun kill-line-or-region () "Kill region if selected, otherwise kill line." (interactive) (if (and mark-active transient-mark-mode)(kill-region (point)(mark))(kill-line))) ;; simple::transpose-lines ;; simple::kill-whole-line (defun pull-line-down (N) "Pull line down N times." (interactive "*p") (let ((col (current-column)))(kill-whole-line 1)(forward-line N)(yank 1)(pop kill-ring)(forward-line -1) (move-to-column col))) ;; simple::transpose-lines ;; simple::kill-whole-line (defun pull-line-up (N) "Pull line up N times." (interactive "*p") (let ((col (current-column)))(kill-whole-line 1)(forward-line (- N))(yank 1)(pop kill-ring)(forward-line -1) (move-to-column col))) ;; simple::goto-line ;; C::point (defun pos-at-beginning-of-line (N) "Return the position at beginning of line N." (save-excursion (goto-line N)(point))) (defun pos-at-end-of-line (N) "Return the position at end of line N." (save-excursion (goto-line N)(end-of-line)(point))) ;; simple::zap-to-char ;; C::delete-region (defun zap-back-to-char (char) "Delete region back to, but not including, CHAR." (interactive "cZap back to char: ") (let ((case-fold-search nil)) (delete-region (point)(progn (search-backward (char-to-string char))(forward-char)(point))))) ;; simple::zap-to-char ;; C::delete-region (defun zap-up-to-char (char) "Delete region up to, but not including, CHAR." (interactive "cZap to char: ") (let ((case-fold-search nil)) (delete-region (point)(progn (search-forward (char-to-string char))(backward-char)(point))))) ;; simple::delete-trailing-whitespace ;; whitespace::whitespace-buffer (defun clean-trails () "Delete ^M glyphs, spaces, and tabs from line ends." (interactive) ; \r means ^M (save-excursion (goto-char (point-min)) ; unlike delete-trailing-whitespace, clean-trails removes ^M (\r) in lisp-mode (let ((count 0))(while (re-search-forward "[\r\t ]+$" nil t)(replace-match "")(setq count (+ count 1))) (message "Cleaned %d lines" count)))) ;; simple::delete-blank-lines ;; whitespace::whitespace-buffer (defun delete-all-blank-lines () "Delete all blank lines in buffer." (interactive) (save-excursion (goto-char (point-min)) (let ((count 0))(while (search-forward "\n\n" nil t)(goto-char (point-min)) (while (search-forward "\n\n" nil t)(replace-match "\n")(setq count (+ count 1))) (goto-char (point-min))) (if (= (following-char) 10)(progn (delete-char 1)(setq count (+ count 1)))) (message "Deleted %d blank lines" count)))) ;; simple::delete-indentation (defun delete-indentation-nospace () "Join this line to previous with no whitespace at join." (interactive) (delete-indentation)(delete-horizontal-space)) ;; simple::end-of-buffer ;; simple::goto-line (defun goto-longest-line () "Go to longest line in buffer." (interactive) (let ((line 1)(length 0)) (save-excursion (goto-char (point-min))(end-of-line)(setq length (current-column)) (while (not (eobp)) (progn (end-of-line 2) (if (> (current-column) length)(progn (setq line (line-number-at-pos))(setq length (current-column))))))) (goto-line line)(message "Line %d is %d characters" line length))) ;; C::downcase-region ;; C::downcase-word ;; belongs in simple (defun downcase-word-or-region (N) "Downcase N words or region." (interactive "*p") (if (and mark-active transient-mark-mode)(downcase-region (point)(mark))(downcase-word N))) (defun upcase-word-or-region (N) "Upcase N words or region." (interactive "*p") (if (and mark-active transient-mark-mode)(upcase-region (point)(mark))(upcase-word N))) ------=_20090404133203_61019--