From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Nikolay Kudryavtsev Newsgroups: gmane.emacs.help Subject: Re: Continuing existing comment, with proper identation Date: Sun, 22 Oct 2023 13:38:22 +0300 Message-ID: <32745012-2072-4bab-8c17-5d3ee68521a4@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="942"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird To: Spencer Baugh , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 22 12:39:20 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 1quVrc-00008a-A1 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 22 Oct 2023 12:39:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quVqw-0004lv-9u; Sun, 22 Oct 2023 06:38:38 -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 1quVqu-0004lY-Lt for help-gnu-emacs@gnu.org; Sun, 22 Oct 2023 06:38:36 -0400 Original-Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quVqm-0003zX-Rh for help-gnu-emacs@gnu.org; Sun, 22 Oct 2023 06:38:36 -0400 Original-Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2b95d5ee18dso37185231fa.1 for ; Sun, 22 Oct 2023 03:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697971105; x=1698575905; darn=gnu.org; h=content-transfer-encoding:in-reply-to:content-language:references :to:subject:user-agent:mime-version:date:message-id:from:from:to:cc :subject:date:message-id:reply-to; bh=z1EGqCcZLgQkqarFlqk9HzLKrhDgwNn8m4XIG/gK5JI=; b=UlUQzKPek8uM5o3Tl9CPr0QoxdwhOoagzM1/Otc0dGNgz8TvafNi0FQ0++77d8ZnkC YQfXvBzDoX7PKgGjsD6jI7gQLTpZ3R0l+bPfP/v5ZlNAxS3wAHwdhANCa+IrOTPny3B6 DAqXYPGxkJ8AYLRqcxCWq8pmoCOn8MIfM8CKac2BSrUQTIsAVVdut/NBI10bV9ee3qHK 63f2OzXN3NDnrjA9rvB/4jMniwsz2I9LgT+p9wj15PZESPa80vCJRcmUUOZ9cHWin+kV 9KaNPIIbdx/X8SwTYW3fqnkOCtirIjaJsJZCPwtQ3NFXSIXOgN7FU2oHHd0vd+/7KhRj XgTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697971105; x=1698575905; h=content-transfer-encoding:in-reply-to:content-language:references :to:subject:user-agent:mime-version:date:message-id:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z1EGqCcZLgQkqarFlqk9HzLKrhDgwNn8m4XIG/gK5JI=; b=rTbcWCLRMzhcgUqP/MlV+Yy5sn3df4Tq0+3Pd/cmLGRBnxzp3WcsMXYTp1GxUX0ueW nfh9hn4xR+csTansLpmgB1nehIP7ulBOZc+KI38ILZzyaz/oAGBq/4zfGKN2J3v6B2vs AchBL/ovj6E3eC25QKIXUXx4ZfZlE0qlwxO5Km67RSW7cDlwU7Id45Yy38kwxwujlWIL 36BEtuEiaCaKnzgMzOEm7qURL2e09Sg2S13YLMKVJQEGLfiTtazmvPFrUKIa75RZmrhx miiEaaitDnIDswq+ggMRpUMq8V+8o5QIBnv8KGrNWeWR5ITAsBFxL5kRDGMCxnTJnKER 4ccQ== X-Gm-Message-State: AOJu0YzxR3C6lJVisFAqTOMaNHES2Uxh5IgqwUHiJu11BKc3uy6HHVtO RC3x8Swt0KQVoCfCZ5Y2s8Y= X-Google-Smtp-Source: AGHT+IGG3LX5rZMGP1h7vAwXf1VAyBBqqqW06rJvbnXHCTUlea+9aSPZqbcvF8QZ81UtnzEGxVCNmg== X-Received: by 2002:a2e:b176:0:b0:2c5:17c0:cd53 with SMTP id a22-20020a2eb176000000b002c517c0cd53mr4284405ljm.42.1697971104490; Sun, 22 Oct 2023 03:38:24 -0700 (PDT) Original-Received: from ?IPV6:2a02:2168:b3fc:c600:e97b:f10a:275f:324e? ([2a02:2168:b3fc:c600:e97b:f10a:275f:324e]) by smtp.gmail.com with ESMTPSA id i4-20020a05651c120400b002b9ec22d9fasm1114382lja.29.2023.10.22.03.38.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Oct 2023 03:38:23 -0700 (PDT) X-Google-Original-From: Nikolay Kudryavtsev Content-Language: ru, en-US In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=nikolay.kudryavtsev@gmail.com; helo=mail-lj1-x236.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 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:145348 Archived-At: Honestly, your best bet is probably implementing literally all of the logic yourself, maybe reusing some code from whatever mode you're willing to support. In a perfect world Emacs would understand comments as proper syntax tree expressions and have some kind of high level API to deal with those. But it does not and there isn't one. Also, extending comments is not your only problem. Indentation is a factor too. Again, there's no unified API. Some major modes use homebrew indentation logic, few use SMIE, now there's tree-sitter too. For example elisp-mode won't indent comments: ;;           The next line should indent up to here(according to the OP rules) ;; But it won't! Then there's also the elephant in the room - comments can be code too. Lets say you want to comment out a very basic C-like if: /*  if(){  *    whatever  */ How would your code know that offset is warranted here? You'd have to run the major mode's normal indentation logic to see it, right? That's why code that comments out stuff generally tries to avoid messing with indentation.