help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bounds-of-thing-at-point for paragraphs


From: Christopher Dimech
Subject: Re: bounds-of-thing-at-point for paragraphs
Date: Sun, 1 Nov 2020 19:34:31 +0100

Yes, but transpose-paragraph does not keep at the same point position.

I was asking how bounds-of-thing-at-point does not take paragraph as argument
as well, since it does for word, sentence, line. Can paragraph be included as 
well?




> Sent: Sunday, November 01, 2020 at 7:22 PM
> From: "Jean Louis" <bugs@gnu.support>
> To: "Christopher Dimech" <dimech@gmx.com>
> Cc: "Help Gnu Emacs" <help-gnu-emacs@gnu.org>
> Subject: Re: bounds-of-thing-at-point for paragraphs
>
> * Christopher Dimech <dimech@gmx.com> [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.
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]