unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: How to open a file in sh-mode
       [not found] <mailman.16658.1218700648.18990.help-gnu-emacs@gnu.org>
@ 2008-08-14  8:28 ` Sebastian Kaps
  2008-08-14 10:29 ` Xah
  1 sibling, 0 replies; 8+ messages in thread
From: Sebastian Kaps @ 2008-08-14  8:28 UTC (permalink / raw
  To: help-gnu-emacs

// Francis Moreau writes:

> I'm trying to open a file with emacs automatically set on sh-mode.
> The file name can't be used to guess that emacs should be in sh-mode
> when opening it.

Put
,----
| # -*- mode:sh -*-
`----
 at the beginning of that file.

-- 
Ciao, Sebastian


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to open a file in sh-mode
       [not found] <mailman.16658.1218700648.18990.help-gnu-emacs@gnu.org>
  2008-08-14  8:28 ` How to open a file in sh-mode Sebastian Kaps
@ 2008-08-14 10:29 ` Xah
  2008-09-11  1:35   ` David Combs
  1 sibling, 1 reply; 8+ messages in thread
From: Xah @ 2008-08-14 10:29 UTC (permalink / raw
  To: help-gnu-emacs

On Aug 14, 12:53 am, "Francis Moreau" <francis.m...@gmail.com> wrote:
> Hello,
>
> I'm trying to open a file with emacs automatically set on sh-mode.
> The file name can't be used to guess that emacs should be in sh-mode
> when opening it.

If the file content's first line starts with “#!”, then you could use
the magic-mode-alist.

-----------------------------------
How Emacs Choose Modes

Emacs determines what mode to use primarily by 2 mechanisms, in order:
(1) Check the first line in the file, using “magic-mode-alist”. (2)
Check the file name's suffix, using “auto-mode-alist”.

The “magic-mode-alist” is a list that emacs use to match the first
line of a file with a mode. For example, if you want files that begin
with the line “<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...” to
always use nxml-mode, then add the following to your “.emacs”:

(add-to-list
 'magic-mode-alist
 '("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0" . nxml-mode))

The magic-mode-alist is a list. In the above example, the string with
the “DOCTYPE” is a regex, used to match the first line of a file.

If emacs goes thru magic-mode-alist and didn't find any match, then
it'll use auto-mode-alist to check on file name suffix. The “auto-mode-
alist” associates a file name suffix with a mode. For example, if you
want files ending in “.js” to always open with js2-mode, then do:

(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))

Note: The double backslash in the string “\\.js\\'” is used to escape
the backslash. So, the regex engine just got “\.js\'”. The “\.” is to
match a period. The “\'” is one of emacs special regex syntax, to
match end of a string. (See also: Text Pattern Matching in Emacs)

Reference: Elisp Manual: Regexp-Backslash.

You can see what are the values of magic-mode-alist or auto-mode-alist
by typing “Alt+x describe-variable”.

There are few minor details about how emacs determines what mode to
load, but the above should cover vast majority of needs. For detail,
see emacs manual.

Reference: (info "(emacs)Choosing Modes").

--------------------------------------------
above from:
http://xahlee.org/emacs/emacs_installing_packages.html

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to open a file in sh-mode
  2008-08-14 10:29 ` Xah
@ 2008-09-11  1:35   ` David Combs
  2008-09-11 22:58     ` unicode encoding and curly quotes [was: How to open a file in sh-mode] Xah
  0 siblings, 1 reply; 8+ messages in thread
From: David Combs @ 2008-09-11  1:35 UTC (permalink / raw
  To: help-gnu-emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2848 bytes --]

In article <64d8ebaf-0c89-4e9d-9aee-86b4e9414449@o40g2000prn.googlegroups.com>,
Xah  <xahlee@gmail.com> wrote:
>On Aug 14, 12:53 am, "Francis Moreau" <francis.m...@gmail.com> wrote:
>> Hello,
>>
>> I'm trying to open a file with emacs automatically set on sh-mode.
>> The file name can't be used to guess that emacs should be in sh-mode
>> when opening it.
>
>If the file content's first line starts with “#!”, then you could use
>the magic-mode-alist.
>
Xah -- question about the characters in your posts:

If I or someone sees eg a url in one of your posts, and
wants to go to that url (because you've suggested doing that,
maybe), it's a little difficult to just cut-n-paste your string,
what with all the extra control or whatever they are characters
mixed in.

What is that stuff, why is it there, and is it really necessary
for you to include it.

Thanks,

David




>-----------------------------------
>How Emacs Choose Modes
>
>Emacs determines what mode to use primarily by 2 mechanisms, in order:
>(1) Check the first line in the file, using “magic-mode-alist”. (2)
>Check the file name's suffix, using “auto-mode-alist”.
>
>The “magic-mode-alist” is a list that emacs use to match the first
>line of a file with a mode. For example, if you want files that begin
>with the line “<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...” to
>always use nxml-mode, then add the following to your “.emacs”:
>
>(add-to-list
> 'magic-mode-alist
> '("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0" . nxml-mode))
>
>The magic-mode-alist is a list. In the above example, the string with
>the “DOCTYPE” is a regex, used to match the first line of a file.
>
>If emacs goes thru magic-mode-alist and didn't find any match, then
>it'll use auto-mode-alist to check on file name suffix. The “auto-mode-
>alist” associates a file name suffix with a mode. For example, if you
>want files ending in “.js” to always open with js2-mode, then do:
>
>(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
>
>Note: The double backslash in the string “\\.js\\'” is used to escape
>the backslash. So, the regex engine just got “\.js\'”. The “\.” is to
>match a period. The “\'” is one of emacs special regex syntax, to
>match end of a string. (See also: Text Pattern Matching in Emacs)
>
>Reference: Elisp Manual: Regexp-Backslash.
>
>You can see what are the values of magic-mode-alist or auto-mode-alist
>by typing “Alt+x describe-variable”.
>
>There are few minor details about how emacs determines what mode to
>load, but the above should cover vast majority of needs. For detail,
>see emacs manual.
>
>Reference: (info "(emacs)Choosing Modes").
>
>--------------------------------------------
>above from:
>http://xahlee.org/emacs/emacs_installing_packages.html
>
>  Xah
>∑ http://xahlee.org/
>
>☄




^ permalink raw reply	[flat|nested] 8+ messages in thread

* unicode encoding and curly quotes [was: How to open a file in  sh-mode]
  2008-09-11  1:35   ` David Combs
@ 2008-09-11 22:58     ` Xah
  2008-09-14 22:35       ` David Combs
  0 siblings, 1 reply; 8+ messages in thread
From: Xah @ 2008-09-11 22:58 UTC (permalink / raw
  To: help-gnu-emacs

David Combs wrote:
> Xah-- question about the characters in your posts:
>
> If I or someone sees eg a url in one of your posts, and
> wants to go to that url (because you've suggested doing that,
> maybe), it's a little difficult to just cut-n-paste your string,
> what with all the extra control or whatever they are characters
> mixed in.
>
> What is that stuff, why is it there, and is it really necessary
> for you to include it.

The summation sign “∑” in my sig is my and my website signet.

in the end of my sig, there's this character “☄” (unicode name
“comet”). It is there so that it forces groups.google.com and Apple
Mail application into sending the message with unicode encoding.
Otherwise, the heuristics'll typically pick Japanese encoding. (in
google groups, last i checked about last year there's no way to set
encoding. And in Apple Mail 2 years ago, there's no unicode encoding
option... it is added now but last i checked there's no preference
that can set encoding ... )

My use of curly quotes “ ” or other unicode chars are just convenience
and practical need. I have in my emacs various easy ways to type them.
The need to quote is for example, seen throughout gnu's docs, but they
used a ascii cludge of backtick for left curly single quote and
straight quote for right curly single quote, e.g. “`something'”.
(quoting is needed for highlighting purporses or to make a phrase's
semantic from normal interpretation in the sentence.)

Since about 2006, i find emacs's support of unicode very roburst and i
have no problem with these and other mathematical chars or chinese in
emacs. In general, opensource langs and tools in e.g. linux world has
much caught on and support unicode, and i think that is good.
(commercial world long ago supported and use these chars in practice
(e.g. Apple in early 1990s and Microsoft Windows since about WindowsNT
4 or Windows2000)) The OpenSource world typically has a lag of 5 to 10
years in catching up most desktop techs. Even today, there are still a
few cave dwelling tech geekers you'll see occationally complaint about
unicode in posts (e.g. Alan M here insists that newsgroup posts should
be in ascii only!). But thankfully these days you'll often see others
tech geekers follow up chiding about the complainer like “dude, get a
proper newsreader” ...

You FreeSoftware and OpenSource supporters really should move on and
embrace unicode.

I have made few suggestions here and elsewhere in the past 2 years
including several private exchanges with Richard Stallman, about
updating emacs doc (and in general all GNU docs convention) to to use
“” and ‘’ in place of painful and ugly and technically problematic and
ambiguous ascii kludge `', among few other modernization issues... but
in general it's met with extreme difficulty...

i've been wanting to file a emacs bug report on this particular
issue ... but with so many resistance and my “troll” persona etc ...
basically it's very disencouraging ...

The problem with `' or ``'' is that:

• it's just 1980's ascii kludge to get around the fact there were no
matching quotes in ascii. In some technical sense, it's misuse and
abuse of symbols.
• it's ugly.
• it's ambiguous. The straight quote has many meanings, and both
straight quote and backtick also has special meanings in elisp lang
and in function's inline doc string.
• it is not possible to do a syntactical parse. (compare it to quoting
with chars that are matching pairs.)

If you think there's some merit in this suggestion, please file a bug
report. (menu “Help‣Send Bug Report...”)

  Xah
∑ http://xahlee.org/> >-----------------------------------
> >How Emacs Choose Modes
>
> >Emacs determines what mode to use primarily by 2 mechanisms, in order:
> >(1) Check the first line in the file, using “magic-mode-alist”. (2)
> >Check the file name's suffix, using “auto-mode-alist”.
>
> >The “magic-mode-alist” is a list that emacs use to match the first
> >line of a file with a mode. For example, if you want files that begin
> >with the line “<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...” to
> >always use nxml-mode, then add the following to your “.emacs”:
>
> >(add-to-list
> > 'magic-mode-alist
> > '("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0" . nxml-mode))
>
> >The magic-mode-alist is a list. In the above example, the string with
> >the “DOCTYPE” is a regex, used to match the first line of a file.
>
> >If emacs goes thru magic-mode-alist and didn't find any match, then
> >it'll use auto-mode-alist to check on file name suffix. The “auto-mode-
> >alist” associates a file name suffix with a mode. For example, if you
> >want files ending in “.js” to always open with js2-mode, then do:
>
> >(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
>
> >Note: The double backslash in the string “\\.js\\'” is used to escape
> >the backslash. So, the regex engine just got “\.js\'”. The “\.” is to
> >match a period. The “\'” is one of emacs special regex syntax, to
> >match end of a string. (See also: Text Pattern Matching in Emacs)
>
> >Reference: Elisp Manual: Regexp-Backslash.
>
> >You can see what are the values of magic-mode-alist or auto-mode-alist
> >by typing “Alt+x describe-variable”.
>
> >There are few minor details about how emacs determines what mode to
> >load, but the above should cover vast majority of needs. For detail,
> >see emacs manual.
>
> >Reference: (info "(emacs)Choosing Modes").
>
> >--------------------------------------------
> >above from:
> >http://xahlee.org/emacs/emacs_installing_packages.html
>
> >  Xah
> >∑http://xahlee.org/
>
> >☄



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: unicode encoding and curly quotes [was: How to open a file in  sh-mode]
  2008-09-11 22:58     ` unicode encoding and curly quotes [was: How to open a file in sh-mode] Xah
@ 2008-09-14 22:35       ` David Combs
  2008-09-15 16:28         ` unicode encoding and curly quotes Nikolaj Schumacher
  2008-09-15 19:09         ` unicode encoding and curly quotes [was: How to open a file in sh-mode] Xah
  0 siblings, 2 replies; 8+ messages in thread
From: David Combs @ 2008-09-14 22:35 UTC (permalink / raw
  To: help-gnu-emacs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1070 bytes --]

In article <44043b4c-ffad-437e-a8d4-5b049fc4d136@v16g2000prc.googlegroups.com>,
Xah  <xahlee@gmail.com> wrote:
>David Combs wrote:
>> Xah-- question about the characters in your posts:
>>
>> If I or someone sees eg a url in one of your posts, and
>> wants to go to that url (because you've suggested doing that,
>> maybe), it's a little difficult to just cut-n-paste your string,
>> what with all the extra control or whatever they are characters
>> mixed in.
>>
>> What is that stuff, why is it there, and is it really necessary
>> for you to include it.
>
>The summation sign “∑” in my sig is my and my website signet.
>
>in the end of my sig, there's this character “☄” (unicode name
>“comet”). It is there so that it forces groups.google.com and Apple
...
...

Well, whatever.   Way over my head.


Anyway, *if* you really want *me* to go look at 
some suggested url, then please do it TWO ways:

. Your current scheme, which I cannot use.
. Plain ascii, 100% ready to be cut-n-pasted into a web-browser,
    with no edits needed.

Thanks,

David




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: unicode encoding and curly quotes
  2008-09-14 22:35       ` David Combs
@ 2008-09-15 16:28         ` Nikolaj Schumacher
  2008-09-15 19:09         ` unicode encoding and curly quotes [was: How to open a file in sh-mode] Xah
  1 sibling, 0 replies; 8+ messages in thread
From: Nikolaj Schumacher @ 2008-09-15 16:28 UTC (permalink / raw
  To: David Combs; +Cc: help-gnu-emacs

dkcombs@panix.com (David Combs) wrote:

> . Plain ascii, 100% ready to be cut-n-pasted into a web-browser,
>     with no edits needed.

I'm sorry.  Which URL are you referring to?  All the URLs I can see are
plain ASCII and can be copied without a problem.

regards,
Nikolaj Schumacher




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: unicode encoding and curly quotes [was: How to open a file in  sh-mode]
  2008-09-14 22:35       ` David Combs
  2008-09-15 16:28         ` unicode encoding and curly quotes Nikolaj Schumacher
@ 2008-09-15 19:09         ` Xah
  2008-09-22 20:17           ` David Combs
  1 sibling, 1 reply; 8+ messages in thread
From: Xah @ 2008-09-15 19:09 UTC (permalink / raw
  To: help-gnu-emacs

On Sep 14, 3:35 pm, dkco...@panix.com (David Combs) wrote:
> In article <44043b4c-ffad-437e-a8d4-5b049fc4d...@v16g2000prc.googlegroups.com>,
>
> Xah  <xah...@gmail.com> wrote:
> >David Combs wrote:
> >> Xah-- question about the characters in your posts:
>
> >> If I or someone sees eg a url in one of your posts, and
> >> wants to go to that url (because you've suggested doing that,
> >> maybe), it's a little difficult to just cut-n-paste your string,
> >> what with all the extra control or whatever they are characters
> >> mixed in.
>
> >> What is that stuff, why is it there, and is it really necessary
> >> for you to include it.
>
> >The summation sign “∑” in my sig is my and my website signet.
>
> >in the end of my sig, there's this character “☄” (unicode name
> >“comet”). It is there so that it forces groups.google.com and Apple
>
> ...
> ...
>
> Well, whatever.   Way over my head.

is that a joke? its hard to tell on newsgroup.

> Anyway, *if* you really want *me* to go look at
> some suggested url, then please do it TWO ways:
>
> . Your current scheme, which I cannot use.
> . Plain ascii, 100% ready to be cut-n-pasted into a web-browser,
>     with no edits needed.

yes i'm also a bit confused. When having a url in my post, maybe a
year ago i used to quote them in a few messages but i quickly stopped
that because newsgroup or email apps will parse wrongly as to include
the quoting char as part of the link.

So, these days i have spaces around any url. I don't think i even
quote them with unicode chars, but possibly with parens. like this:
( http://example.com/ )

perhaps you mean something like the following are hard to copy/paste??

• http://example.com/

... unless there's something in your message i really missed out...
please take a look at unicode. It's really here to stay for good. It's
in MS Windows NT and decendents from the ground up (i.e. since mid
1990s), it's the base encoding in XML standard and various other
protocols and langs (e.g. java), supported by elisp as far as my
experience goes better than any other lang in practical sense, and
required by law for any comp in china and Chinese sites are some major
percentage of the world's web traffic... also if u look at Wikipedia,
which is world's top 5 web traffic for 2 or more years, it uses
unicode chars liberally ...

see also:

http://en.wikipedia.org/wiki/GB_18030
http://en.wikipedia.org/wiki/Internet

some quote:

«GB18030 can be considered a Unicode Transformation Format (i.e. an
encoding of all Unicode code points) that maintains compatibility with
a legacy character set. Like UTF-8, GB18030 is a superset of ASCII and
can represent the whole range of Unicode code points; »

«After English (30% of Web visitors) the most requested languages on
the World Wide Web are Chinese (17%), Spanish (9%), Japanese (7%),
French (5%) and German (5%).[8]

By continent, 38% of the world's Internet users are based in Asia, 27%
in Europe, 18% in North America, 10% in Latin America and the
Caribbean, and 7% in Australia.[6]»

 Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: unicode encoding and curly quotes [was: How to open a file in  sh-mode]
  2008-09-15 19:09         ` unicode encoding and curly quotes [was: How to open a file in sh-mode] Xah
@ 2008-09-22 20:17           ` David Combs
  0 siblings, 0 replies; 8+ messages in thread
From: David Combs @ 2008-09-22 20:17 UTC (permalink / raw
  To: help-gnu-emacs

Xah, thanks much for your explanations.


David




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-09-22 20:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.16658.1218700648.18990.help-gnu-emacs@gnu.org>
2008-08-14  8:28 ` How to open a file in sh-mode Sebastian Kaps
2008-08-14 10:29 ` Xah
2008-09-11  1:35   ` David Combs
2008-09-11 22:58     ` unicode encoding and curly quotes [was: How to open a file in sh-mode] Xah
2008-09-14 22:35       ` David Combs
2008-09-15 16:28         ` unicode encoding and curly quotes Nikolaj Schumacher
2008-09-15 19:09         ` unicode encoding and curly quotes [was: How to open a file in sh-mode] Xah
2008-09-22 20:17           ` David Combs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).