DURING the long, insomniac evenings after his wife had gone to bed, Raymond Chandler sat in the study of his home in Southern California and corresponded with people from all over the world. For almost 20 years he expressed a wide range of opinions to editors, publishers, agents, authors and admirers of his detective fiction.
Chandler, author of ''The Big Sleep,'' ''Farewell, My Lovely'' and ''The Long Goodbye'' and creator of the fictional detective Philip Marlowe, had harsh words for Alfred Hitchcock's treatment of screenwriters, lectured E. Howard Hunt on the ethics of plagiarizing from oneself, declared that the only writing school necessary is to ''analyze and imitate'' and fulminated against ''the literary life'': ''all this desperate building of castles on cobwebs, the long-drawn acrimonious struggle to make something important which we all know will be gone forever in a few years.''
Chandler's passions and prejudices are on full display in ''Selected Letters of Raymond Chandler,'' edited by Frank MacShane, which Columbia University Press will publish on Oct. 26. Mr. MacShane, author of ''The Life of Raymond Chandler'' and ''The Life of John O'Hara,'' writes in the introduction that Chandler, who died in 1959, was ''one of the finest letter writers American literature has produced over the last 200 years.'' He adds that Chandler wanted to express his thoughts and feeling to whoever would write him in return.
One who did was Ian Fleming, who sent him a letter after Chandler reviewed ''Moonraker'' for The Sunday Times of London. Chandler replied: ''I thought my review was no more than you deserved and I tried to write it in such a way that the good part could be quoted and the bad parts left out. After all, old boy, there had to be some bad parts. I think you will have to make up your mind what kind of a writer you are going to be.'' Cops and Crooks
To Eric Partridge, the English literary critic and lexicographer, Chandler wrote: ''Incidentally, it doesn't follow that a man who has been in stir writes the best prison lingo any more than it follows that a man who has been a police officer writes the best detective stories. Cops and crooks are readers of crime literature, and I have no doubt that many a Western sheriff has ornamented his language and perhaps even his costume from a study of six-gun literature.''
Seeking an interview, Chandler wrote to Luciano Lucania, who was known as ''Lucky Luciano'' and who was living in Naples after having been deported from the United States for criminal activities. ''Some of my questions to you may be rather brutal,'' he said, ''but if you decline to answer them, there will be no record that they have been asked. There will be nothing published by me which you do not say, but of course, I cannot be responsible for editorial comment.'' Chandler's sympathetic article based on that interview, titled ''My Friend Luco'' and written for The Sunday Times of London, was never published.
In a 1950 letter to W. Somerset Maugham, Chandler said: ''I think it's rather a pity that somewhere along the line, seeing you have had time for so many things, you did not write a detective story. Not only would it have given us something to shoot at, but it would have quieted my long annoyance with those who gabble about the 'classic' detective story. We should have had at least one specimen to which the term might be applied without idiocy.'' 'Vicious Propaganda'
He returned to the subject in a letter to Maugham the following year, remarking on a recent visit from J.B. Priestley, who told Chandler that he wrote well and that he should write a straight novel. ''Of course I have heard this before in other connections,'' Chandler said. ''If you write well, you should not be writing a mystery. Mysteries should only be written by people who can't write. I regard this as vicious propaganda from the Edmund Wilson crowd. Obviously you can't expect detective fiction to be anything but subliterary, to use Edmund Wilson's word, if you insist on weeding out from that field anyone who shows any pretentions to skill or imagination in the use of words.''
But Chandler reserved much of his contempt for Hollywood, where he helped write screenplays, including the one for James M. Cain's ''Double Indemnity.'' When he had earned enough to leave, he and his wife, Cissy, moved to La Jolla, where they lived for most of the rest of their lives.
''Like every writer, or almost every writer, who goes to Hollywood, I was convinced in the beginning that there must be some discoverable method of working in pictures which would not be completely stultifying to whatever creative talent one might happen to possess,'' he lamented to Hamish Hamilton, his English publisher. ''But like others before me I discovered that this was a dream. It's nobody's fault; it's part of the structure of the industry. Too many people have too much to say about a writer's work. It ceases to be his own. And after a while he ceases to care about it. He has brief enthusiasms, but they are destroyed before they can flower. People who can't write tell him how to write.'' A Waste of Time
Chandler wrote but never mailed an embittered letter to Alfred Hitchcock, who disregarded Chandler's suggestions for the script of ''Strangers on a Train'': ''If you wanted something written in skim milk, why on earth did you bother to come to me in the first place?'' he asked. ''What a waste of money! What a waste of time! It's no answer to say that I was well paid. Nobody can be adequately paid for wasting his time.''
One of the most unusual Chandler letters was written in 1952 to Mr. Hunt, who later became an aide to President Richard M. Nixon and served 32 months in prison for his part in the Watergate conspiracy. Mr. Hunt has written more than 50 novels, many of them paperbacks under a pseudonym, but his current hardcover novel, ''The Gaza Intercept'' (Stein & Day), was recently published under his own name. However, at the time Chandler wrote to him, Mr. Hunt was assigned to the American Embassy in Mexico City.
When the editors of Pocket Books sent Chandler a letter that Mr. Hunt had sent to them, accusing Chandler of plagiarizing from his own articles in a detective magazine of the 1930's, the author replied that he had a perfect right to use them. ''I am the copyright owner, I can use my material in any way I see fit,'' he declared. He then added that ''a wide selection of opinions on the subject'' had persuaded him to use them because a whole generation might possibly want to read those stories that had been written for an ephemeral publication.
The last five years of Chandler's life, after his wife's death in 1954, were marked by frantic attempts to find a solution to loneliness, Mr. MacShane writes. One month before his death he wrote to Maurice Guinness, an English detective novelist, who suggested that Philip Marlowe marry. Chandler disagreed. ''I think he will always have a fairly shabby office, a lonely house, a number of affairs, but no permanent connection.'' he replied. ''I think he will always be awakened at some inconvenient hour by some inconvenient person to do some inconvenient job. I see him always in a lonely street, in lonely rooms, puzzled but never quite defeated.''