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

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

bounds-of-thing-at-point for paragraphs


From: Christopher Dimech
Subject: bounds-of-thing-at-point for paragraphs
Date: Sun, 1 Nov 2020 17:08:04 +0100

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?


(defun Skip-Over-Paragraphs (arg)

   (let ((Prg-Bounds (bounds-of-thing-at-point 'paragraph)))

      ;; ----------------------------------------------------------------
      (when Wrd-Bounds
         (let*
            ( (Beg (point))
              (End (cdr Prg-Bounds))
              (Shift (- Beg End))
              ;; --------------------------------------------------------
              (Cursor-Psn
                 (save-excursion
                    (goto-char End)  ; [#A]
                    (if (condition-case err
                           (progn    ; bodyform
                              (transpose-paragraphs arg) ; [#B]
                              t
                           )
                           (message err) ; Handler when [#B] fails
                        )
                        ;; ----------------------------------------------
                        (+ (point) Shift)  ; Shift after executing [#B]
                        nil                ; [#B] failed
                        ;; ----------------------------------------------
                    )
                 )
              )
              ;; --------------------------------------------------------
            )
            (when Cursor-Psn (goto-char Cursor-Psn))
         )
      )
      ;;-----------------------------------------------------------------

   ) ; let bounds (start and end locations of word)

)




reply via email to

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