From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: steve-humphreys@gmx.com Newsgroups: gmane.emacs.help Subject: Re: bounds for strings with - between subwords Date: Fri, 7 May 2021 03:17:38 +0200 Message-ID: References: <871raj32ba.fsf@zoho.eu> <87h7jf1l7s.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13757"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: moasenwood@zoho.eu Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 07 03:18:27 2021 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 1lep8N-0003Rp-Al for geh-help-gnu-emacs@m.gmane-mx.org; Fri, 07 May 2021 03:18:27 +0200 Original-Received: from localhost ([::1]:41652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lep8L-0005LD-KS for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 06 May 2021 21:18:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lep7g-0005L5-6Y for help-gnu-emacs@gnu.org; Thu, 06 May 2021 21:17:44 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:50449) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lep7d-0006St-PV for help-gnu-emacs@gnu.org; Thu, 06 May 2021 21:17:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620350259; bh=MLttcXwlrJuIaYeuZ/AOPSJDe5rRBr8IwqotYPtsAho=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ViakFCOOrXMehnO0OsNmTkyYhP0YmGUyXULtI5zkYutb9cpDDAOf4r78pHT5TwK8e Rhv7XP2DFQhpvfxaPpheQnJLhnpDc7RMGDDIysAqJv2SoSGJgd2khlafL9H8hs1JHS 9DDNv6rw6vK8PAnlJwSzmKl5PuBJ8VbrJLlJfWE4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs12.server.lan [172.19.170.180]) (via HTTP); Fri, 7 May 2021 03:17:38 +0200 Importance: normal Sensitivity: Normal In-Reply-To: <87h7jf1l7s.fsf@zoho.eu> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:Qt4XL0RnaD4LnTfc2Uca9HQRsShC29qfjYlV6SXO6RXNEvf++TETDQTqC7osi/Li1etS/ CptaRDmTvvnUE4jZLo6I7gHv7GDjjtZ4KINlLrXlW/Isaf3bG5kmwg23Yb8jLxY5fYla+oSo0t9d AW/caDW0emhmXnD2R6brtg9yJV331xaaIQJwSF3Q7SjnClzzEwPwcBpJ+F+y572TE7O5bZl6F9o1 nzRNsG7EPGNXZpy6FGTKhtCTTD5XjS/O+prZkq6FttC6tBYKNzrgmMuWtyoMh74O1dyEKqxQIOIA +c= X-UI-Out-Filterresults: notjunk:1;V03:K0:eXhMcMD3mI8=:cwcjRQa0WorTo+0XEYdHiS nRo+LzBHqXbmLwxmp60M3wJY6M1RFwahwhXuIAhQwsEPwC6ZSNMh18vGURWtO3Io82vjkOYP6 eK3xljvArxwriZ6aVbbSIBKw3pSVruHdokTChi9kYE550Q0X5yzoHdqoGrnmvJJNg3tPMxWrM c5xIajjlRydk980BpVcyPCZWcagTSEOlMRHUmlbN0yrMF1Se14gval22bGkCCDrocR8V3cC7G 4mYV4NrsnPpGOkXdp3xpIqzdYjaFIQ38uLp2BXjU6DCo0Eu9U/o/RD1rbrcIanHQONw4hwuv8 YWoUPHoKwOzwz/rzCJLwAU66HAev8kIlNfTN7tEV7+ChGAf8VjBISp6EyPVvC+PHtRC3SnuNq U/oOHI4VB8H6vJnKKbkAszR6vHCmw4THs4Yw4z2wkBu9r79ofu4E8BG0M0NVsFXAhW/tfU/Vy HHduDq/fSM/g0+Bz6xXBlowBKpiDMF2rY4jKzrDGff07kG9GCLNVEOg4yMRGOnXKo7tS6uKs4 zLURo5oMChAkWi3f3bAAyww5EuaJugVeWz9dkaxSdv1tPXA1yoz1ogW8kub3eDlUjecHaS4BP 1cr3leJtxEEn8g1FA/guL9z69oMZSO+XGNqevTL2n28EkToSMR0gruByZWgxpVLuWFrqRCfDq +Qbi6eKs1XKSzZcc+O6S1Q13V68bAm8mlibQFCvNewmkql8COTcvB5BodRlwOu0Y90is8CDef SpQjB0tVvIRmV7jj3yCXiRCulVRjk+WQgx1DG3DYxRGxWsPd1x/8OfPje5pj6KLc28Uqf9Ny Received-SPF: pass client-ip=212.227.17.21; envelope-from=steve-humphreys@gmx.com; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:129540 Archived-At: This is what I've got But when I get to option 5, the string e.g. "Bibl-Stockwell-Mansinha-Lowe-= 1996" is not being downcased. =2D------- (defun alpha-bounds () "Gets bounds of a subword unit defined by regular expression [a-zA-Z]." (let ( ($bounds nil) $ma $mb ) ; var initially bound to nil (skip-chars-backward "[:alpha:]") ; equivalent to [a-zA-Z] (setq $ma (point)) (skip-chars-forward "[:alpha:]") (setq $mb (point)) (setq $bounds (bounds-of-thing-at-point 'word)) (cons $ma $mb) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun alnum-dash-bounds () "Gets bounds of a subword unit defined by [:alnum:] and dash." (let ( ($bounds nil) $ma $mb ) (skip-chars-backward "[:alnum:]-") ; same as ""[a-zA-Z0-9]-" (setq $ma (point)) (skip-chars-forward "[:alnum:]-") (setq $mb (point)) (cons $ma $mb) )) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun letter-shape-shift () "Toggles letter between majiscule and miniscule at cursor point." (interactive) (let ( (case-fold-search nil) ) (cond ((looking-at "[[:lower:]]") (upcase-region (point) (1+ (point)))) ((looking-at "[[:upper:]]") (downcase-region (point) (1+ (point)))) ))) ;; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= +++++++++++++++ (defun shape-sweep () "Shifts letters between majuscule and minuscule." (interactive) (let ( (deactivate-mark nil) $bounds $ma $mb $dbounds $mc $md) ;; sets $ma and $mb (if (use-region-p) ;; --------------------------------------------------------------= --------------- ;; [if] using a region (setq $ma (region-beginning) $mb (region-end)) ;; --------------------------------------------------------------= --------------- ;; [else] not using a region, focus on word (save-excursion ;; Get bounds for words [:alpha:] (setq $bounds (alpha-bounds)) (setq $ma (car $bounds) $mb (cdr $bounds)) ) (save-excursion ;; get bounds for word ligatures, e.g. "bibl-stockwell-1996" (setq $dbounds (alnum-dash-bounds)) (setq $mc (car $dbounds) $md (cdr $dbounds)) )) ;; Prints bounds to the message buffer when sub-string exists. (when (string-match-p (regexp-quote "noprint") "print-bounds") (message "\n----- gilgamesh-shape-sweep -----") (message "Bounds: %s %s %s" $bounds $ma $mb) (message "Region: [%s]\n" (buffer-substring $ma $mb)) ) (when (not (eq last-command this-command)) (put this-command 'state 0)) (cond ;; --------------------------------------------------------------= ------------------- ((equal 0 (get this-command 'state)) (gilgamesh-letter-shape-shift) ;; shifts letter to majuscu= le or miniscule (put this-command 'state 1)) ;; --------------------------------------------------------------= ------------------- ((equal 1 (get this-command 'state)) (gilgamesh-letter-shape-shift) ;; shifts letter to origina= l shape (put this-command 'state 2)) ;; --------------------------------------------------------------= ------------------- ((equal 2 (get this-command 'state)) (upcase-initials-region $ma $mb) ;; first letter of each wor= d to majuscule (put this-command 'state 3)) ;; --------------------------------------------------------------= ------------------- ((equal 3 (get this-command 'state)) (upcase-region $ma $mb) ;; region to majuscule (put this-command 'state 4)) ;; --------------------------------------------------------------= ------------------- ((equal 4 (get this-command 'state)) (downcase-region $ma $mb) ;; region to miniscule (put this-command 'state 5)) ;; --------------------------------------------------------------= ------------------- ((equal 5 (get this-command 'state)) (downcase-region $mc $md) (put this-command 'state 0)) )) > Sent: Friday, May 07, 2021 at 11:44 AM > From: "Emanuel Berg via Users list for the GNU Emacs text editor" > To: help-gnu-emacs@gnu.org > Subject: Re: bounds for strings with - between subwords > > Christopher Dimech wrote: > > >> > (defun alpha-bounds () > >> > "Gets bounds of a subword unit defined by regular expression [a-= zA-Z]." > >> > (let ( ($bounds nil) $ma $mb ) > >> > (skip-chars-backward "[:alpha:]") > >> > (setq $ma (point)) > >> > (skip-chars-forward "[:alpha:]") > >> > (setq $mb (point)) > >> > (setq $bounds (bounds-of-thing-at-point 'word)) > >> > (cons $ma $mb) )) > >> > >> You can put all that in the `let' to avoid the use of `setq'. > >> > >> Also $bounds doesn't seem to do anything? > > > > bounds are used in another function. You can see there is > > (cons $ma $mb) at the end, > > which is used as output when you call "alpha-bounds". > > $bounds still isn't used anywhere else and cannot be, either. > > >> And what's the purpose of the $? > > > > I use $ no tell me the variable is local and not being > > modified from outside. It is coming from the $1, $2, $3, ... > > function parameter idea. > > But they cannot be modified from the outside so no need to > worry about that. > > -- > underground experts united > https://dataswamp.org/~incal > > >