From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: bounds-of-thing-at-point for paragraphs Date: Sun, 1 Nov 2020 21:22:26 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13305"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/+ (1036f0e) (2020-10-18) Cc: Help Gnu Emacs To: Christopher Dimech Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 01 19:24:00 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZI1H-0003MP-Ar for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 01 Nov 2020 19:23:59 +0100 Original-Received: from localhost ([::1]:55812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZI1G-0007B8-DC for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 01 Nov 2020 13:23:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZHzw-0005sI-Nr for help-gnu-emacs@gnu.org; Sun, 01 Nov 2020 13:22:38 -0500 Original-Received: from static.rcdrun.com ([95.85.24.50]:46831) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZHzu-0002DJ-JK for help-gnu-emacs@gnu.org; Sun, 01 Nov 2020 13:22:36 -0500 Original-Received: from localhost ([::ffff:197.157.0.60]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by static.rcdrun.com with ESMTPSA id 00000000002A0B42.000000005F9EFCE6.00000E68; Sun, 01 Nov 2020 18:22:30 +0000 Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=95.85.24.50; envelope-from=bugs@gnu.support; helo=static.rcdrun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/01 10:30:20 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -3 X-Spam_score: -0.4 X-Spam_bar: / X-Spam_report: (-0.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_SORBS_WEB=1.5, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:124881 Archived-At: * Christopher Dimech [2020-11-01 19:09]: > Been trying to write a function to transpose two paragraphs but keep the cursor > at the same position. How is it that bounds-of-thing-at-point does not take > paragraph as argument? That is very nice. I like ivy-mode from GNU ELPA, it is package for automatic completion of many functions. There are many various completion packages. It may help you faster explore which functions are available. I was looking if such function already exists by doing {C-h f} and then I get list of functions, I have tried typing "trans" and "para" and I can find function `transpose-paragraphs' You may spare your efforts by finding some probably already existing functions. If you wish to make your own function out of `transpose-paragraphs' you may come with cursor on the function name, above here ^ and type {C-h f} then you press TAB and enter into file `paragraphs.el' where you can find how function is written. Then you may copy the same function and name it `my-transpose-paragraphs' and try modifying it as you wish. You could as well modify original function to do what you wish and save it in your configuration. See below: > (defun Skip-Over-Paragraphs (arg) I understand that some programming languages have mixture of upper case and lower case function names, in Lisp that is not so common. I believe it is common in some versions of Lisp, not in Emacs lisp. As: (setq A 1) (setq a 2) are not same so, so it is better writing all lower case letters. > (let ((Prg-Bounds (bounds-of-thing-at-point 'paragraph))) > > ;; ---------------------------------------------------------------- > (when Wrd-Bounds > (let* > ( (Beg (point)) > (End (cdr Prg-Bounds)) > (Shift (- Beg End)) I understand you may need now for visibility or orientation some space at ( (Beg)) yet by convention there is no such space. You better not make new lines after let* to make it easier readable for people who are familiar to different style. Lisp is great, you may write it anyhow, but for readability there are some conventions. You may mark the function and simply press TAB and it will indent it for you. Please see the Emacs Lisp manual as it is built into Emacs. There is section "Tips" where you can read various conventions. > ;; -------------------------------------------------------- > (Cursor-Psn > (save-excursion > (goto-char End) ; [#A] > (if (condition-case err > (progn ; bodyform > (transpose-paragraphs arg) ; [#B] > t > ) Normally ending parenthesis you put straight after t. I suggest you use Options -> Highlight matching parenthesis to help you see where you are. -- There are 50 messages yet in my incoming mailbox.