From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: How to convert an arbitrary string into a filename Date: Wed, 26 Apr 2023 12:42:38 +0700 Message-ID: References: <87wn1z8fgo.fsf@mbork.pl> 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="34094"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs mailing list To: Marcin Borkowski Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 26 07:43:07 2023 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 1prXvm-0008fK-G1 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 26 Apr 2023 07:43:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prXvc-0001oc-Ts; Wed, 26 Apr 2023 01:42:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1prXva-0001mv-Ks for help-gnu-emacs@gnu.org; Wed, 26 Apr 2023 01:42:54 -0400 Original-Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1prXvZ-0000LC-4I for help-gnu-emacs@gnu.org; Wed, 26 Apr 2023 01:42:54 -0400 Original-Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f195b164c4so33754015e9.1 for ; Tue, 25 Apr 2023 22:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682487771; x=1685079771; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qxPlGUfVfry+aE82asUsyXhTC6KsVUXkEkwPs+xyEpo=; b=BNs4X4SzYQGQG3mY7mH9d7i8vHO9AiyEenBUPLmXS7LdE7CaN8YTSBSdieBpanj565 Cn5wPmCNNS9pDjyx3c+ryCWkuLiJdqsjNvBLKrqOIiLdPKnQQZByRf2lpJxzxSdv8DI8 x5Fe3m/2y7yJfYpJ//pzxpjTm0JyTuUfLknPCpjyOdZUwtN6iVL5HmYrc90qoRdilJ/t 3LNiCQDI+z/zG/3fMS4kQiHyYC2ZSopKWqTo0RAbAGznj5lX9u7FQ+P9JYOLYmzilX1+ zihI7HSi/AtM5x5UTnVeBgkF1fWMtQTACfUWnU7M3NbjCx4vhG78iju7atdqOaQvrj2z pWqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682487771; x=1685079771; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qxPlGUfVfry+aE82asUsyXhTC6KsVUXkEkwPs+xyEpo=; b=P2ECqLHqECq8wOjLZ37AmTjDXl1PU+aVIl0yiauLB2D5LXfPhbfwKHVDWGGUQIGFC9 dCwSnjEB+rHdiTeFp07/CioUsDC7eUM+JQ68ZJQauwuZ9cgzJNXkDS+7FAjUN5yndIPn Ef0azGU0Chn1sxTeIcv/AucjVN7w15xwzwDGb8O8byxDDjJZ+SIpAvhCXfVdhfwkCcJw R1//ds4WptyPvL/yJnjZeQSTgHwpOX1qBn/coUZut3qcJRJlEi0QrsWyvrr/nMSZP8RK ku4++MzSlcPsQlfd7kbb5CBt1jwhEQ4LYiLXmj/pANGrqanDl6010GoZkW5w1IDA/GXl qF/g== X-Gm-Message-State: AAQBX9fWARy6M+PuRb3NJY+tbKSZ8Y8lWrZ5/cFo70hB6U0NeXrcFTwn Mz/+aQHBTxd0tfVUUqgUdMytFL0pzJqwPK+2yDQyeg27 X-Google-Smtp-Source: AKy350YGny35wKl8vFeeStFuVTDkzeJIm++4oOY+cdG2lqrOF2o//+xy9ja6e+Ssy7RVFhuVLmfE/rFc/7X2ORjjsyo= X-Received: by 2002:a1c:7705:0:b0:3ee:4ff0:83d6 with SMTP id t5-20020a1c7705000000b003ee4ff083d6mr11140989wmi.40.1682487770524; Tue, 25 Apr 2023 22:42:50 -0700 (PDT) In-Reply-To: <87wn1z8fgo.fsf@mbork.pl> Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=yurivkhan@gmail.com; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143389 Archived-At: On Wed, 26 Apr 2023 at 10:56, Marcin Borkowski wrote: > given an arbitrary string, say "Hello, world!!!", I want to have > a filename with all the runs of weird characters (that is, > non-alphanumeric ones) converted to dashes (say, "Hello-world"). Is > there a function for that in Emacs already or should I write my own? It looks like you want to generate file names for blog posts or articles so that URLs look pretty. While a useful goal, the mechanic you ask for is lossy, so multiple titles could map into the same file name, which, in the worst case, could lead to data loss, or require disambiguation of some kind. (Also, depending on how wide your audience is and what your implementation=E2=80=99s definition of alphanumeric is, it might turn title= s written in non-Latin-based scripts into an empty string, and fixing that might be moderately easy for some scripts (e.g. Greek, Cyrillic) and hard for others (e.g. CJK).)