XEmacs equivalents of line-beginning-position, line-end-position and match-string-no-properties

XEmacs equivalents of line-beginning-position, line-end-position and match-string-no-properties

Post by Jakub Nare » Sat, 25 Oct 2003 02:22:19


I am writing on-the-fly version of tildify, named sierotki.el. This
package automatically inserts tildes (non-breakable (La)TeX space) after
single letter prepositions during writing. This is needed to avoid one
letter prepositions at line endings in TeX documents, which is required by
the Polish and Czech ortography/typography rules. It can be found at

http://www.yqcomputer.com/ ~jnareb/sierotki.el

This package works only for (La)TeX and lacks more elaborate features of
the tildify package (this is GNU Emacs package). One of features I try
to add is the detection if we are in obeyspaces or verbatimlike mode,
where tildes are unwanted. One if the tests it checking if we are inside
the *** \verb command.

I am using GNU Emacs and I used in this function (named inverbp) the
line-beginning-position, line-beginning-end and match-string-properties
functions, which as far as I know are absent in XEmacs 21.4. I'd rather
have the package/function which functions in XEmacs as good as in
FSF Emacs.

Therefore I have the following question: what are the XEmacs equivalents
of line-beginning-position, line-beginning-end (which are used to delimit
search) and match-string-no-properties (to match string regardless of
syntax highlighting)?

All comments appreciated...


The code of inverbp follows:

(defun texinverbp ()
"Determine if point is inside *** \\verb command.
Returns nil or the pair (POINT-VERB-BEG . POINT-VERB-END) of positions where
\\verb argument begins and ends or the position POINT-VERB-BEG where \\verb
command argument begins if \\verb is unfinished (has no closing delimiter).

This command uses the fact that the argument to \\verb cannot contain end of
line characters. Does not work with nested \\verb s.

May not work in XEmacs."
(interactive)
(let ((point (point))
beg
end
delim)
(save-excursion
(and (setq beg (and (re-search-backward "\\\\verb\\*?\\([^a-zA-Z*\\n]\\)"
(line-beginning-position) t)
(match-end 0)))
(setq delim (regexp-quote (match-string-no-properties 1)))
(goto-char beg)
;;(or (insert "!") t)
(setq end (and (skip-chars-forward (concat "^" delim)
(line-end-position))
(point)))
(or (eolp)
(looking-at (concat "[" delim "]")))
;;(or (insert "!") t)
(cond ((>= point end) nil)
((eolp) beg)
(t (cons beg end)))))))


--
Jakub Narski mailto: XXXX@XXXXX.COM
ZTHiL IFT UW http://www.yqcomputer.com/ ~jnareb/
 
 
 

XEmacs equivalents of line-beginning-position, line-end-position and match-string-no-properties

Post by Kalle Olav » Sat, 25 Oct 2003 07:46:07

Jakub Narebski < XXXX@XXXXX.COM > writes:


Both XEmacs 21.4 and Emacs 21.3 have point-at-bol and point-at-eol.
I don't know what corresponds to match-string-no-properties.

 
 
 

XEmacs equivalents of line-beginning-position, line-end-position and match-string-no-properties

Post by Jakub Nars » Sat, 25 Oct 2003 09:15:54


Thanks. This is good solution, because it works in FSF Emacs too:

point-at-bol is an alias for `line-beginning-position' in `subr'.
(line-beginning-position &optional N)

The XEmacs version is more elaborate, but I don't use neither COUNT/N
nor BUFFER argument.

`point-at-bol' is a built-in function
(point-at-bol &optional COUNT BUFFER)


Maybe in XEmacs string matching is done without taking into account text
properties?

--
Jakub Narski mailto: XXXX@XXXXX.COM
ZTHiL IFT UW http://www.yqcomputer.com/ ~jnareb/
 
 
 

XEmacs equivalents of line-beginning-position, line-end-position and match-string-no-properties

Post by Stephen J. » Sat, 25 Oct 2003 12:51:47

>>>>> "Jakub" == Jakub Nar <Jakub> writes:

>> I don't know what corresponds to match-string-no-properties.

Jakub> Maybe in XEmacs string matching is done without taking into
Jakub> account text properties?

Matching doesn't care about properties. What
match-string-no-properties does is discard the properties from the
substring before returning it.

If you do something like

(unless (fboundp 'match-string-no-properties)
(defalias 'match-string-no-properties 'match-string))

you should be OK, except that if the source buffer has text properties
(such as a special face) on that range of characters, they will be
returned with the string and pasted with the string.

If that's unacceptable (or even unacceptably ugly) post to
xemacs-beta; either I'll take more time and figure out how to
accomplish the same thing, or (I hope) some other geek will answer
before I get around to it.

--
Institute of Policy and Planning Sciences http://www.yqcomputer.com/
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Ask not how you can "do" free software business;
ask what your business can "do for" free software.