Re: [PATCH] Match last names with an "O'" prefix (like "Foo O'Bar").

Roland Winkler <[email protected]> Tue, 04 Mar 2025 10:02:22 -0600
Newsgroups gmane.emacs.bbdb.user
Message-ID <[email protected]>
Thanks. -- I am not sure it makes sense to try to make sure that such a
user option by default covers all possible scenarios.  Every now and
then (once per year?) I find that these regexps do not work for me, when
I find it easier to just edit the name field via 'C-u e' when you can
edit the first- and last-name parts individually.


On Sun, Mar 02 2025, Asher Gordon wrote:
> We can't simply add "O'" to bbdb-lastname-prefixes, because of the
> "\\>" in the regexp. This also allows names like "Foo Bar-O'Baz",
> "Foo O'Bar-Baz-Why-O'Why-Did-You-Name-Me-This", etc. It even allows
> things like "Foo von O'Bar", though I imagine that would be quite
> uncommon.
> ---
>  lisp/bbdb.el | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/lisp/bbdb.el b/lisp/bbdb.el
> index 8ad557e..81f4dd0 100644
> --- a/lisp/bbdb.el
> +++ b/lisp/bbdb.el
> @@ -622,10 +622,11 @@ Case is ignored."
>    :type '(repeat string))
>  
>  (defcustom bbdb-lastname-re
> -  (concat "[- \t]*\\(\\(?:\\<"
> -          (regexp-opt bbdb-lastname-prefixes)
> -          ;; multiple last names concatenated by `-'
> -          "\\>[- \t]+\\)?\\(?:\\w+[ \t]*-[ \t]*\\)*\\w+\\)\\'")
> +  (let ((name-re "\\(?:O'\\)?\\w+"))
> +    (concat "[- \t]*\\(\\(?:\\<"
> +            (regexp-opt bbdb-lastname-prefixes)
> +            ;; multiple last names concatenated by `-'
> +            "\\>[- \t]+\\)?\\(?:" name-re "[ \t]*-[ \t]*\\)*" name-re "\\)\\'"))
>    "Regexp matching the last name of a full name.
>  Its first parenthetical subexpression becomes the last name."
>    :group 'bbdb-record-edit